var content=(function(){"use strict";function rT(a){return a}const $=globalThis.browser?.runtime?.id?globalThis.browser:globalThis.chrome,ca="paperlens_onboarding_completed";class an{static instance;constructor(){}static getInstance(){return an.instance||(an.instance=new an),an.instance}async shouldShow(){try{return!(await $.storage.local.get(ca))[ca]}catch(e){return console.warn("[PaperLens Onboarding] Failed to read onboarding state:",e),!0}}async markComplete(){try{await $.storage.local.set({[ca]:!0}),console.log("[PaperLens Onboarding] Marked as completed")}catch(e){console.error("[PaperLens Onboarding] Failed to mark onboarding complete:",e)}}async reset(){try{await $.storage.local.remove(ca),console.log("[PaperLens Onboarding] State reset")}catch(e){console.error("[PaperLens Onboarding] Failed to reset onboarding state:",e)}}}const hh=`/**
 * Onboarding Overlay Styles
 *
 * \u9996\u6B21\u5B89\u88C5\u5F15\u5BFC\u906E\u7F69\u5C42 + \u63D0\u793A\u5361\u7247\u6837\u5F0F\u3002
 * \u76F4\u63A5\u6CE8\u5165\u5230\u9875\u9762 DOM\uFF08\u975E Shadow DOM\uFF09\uFF0C\u56E0\u4E3A\u9700\u8981\u8986\u76D6\u6574\u4E2A\u9875\u9762\u3002
 */

.pl-onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483647;
  pointer-events: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

/* \u2500\u2500 \u9AD8\u4EAE\u533A\u57DF \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-highlight {
  position: fixed;
  display: none;
  border-radius: 6px;
  box-shadow:
    0 0 0 4px #2563eb,
    0 0 0 9999px rgba(0, 0, 0, 0.6);
  z-index: 1;
  transition: all 0.3s ease;
}

/* \u2500\u2500 \u63D0\u793A\u5361\u7247 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card {
  position: fixed;
  display: none;
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  z-index: 2;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.05),
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  color: #1f2937;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pl-onboarding-card--visible {
  opacity: 1;
  transform: translateY(0);
}

/* \u2500\u2500 \u5361\u7247\u6807\u9898 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #111827;
  line-height: 1.4;
}

/* \u2500\u2500 \u5361\u7247\u8BF4\u660E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #6b7280;
  margin-bottom: 16px;
}

/* \u2500\u2500 \u5361\u7247\u5E95\u90E8 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* \u2500\u2500 \u6B65\u9AA4\u6307\u793A\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card-step {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 500;
}

/* \u2500\u2500 \u6309\u94AE\u7EC4 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-card-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* \u2500\u2500 \u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-onboarding-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.pl-onboarding-btn--skip {
  background: transparent;
  color: #9ca3af;
}

.pl-onboarding-btn--skip:hover {
  color: #6b7280;
  background: #f3f4f6;
}

.pl-onboarding-btn--next {
  background: #2563eb;
  color: #ffffff;
}

.pl-onboarding-btn--next:hover {
  background: #1d4ed8;
}

/* \u2500\u2500 \u6DF1\u8272\u6A21\u5F0F\u9002\u914D \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@media (prefers-color-scheme: dark) {
  .pl-onboarding-highlight {
    box-shadow:
      0 0 0 4px #60a5fa,
      0 0 0 9999px rgba(0, 0, 0, 0.75);
  }

  .pl-onboarding-card {
    background: #1f2937;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.1),
      0 20px 25px -5px rgba(0, 0, 0, 0.4),
      0 8px 10px -6px rgba(0, 0, 0, 0.3);
    color: #e5e7eb;
  }

  .pl-onboarding-card-title {
    color: #f3f4f6;
  }

  .pl-onboarding-card-desc {
    color: #9ca3af;
  }

  .pl-onboarding-card-step {
    color: #6b7280;
  }

  .pl-onboarding-btn--skip {
    color: #6b7280;
  }

  .pl-onboarding-btn--skip:hover {
    color: #9ca3af;
    background: #374151;
  }

  .pl-onboarding-btn--next {
    background: #3b82f6;
  }

  .pl-onboarding-btn--next:hover {
    background: #60a5fa;
  }
}
`,Ot=".paperlens-metric-host",Ut=".paperlens-citation-host",Nn=".paperlens-save-host",Rn=".paperlens-export-host",fh=".paperlens-abstract-host",Pn=".pl-translate-wrapper",mh=".paperlens-checkbox-host",bh=".paperlens-filter-toolbar-host",gh=".pl-toolbar-progress",yh=".pl-toolbar-cancel-btn",xh=".paperlens-article-type-host",Us=".paperlens-extra-download-host",mi=".paperlens-zotero-host",on=[{selector:bh,title:"\u{1F680} \u7B5B\u9009\u4E0E\u6392\u5E8F",description:"\u6309\u5F71\u54CD\u56E0\u5B50\u3001\u88AB\u5F15\u6B21\u6570\u3001\u5E74\u4EFD\u3001\u5206\u533A\u548C\u5F00\u653E\u83B7\u53D6\u72B6\u6001\u7B5B\u9009\u7ED3\u679C\uFF0C\u4E5F\u53EF\u4EE5\u6279\u91CF\u5BFC\u51FA\u6216\u4FDD\u5B58\u5230 Zotero\u3002",preferredPosition:"bottom"},{selector:Ot,title:"\u{1F4CA} \u671F\u520A\u6307\u6807",description:"\u5728\u8BBA\u6587\u65C1\u663E\u793A IF\u3001JCR \u5206\u533A\u548C\u4E2D\u79D1\u9662\u5206\u533A\uFF0C\u5E2E\u52A9\u4F60\u5FEB\u901F\u5224\u65AD\u671F\u520A\u4FE1\u606F\u3002",preferredPosition:"top"},{selector:Nn,title:"\u2B50 \u4FDD\u5B58\u5230\u6587\u732E\u5E93",description:"\u70B9\u51FB\u201C\u6536\u85CF\u201D\u5373\u53EF\u4FDD\u5B58\u8BBA\u6587\u3002\u767B\u5F55\u540E\u53EF\u540C\u6B65\u5230\u4F60\u7684\u5728\u7EBF\u6587\u732E\u5E93\u3002",preferredPosition:"right"},{selector:Rn,title:"\u{1F4E5} \u5BFC\u51FA\u5F15\u7528",description:"\u652F\u6301 RIS\u3001BibTeX\u3001MEDLINE\u3001CSV\uFF0C\u53EF\u7528\u4E8E Zotero\u3001EndNote \u548C LaTeX\u3002",preferredPosition:"right"},{selector:Pn,title:"AI \u89E3\u8BFB",description:"\u5728\u8BBA\u6587\u9875\u9762\u67E5\u770B\u9898\u76EE\u3001\u6458\u8981\u3001\u5173\u952E\u8BCD\u548C\u7ED3\u6784\u5316\u89E3\u8BFB\uFF0C\u9002\u5408\u5FEB\u901F\u4E86\u89E3\u6587\u7AE0\u8981\u70B9\u3002",preferredPosition:"right"}],Hs=3,Ah=500,Ch=300;let Cr=0,Ie=null,Ye=null,ie=null,ua=null,vr=null,wr=null,In=null,Sr=null,da=!1;function vh(a){if(!a||!a.offsetParent)return!1;const e=a.getBoundingClientRect();return e.width>0&&e.height>0}function zs(a){Cr=0,da=!1,ua=a,Sh(),pa(Cr)}function wh(){bi(),gi(),Js(),Vs(),Cr=0,In=null,da=!1,ua=null}function bi(){vr!==null&&(clearTimeout(vr),vr=null)}function Js(){wr&&(window.removeEventListener("resize",wr),wr=null)}function gi(){Sr&&(Sr(),Sr=null)}function Sh(){if(Ie)return;Ie=document.createElement("div"),Ie.className="pl-onboarding-overlay",Ie.setAttribute("data-paperlens-onboarding","");const a=document.createElement("style");a.textContent=hh,Ie.appendChild(a),Ye=document.createElement("div"),Ye.className="pl-onboarding-highlight",Ie.appendChild(Ye),ie=document.createElement("div"),ie.className="pl-onboarding-card",Ie.appendChild(ie),Ie.addEventListener("click",e=>{e.target===Ie||e.target}),document.body.appendChild(Ie),wr=()=>Eh(),window.addEventListener("resize",wr)}function Vs(){Ie&&(Ie.remove(),Ie=null),Ye=null,ie=null}function pa(a,e=0){if(a>=on.length){Ys(da);return}Cr=a;const t=Th(a);if(t){_h(a,t);return}e<Hs?vr=setTimeout(()=>{vr=null,pa(a,e+1)},Ah):(console.warn(`[PaperLens Onboarding] Step ${a+1} target not found after ${Hs} retries, skipping`),pa(a+1))}function Th(a){const e=on[a];if(!e)return null;const t=document.querySelectorAll(e.selector);for(const n of t)if(n instanceof HTMLElement&&vh(n))return n;return null}function Eh(){!In||!Ie||(Ws(In),Gs(In,on[Cr].preferredPosition))}function _h(a,e){In=e,da=!0,Dh(a),ie&&ie.classList.remove("pl-onboarding-card--visible"),e.scrollIntoView({behavior:"smooth",block:"center"});let t=!1;const n=()=>{t||(t=!0,Ws(e),Gs(e,on[a].preferredPosition),ie&&(ie.classList.remove("pl-onboarding-card--visible"),ie.offsetHeight,ie.classList.add("pl-onboarding-card--visible")))},r=()=>{n()};if("onscrollend"in window){window.addEventListener("scrollend",r,{once:!0});const i=setTimeout(()=>{window.removeEventListener("scrollend",r),n()},Ch);Sr=()=>{window.removeEventListener("scrollend",r),clearTimeout(i)}}else{const i=setTimeout(n,500);Sr=()=>{clearTimeout(i)}}}function Ws(a){if(!Ye)return;const e=a.getBoundingClientRect();Ye.style.position="fixed",Ye.style.top=`${e.top-4}px`,Ye.style.left=`${e.left-4}px`,Ye.style.width=`${e.width+8}px`,Ye.style.height=`${e.height+8}px`,Ye.style.display="block"}function Gs(a,e){if(!ie)return;const t=a.getBoundingClientRect(),n=360,r=16,i=window.innerWidth,o=window.innerHeight;ie.style.visibility="hidden",ie.style.display="block";const s=ie.offsetHeight;ie.style.visibility="";let l,c,u=e;switch(e){case"top":t.top-s-r<10&&(u="bottom");break;case"bottom":t.bottom+s+r>o-10&&(u="top");break;case"left":t.left-n-r<10&&(u="right");break;case"right":t.right+n+r>i-10&&(u="left");break}switch(u){case"top":l=t.top-s-r,c=t.left+t.width/2-n/2;break;case"bottom":l=t.bottom+r,c=t.left+t.width/2-n/2;break;case"left":l=t.top+t.height/2-s/2,c=t.left-n-r;break;case"right":l=t.top+t.height/2-s/2,c=t.right+r;break}c=Math.max(16,Math.min(c,i-n-16)),l=Math.max(16,Math.min(l,o-s-16)),ie.style.top=`${l}px`,ie.style.left=`${c}px`,ie.style.width=`${n}px`}function Dh(a){if(!ie)return;const e=on[a],t=a===on.length-1;ie.innerHTML="";const n=document.createElement("div");n.className="pl-onboarding-card-title",n.textContent=e.title,ie.appendChild(n);const r=document.createElement("div");r.className="pl-onboarding-card-desc",r.textContent=e.description,ie.appendChild(r);const i=document.createElement("div");i.className="pl-onboarding-card-footer";const o=document.createElement("span");o.className="pl-onboarding-card-step",o.textContent=`${a+1}/${on.length}`,i.appendChild(o);const s=document.createElement("div");s.className="pl-onboarding-card-btns";const l=document.createElement("button");l.className="pl-onboarding-btn pl-onboarding-btn--skip",l.textContent="\u8DF3\u8FC7",l.addEventListener("click",()=>Ys(!0)),s.appendChild(l);const c=document.createElement("button");c.className="pl-onboarding-btn pl-onboarding-btn--next",c.textContent=t?"\u5F00\u59CB\u4F7F\u7528 \u2728":"\u4E0B\u4E00\u6B65 \u2192",c.addEventListener("click",()=>{bi(),gi(),pa(a+1)}),s.appendChild(c),i.appendChild(s),ie.appendChild(i)}async function Ys(a){bi(),gi(),Js(),Vs(),In=null,a&&ua?await ua():a||console.log("[PaperLens Onboarding] No steps could be shown \u2014 not marking complete, will retry next visit")}const ha=[];function Fh(a,e){const t=a.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/^\*:\/\//,"(https?|ftp):\\/\\/").replace(/\*/g,".*");return new RegExp("^"+t+"$").test(e)}function V(a){if(!a)throw new Error("[AdapterRegistry] Cannot register null or undefined adapter");const e=ha.findIndex(t=>t.id===a.id);e>=0&&(console.warn(`[AdapterRegistry] Adapter with id "${a.id}" already registered, replacing...`),ha.splice(e,1)),ha.push(a),console.log(`[AdapterRegistry] Registered adapter: ${a.id} (${a.name})`)}function kh(a){const e=location.href;for(const t of ha)for(const n of t.matches)if(Fh(n,e))return console.log(`[AdapterRegistry] Detected adapter: ${t.id} (${t.name}) for URL: ${e}`),t;return console.debug(`[AdapterRegistry] No adapter found for URL: ${e}`),null}class W{isSearchPage(){return!1}isArticlePage(){return!1}parseSearchResults(){return[]}parseArticlePage(){return null}getMetricBarAnchor(e){return{element:e,position:"after"}}getResultsContainer(){return document.body}getPageInfo(){return{pageNum:1,totalPages:1,url:location.href}}}const Lh=".top-wrapper",Nh="section.search-results-list",Zs="section.search-results-list",fa="div.search-results-chunks",lt="div.search-results-chunk",_e="article.full-docsum",Qs="div.docsum-content",yi="div.docsum-snippet",Ks="span.docsum-pmid",Ht="a.docsum-title",sn="data-article-id",Rh="a.docsum-title",Xs="span.docsum-authors.full-authors",Tr="span.docsum-journal-citation.full-journal-citation",xi="span.docsum-journal-citation.short-journal-citation",ma="span.publication-type",ba="div.docsum-citation.full-citation",Ph="main#article-details",Ih="h1.heading-title, h1.title",Mh="div.article-source, span.citation, div.citation",el='span#doi a, span#doi, a[href*="doi.org"]',Bh="span#pmid, strong.current-id",jh="span#pmc",qh="div.article-meta, div.abstract-content",$h=/doi:\s*(10\.\d{4,}\/[^\s.]+(?:\.[^\s]+)*?)(?:\.\s|$)/i,Oh=/\b(\d{4})\b/,Uh=/^((?:18|19|20)\d{2}(?:\s+[A-Za-z]{3,9})?(?:\s+\d{1,2})?)/;function tl(a){return a.match($h)?.[1]??null}function Ai(a){const e=a.match(Oh);if(e?.[1]){const t=parseInt(e[1],10);if(t>=1800&&t<=2100)return t}return null}function Hh(a){const e=a.indexOf(".");return e<0?null:a.slice(e+1).trim().match(Uh)?.[1]??null}function zh(a){const e=a.indexOf(".");return e>0?a.substring(0,e).trim():a.trim()}function Ci(a){const e=a.indexOf(".");return e>0?a.substring(0,e).trim():a.trim()}function nl(a){return a.textContent?.trim()??""}function rl(a){if(!a)return[];const e=a.replace(/\.\s*$/,"").trim();return e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0):[]}function ga(a){return a&&a.replace(/\.\s*$/,"").trim()||null}function ya(a){let t=a.querySelector(Ht)?.getAttribute(sn)??"";t||(t=a.querySelector(Ks)?.textContent?.trim()??"");const n=a.querySelector(Rh),r=n?nl(n):"",o=a.querySelector(Tr)?.textContent?.trim()??"",l=a.querySelector(xi)?.textContent?.trim()??"",c=tl(o),u=Ai(o),d=Hh(o),p=Ci(o),m=zh(l),y=a.querySelector(Xs)?.textContent?.trim()??"",x=rl(y),T=a.querySelector(yi)?.textContent?.replace(/\s+/g," ").trim(),F=a.querySelector(ma),w=ga(F?.textContent?.trim()??null),b={PMID:t,title:r,journal:p,fetchedAt:Date.now()};return c&&(b.DOI=c),m&&m!==p&&(b.journalAbbr=m),x.length>0&&(b.authors=x),T&&(b.abstractSnippet=T),u!==null&&(b.year=u),d&&(b.publicationDate=d),w&&(b.articleType=w),b}class Jh extends W{id="pubmed";name="PubMed";matches=["*://pubmed.ncbi.nlm.nih.gov/*"];isSearchPage(){return new URLSearchParams(location.search).has("term")}isArticlePage(){const e=location.pathname;return/^\/\d+\/?$/.test(e)}parseSearchResults(){const e=[],t=document.querySelectorAll(_e);for(const n of t)try{const r=this.parseArticleElement(n);r&&e.push(r)}catch(r){console.error("[PubMedAdapter] Failed to parse article:",r)}return e}parseArticlePage(){const e=document.querySelector(Ph);if(!e)return console.warn("[PubMedAdapter] Article page main content not found"),null;try{const n=e.querySelector(Bh)?.textContent?.trim()??"",i=e.querySelector(Ih)?.textContent?.trim()??"",s=e.querySelector(Mh)?.textContent?.trim()??"",c=e.querySelector(el)?.getAttribute("href")??"",u=/10\.\d{4,}\/[^\s?]+/i,d=c.match(u)?.[0]??null,p=Ci(s),m=Ai(s),y=e.querySelector(qh)?.querySelector(ma)?.textContent?.trim()??null,x=y?ga(y):null;return{title:i,journalName:p,pmid:n||void 0,doi:d||void 0,year:m||void 0,articleTypes:x?[x]:void 0,url:location.href,hostElement:e,source:this.id}}catch(t){return console.error("[PubMedAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector(ba);if(t)return{element:t,position:"before"};const n=e.querySelector(Qs);return n&&n.firstElementChild?{element:n.firstElementChild,position:"before"}:super.getMetricBarAnchor(e)}getResultsContainer(){return document.querySelector(Zs)}getPageInfo(){const e={pageNum:1,totalPages:1,url:location.href};try{const t=new URLSearchParams(location.search),n=t.get("page");if(n){const o=parseInt(n,10);!isNaN(o)&&o>0&&(e.pageNum=o)}const r=document.querySelector(".page-numbers, .pagination");if(r){const o=r.querySelector("a:last-child");if(o){const l=o.getAttribute("href");if(l){const c=l.match(/page=(\d+)/);c&&(e.totalPages=parseInt(c[1],10))}}const s=r.querySelectorAll('a[href*="page="]');if(s.length>0&&e.totalPages===1)for(const l of s){const c=l.getAttribute("href");if(c){const u=c.match(/page=(\d+)/);if(u){const d=parseInt(u[1],10);d>e.totalPages&&(e.totalPages=d)}}}}const i=t.get("size");if(i){const o=parseInt(i,10);!isNaN(o)&&o>0&&(e.itemsPerPage=o)}}catch(t){console.warn("[PubMedAdapter] Failed to extract page info:",t)}return e}parseArticleElement(e){const t=e.querySelector(Ht);let n=t?.getAttribute(sn)??"";n||(n=e.querySelector(Ks)?.textContent?.trim()??"");const r=t?nl(t):"";if(!r)return console.warn("[PubMedAdapter] Article without title, skipping"),null;const o=e.querySelector(Tr)?.textContent?.trim()??"",s=Ci(o);if(!s)return console.warn("[PubMedAdapter] Article without journal name, skipping"),null;const l=tl(o),c=Ai(o),d=e.querySelector(Xs)?.textContent?.trim()??"",p=rl(d),h=e.querySelector(yi)?.textContent?.replace(/\s+/g," ").trim(),y=e.querySelector(ma),x=ga(y?.textContent?.trim()??null),T=x?[x]:void 0,F=t?.getAttribute("href");return{title:r,journalName:s,pmid:n||void 0,doi:l||void 0,year:c||void 0,authors:p.length>0?p:void 0,abstractSnippet:h,articleTypes:T,url:F||void 0,hostElement:e,source:this.id}}}const al=/[-–—]\s*([^,\-–—\d][^,\-–—]*?),\s*((?:19|20)\d{2})\b/,il=/\b((?:19|20)\d{2})\b/,Vh=/\s[-–—]\s/,Wh=/^\/scholar\/?$/,ol=/^\/scholar_lookup\/?$/,Gh=["title","doi","journal","author","pmid","publication_year","pages"],sl=/(?:^|\s)(?:books\.google|scholar\.google|researchgate|academia\.edu|semanticscholar|pubmed|ncbi|nih\.gov|arxiv|biorxiv|medrxiv|ssrn|repository|proquest|springer\.com|wiley\.com|sciencedirect|tandfonline|jstor|ieeexplore|dl\.acm|nature\.com|nejm\.org|thelancet\.com)(?:\s|$)/i,Yh=[{pattern:/:\/\/(?:www\.)?nejm\.org\//i,journal:"New England Journal of Medicine"},{pattern:/:\/\/academic\.oup\.com\/jnci(?:\/|$)/i,journal:"JNCI-Journal of the National Cancer Institute"},{pattern:/:\/\/jamanetwork\.com\/journals\/jama(?:\/|$)/i,journal:"JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION"},{pattern:/10\.3322\/caac/i,journal:"CA-A Cancer Journal for Clinicians"},{pattern:/:\/\/ascopubs\.org\/doi\/(?:abs|full|pdf)\/10\.1200\/jco/i,journal:"Journal of Clinical Oncology"},{pattern:/:\/\/(?:www\.)?thelancet\.com\/journals\/lanonc(?:\/|$)/i,journal:"Lancet Oncology"}];class Zh extends W{id="google-scholar";name="Google Scholar";matches=["*://scholar.google.com/*","*://scholar.google.com.hk/*","*://scholar.google.co.jp/*","*://scholar.google.com.tw/*","*://scholar.google.com.*/*"];isSearchPage(){const e=new URLSearchParams(location.search);return Wh.test(location.pathname)?e.has("q")||document.querySelector("div.gs_ri")!==null:ol.test(location.pathname)?Gh.some(t=>e.has(t))||document.querySelector("div.gs_ri")!==null:!1}isArticlePage(){return!1}parseSearchResults(){const e=[],t=document.querySelectorAll("div.gs_ri");for(const n of t)try{const r=this.parseResultElement(n);r&&e.push(r)}catch(r){console.error("[GoogleScholarAdapter] Failed to parse result:",r)}return e}parseArticlePage(){return null}getMetricBarAnchor(e){const t=e.querySelector("div.gs_a");return t?{element:t,position:"after"}:super.getMetricBarAnchor(e)}getResultsContainer(){return document.getElementById("gs_res_ccl_mid")??document.getElementById("gs_res_ccl_top")??document.querySelector("#gs_res_ccl")}getPageInfo(){const e={pageNum:1,totalPages:1,url:location.href};try{const n=new URLSearchParams(location.search).get("start");if(n){const i=parseInt(n,10);!isNaN(i)&&i>=0&&(e.pageNum=Math.floor(i/10)+1,e.itemsPerPage=10)}const r=document.getElementById("gs_ab_md");if(r){const o=(r.textContent??"").match(/[\d,]+/);if(o){const s=parseInt(o[0].replace(/,/g,""),10);!isNaN(s)&&s>0&&(e.totalItems=s,e.totalPages=Math.ceil(s/(e.itemsPerPage??10)))}}}catch(t){console.warn("[GoogleScholarAdapter] Failed to extract page info:",t)}return e}parseResultElement(e){const t=e.querySelector("h3.gs_rt a"),n=e.querySelector("h3.gs_rt"),r=this.cleanTitle(t?.textContent??n?.textContent??"");if(!r)return console.warn("[GoogleScholarAdapter] Result without title, skipping"),null;const o=e.querySelector("div.gs_a")?.textContent?.trim()??"",s=e.closest("div.gs_r")??e,l=t?.href??t?.getAttribute("href")??"",c=this.collectArticleUrls(s,l),u=this.parseMetaText(o),d=this.inferJournalFromUrls(c),p=d.journalCandidates[0]??"",m=this.shouldPreferInferredJournal(u.journalName)?p||u.journalName:u.journalName||p,h=this.uniqueStrings([m,u.journalName,...d.journalCandidates]),y=u.year,x=this.parseAuthors(o),T=e.querySelector("div.gs_rs"),F=T?.textContent?.replace(/\s+/g," ").trim()??void 0;return{title:r,journalName:m,journalCandidates:h,authors:x,year:y,url:t?.getAttribute("href")??void 0,doi:this.extractDOI(l,T?.textContent??"")??this.extractLookupDOI(),issn:d.issn,abstractSnippet:F||void 0,hostElement:s,source:this.id}}parseMetaText(e){let t="",n;const r=e.split(Vh).map(c=>c.trim()).filter(Boolean),i=r.length>=2?r[1]:"";if(i){t=this.extractJournalFromPublicationSection(i);const c=i.match(il);if(c&&(n=parseInt(c[1],10)),t)return{journalName:t,year:n}}const o=e.match(al);if(o)return t=o[1].trim(),n=parseInt(o[2],10),{journalName:t,year:n};const s=e.match(/[-–—]\s*([^,\-–—]*?)\s+((?:19|20)\d{2})\b/);if(s){const c=s[1].trim();if(c.length>1)return t=c,n=parseInt(s[2],10),{journalName:t,year:n}}const l=e.match(il);return l&&(n=parseInt(l[1],10)),{journalName:t,year:n}}cleanTitle(e){return e.replace(/^\s*(?:\[[^\]]+\]\s*)+/,"").replace(/\s+/g," ").trim()}shouldPreferInferredJournal(e){return!e||/…|\.\.\./.test(e)}uniqueStrings(e){const t=new Set,n=[];for(const r of e){const i=r?.replace(/\s+/g," ").trim();!i||t.has(i.toLowerCase())||(t.add(i.toLowerCase()),n.push(i))}return n}collectArticleUrls(e,t){const n=[];t&&n.push(t);for(const r of e.querySelectorAll("a[href]")){const i=r.href||r.getAttribute("href")||"";!i||/^javascript:/i.test(i)||n.push(i)}return this.uniqueStrings(n)}inferJournalFromUrls(e){const t=[];let n;for(const r of e){const i=this.safeDecodeUrl(r);for(const s of Yh)s.pattern.test(i)&&t.push(s.journal);const o=this.extractIssnFromScienceDirectPii(i);o&&!n&&(n=o)}return{journalCandidates:this.uniqueStrings(t),issn:n}}safeDecodeUrl(e){try{return decodeURIComponent(e)}catch{return e}}extractIssnFromScienceDirectPii(e){const t=e.match(/\/pii\/S(\d{4})(\d{3}[\dX])/i);if(!(!t?.[1]||!t?.[2]))return`${t[1]}-${t[2].toUpperCase()}`}extractJournalFromPublicationSection(e){const t=e.replace(/\s+/g," ").trim();if(/\.[a-z]{2,}(?:\/|$)/i.test(t)||!t||sl.test(t))return"";let n=t.replace(/\b((?:19|20)\d{2})\b.*$/,"").trim();return!n||(n=n.replace(/[,.;:\s]+$/,"").replace(/\b(?:vol(?:ume)?|issue|no\.?|number|pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\s+\d+[\s\S]*$/,"").replace(/[,.;:\s]+$/,"").trim(),!n||/^\d/.test(n))||sl.test(n)?"":n}isCitationLibraryPage(){return location.pathname!=="/citations"?!1:new URLSearchParams(location.search).has("user")}extractDOI(e,t){const n=this.safeDecodeUrl(e),r=n.match(/doi\.org\/(10\.\d{4,}\/[^\s?&#]+)/i);if(r?.[1])return r[1];const i=n.match(/\/(10\.\d{4,9}\/[^\s?&#]+)/i);if(i?.[1])return i[1];const o=t.match(/(10\.\d{4,9}\/[\w.\-]+[\w])/);if(o?.[1])return o[1]}extractLookupDOI(){return ol.test(location.pathname)&&new URLSearchParams(location.search).get("doi")?.replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/^doi:\s*/i,"").trim()||void 0}parseAuthors(e){const t=e.search(/[\u2013\u2014]/),n=e.indexOf(" - "),r=t>0?t:n>0?n:-1;if(r<=0)return;const i=e.slice(0,r).trim();if(!i||i.length<2)return;const o=i.split(/,\s*|\s*&\s*|\s+and\s+/i).map(s=>s.trim().replace(/^\s*\[?\d+\]?\s*/,"")).filter(s=>s.length>0&&s.length<100);if(!(o.length===0||o.length>20))return o}parseCitationLibrary(){const e=[],t=document.querySelectorAll("tr.gsc_a_tr");for(const n of t)try{const r=n.querySelector("a.gsc_a_at"),i=r?.textContent?.trim()??"";if(!i)continue;const o=n.querySelectorAll("div.gs_gray");let s="",l;const c=n.querySelector("span.gsc_a_h.gsc_a_hc");if(c){const d=parseInt(c.textContent?.trim()??"",10);isNaN(d)||(l=d)}for(let d=0;d<o.length;d++){const m=o[d].textContent?.trim()??"";if(!m)continue;const h=m.match(al);if(h&&!s){s=h[1].trim(),l||(l=parseInt(h[2],10));continue}if(d===0)continue;const y=m.match(/^([A-Za-z][A-Za-z\s\.\&\-\/\:]+?),?\s*((?:19|20)\d{2})\b/);if(y&&!s){s=y[1].trim(),l||(l=parseInt(y[2],10));continue}const x=m.match(/^([A-Za-z][A-Za-z\s\.\&\-\/\:]+?)\s+\d+/);if(x&&!s){s=x[1].trim();continue}const T=m.match(/^([A-Za-z][A-Za-z\s\.\&\-\/\:]+)$/);if(T&&!s){const F=T[1].trim(),w=F.split(/\s+/),b=F.length>=8||w.length>=2,v=/^(Elsevier|Springer|Springer Nature|Wiley|Wiley\-Blackwell|IEEE|ACM|PLOS|MDPI|Frontiers|Taylor & Francis|SAGE Publications|SAGE|Oxford University Press|Cambridge University Press|Nature Publishing Group|BMC|IOP Publishing|APS|ACS|RSC|AAAS)$/i.test(F),D=/^(Nature|Science|Cell|eLife|Lancet|BMJ|JAMA|NEJM|PNAS|PRL|Angew)$/i.test(F);(b||D)&&!v&&!/\d/.test(F)&&(s=F)}}const u=r?.getAttribute("href")??void 0;e.push({title:i,journalName:s,year:l,url:u,hostElement:n,source:this.id})}catch(r){console.error("[GoogleScholarAdapter] Failed to parse citation row:",r)}return e}getCitationLibraryAnchor(e){const t=e.querySelector("td.gsc_a_t");if(t){const n=t.querySelector("a.gsc_a_at");return n?{element:n,position:"after"}:{element:t,position:"append"}}return super.getMetricBarAnchor(e)}}const vi=/\b((?:19|20)\d{2})\b/,Qh=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,wi=['a[href*="/kcms2/article/abstract"]','a[href*="/kcms2/article/"]','a[href*="/kcms/detail/"]','a[href*="/KCMS/detail/"]'].join(","),xa="paperlens-cnki-enhancement-line",ll="data-paperlens-cnki-detail";class Kh extends W{id="cnki";name="\u4E2D\u56FD\u77E5\u7F51";matches=["*://kns.cnki.net/*","*://www.cnki.net/*","*://navi.cnki.net/*"];isSearchPage(){const e=location.pathname;return e.includes("/kns8s/defaultresult")||e.includes("/kns/brief/")||e.includes("/kns8s/search")}isArticlePage(){const e=location.pathname;return/\/kcms2\/article\//.test(e)||/\/detail\//.test(e)}parseSearchResults(){const e=[],t=this.parseTableView();if(t.length>0)return t;const n=this.parseSummaryView();return n.length>0?n:e}parseArticlePage(){try{const e=document.querySelector(".detail")??document.querySelector("main")??document.body,n=(e.querySelector("h1")??e.querySelector(".title"))?.textContent?.trim()??"";if(!n)return console.warn("[CnkiAdapter] Article page without title"),null;const r=this.extractDetailPageJournal(e),i=this.extractDetailPageYear(e),o=e.querySelectorAll(".author a"),s=o.length>0?Array.from(o).map(m=>m.textContent?.trim()).filter(m=>m.length>0):void 0,c=(e.querySelector('[name="DOI"]')??e.querySelector('a[href*="doi.org/"]'))?.textContent?.trim()??void 0,d=(e.querySelector(".abstract")??e.querySelector("#ChDivSummary"))?.textContent?.replace(/\s+/g," ").trim()??void 0,p=this.extractDetailPageFullTextUrl(e);return{title:n,journalName:r,year:i,authors:s,doi:c,url:location.href,nativeFullTextUrl:p,abstractSnippet:d||void 0,hostElement:e,source:this.id}}catch(e){return console.error("[CnkiAdapter] Failed to parse article page:",e),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.getOrCreateDetailEnhancementLine(e);if(r)return{element:r,position:"append"}}const t=e.querySelector("td.name");if(t)return{element:this.getOrCreateEnhancementLine(e,t)??t,position:"append"};const n=this.getDirectCells(e)[1];return n?{element:this.getOrCreateEnhancementLine(e,n)??n,position:"append"}:{element:e,position:"prepend"}}getResultsContainer(){const e=document.querySelector("table.result-table-list")??document.querySelector(".result-table-list")??document.querySelector(".result-table")??document.querySelector("#gridTable")??document.querySelector(".s-single")?.parentElement;return e||this.findArticleTable()}getPageInfo(){const e={pageNum:1,totalPages:1,url:location.href};try{const t=new URLSearchParams(location.search),n=t.get("curpage");if(n){const o=parseInt(n,10);!isNaN(o)&&o>0&&(e.pageNum=o)}const r=document.querySelector("#pc_1")??document.querySelector(".pager-title-cell em");if(r){const s=(r.textContent?.trim()??"").match(/\d+/);if(s){const l=parseInt(s[0],10);!isNaN(l)&&l>0&&(e.totalPages=l)}}const i=t.get("pageSize");if(i){const o=parseInt(i,10);!isNaN(o)&&o>0&&(e.itemsPerPage=o)}}catch(t){console.warn("[CnkiAdapter] Failed to extract page info:",t)}return e}parseTableView(){const e=[],t=this.findTableRows();for(const n of t)if(!n.classList.contains("header"))try{const r=this.parseTableRow(n);r&&e.push(r)}catch(r){console.error("[CnkiAdapter] Failed to parse table row:",r)}return e}parseSummaryView(){const e=[],t=document.querySelectorAll(".s-single");for(const n of t)try{const r=n.querySelector("a.fz14"),i=r?.textContent?.trim()??"";if(!i)continue;const o=n.querySelector(".source")?.textContent?.trim()??"";e.push({title:i,journalName:o,url:r?.getAttribute("href")??void 0,hostElement:n,source:this.id})}catch(r){console.error("[CnkiAdapter] Failed to parse summary item:",r)}return e}parseTableRow(e){const t=this.findTitleElement(e),n=this.cleanText(t?.textContent??"");if(!n)return console.warn("[CnkiAdapter] Table row without title, skipping"),null;const r=this.extractJournalFromRow(e),i=this.getDirectCells(e),s=this.cleanText(e.querySelector("td.date")?.textContent??i[4]?.textContent??"").match(vi),l=s?parseInt(s[1],10):void 0,c=this.cleanText(e.querySelector("td.author")?.textContent??i[2]?.textContent??"").replace(/显示全部作者/g,""),u=c?c.split(/[;；,，]/).map(h=>h.trim()).filter(Boolean):void 0,d=this.extractDoi(e),p=this.cleanText(i[5]?.textContent??""),m=p?[p]:void 0;return{title:n,journalName:r,year:l,authors:u,doi:d,url:this.toAbsoluteUrl(t?.getAttribute("href")),hostElement:e,articleTypes:m,source:this.id}}extractJournalFromRow(e){const t=e.querySelector("td.name .source");if(t){const o=t.getAttribute("data-source");if(o)return o.trim();const s=t.textContent?.trim()??"";if(s)return s}const n=e.querySelector("td.source");if(n){const o=this.cleanText(n.textContent??"");if(o)return o}const i=this.getDirectCells(e)[3];if(i){const o=i.querySelector("a"),s=this.cleanText(o?.textContent??i.textContent??"");if(s)return s}return""}findTableRows(){const e=[],t=new Set,n=["table.result-table-list tbody tr",".result-table-list tbody tr","#gridTable tbody tr",".result-table tbody tr","table tbody tr"];for(const r of n)document.querySelectorAll(r).forEach(i=>{t.has(i)||this.findTitleElement(i)&&(t.add(i),e.push(i))});return e}findArticleTable(){for(const e of Array.from(document.querySelectorAll("table")))if(e.querySelector(wi)||e.querySelector("td.name a.fz14"))return e;return null}findTitleElement(e){const t=e.querySelector("td.name a.fz14");if(t)return t;const i=this.getDirectCells(e)[1]?.querySelector(wi);return i||e.querySelector(wi)}getOrCreateEnhancementLine(e,t){const n=t.querySelector(`.${xa}`);if(n)return n;const r=t.ownerDocument.createElement("div");r.className=xa,r.style.cssText=["display:flex","flex-wrap:wrap","align-items:center","gap:6px","margin-top:6px","line-height:1.4"].join(";");const i=this.findTitleElement(e);return i?.parentElement===t?i.insertAdjacentElement("afterend",r):t.appendChild(r),r}getOrCreateDetailEnhancementLine(e){const t=e.querySelector(".top-tip"),n=t?.querySelector("a")??t?.querySelector(".source a")??t?.querySelector(".source")??e.querySelector(".source a")??e.querySelector(".source"),r=n?.parentElement??t;if(!r)return null;const i=r.querySelector(`.${xa}[${ll}="true"]`);if(i)return i;const o=r.ownerDocument.createElement("span");return o.className=xa,o.setAttribute(ll,"true"),o.style.cssText=["display:inline-flex","flex-wrap:wrap","align-items:center","gap:6px","margin-left:8px","vertical-align:middle","max-width:100%"].join(";"),n?n.insertAdjacentElement("afterend",o):r.appendChild(o),o}getDirectCells(e){return Array.from(e.children).filter(t=>t.tagName.toLowerCase()==="td")}cleanText(e){return e.replace(/\s+/g," ").trim()}toAbsoluteUrl(e){if(e)try{return new URL(e,location.href).href}catch{return e}}extractDoi(e){const t=e.querySelector('a[href*="doi.org/"]');return[t?.getAttribute("href"),t?.textContent,e.textContent].filter(Boolean).join(" ").match(Qh)?.[0]}extractDetailPageJournal(e){const t=e.querySelector(".top-tip a");if(t){const r=t.textContent?.trim()??"";if(r)return r}const n=e.querySelector(".source");if(n){const r=n.textContent?.trim()??"";if(r)return r}return""}extractDetailPageFullTextUrl(e){const t=['a[href*="download.aspx"]','a[href*="/kcms/download/"]','a[href*="/KCMS/download/"]','a[href*="download?filename="]',".doc-operate a[href]",".download a[href]","a.btn-download[href]"].join(","),n=Array.from(e.querySelectorAll(t));for(const r of n){const i=r.getAttribute("href");if(!i)continue;const o=this.cleanText(r.textContent??""),s=i.toLowerCase();if(/下载|原文|pdf|caj|整本/.test(o)||/download|pdf|caj/.test(s))return this.toAbsoluteUrl(i)}}extractDetailPageYear(e){const n=(e.querySelector(".top-tip")?.textContent?.trim()??"").match(vi);if(n)return parseInt(n[1],10);const r=e.querySelector(".date")??e.querySelector('[name="publishdate"]');if(r){const o=(r.textContent?.trim()??"").match(vi);if(o)return parseInt(o[1],10)}}}const cl=/\b((?:19|20)\d{2})\b/,ul=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,dl=/\b\d{4}-\d{3}[\dX]\b/i;class Xh extends W{id="wos";name="Web of Science";matches=["*://www.webofscience.com/*"];isSearchPage(){return/\/(search|results)/.test(location.pathname)}isArticlePage(){const e=location.pathname;return/\/full-record\//.test(e)||e.includes("/wos/woscc/full-record")}parseSearchResults(){const e=[],t=document.querySelectorAll("app-record");for(const r of t)try{const i=this.parseRecordElement(r);i&&e.push(i)}catch(i){console.error("[WoSAdapter] Failed to parse app-record:",i)}if(e.length>0)return e;const n=document.querySelectorAll(".search-results-item");for(const r of n)try{const i=this.parseLegacyItem(r);i&&e.push(i)}catch(i){console.error("[WoSAdapter] Failed to parse legacy item:",i)}return e}parseArticlePage(){try{const e=this.getDetailHostElement(),t=["h1",".title",'[data-name="title"]','[data-ta*="title"]','[data-test*="title"]'],n=this.queryFirst(e,t)??this.queryFirst(document,t),r=this.getMetaContent("citation_title")??this.cleanText(n?.textContent);if(!r)return console.warn("[WoSAdapter] Article page without title"),null;const i=this.getMetaContent("citation_journal_title")??this.extractDetailPageJournal(e),o=this.extractDetailPageYear(e),s=this.cleanDoi(this.getMetaContent("citation_doi"))??this.extractDetailPageDoi(e),l=this.getMetaContents("citation_author"),c=l.length>0?l:this.extractAuthorsFromRoot(e),u=this.queryFirst(e,[".abstract",'[data-name="abstract"]','[data-ta*="abstract"]','[data-test*="abstract"]']),d=this.getMetaContent("citation_abstract")??this.cleanText(u?.textContent)??void 0;return{title:r,journalName:i,year:o,authors:c,doi:s,articleTypes:this.extractArticleTypesFromRoot(e),issn:this.getMetaContent("citation_issn")??this.getMetaContent("citation_eissn")??this.extractIssnFromRoot(e,!1),url:location.href,abstractSnippet:d,hostElement:e,source:this.id}}catch(e){return console.error("[WoSAdapter] Failed to parse article page:",e),null}}getMetricBarAnchor(e){const t=e.shadowRoot??e,n=t.querySelector("h3.title")??t.querySelector('[data-ta*="title"]')??t.querySelector('[data-test*="title"]')??t.querySelector("h3");if(n)return{element:n,position:"after"};const i=(e.matches("app-record")?e:e.querySelector("app-record"))?.shadowRoot,o=i?.querySelector("h3.title")??i?.querySelector('[data-ta*="title"]')??i?.querySelector('[data-test*="title"]')??i?.querySelector("h3");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".search-results-list")??document.querySelector('[class*="search-results"]')??document.querySelector("app-search-results")??document.querySelector("app-record-list")??null}getPageInfo(){const e={pageNum:1,totalPages:1,url:location.href};try{const n=new URLSearchParams(location.search).get("page");if(n){const o=parseInt(n,10);!isNaN(o)&&o>0&&(e.pageNum=o)}const r=document.querySelector(".pagination")??document.querySelector('[class*="pager"]');if(r){const o=r.querySelector("li:last-child a")??r.querySelector(".last a");if(o){const s=o.textContent?.trim()??"",l=parseInt(s,10);!isNaN(l)&&l>0&&(e.totalPages=l)}}const i=document.querySelector(".search-results-count")??document.querySelector('[class*="result-count"]');if(i){const s=(i.textContent?.trim()??"").match(/[\d,]+/);if(s){const l=parseInt(s[0].replace(/,/g,""),10);!isNaN(l)&&l>0&&(e.totalItems=l)}}}catch(t){console.warn("[WoSAdapter] Failed to extract page info:",t)}return e}parseRecordElement(e){const t=e.shadowRoot??e,n=this.queryFirst(t,["h3.title a","h3 a",".title a",'[data-ta="summary-record-title"] a','[data-ta*="title"] a','[data-test*="title"] a','a[aria-label*="title"]',"a[title]"]),r=this.cleanText(n?.textContent)??this.cleanText(n?.getAttribute("title"))??"";if(!r)return console.warn("[WoSAdapter] app-record without title, skipping"),null;const i=this.extractJournalFromRoot(t),o=this.extractYearFromRoot(t),s=this.extractDoiFromRoot(t),l=this.extractAuthorsFromRoot(t),c=e.closest(".search-results-item")??e;return{title:r,journalName:i,year:o,authors:l,doi:s,articleTypes:this.extractArticleTypesFromRoot(t),issn:this.extractIssnFromRoot(t),url:this.toAbsoluteUrl(n?.getAttribute("href")),hostElement:c,source:this.id}}parseLegacyItem(e){const t=this.queryFirst(e,["a[title]","h3 a",".title a",'[data-ta*="title"] a','[data-test*="title"] a']),n=this.cleanText(t?.getAttribute("title"))??this.cleanText(t?.textContent)??"";if(!n)return console.warn("[WoSAdapter] Legacy item without title, skipping"),null;const r=this.extractJournalFromRoot(e),i=this.extractYearFromRoot(e);return{title:n,journalName:r,year:i,authors:this.extractAuthorsFromRoot(e),doi:this.extractDoiFromRoot(e),articleTypes:this.extractArticleTypesFromRoot(e),issn:this.extractIssnFromRoot(e),url:this.toAbsoluteUrl(t?.getAttribute("href")),hostElement:e,source:this.id}}extractJournalFromRoot(e){const t=[".source-title span",".source-title",'[data-name="sourceTitle"]','[data-name="source"]','[data-ta*="source"]','[data-test*="source"]','[data-ta*="journal"]','[data-test*="journal"]',"p.source"];for(const r of t){const i=this.cleanJournalName(this.queryFirst(e,[r])?.textContent);if(i)return i}const n=this.cleanText(this.queryFirst(e,[".summary",'[data-name="summary"]'])?.textContent);return this.extractJournalFromSummary(n)??""}extractYearFromRoot(e){const t=this.queryFirst(e,[".pub-year",'[data-name="publicationDate"]','[data-name="published"]','[data-ta*="date"]','[data-test*="date"]',".summary",'[data-name="summary"]']);return this.extractYear(t?.textContent)}extractDoiFromRoot(e,t=!0){const n=e.querySelector("[data-doi]"),r=this.cleanDoi(n?.getAttribute("data-doi"));if(r)return r;const i=e.querySelector('a[href*="doi.org/"]'),o=this.cleanDoi(i?.getAttribute("href"));if(o)return o;const s=this.queryFirst(e,['[data-name="doi"]','[data-ta*="doi"]','[data-test*="doi"]']);return this.cleanDoi(s?.textContent)??(t?this.cleanDoi(e.textContent):void 0)}extractDetailPageJournal(e){return this.extractJournalFromRoot(e)}extractDetailPageYear(e){const t=this.getMetaContent("citation_publication_date")??this.getMetaContent("citation_online_date")??this.getMetaContent("citation_year");return this.extractYear(t)??this.extractYearFromRoot(e)}extractDetailPageDoi(e){return this.extractDoiFromRoot(e,!1)}getDetailHostElement(){return document.querySelector(".full-record")??document.querySelector('[data-name="full-record"]')??document.querySelector('[data-ta*="full-record"]')??document.querySelector('[data-test*="full-record"]')??document.querySelector("main")??document.body}extractAuthorsFromRoot(e){const t=e.querySelectorAll([".authors a",'[data-name="authors"] a','[data-ta*="author"] a','[data-test*="author"] a',".authors span",'[data-name="authors"] span'].join(", ")),n=Array.from(t).map(c=>this.cleanAuthorName(c.textContent)).filter(c=>!!c);if(n.length>0)return[...new Set(n)];const r=this.queryFirst(e,[".authors",'[data-name="authors"]','[data-ta*="author"]','[data-test*="author"]']),i=this.cleanText(r?.textContent);if(!i)return;const o=i.replace(/^By\s*[:：]\s*/i,""),l=(o.includes(";")?o.split(";"):o.split(/\s{2,}/)).map(c=>this.cleanAuthorName(c)).filter(c=>!!c);return l.length>0?[...new Set(l)]:void 0}extractArticleTypesFromRoot(e){const t=['[data-name="documentType"]','[data-name="document-type"]','[data-ta*="document-type"]','[data-test*="document-type"]',".document-type",".doctype"],r=this.firstTextFromSelectors(e,t)??this.extractLabeledValue(e.textContent,["Document Type","Publication Type","Article Type"]);if(!r)return;const i=r.replace(/^(?:Document Type|Publication Type|Article Type)\s*[:：]\s*/i,"").split(/[;|]/).flatMap(o=>o.split(/\s{2,}/)).map(o=>this.cleanText(o)).filter(o=>!!o).filter(o=>!cl.test(o)&&!ul.test(o)&&!dl.test(o));return i.length>0?[...new Set(i)]:void 0}extractIssnFromRoot(e,t=!0){const n=['[data-name="issn"]','[data-name="eissn"]','[data-ta*="issn"]','[data-test*="issn"]',".issn"],r=this.firstTextFromSelectors(e,n);return this.cleanIssn(r)??(t?this.cleanIssn(e.textContent):void 0)}cleanAuthorName(e){return this.cleanText(e)?.replace(/^By\s*[:：]\s*/i,"").replace(/\s*\([^)]*\)\s*$/,"")||void 0}extractJournalFromSummary(e){if(!e)return;const t=e.match(/\b(?:Source|Source Title|Publication Name|Journal|Published in)\s*[:：]\s*([^.;|]+)/i);if(t)return this.cleanJournalName(t[1])}firstTextFromSelectors(e,t){for(const n of t){const r=this.cleanText(this.queryFirst(e,[n])?.textContent);if(r)return r}}extractLabeledValue(e,t){const n=this.cleanText(e);if(n)for(const r of t){const i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o="(?:Published|Publication Date|Publication Year|DOI|ISSN|eISSN|Source|Source Title|Authors|Times Cited|Accession Number|Volume|Issue|Pages?)",s=n.match(new RegExp(`${i}\\s*[:\uFF1A]\\s*([\\s\\S]*?)(?=\\s+${o}\\s*[:\uFF1A]|$)`,"i"));if(s)return this.cleanText(s[1])}}cleanJournalName(e){return this.cleanText(e)?.replace(/^(?:Source|Source Title|Publication Name|Journal|Published in)\s*[:：]\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|Pages?)\b.*$/i,"").replace(/\s*[,;|]\s*$/,"").trim()||void 0}extractYear(e){const t=this.cleanText(e)?.match(cl);return t?parseInt(t[1],10):void 0}cleanDoi(e){const t=this.cleanText(e);if(!t)return;let n=t;try{n=decodeURIComponent(t)}catch{n=t}const r=n.match(ul);if(r)return r[0].replace(/[.,;]+$/,"")}cleanIssn(e){return this.cleanText(e)?.match(dl)?.[0].toUpperCase()}queryFirst(e,t){for(const n of t)try{const r=e.querySelector(n);if(r)return r}catch{}return null}cleanText(e){return e?.replace(/\s+/g," ").trim()||void 0}getMetaContent(e){return this.cleanText(document.querySelector(`meta[name="${e}"]`)?.getAttribute("content")??document.querySelector(`meta[property="${e}"]`)?.getAttribute("content"))}getMetaContents(e){return Array.from(document.querySelectorAll(`meta[name="${e}"], meta[property="${e}"]`)).map(t=>this.cleanText(t.getAttribute("content"))).filter(t=>!!t)}toAbsoluteUrl(e){if(e)try{return new URL(e,location.href).href}catch{return e}}}const ef=/\b((?:19|20)\d{2})\b/,tf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,nf=/\b(?:arxiv|bioRxiv|medRxiv|SSRN)\b/i,rf=[{pattern:/^Proceedings of the National Academy of Sciences$/i,canonical:"Proceedings of the National Academy of Sciences of the United States of America"}],pl=[{pattern:/\b(?:NeurIPS|NIPS|Neural Information Processing Systems)\b/i,canonical:"NeurIPS"},{pattern:/\bCVPR\b|Computer Vision and Pattern Recognition/i,canonical:"CVPR"},{pattern:/\bICCV\b|International Conference on Computer Vision/i,canonical:"ICCV"},{pattern:/\bECCV\b|European Conference on Computer Vision/i,canonical:"ECCV"},{pattern:/\bICML\b|International Conference on Machine Learning/i,canonical:"ICML"},{pattern:/\bICLR\b|International Conference on Learning Representations/i,canonical:"ICLR"},{pattern:/\bKDD\b|Knowledge Discovery and Data Mining/i,canonical:"KDD"},{pattern:/\bSIGIR\b/i,canonical:"SIGIR"},{pattern:/\bSIGMOD\b/i,canonical:"SIGMOD"},{pattern:/\bVLDB\b/i,canonical:"VLDB"},{pattern:/\bACL\b|Association for Computational Linguistics/i,canonical:"ACL"},{pattern:/\bEMNLP\b/i,canonical:"EMNLP"},{pattern:/\bAAAI\b/i,canonical:"AAAI"},{pattern:/\bIJCAI\b/i,canonical:"IJCAI"},{pattern:/\bCHI\b|Human Factors in Computing Systems/i,canonical:"CHI"},{pattern:/\bWWW\b|World Wide Web Conference/i,canonical:"WWW"},{pattern:/\bSOSP\b/i,canonical:"SOSP"},{pattern:/\bOSDI\b/i,canonical:"OSDI"},{pattern:/\bUSENIX\b/i,canonical:"USENIX"}],af=/\b(?:conference|symposium|workshop|congress)\b/i;class of extends W{id="semantic-scholar";name="Semantic Scholar";matches=["*://www.semanticscholar.org/*"];isSearchPage(){return location.pathname!=="/search"?!1:new URLSearchParams(location.search).has("q")}isArticlePage(){const e=location.pathname.split("/").filter(Boolean);return e[0]==="paper"&&e.length>=2}parseSearchResults(){const e=[],t=new Set,n=new Set;for(const r of this.getSearchResultHosts())if(!t.has(r)){t.add(r);try{const i=this.parseSearchResultHost(r);if(!i)continue;const o=this.articleKey(i);if(n.has(o))continue;n.add(o),e.push(i)}catch(i){console.error("[SemanticScholarAdapter] Failed to parse result:",i)}}return e}parseArticlePage(){try{if(/page not found/i.test(document.title))return null;const e=this.getDetailHostElement();if(!e)return null;const t=this.getJsonLdArticle(),n=this.getMetaContent("citation_title")??this.cleanTitle(t?.headline??t?.name??"")??this.cleanTitle(this.queryText(e,['h1[data-test-id*="title"]','h1[data-testid*="title"]',"h1",'[data-test-id*="paper-title"]','[data-testid*="paper-title"]',".paper-detail-title"]));if(!n)return console.warn("[SemanticScholarAdapter] Article page without title"),null;const r=this.getMetaContent("citation_journal_title")||this.extractJsonLdVenue(t)||this.extractVenue(e),i=this.normalizeVenue(r),o=this.unique([r,i.canonical,i.displayName,this.getMetaContent("citation_conference_title")]),s=this.cleanDoi(this.getMetaContent("citation_doi"))??this.extractDoi(e),l=this.extractYear(this.getMetaContent("citation_publication_date"))??this.extractYear(t?.datePublished)??this.extractYear(this.queryText(e,[".cl-paper-pubdates",'[data-test-id*="pubdate"]','[data-testid*="pubdate"]','[data-test-id*="publication-date"]','[data-testid*="publication-date"]',"time"]))??this.extractYear(this.extractDetailHeaderText(e)),c=this.unique([...this.getMetaContents("citation_author"),...this.extractJsonLdAuthors(t),...this.extractAuthors(e)]),u=this.cleanAbstract(this.getMetaContent("citation_abstract"))??this.cleanAbstract(t?.description)??this.extractAbstract(e);return{title:n,journalName:i.canonical||i.displayName||r||"",journalCandidates:o,authors:c,year:l,doi:s,pmid:this.extractPmid(e),url:location.href,abstractSnippet:u,articleTypes:this.inferArticleTypes(r,this.extractPublicationTypeText(e),t),issn:this.getMetaContent("citation_issn")??this.getMetaContent("citation_eissn")??void 0,hostElement:e,source:this.id}}catch(e){return console.error("[SemanticScholarAdapter] Failed to parse article page:",e),null}}getMetricBarAnchor(e){const t=this.queryFirst(e,[".cl-paper__bulleted-row",".cl-paper-pubdates",'[data-test-id="paper-meta"]','[data-testid="paper-meta"]','[data-test-id*="venue"]','[data-testid*="venue"]']);if(t)return{element:t,position:"after"};const n=this.queryFirst(e,['[data-test-id="title-link"]','[data-testid="title-link"]',".cl-paper-title","h1","h2","h3"]);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector('[data-test-id="result-page"]')??document.querySelector('[data-testid="result-page"]')??document.querySelector(".result-page")??document.querySelector("main")}getPageInfo(){const e={pageNum:1,totalPages:1,url:location.href,itemsPerPage:10},t=new URLSearchParams(location.search).get("page");if(t){const n=Number.parseInt(t,10);Number.isFinite(n)&&n>0&&(e.pageNum=n)}return e}parseSearchResultHost(e){const t=this.getTitleLink(e),n=this.cleanTitle(t?.textContent??this.queryText(e,[".cl-paper-title","h2","h3"]));if(!n)return null;const r=this.extractVenue(e),i=this.normalizeVenue(r),o=this.extractDoi(e);return{title:n,journalName:i.canonical||i.displayName||r||"",journalCandidates:this.unique([r,i.canonical,i.displayName]),authors:this.extractAuthors(e),year:this.extractYear(this.queryText(e,[".cl-paper-pubdates",'[data-test-id*="pubdate"]','[data-testid*="pubdate"]','[data-test-id*="publication-date"]','[data-testid*="publication-date"]']))??this.extractYear(e.textContent??""),doi:o,pmid:this.extractPmid(e),url:this.absoluteUrl(t?.getAttribute("href"))??void 0,abstractSnippet:this.extractAbstract(e),articleTypes:this.inferArticleTypes(r,e.textContent??""),hostElement:e,source:this.id}}getSearchResultHosts(){const e=new Set,t=[".cl-paper-row[data-paper-id]",".cl-paper-row",".paper-row","[data-paper-id]",'[data-test-id*="paper-row"]','[data-testid*="paper-row"]',"article"];for(const n of document.querySelectorAll(t.join(",")))(this.getTitleLink(n)||n.querySelector(".cl-paper-title"))&&e.add(n);if(e.size===0){const n=document.querySelectorAll('a[data-test-id="title-link"][href*="/paper/"],a[data-testid="title-link"][href*="/paper/"],a[href^="/paper/"],a[href*="semanticscholar.org/paper/"]');for(const r of n)e.add(this.closestResultHost(r))}return[...e]}getTitleLink(e){const t=this.queryFirst(e,['a[data-test-id="title-link"][href*="/paper/"]','a[data-testid="title-link"][href*="/paper/"]','a[href^="/paper/"]','a[href*="semanticscholar.org/paper/"]']);if(t instanceof HTMLAnchorElement)return t;const r=this.queryFirst(e,[".cl-paper-title","h2","h3"])?.closest('a[href*="/paper/"]');return r instanceof HTMLAnchorElement?r:null}closestResultHost(e){return e.closest(".cl-paper-row")??e.closest(".paper-row")??e.closest("[data-paper-id]")??e.closest('[data-test-id*="paper"]')??e.closest('[data-testid*="paper"]')??e.closest("article")??e.closest("li")??e.parentElement??e}getDetailHostElement(){const e=document.querySelector('[data-test-id*="paper-detail"]')??document.querySelector('[data-testid*="paper-detail"]')??document.querySelector(".paper-detail")??document.querySelector(".paper-detail-page")??document.querySelector("#paper-header")??document.querySelector(".paper-header")??document.querySelector("main")??document.querySelector("article");if(e)return e;const t=this.queryFirst(document,['h1[data-test-id*="title"]','h1[data-testid*="title"]','[data-test-id*="paper-title"]','[data-testid*="paper-title"]',".paper-detail-title","h1"]);return t?t.closest('[data-test-id*="paper-detail"]')??t.closest('[data-testid*="paper-detail"]')??t.closest('[class*="paper-detail"]')??t.closest('[class*="paper-header"]')??t.closest('[class*="paper__header"]')??t.closest("section")??t.closest("div")??null:null}extractVenue(e){const t=this.queryText(e,['[data-test-id="normalized-venue-link"] [data-test-id="venue-metadata"]','[data-testid="normalized-venue-link"] [data-testid="venue-metadata"]','[data-test-id="venue-metadata"]','[data-testid="venue-metadata"]','[data-test-id*="venue"]','[data-testid*="venue"]','a[href^="/venue?name="]','a[href*="/venue?name="]',".cl-paper-venue",'[class*="venue"]']);return this.cleanVenue(t)}normalizeVenue(e){const t=this.cleanVenue(e);if(!t)return{displayName:"",canonical:""};for(const n of rf)if(n.pattern.test(t))return{displayName:t,canonical:n.canonical};for(const n of pl)if(n.pattern.test(t))return{displayName:t,canonical:n.canonical};return{displayName:t,canonical:t}}inferArticleTypes(e,t,n){const r=e??"",i=`${r} ${t}`.replace(/\s+/g," ");if(nf.test(i))return["Preprint"];if(pl.some(s=>s.pattern.test(i))||af.test(r))return["Conference"];const o=Array.isArray(n?.["@type"])?n?.["@type"]?.join(" "):n?.["@type"];return o&&/preprint/i.test(o)?["Preprint"]:e?["JournalArticle"]:[]}extractPublicationTypeText(e){return this.queryText(e,['[data-test-id*="publication-type"]','[data-testid*="publication-type"]','[data-test-id*="paper-type"]','[data-testid*="paper-type"]','[class*="publication-type"]','[class*="paper-type"]'])}extractDetailHeaderText(e){return[this.queryText(e,[".cl-paper-pubdates",'[data-test-id*="pubdate"]','[data-testid*="pubdate"]','[data-test-id*="publication-date"]','[data-testid*="publication-date"]',"time"]),this.extractVenue(e),this.extractPublicationTypeText(e)].filter(Boolean).join(" ")}extractAuthors(e){const t=new Set,n=['[data-test-id="author-list"] a','[data-testid="author-list"] a','[data-test-id*="author"] a[href*="/author/"]','[data-testid*="author"] a[href*="/author/"]','.cl-paper-authors a[href*="/author/"]','a[href^="/author/"]'];for(const r of e.querySelectorAll(n.join(","))){const i=this.cleanText(r.textContent);i&&(/show|authors?|more|expand|\.\.\./i.test(i)||t.add(i))}return[...t]}extractAbstract(e){return this.cleanAbstract(this.queryText(e,[".tldr-abstract-replacement",'[data-test-id*="tldr"]','[data-testid*="tldr"]','[data-test-id*="abstract"]','[data-testid*="abstract"]',".abstract"]))??void 0}extractDoi(e){const t=e.querySelector('a[href*="doi.org/"]'),n=t instanceof HTMLAnchorElement?this.cleanDoi(t.href):void 0;return n||(this.cleanDoi(e.textContent??"")??void 0)}extractPmid(e){const t=e.querySelector('a[href*="pubmed.ncbi.nlm.nih.gov/"]');if(t instanceof HTMLAnchorElement){const r=t.href.match(/pubmed\.ncbi\.nlm\.nih\.gov\/(\d+)/);if(r?.[1])return r[1]}return(e.textContent??"").match(/\bPMID[:\s]+(\d{5,12})\b/i)?.[1]}getJsonLdArticle(){for(const e of document.querySelectorAll('script[type="application/ld+json"]'))try{const t=JSON.parse(e.textContent??""),r=(Array.isArray(t)?t:[t]).find(i=>{const o=Array.isArray(i["@type"])?i["@type"].join(" "):i["@type"]??"";return/article|scholarly|creativework/i.test(o)||!!i.headline});if(r)return r}catch{}return null}extractJsonLdVenue(e){if(!e)return"";const t=e.isPartOf;if(typeof t=="string")return t;if(t?.name)return t.name;const n=e.publisher;return typeof n=="string"?n:n?.name??""}extractJsonLdAuthors(e){return e?.author?(Array.isArray(e.author)?e.author:[e.author]).map(n=>typeof n=="string"?n:n.name??"").map(n=>this.cleanText(n)).filter(n=>!!n):[]}queryFirst(e,t){for(const n of t){const r=e.querySelector(n);if(r)return r}return null}queryText(e,t){const n=this.queryFirst(e,t);return this.cleanText(n?.textContent)??""}getMetaContent(e){const t=`meta[name="${e}"], meta[property="${e}"]`,r=document.querySelector(t)?.getAttribute("content");return this.cleanText(r)??void 0}getMetaContents(e){return[...document.querySelectorAll(`meta[name="${e}"], meta[property="${e}"]`)].map(t=>this.cleanText(t.getAttribute("content"))).filter(t=>!!t)}extractYear(e){const t=e?.match(ef);return t?.[1]?Number.parseInt(t[1],10):void 0}cleanTitle(e){return this.cleanText(e)?.replace(/^\[[^\]]+\]\s*/,"").replace(/\s*\|\s*Semantic Scholar$/i,"").trim()||null}cleanVenue(e){return this.cleanText(e)?.replace(/^Published\s+in\s+/i,"").replace(/^Venue[:\s]+/i,"").replace(/^Journal[:\s]+/i,"").replace(/^Conference[:\s]+/i,"").replace(/\s*\|\s*Semantic Scholar$/i,"").trim()??""}cleanAbstract(e){return this.cleanText(e)?.replace(/^TLDR\s*:?\s*/i,"").replace(/\s*Expand\s*$/i,"").trim()||null}cleanDoi(e){if(!e)return;let t=e;try{t=decodeURIComponent(e)}catch{t=e}const n=t.match(tf);if(n?.[0])return n[0].replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/[)\].,;:]+$/g,"")}cleanText(e){return e?.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()||null}absoluteUrl(e){if(!e)return null;try{return new URL(e,location.origin).href}catch{return null}}unique(e){const t=new Set,n=[];for(const r of e){const i=this.cleanText(r);if(!i)continue;const o=i.toLowerCase();t.has(o)||(t.add(o),n.push(i))}return n}articleKey(e){return e.doi??e.url??`${e.title}|${e.journalName}|${e.year??""}`}}const hl=/\b((?:19|20)\d{2})\b/,sf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,fl="paperlens-wanfang-enhancement-line",Er=/(?:期刊论文|学位论文|会议论文|专利|科技报告|成果|标准|地方志|图书|视频)/,lf=['a[href*="/Paper/Detail"]','a[href*="/paper/detail"]','a[href^="/periodical/"]','a[href^="/thesis/"]','a[href^="/conference/"]','a[href*="d.wanfangdata.com.cn/periodical/"]','a[href*="d.wanfangdata.com.cn/thesis/"]','a[href*="d.wanfangdata.com.cn/conference/"]'].join(","),_r={WF_QK:"\u4E2D\u6587\u671F\u520A",WF_XW:"\u5B66\u4F4D\u8BBA\u6587",WF_HY:"\u4F1A\u8BAE\u8BBA\u6587",WF_ZL:"\u4E13\u5229",WF_BZ:"\u6807\u51C6",WF_TS:"\u56FE\u4E66"};class cf extends W{id="wanfang";name="\u4E07\u65B9\u6570\u636E";matches=["*://www.wanfangdata.com.cn/*","*://med.wanfangdata.com.cn/*","*://s.wanfangdata.com.cn/*","*://d.wanfangdata.com.cn/*"];isSearchPage(){if(location.hostname==="s.wanfangdata.com.cn")return/^\/(?:paper|periodical|thesis|conference|patent|nstr|cstad|standard|law|localchronicleitem|localchronicle|video|book)\b/i.test(location.pathname);const e=location.pathname.toLowerCase();return e.includes("/paper/search")||e==="/search"||e.includes("/search")}isArticlePage(){const e=location.pathname.toLowerCase();return e.includes("/paper/detail")||location.hostname==="d.wanfangdata.com.cn"&&/^\/(?:periodical|thesis|conference)\//.test(e)}parseSearchResults(){const e=[],t=new Set,n=this.getResultsContainer()??document.body;for(const r of n.querySelectorAll(lf)){const i=this.findResultHost(r);if(!(!i||t.has(i))){t.add(i);try{const o=this.parseResultHost(i,r);o&&e.push(o)}catch(o){console.error("[WanfangAdapter] Failed to parse result:",o)}}}if(location.hostname==="s.wanfangdata.com.cn"){const r=this.parseCurrentSearchResults(n);if(r.length>0)return this.uniqueArticlesByIdentity([...r,...e])}return e}parseArticlePage(){try{const e=this.getDetailHostElement();if(!e)return null;const t=this.cleanTitle(e.querySelector(".headline h2")?.textContent??e.querySelector("h2")?.textContent??"");if(!t)return null;const n=this.getDbid(location.href),r=_r[n??""]??this.extractDetailType(),o=this.isJournalType(r)?this.extractDetailJournal(e):"",s=this.extractSourceId(location.href,e);return{title:t,journalName:o,journalCandidates:o?[o]:void 0,authors:this.extractDetailAuthors(e),year:this.extractDetailYear(e,r),doi:this.extractDetailDoi(e),sourceId:s,url:this.toCanonicalArticleUrl(location.href)??location.href,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractDetailAbstract(e),hostElement:e,articleTypes:r?[r]:void 0,source:this.id}}catch(e){return console.error("[WanfangAdapter] Failed to parse article page:",e),null}}getMetricBarAnchor(e){const t=e.querySelector(".item-title")??e.querySelector(".reference")??e.querySelector(".content")??this.findCurrentSearchTitleBlock(e)??e.querySelector(".headline")??e.querySelector("h2")?.parentElement;return t?{element:this.getOrCreateEnhancementLine(t),position:"append"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector("#resultsList")??document.querySelector("#paper-content-wrap")??document.querySelector(".result-list-container")??document.querySelector(".mod-results-list")??document.querySelector(".result-list")??document.querySelector(".table-list")??document.querySelector(".detail-list")??document.querySelector("main")??document.querySelector("[data-paperlens-results]")}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("p")??e.get("page")??"1",10),n=document.body.textContent?.match(/共\s*(\d+)\s*页/)?.[1],r=n?Number.parseInt(n,10):1;return{pageNum:Number.isFinite(t)&&t>0?t:1,totalPages:Number.isFinite(r)&&r>0?r:1,url:location.href,itemsPerPage:10}}parseResultHost(e,t){const n=this.cleanTitle(t.textContent??"");if(!n)return null;const r=this.getMetaParagraph(e),i=this.cleanText(r?.textContent??""),o=this.extractBracketType(i)||this.typeFromUrl(t.getAttribute("href")),l=this.isJournalType(o)?this.extractJournalFromMeta(r):"",c=this.extractSourceId(t.getAttribute("href"),e);return{title:n,journalName:l,journalCandidates:l?[l]:void 0,authors:this.extractAuthorsFromMeta(r,o,t),year:this.extractYear(i),doi:this.extractSearchDoi(e),sourceId:c,url:this.toAbsoluteUrl(t.getAttribute("href")),nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractSearchAbstract(e),hostElement:e,articleTypes:o?[o]:void 0,source:this.id}}parseCurrentSearchResults(e){const t=this.findCurrentSearchResultHosts(e),n=[],r=new Set;for(const i of t)try{const o=this.parseCurrentSearchHost(i);if(!o)continue;const s=[o.sourceId,o.url,o.title,o.year].filter(Boolean).join("|");if(s&&r.has(s))continue;s&&r.add(s),n.push(o)}catch(o){console.error("[WanfangAdapter] Failed to parse current search host:",o)}return n}findCurrentSearchResultHosts(e){const t=Array.from(e.querySelectorAll(".new-list .list-item, .list-item .content")).map(r=>r.matches(".list-item")?r:r.closest(".list-item")).filter(r=>!!r).map(r=>this.findCurrentSearchMetadataHost(r)).filter(r=>this.isCurrentSearchResultHost(r));if(t.length>0)return t.filter((r,i,o)=>o.findIndex(s=>s===r)===i);const n=Array.from(e.querySelectorAll("div, article, li, section")).map(r=>this.findCurrentSearchMetadataHost(r)).filter(r=>this.isCurrentSearchResultHost(r));return n.filter(r=>!n.some(i=>i!==r&&r.contains(i)))}isCurrentSearchResultHost(e){const t=this.cleanText(e.textContent??"");if(!t)return!1;const n=!!e.querySelector(".reference"),r=!!e.querySelector(".essay-type")||Er.test(t)||/\[\s*(?:期刊论文|学位论文|会议论文|专利|科技报告|成果|标准)\s*\]/.test(t),i=!!e.querySelector(".abstract")||/摘要[:：]/.test(t),o=!!e.querySelector(".wf-list-button, .online-read, .list-button-quote")||/(?:在线阅读|下载|引用|收藏)/.test(t),s=this.findCurrentSearchTitleLink(e),l=!!this.extractCurrentSearchTitleFromHost(e),c=/(?:被引|下载)[:：]\s*\d+/.test(t);return!(!s&&!n&&!l||!r||!i&&!o&&!c)}parseCurrentSearchHost(e){const t=this.cleanText(e.textContent??"");if(!t)return null;const n=this.findCurrentSearchMetadataHost(e),r=this.findCurrentSearchTitleLink(e),i=this.cleanTitle(e.querySelector(".reference a")?.textContent??r?.textContent??this.extractCurrentSearchTitleFromHost(e)??this.extractCurrentSearchTitle(t)??"");if(!i)return null;const o=this.cleanText(e.querySelector(".essay-type")?.textContent??t.match(Er)?.[0]??t.match(/\[\s*([^\]]+)\s*\]/)?.[1]??""),l=this.isJournalType(o)?this.cleanJournalName(t.match(/《([^》]+)》/)?.[1]??""):"",c=Array.from(e.querySelectorAll(".reference a[href], .content a[href], .wf-search-card__meta a[href], .meta-row a[href]")).map(m=>this.cleanText(m.textContent??"")).filter(m=>m&&m!==i&&!/^(?:在线阅读|下载|引用|收藏|登录|注册)$/.test(m)&&!/《[^》]+》/.test(m)).slice(0,8),u=c.length>0?c:this.extractCurrentSearchAuthors(t),d=r?.getAttribute("href")??n.querySelector('a[href*="/periodical/"], a[href*="/thesis/"], a[href*="/conference/"], a[href*="/Paper/Detail"], a[href*="d.wanfangdata.com.cn/"]')?.getAttribute("href")??this.modernDetailUrlFromItemMetadata(n),p=this.cleanText(e.querySelector(".abstract")?.textContent?.replace(/^摘要[:：]?\s*/,"")??t.match(/摘要[:：]\s*(.+?)(?=\s*(?:在线阅读|下载|引用|收藏|评审材料|被引[:：]|下载[:：]|$))/)?.[1]??"")||void 0;return{title:i,journalName:l,journalCandidates:l?[l]:void 0,authors:u?.length?u:void 0,year:this.extractYear(t),sourceId:this.extractSourceId(d,n),url:this.toCanonicalArticleUrl(d)??this.toAbsoluteUrl(d),nativeFullTextUrl:this.extractNativeFullTextUrl(n),abstractSnippet:p,hostElement:e,articleTypes:o?[o]:void 0,source:this.id}}findResultHost(e){return e.closest(".item-content")??e.closest("tr")??e.closest(".result-list-item")??e.closest(".paper-list-item")??e.closest(".detail-list")??e.closest(".item")??e.closest("li")??e.closest("article")??e.closest("[data-paperlens-result]")}findCurrentSearchTitleLink(e){const t=e.querySelector(".reference a[href]")??e.querySelector("h1 a, h2 a, h3 a")??e.querySelector('a[href*="/periodical/"], a[href*="/thesis/"], a[href*="/conference/"], a[href*="/Paper/Detail"], a[href*="d.wanfangdata.com.cn/"]');if(!t)return null;const n=this.cleanTitle(t.textContent??"");return!n||/^(?:在线阅读|下载|引用|收藏|登录|注册)$/.test(n)?null:t}findCurrentSearchTitleBlock(e){const t=this.findCurrentSearchTitleLink(e)?.closest("h1, h2, h3, .title, .record-title");return t||(Array.from(e.querySelectorAll("h1, h2, h3, div, p, span")).filter(r=>{const i=this.cleanText(r.textContent??"");return!i||i.length>180||/(?:在线阅读|下载|引用|收藏|摘要[:：]|被引[:：]|下载[:：])/.test(i)?!1:/^\[?\d+\]?[.．、]?\s*\S/.test(i)}).sort((r,i)=>this.cleanText(r.textContent??"").length-this.cleanText(i.textContent??"").length)[0]??null)}findCurrentSearchMetadataHost(e){let t=e;for(;t&&t!==document.body;){if(t.matches(".item-checkbox[data-itemid], [data-content], [data-id]")||t.querySelector(".item-checkbox[data-itemid], [data-content], [data-id]"))return t;t=t.parentElement}return e}extractCurrentSearchTitle(e){const t=e.match(new RegExp(String.raw`^\[?\d+\]?[.．、]?\s*(.+?)(?=\s*\[\s*${Er.source}\s*\]|\s+${Er.source}\b)`));return this.cleanTitle(t?.[1]??"")||void 0}extractCurrentSearchTitleFromHost(e){const t=this.findCurrentSearchTitleBlock(e);if(t){const n=t.cloneNode(!0);n.querySelectorAll('[class^="paperlens-"], [class*=" paperlens-"]').forEach(o=>o.remove());const r=this.cleanText(n.textContent??""),i=this.cleanTitle(r.replace(/^\[?\d+\]?[.．、]?\s*/,""));if(i)return i}return this.extractCurrentSearchTitle(this.cleanText(e.textContent??""))}extractCurrentSearchAuthors(e){const t=e.match(new RegExp(String.raw`\[\s*${Er.source}\s*\]\s*(.+?)\s*-\s*《`)),n=this.cleanText(t?.[1]??"");if(!n)return;const r=n.split(/[\s,，;；/]+/).map(i=>i.trim()).filter(i=>i&&!/[0-9]/.test(i)&&!/^(?:北大核心|CSTPCD|CSCD|CSSCI|SCI|EI|在线阅读|下载|引用|收藏|评审材料)$/.test(i)).slice(0,8);return r.length>0?r:void 0}getMetaParagraph(e){for(const t of Array.from(e.querySelectorAll("p"))){const n=t.textContent??"";if(!/【摘要】|^摘要/.test(n)&&this.extractBracketType(n))return t}if(e.matches("tr, .detail-list"))return e;for(const t of Array.from(e.querySelectorAll([".item-intro p",".item-intro",".paper-info",".detail-info",".result-info",".item-meta",".meta",".source",".periodical","td:not(.paperTitleTd)","p"].join(",")))){if(t.closest(".item-title, .paperTitleTd"))continue;const n=t.textContent??"";if(!/【摘要】|^摘要/.test(n)&&(t.querySelector("a")||hl.test(n)||/《[^》]+》/.test(n)))return t}return null}extractBracketType(e){const t=e.match(/【([^】]+)】/),n=this.cleanText(t?.[1]??"");return this.isKnownResourceType(n)?n:""}isKnownResourceType(e){return/期刊|学位|会议|专利|标准|图书|报纸|成果/i.test(e)}typeFromUrl(e){const t=this.getDbid(e??"");if(t&&_r[t])return _r[t];try{const n=new URL(e??"",location.href).pathname.toLowerCase();if(n.includes("/periodical/"))return"\u4E2D\u6587\u671F\u520A";if(n.includes("/thesis/"))return"\u5B66\u4F4D\u8BBA\u6587";if(n.includes("/conference/"))return"\u4F1A\u8BAE\u8BBA\u6587"}catch{}return""}isJournalType(e){return!!(e&&/期刊/i.test(e))}extractJournalFromMeta(e){if(!e)return"";const t=e.querySelector('a[href*="/Periodical/Jump"]'),n=this.cleanJournalName(t?.textContent??"");if(n)return n;const r=this.cleanJournalName(e.textContent?.match(/《([^》]+)》/)?.[1]??"");if(r)return r;const i=Array.from(e.querySelectorAll('a[href*="d.wanfangdata.com.cn/periodical/"], a[href*="/periodical/"]')).find(o=>!o.closest(".item-title, .paperTitleTd"));return this.cleanJournalName(i?.textContent??"")}extractAuthorsFromMeta(e,t,n){if(!e)return;const r=Array.from(e.querySelectorAll("a")),i=[];if(this.isJournalType(t))for(const o of r){const s=o.getAttribute("href")??"";if(o===n||this.isDetailLink(o))continue;if(s.includes("/Periodical/Jump"))break;const l=this.cleanText(o.textContent??"");l&&i.push(l)}else if(/学位/.test(t)){const o=this.cleanText(r.find(s=>this.isAuthorSearchLink(s))?.textContent??"");o&&i.push(this.cleanText(o))}else{const o=this.cleanText(r.find(s=>this.isAuthorSearchLink(s))?.textContent??"");o&&i.push(o)}return i.length>0?i:void 0}isAuthorSearchLink(e){const t=decodeURIComponent(e.getAttribute("href")??"");return/(?:^|[?&])q=.*作者[:=：]/.test(t)||/\/Author\//i.test(t)}isDetailLink(e){const t=e.getAttribute("href")??"";return/\/Paper\/Detail|\/paper\/detail|d\.wanfangdata\.com\.cn\/(?:periodical|thesis|conference)\//i.test(t)}extractSearchAbstract(e){for(const t of Array.from(e.querySelectorAll("p")))if(/【摘要】/.test(t.textContent??""))return this.cleanText(t.textContent??"").replace(/^【摘要】\s*/,"")||void 0}getDetailHostElement(){return document.querySelector(".newContext .content")??document.querySelector(".content")??document.querySelector(".newContext")??null}extractDetailType(){const e=this.getDbid(location.href);if(e&&_r[e])return _r[e];const t=location.pathname.toLowerCase();if(location.hostname==="d.wanfangdata.com.cn"){if(t.includes("/periodical/"))return"\u4E2D\u6587\u671F\u520A";if(t.includes("/thesis/"))return"\u5B66\u4F4D\u8BBA\u6587";if(t.includes("/conference/"))return"\u4F1A\u8BAE\u8BBA\u6587"}const n=this.cleanText(document.querySelector(".breadcrumbs")?.textContent??"");return/学位/.test(n)?"\u5B66\u4F4D\u8BBA\u6587":/会议/.test(n)?"\u4F1A\u8BAE\u8BBA\u6587":""}extractDetailJournal(e){const t=[...Array.from(document.querySelectorAll('.breadcrumbs a[href*="/Periodical/Jump"]')),...Array.from(e.querySelectorAll('a[href*="/Periodical/Jump"]')),...Array.from(document.querySelectorAll('.side a[href*="/Periodical/Jump"], .aside a[href*="/Periodical/Jump"]'))];for(const n of t){const r=this.cleanJournalName(n.textContent??"");if(r&&!/首页/.test(r))return r}return""}extractDetailAuthors(e){const t=e.querySelector(".details");if(!t)return;const n=[],r=this.findDetailRowByLabel(t,/^作者$/),i=r?.querySelector(".table-td")??r;if(i)for(const o of Array.from(i?.querySelectorAll("a")??[])){const s=this.cleanText(o.textContent??"");s&&n.push(s)}return n.length>0?n:void 0}extractDetailYear(e,t){if(this.isJournalType(t)){const r=document.querySelector('a[href*="/Periodical/Jump"][href*="year="]'),i=this.extractYearFromUrlParam(r?.getAttribute("href"),"year")??this.extractYear(r?.textContent??"");if(i)return i;const s=this.cleanText(document.querySelector(".sourceTitle")?.textContent??document.querySelector(".side, .aside")?.textContent??"").match(/((?:19|20)\d{2})年\s*\d+\s*卷/);return s?.[1]?Number.parseInt(s[1],10):void 0}const n=e.querySelector(".details");if(n)for(const r of Array.from(n.querySelectorAll(".table-tr"))){const i=this.cleanText(r.querySelector(".table-th")?.textContent??"").replace(/[：:]$/,"");if(/发布时间|首次上网|DOI|作者|导师/.test(i))continue;const o=this.extractYear(r.textContent??"");if(o)return o}}extractYearFromUrlParam(e,t){if(e)try{const n=new URL(e,location.href).searchParams.get(t);return n?this.extractYear(n):void 0}catch{return}}findDetailRowByLabel(e,t){for(const n of Array.from(e.querySelectorAll(".table-tr"))){const r=this.cleanText(n.querySelector(".table-th")?.textContent??"").replace(/[：:]$/,"");if(t.test(r))return n}return null}extractDetailAbstract(e){const t=e.querySelector(".abstracts p")?.textContent??e.querySelector(".abstracts")?.textContent??"";return this.cleanText(t.replace(/^摘要/,"").replace(/\s*更多\s*$/,""))||void 0}extractDetailDoi(e){const t=e.querySelector(".details"),n=t?this.findDetailRowByLabel(t,/^DOI$/i):null;return n?this.extractDoi(n):void 0}extractSearchDoi(e){for(const t of Array.from(e.querySelectorAll('a[href*="doi.org/"]'))){if(this.isRelatedContext(t))continue;const n=this.extractDoi(t);if(n)return n}for(const t of Array.from(e.querySelectorAll("p, .item-meta, .meta, .source, .doi"))){if(this.isRelatedContext(t))continue;const n=this.cleanText(this.textWithoutRelatedContexts(t));if(!/(?:^|\s)DOI\s*[:：]?/i.test(n))continue;const r=this.extractDoiFromText(n);if(r)return r}}extractDoi(e){const t=e.querySelector('a[href*="doi.org/"]'),n=[t?.getAttribute("href"),t?.textContent,e.textContent].filter(Boolean).join(" ");return this.extractDoiFromText(n)}extractDoiFromText(e){return e.match(sf)?.[0]?.replace(/[)\].,;:]+$/g,"")}isRelatedContext(e){return!!e.closest(["#similarLiterature",".similar",".related",".relatePaper",".relateScholar",".recommend",".reference",".references",".citation"].join(","))}textWithoutRelatedContexts(e){const t=e.cloneNode(!0);for(const n of Array.from(t.querySelectorAll(["#similarLiterature",".similar",".related",".relatePaper",".relateScholar",".recommend",".reference",".references",".citation"].join(","))))n.remove();return t.textContent??""}extractNativeFullTextUrl(e){const t=e.querySelector('a[href*="MedFulltext"], a.btn-download[href], a.lnk-download[href]')??Array.from(e.querySelectorAll("a[href]")).find(n=>/下载/.test(this.cleanText(n.textContent??"")));return this.toSafeHttpUrl(t?.getAttribute("href"))}extractYear(e){const t=e.match(hl);return t?.[1]?Number.parseInt(t[1],10):void 0}getDbid(e){try{const n=new URL(e,location.href).searchParams.get("dbid");if(n)return n}catch{}return/DegreePaper_/i.test(e)?"WF_XW":/ConferencePaper_/i.test(e)?"WF_HY":/PeriodicalPaper_/i.test(e)?"WF_QK":null}extractSourceId(e,t){const n=this.extractRawSourceId(e)??this.extractRawSourceId(t?.querySelector("[data-content]")?.getAttribute("data-content"))??this.extractRawSourceId(t?.querySelector("[data-id]")?.getAttribute("data-id"))??this.sourceIdFromItemMetadata(t);return n?`wanfang:${n}`:void 0}extractRawSourceId(e){if(!e)return;try{const r=new URL(e,location.href),i=r.searchParams.get("id");if(i)return i;const o=r.pathname.match(/\/(periodical|thesis|conference)\/([A-Za-z0-9_-]+)/i);if(o?.[1]&&o[2])return`${{periodical:"PeriodicalPaper",thesis:"DegreePaper",conference:"ConferencePaper"}[o[1].toLowerCase()]}_${o[2]}`}catch{}const t=e.match(/\b(?:PeriodicalPaper|DegreePaper|ConferencePaper|Patent|Standard|Book)_[A-Za-z0-9_-]+\b/i)?.[0];if(t)return t;const n=e.match(/\/(periodical|thesis|conference)\/([A-Za-z0-9_-]+)/i);if(n?.[1]&&n[2])return`${{periodical:"PeriodicalPaper",thesis:"DegreePaper",conference:"ConferencePaper"}[n[1].toLowerCase()]}_${n[2]}`}sourceIdFromItemMetadata(e){const t=e?.querySelector(".item-checkbox"),n=t?.getAttribute("data-itemid"),r=t?.getAttribute("data-dbid")??"";if(!n)return;const o={WF_QK:"PeriodicalPaper",WF_XW:"DegreePaper",WF_HY:"ConferencePaper"}[r];return o?`${o}_${n}`:n}modernDetailUrlFromItemMetadata(e){const t=e?.querySelector(".item-checkbox"),n=t?.getAttribute("data-itemid"),r=t?.getAttribute("data-dbid")??"";if(!n)return;const o={WF_QK:"periodical",WF_XW:"thesis",WF_HY:"conference"}[r];return o?`https://d.wanfangdata.com.cn/${o}/${n}`:void 0}toCanonicalArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const i=new URL(t,location.href).pathname.match(/^\/(periodical|thesis|conference)\/([A-Za-z0-9_-]+)$/i);if(i?.[1]&&i[2])return`https://d.wanfangdata.com.cn/${i[1].toLowerCase()}/${i[2]}`}catch{}const n=this.extractRawSourceId(e);if(!n)return t;try{const r=new URL(e??"",location.href);return r.hostname==="d.wanfangdata.com.cn"?r.href:new URL(`/Paper/Detail/${n}`,r.origin).href}catch{return t}}uniqueArticlesByIdentity(e){const t=new Set;return e.filter(n=>{const r=[n.sourceId,n.url,n.title,n.year].filter(Boolean).join("|");return r?t.has(r)?!1:(t.add(r),!0):!0})}getOrCreateEnhancementLine(e){const t=e.querySelector(`.${fl}`);if(t)return t;const n=e.ownerDocument.createElement("div");return n.className=fl,n.style.cssText=["display:flex","flex-wrap:wrap","align-items:center","gap:6px","margin-top:6px","line-height:1.4"].join(";"),e.appendChild(n),n}cleanTitle(e){return this.cleanText(e).replace(/^\d+\.\s*/,"").replace(/^目录[:：]?\s*/i,"").replace(/[《》]/g,"")}cleanJournalName(e){return this.cleanText(e).replace(/[《》]/g,"")}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}toAbsoluteUrl(e){if(e)try{return new URL(e,location.href).href}catch{return e}}toSafeHttpUrl(e){if(e)try{const t=new URL(e,location.href);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}}const uf=/\b((?:19|20)\d{2})\b/,Aa=/\b10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+/i,df=/(?:https?:\/\/(?:dx\.)?doi\.org\/)?10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+/gi,Si="paperlens-baidu-scholar-enhancement-line",Mn=[".sc_content",".result",".result-item","[data-paperlens-baidu-result]"].join(","),Dr=[".sc_title a","h3 a",".result-title a",'a[data-click*="title"]'].join(","),pf=/(?:资源类型|类型|文献类型)\s*[:：]\s*([^；;，,\s]+)/,Fr=/学位|硕士|博士|专利|图书|书籍|会议|标准|报纸|网页|资讯|百科|课程|视频|conference|proceedings?|preprint|thesis|dissertation|patent|book|chapter|newspaper|web/i,Ti=/[-–—]\s*《?([^《》,，;；\-–—]+?)》?\s*(?:[,，]\s*|\s+)((?:19|20)\d{2})(?:年)?(?:\b|(?=\s|[-–—,，.。;；]|来源|DOI|被引|引用|$))(?:\s*(?:(?:[-–—]|[,，.。;；]|来源\s*[:：]?)\s*)?([^；;\n]+))?/,Ei=/中国知网|知网|百度文库|百度百科|万方数据|维普|豆瓣|百科|文库|Wanfang|CNKI|CQVIP|xueshu|example\.|www\.|https?:\/\/|\.(?:com|cn|org|net|edu)\b/i,hf=/百度文库|百度百科|文库|百科|微信公众号|公众号|微信|搜狐网?|丁香园|医学界|医脉通|medlive|豆瓣|知乎|百度经验|百家号|博客|新闻|资讯|转载|课程|视频|学报网|期刊网|杂志网|example\.|wikipedia|blog|news|portal|wenku/i,ff=/(?:万方|wanfang|中国知网|知网|cnki|维普|cqvip|pubmed|ncbi|doi\.org|crossref|springer|wiley|sciencedirect|tandfonline|oup|cambridge|sagepub|nature\.com|science\.org|ieee|acm|jstor|biorxiv|medrxiv|arxiv|scholar|xueshu)/i,mf=["CA: A Cancer Journal for Clinicians","CA-A Cancer Journal for Clinicians","New England Journal of Medicine","The Lancet","The Lancet Oncology","Journal of Clinical Oncology","JAMA","Nature","Science"];class bf extends W{id="baidu-scholar";name="\u767E\u5EA6\u5B66\u672F";matches=["*://xueshu.baidu.com/*"];isSearchPage(){return new URLSearchParams(location.search).has("wd")&&(location.pathname==="/s"||location.pathname==="/ndscholar/browse/search")}isArticlePage(){return!1}parseSearchResults(){const e=[];if(this.isSecurityVerificationPage())return this.clearStaleEnhancementsInContainer(),e;const t=this.getResultsContainer()??document.body;if(!t)return e;for(const n of this.getResultHosts(t))try{const r=this.parseResultHost(n);r?e.push(r):this.clearStaleEnhancements(n)}catch(r){console.error("[BaiduScholarAdapter] Failed to parse result:",r),this.clearStaleEnhancements(n)}return e}parseArticlePage(){return null}getMetricBarAnchor(e){const t=e.querySelector(".sc_title")??e.querySelector("h3")??e.querySelector(".result-title");if(t)return{element:this.getOrCreateEnhancementLine(t),position:"append"};const n=e.querySelector(".sc_info")??e.querySelector(".result-meta");return n?{element:n,position:"after"}:{element:e,position:"append"}}getResultsContainer(){return document.querySelector("#bdxs_result_lists")??document.querySelector("#bdxs_result_list")??document.querySelector("main")??document.querySelector("#container")??document.querySelector("[data-paperlens-baidu-results]")}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"",10),n=Number.parseInt(e.get("pn")??"0",10);return{pageNum:Number.isFinite(t)&&t>0?t:Math.floor(Math.max(0,Number.isFinite(n)?n:0)/10)+1,totalPages:1,url:location.href,itemsPerPage:10}}parseResultHost(e){const t=e.querySelector(Dr),n=this.cleanTitle(t?.textContent??"");if(!n)return null;const r=this.cleanText(this.collectMetaText(e));if(this.isVerificationResult(n,r))return null;const i=this.extractExplicitType(e,r),o=this.extractArticleTypes(i),s=this.toAbsoluteUrl(t?.getAttribute("href")),l=this.extractAuthors(e,r),c=this.extractDoi(s,r),u=this.extractJournalName(e,r,o,!!c),d=this.extractSourceId(t?.getAttribute("href"),n,this.sourceIdDisambiguator(r,o,u,l,c));return{title:n,journalName:u,journalCandidates:u?[u]:void 0,authors:l,year:this.extractYearFromMeta(r),doi:c,sourceId:d,url:s,abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o,source:this.id}}collectMetaText(e){const t=Array.from(e.querySelectorAll([".sc_info",".sc_author",".sc_source",".sc_time",".sc_journal",".result-meta",".c_author",".c_source","[data-paperlens-meta]"].join(",")));return t.length===0?this.cleanText(this.textWithoutTitle(e)):t.map(n=>n.textContent??"").filter(Boolean).join(" ")}extractExplicitType(e,t){return this.cleanText(e.querySelector("[data-paperlens-type], .sc_type, .c_type, .result-type")?.textContent??"")||this.cleanText(t.match(pf)?.[1]??"")}extractArticleTypes(e){if(/学位|硕士|博士/.test(e))return["\u5B66\u4F4D\u8BBA\u6587"];if(/专利|patent/i.test(e))return["\u4E13\u5229"];if(/会议|conference|proceeding/i.test(e))return["\u4F1A\u8BAE\u8BBA\u6587"];if(/图书|书籍|book|chapter/i.test(e))return["\u56FE\u4E66"];if(/网页|百科|资讯|web/i.test(e))return["\u7F51\u9875"];if(/preprint/i.test(e))return["\u9884\u5370\u672C"];if(/期刊|journal article/i.test(e))return["\u671F\u520A"]}extractJournalName(e,t,n,r){const i=n?.join(" ")??"";if(Fr.test(i))return"";const o=r||/期刊|journal/i.test(i)||/(?:类型|文献类型)\s*[:：]\s*(?:期刊|Journal Article)/i.test(t),s=this.cleanText((e.querySelector("[data-paperlens-journal], .sc_source, .c_source")?.textContent??"").replace(/^(?:来源|Source)\s*[:：]\s*/i,"")),l=this.extractCitationSource(s);if(l)return l;const c=this.extractLabeledJournal(s,o);if(c)return c;const u=this.cleanJournalName(this.stripCurrentArticleSourceTail(s));if(u&&!Ei.test(u)&&!this.hasCitationDoiContext(u)&&!this.isNonScholarlySourceText(s)&&(this.hasCjk(u)||o))return u;const d=this.extractCitationSource(t);if(d)return d;const p=this.extractLabeledJournal(t,o);if(p)return p;const m=this.cleanJournalName(t.match(/《([^》]+)》/)?.[1]??"");if(m&&!Ti.test(t)&&!Fr.test(i)&&!this.hasUntrustedQuotedTail(t))return m;const h=o?this.extractKnownEnglishJournal(t):"";return h||""}extractLabeledJournal(e,t){if(this.isNonScholarlySourceText(e))return"";const n=[/(?:期刊|刊名|发表于)\s*[:：]\s*《?([^《》；;,，]+?)》?(?=\s*(?:(?:19|20)\d{2}年?\b|(?:DOI|被引|引用|年份|时间|Year|类型|文献类型)\s*[:：]?|[；;,，]|$))/i,/(?:来源期刊|期刊来源)\s*[:：]\s*《?([^《》；;,，]+?)》?(?=\s*(?:(?:19|20)\d{2}年?\b|(?:DOI|被引|引用|年份|时间|Year|类型|文献类型)\s*[:：]?|[；;,，]|$))/i];for(const r of n){const i=this.cleanJournalName(e.match(r)?.[1]??"");if(i&&!Fr.test(i)&&i.length>1)return i}if(t){const r=this.cleanJournalName(e.match(/(?:Source|来源)\s*[:：]\s*([^；;,，]+?)(?:\s+(?:类型|文献类型|时间|年份|被引|DOI)\s*[:：]|$)/i)?.[1]??""),i=this.stripCurrentArticleSourceTail(r);if(i&&!Fr.test(i)&&!Ei.test(i)&&!this.hasCitationDoiContext(i)&&i.length>1)return i}return""}extractKnownEnglishJournal(e){const t=this.cleanText(e).toLowerCase();if(!t)return"";for(const n of mf)if(t.includes(n.toLowerCase()))return n;return""}extractAuthors(e,t){const n=this.cleanText(e.querySelector("[data-paperlens-authors], .sc_author, .c_author")?.textContent??""),r=this.cleanText(t.match(/(?:作者|Author)\s*[:：]\s*([\s\S]+?)(?:\s+(?:来源|Source|类型|期刊|刊名|发表于|授予单位|时间|年份|被引|DOI)\s*[:：]|$)/i)?.[1]??""),i=n||r||this.extractBareCitationAuthors(t),o=this.cleanText(i).replace(/^(?:作者|Author)\s*[:：]\s*/i,"").split(/[;,，；]/).map(s=>this.cleanText(s)).filter(s=>s&&!/^(?:作者|等)$/.test(s)&&!/摘要|来源|类型|网页|资讯|AI\b/i.test(s)).slice(0,12);return o.length>0?o:void 0}extractSourceId(e,t,n){const r=e??"",i=this.normalizeTrackingUrl(r);try{const o=new URL(i,location.href),l=this.isBaiduHost(o.hostname)&&/\/(?:usercenter\/paper\/show|paper|detail)/.test(o.pathname)?o.searchParams.get("paperid")??o.searchParams.get("id")??o.searchParams.get("pid"):null;if(l)return`baidu-scholar:${l}`}catch{}return`baidu-scholar:${this.stableHash(`${i}|${t}|${n}`)}`}extractDoi(e,t){return this.extractDoiFromUrlPath(e)??this.extractLabeledDoi(t)}extractYearFromMeta(e){const t=this.stripDoiText(this.stripCurrentArticleCountFields(this.normalizeCjkSpacing(e))),n=t.match(/(?:年份|时间|Year)\s*[:：]?\s*((?:19|20)\d{2})/i);if(n?.[1])return Number.parseInt(n[1],10);const r=t.match(/[,，]\s*((?:19|20)\d{2})\b/);return r?.[1]?Number.parseInt(r[1],10):this.extractYear(t)}extractAbstract(e){const t=e.querySelector(".sc_abstract")?.textContent??e.querySelector(".sc_content_summary")?.textContent??e.querySelector(".c_abstract")?.textContent??this.extractFallbackAbstract(e)??"";return this.cleanText(t.replace(/^摘要\s*[:：]/,""))||void 0}extractYear(e){const t=e.match(uf);return t?.[1]?Number.parseInt(t[1],10):void 0}sourceIdDisambiguator(e,t,n,r,i){return this.cleanText([n,i,r?.join("|"),t?.join("|"),this.extractYearFromMeta(e),this.extractExplicitType(document.createElement("div"),e),this.cleanText(e.match(Ti)?.[1]??""),this.extractDisambiguatingSource(e),this.extractGrantingUnit(e)].filter(Boolean).join("|"))}extractDisambiguatingSource(e){const t=this.cleanText(e.match(/(?:来源|Source)\s*[:：]\s*([^；;,，]+?)(?=\s*(?:(?:类型|文献类型|授予单位|时间|年份|被引|引用|参考文献|DOI)\s*[:：]|$))/i)?.[1]??"");return this.cleanText(this.stripCurrentArticleSourceTail(t))}extractGrantingUnit(e){return this.cleanText(e.match(/授予单位\s*[:：]\s*([^；;,，]+?)(?=\s*(?:(?:类型|文献类型|时间|年份|被引|引用|参考文献|DOI)\s*[:：]|$))/i)?.[1]??"")}getOrCreateEnhancementLine(e){const t=e.querySelector(`.${Si}`);if(t)return t;const n=e.ownerDocument.createElement("div");return n.className=Si,n.style.cssText=["display:flex","flex-wrap:wrap","align-items:center","gap:6px","margin-top:6px","line-height:1.4"].join(";"),e.appendChild(n),n}cleanTitle(e){return this.cleanText(e).replace(/^\s*(?:\[[^\]]+\]\s*)+/,"").replace(/[《》]/g,"")}cleanJournalName(e){const t=this.cleanText(e).replace(/[《》]/g,"");return/^(?:AI|IF|CCF|JCR|CAS)$/i.test(t)?"":t}extractCitationSource(e){const t=e.match(Ti),n=this.cleanJournalName(t?.[1]??""),r=this.cleanText(t?.[3]??"");return n&&this.hasCjk(n)&&!Fr.test(n)&&!this.isNonScholarlySourceText(e)&&this.isTrustedCitationTail(r)&&!Ei.test(n)?n:""}extractBareCitationAuthors(e){const t=this.cleanText(e.match(/^(.+?)\s*[-–—]\s*《?[^《》,，;；\-–—]+?》?\s*(?:[,，]\s*|\s+)(?:19|20)\d{2}(?:年)?(?:\b|(?=\s|[-–—,，.。;；]|来源|DOI|被引|引用|$))/)?.[1]??"");return!t||/摘要|来源|类型|网页|资讯|AI\b|https?:\/\/|www\.|\.(?:com|cn|org|net)\b/i.test(t)?"":t}extractDoiFromUrlPath(e){if(e)try{const t=new URL(e,location.href);if(this.isBaiduHost(t.hostname))return;const n=this.safeDecode(t.pathname),r=this.isDoiResolverHost(t.hostname)?n.replace(/^\/+/,""):this.extractPublisherDoiPath(n);if(!this.isDoiResolverHost(t.hostname)&&!this.isConservativePublisherDoiPath(r)||this.hasSuspiciousDoiPathSuffix(r))return;const i=r.match(Aa);return this.normalizeDoiCandidate(i?.[0])}catch{const t=e.split(/[?#]/)[0],n=this.safeDecode(t),r=n.match(/^https?:\/\/(?:dx\.)?doi\.org\/(.+)$/i),i=r?r[1]:this.extractPublisherDoiPath(n);return!i||!r&&!this.isConservativePublisherDoiPath(i)||this.hasSuspiciousDoiPathSuffix(i)?void 0:this.normalizeDoiCandidate(i.match(Aa)?.[0])}}extractLabeledDoi(e){const t=this.cleanText(e);for(const n of t.matchAll(/(?:^|[\s;；,，([{（【])(?:DOI\s*[:：]?\s*)?((?:https?:\/\/(?:dx\.)?doi\.org\/)?10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+)/gi)){const r=n.index??0,i=t.slice(0,r),o=Math.max(i.lastIndexOf(";"),i.lastIndexOf("\uFF1B"),i.lastIndexOf(" \u4F5C\u8005"),i.lastIndexOf(" Author"),i.lastIndexOf(" \u6765\u6E90"),i.lastIndexOf(" Source"),i.lastIndexOf(" \u7C7B\u578B"),i.lastIndexOf(" \u6587\u732E\u7C7B\u578B"),i.lastIndexOf(" \u671F\u520A"),i.lastIndexOf(" \u520A\u540D")),s=i.slice(Math.max(0,o));if(this.hasCitationDoiContext(s)||this.hasAdjacentCitationDoiContext(i,o))continue;const l=this.normalizeDoiCandidate(n[1]);if(l)return l}}normalizeDoiCandidate(e){const t=this.cleanDoi(e);if(t&&!this.hasSuspiciousDoiPathSuffix(t))return/^10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+$/i.test(t)?t:void 0}cleanDoi(e){let t=e;for(;t;){const n=t;for(t=t.replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/[.,;:。；：，、]+$/g,"").replace(/\/+$/g,"");t.endsWith(")")&&this.countCharacters(t,")")>this.countCharacters(t,"(");)t=t.slice(0,-1);for(;t.endsWith("]")&&this.countCharacters(t,"]")>this.countCharacters(t,"[");)t=t.slice(0,-1);if(t===n)break}return t?.toLowerCase()}countCharacters(e,t){return e.split(t).length-1}hasCjk(e){return/[\u3400-\u9fff]/.test(e)}isBaiduHost(e){return e==="baidu.com"||e.endsWith(".baidu.com")}isTrustedCitationTail(e){return e?this.isNonScholarlySourceText(e)?!1:this.isCurrentArticleMetadataTail(e)?!0:ff.test(e):!0}isNonScholarlySourceText(e){const t=this.normalizeCjkSpacing(e);return hf.test(t)}hasCitationDoiContext(e){const t=this.stripCurrentArticleCountFields(this.normalizeCjkSpacing(e));return/(?:参考文献|引用文献|被引文献|被引用文献)\s*(?:DOI\s*[:：]?|[:：;；,，.。-]|$)|\b(?:References?|Cites|Citing(?:\s+article)?|Cited(?:\s+article)?|Citation(?:\(s\)|s)?)(?:\s*\(\s*\d[\d,]*\s*\))?\s*(?:DOI\s*[:：]?|[:：;；,，.。-]|$)/i.test(t)}hasAdjacentCitationDoiContext(e,t){if(t<0)return!1;const n=e.slice(0,t),r=Math.max(n.lastIndexOf(";"),n.lastIndexOf("\uFF1B"),n.lastIndexOf(","),n.lastIndexOf("\uFF0C")),i=n.slice(Math.max(0,r));return this.hasCitationDoiContext(i)&&!Aa.test(i)}isCurrentArticleMetadataTail(e){return this.stripDoiText(this.stripCurrentArticleCountFields(this.normalizeCjkSpacing(e))).trim().length===0}stripCurrentArticleCountFields(e){return e.replace(/(?:被引(?:量|数|次数|频次)?|被?引用(?:量|数|次数|频次)?|参考文献(?:量|数|次数|频次)?)\s*[:：]?\s*(?:暂无|无|--|-|\d[\d,，]*(?:\.\d+)?(?:\s*万)?(?:\s*(?:次|篇|条))?\s*[+＋]?)/g,"").replace(/\b(?:cited by|citation count|citations?|citation\(s\)|references?\s+count|references?)\s*[:：]?\s*(?:N\/A|na|--|-|\d[\d,]*(?:\.\d+)?\s*[KMB]?\+?(?:\s*(?:times?|articles?|papers?))?)/gi,"")}stripCurrentArticleSourceTail(e){return this.stripDoiTail(this.stripCurrentArticleCountFields(e)).replace(/(?:参考文献|引用文献|被引文献|被引用文献)\s*(?:DOI\s*[:：]?|[:：;；,，.。-])[\s\S]*$/i,"").replace(/\b(?:References?|Cites|Citing(?:\s+article)?|Cited(?:\s+article)?|Citation(?:\(s\)|s)?)(?:\s*\(\s*\d[\d,]*\s*\))?\s*(?:DOI\s*[:：]?|[:：;；,，.。-])[\s\S]*$/i,"").replace(/\s+(?:19|20)\d{2}年?\b[\s\S]*$/,"").replace(/\s+Journal Article\b[\s\S]*$/i,"").replace(/[([{（【\s]+$/g,"").trim()}stripDoiText(e){return e.replace(/\bDOI\s*[:：]?\s*(?:https?:\/\/(?:dx\.)?doi\.org\/)?10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+/gi,"").replace(df,"")}stripDoiTail(e){return e.replace(/\bDOI\s*[:：]?\s*(?:https?:\/\/(?:dx\.)?doi\.org\/)?10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+[\s\S]*$/i,"").replace(/https?:\/\/(?:dx\.)?doi\.org\/10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+[\s\S]*$/i,"").replace(/\b10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+[\s\S]*$/i,"")}normalizeCjkSpacing(e){let t=this.cleanText(e);for(;/[\u3400-\u9fff]\s+[\u3400-\u9fff]/.test(t);)t=t.replace(/([\u3400-\u9fff])\s+([\u3400-\u9fff])/g,"$1$2");return t}isSecurityVerificationPage(){const e=Array.from(document.querySelectorAll(['iframe[src*="verify"]','iframe[src*="captcha"]','iframe[src*="challenge"]','iframe[src*="access-check"]','iframe[src*="security-check"]','form[action*="verify"]','form[action*="captcha"]','form[action*="challenge"]','form[action*="access-check"]','form[action*="security-check"]','[id*="captcha" i]','[class*="captcha" i]','[id*="challenge" i]','[class*="challenge" i]','[id*="access-check" i]','[class*="access-check" i]','[id*="security-check" i]','[class*="security-check" i]','[id*="verify-code" i]','[class*="verify-code" i]'].join(","))),t=document.querySelector("#bdxs_result_lists, #bdxs_result_list, [data-paperlens-baidu-results]"),n=!!t,r=document.querySelector("#container"),i=t??r,o=n||!!r,s=this.hasScholarlyResultEvidence(i),l=this.hasVerificationResultRow(i),c=this.cleanText(`${document.title??""} ${document.body?.textContent??""}`),u=`${c.slice(0,2e3)} ${c.slice(-3e3)}`;return l||e.some(d=>this.isStrongVerificationElement(d))||e.length>0&&!s||this.hasChallengeCopy(this.getTextOutsideResultHosts())||!s&&this.hasChallengeCopy(u)||!o&&/百度安全验证|网络不给力，请稍后重试|请完成以下验证/i.test(u)?!0:!o&&/请输入验证码|系统检测到您的请求存在异常/i.test(u)}isStrongVerificationElement(e){if(e.matches(Mn)&&this.hasScholarlyResultEvidence(e))return!1;if(`${e.id??""} ${e.getAttribute("class")??""}`.split(/\s+/).some(r=>/^(?:captcha|challenge|access-check|security-check|verify-code)$/i.test(r)))return!0;const n=e.getAttribute("src")??e.getAttribute("action")??"";if(!n)return!1;try{const r=new URL(n,location.href),i=r.hostname.toLowerCase();return i==="verify.baidu.com"||i.endsWith(".verify.baidu.com")||i==="wappass.baidu.com"||i==="passport.baidu.com"?!0:/(?:^|\/)(?:captcha|verify|security-check|challenge|access-check)(?:[/?#]|$)/i.test(`${r.pathname}${r.search}`)}catch{return/(?:^|\/)(?:captcha|verify|security-check|challenge|access-check)(?:[/?#]|$)/i.test(n)}}hasChallengeCopy(e){return/(?:百度安全验证|安全验证|安全校验|滑块验证|拖动滑块|请完成以下验证|请输入验证码|系统检测到您的请求存在异常|Access check|Continue after check)/i.test(e)}getTextOutsideResultHosts(){if(!document.body)return"";const e=document.body.cloneNode(!0);return e.querySelectorAll([Mn,"script","style","noscript"].join(",")).forEach(t=>t.remove()),this.cleanText(e.textContent??"")}hasVerificationResultRow(e){return e?this.getResultHosts(e).some(t=>{const n=this.cleanText(t.querySelector(Dr)?.textContent??""),r=this.cleanText(this.collectMetaText(t));if(this.isVerificationResult(n,r))return!0;const i=this.cleanText(t.textContent??"");return this.hasChallengeCopy(i)&&!this.hasScholarlyResultEvidence(t)}):!1}hasScholarlyResultEvidence(e){return e?this.getResultHosts(e).some(t=>{const n=this.cleanText(t.querySelector(Dr)?.textContent??"");if(!n)return!1;const r=this.cleanText(this.collectMetaText(t));if(this.isVerificationResult(n,r))return!1;const i=this.cleanText(t.textContent??"");return Aa.test(i)||/(?:来源期刊|刊名|来源|Source|Journal Article|作者|Author|类型\s*[:：]\s*期刊|文献类型\s*[:：]\s*期刊)/i.test(i)}):!1}getResultHosts(e){const t=e.matches(Mn)?[e]:Array.from(e.querySelectorAll(Mn));if(t.length>0)return t;const n=Array.from(e.querySelectorAll(Dr)),r=[],i=new Set;for(const o of n){const s=this.findCurrentResultHost(o);!s||i.has(s)||(i.add(s),r.push(s))}return r}findCurrentResultHost(e){const t=this.cleanTitle(e.textContent??"");if(!t)return null;let n=e.closest("h1, h2, h3")?.parentElement??e.parentElement;for(;n&&n!==document.body;){const r=this.cleanText(n.textContent??"");if(r.includes(t)&&(/(?:来源|Source|被引|DOI|收藏|摘要|期刊)/i.test(r)||/(?:19|20)\d{2}年/.test(r)))return n;n=n.parentElement}return e.parentElement}textWithoutTitle(e){const t=e.cloneNode(!0);return t.querySelector(Dr)?.remove(),t.textContent??""}extractFallbackAbstract(e){return this.cleanText(this.textWithoutTitle(e)).match(/摘要[:：]\s*(.+?)(?=\s*(?:来源|Source|被引|DOI|收藏|$))/)?.[1]}isVerificationResult(e,t){const n=this.cleanText(e),r=this.cleanText(t);return/^百度学术$/i.test(n)&&/安全检测中|请稍候|稍后|验证|captcha|verify/i.test(r)||/^(?:安全验证|安全校验|滑块验证)$/i.test(n)&&/(?:拖动滑块|滑块验证|安全校验|继续访问|captcha|verify|验证码)/i.test(r)||/^(?:请完成以下验证|百度安全验证|网络不给力，请稍后重试|请输入验证码)$/i.test(n)||/^(?:Access check|请完成以下验证|百度安全验证|请输入验证码)$/i.test(n)&&/(?:验证后继续访问|Continue after check|captcha|verify|百度学术)/i.test(r)||/^(?:系统检测到您的请求存在异常|访问异常|请输入验证码完成验证)$/i.test(n)&&/(?:请输入验证码|滑块验证|验证后继续访问|Continue after check|captcha|verify)/i.test(r)||/(?:百度安全验证|请完成以下验证|访问异常|请输入验证码|系统检测到您的请求存在异常)/i.test(n)&&/(?:请输入验证码|滑块验证|验证后继续访问|Continue after check|captcha|verify|百度学术)/i.test(r)?!0:/^(?:验证后继续访问|Continue after check|请输入验证码|滑块验证)$/i.test(r)}isDoiResolverHost(e){const t=e.toLowerCase();return t==="doi.org"||t==="dx.doi.org"}hasSuspiciousDoiPathSuffix(e){const n=e.replace(/^\/+/,"").replace(/^10\.\d{4,9}\//i,"").split("/").filter(Boolean);return n.length>2&&/^\d{5,}$/.test(n.at(-1)??"")||/\/(?:supplementary|supplement|article-info|citations?|references?|metrics|figures?|full|abstract|epdf|pdf)$/i.test(e)}isConservativePublisherDoiPath(e){return/^10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+$/i.test(e)}extractPublisherDoiPath(e){return e.match(/\/doi\/(?:(?:full|abs|pdf|epdf|abstract)\/)?(10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+)$/i)?.[1]??""}stableHash(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),`${(t>>>0).toString(36)}${(n>>>0).toString(36)}`}hasUntrustedQuotedTail(e){const t=this.cleanText(e.match(/《[^》]+》\s*(?:[,，.。;；]?\s*(?:19|20)\d{2}(?:年)?)?\s*([^；;\n]*)/)?.[1]??"");return!!t&&!this.isTrustedCitationTail(t)}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}safeDecode(e){try{return decodeURIComponent(e)}catch{return e}}normalizeTrackingUrl(e){if(!e)return"";try{const t=new URL(e,location.href);if(!this.isBaiduHost(t.hostname))return this.normalizeExternalUrl(t);for(const n of Array.from(t.searchParams.keys()))this.isBaiduTrackingParam(n)&&t.searchParams.delete(n);return`${t.origin}${t.pathname}${t.search}${t.hash}`}catch{return e.replace(/([?&])(?:tn|sc_[^=&]*|wd|ie|rsv_[^=&]*|oq|bs|f|usm|rsp|inputT|pn|page)=[^&#]*/gi,"$1").replace(/[?&]+$/,"")}}isBaiduTrackingParam(e){return/^(?:tn|sc_|wd|ie|rsv_|oq|bs|usm|rsp|inputT)/i.test(e)||/^(?:f|pn|page)$/i.test(e)}normalizeExternalUrl(e){for(const n of Array.from(e.searchParams.keys()))(/^utm_/i.test(n)||/^(?:fbclid|gclid|yclid|mc_cid|mc_eid|spm)$/i.test(n))&&e.searchParams.delete(n);const t=Array.from(e.searchParams.entries()).sort(([n,r],[i,o])=>n.localeCompare(i)||r.localeCompare(o));e.search="";for(const[n,r]of t)e.searchParams.append(n,r);return this.normalizeDoiIdentityInUrl(e.href)}normalizeDoiIdentityInUrl(e){return e.replace(/\/doi\/(?:(?:full|abs|pdf|epdf|abstract)\/)?/gi,t=>t.toLowerCase()).replace(/10\.\d{4,9}(?:\/|%2f)[-._;()/:<>+\[\]A-Z0-9%]+/gi,t=>t.toLowerCase())}clearStaleEnhancements(e){e.querySelectorAll([".paperlens-metric-host",".paperlens-extra-tags",".paperlens-extra-download-host",".paperlens-zotero-host",".paperlens-action-row",".paperlens-save-host",".paperlens-export-host",`.${Si}`].join(",")).forEach(t=>t.remove()),e.removeAttribute("data-paperlens-article-id"),e.removeAttribute("data-paperlens-article-signature")}clearStaleEnhancementsInContainer(){const e=this.getResultsContainer();if(!e)return;const t=e.matches(Mn)?[e]:Array.from(e.querySelectorAll(Mn));if(t.length>0){t.forEach(n=>this.clearStaleEnhancements(n));return}this.clearStaleEnhancements(e)}toAbsoluteUrl(e){if(e)try{return new URL(e,location.href).href}catch{return e}}}const gf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,yf=/\b((?:19|20)\d{2})\b/,xf="#completesearch-publs ul.publ-list > li.entry",Af="#publ-section ul.publ-list > li.entry",Cf="ul.publ-list > li.entry",vf=[{pattern:/\b(?:NIPS|NeurIPS|Neural Information Processing Systems)\b/i,canonical:"NeurIPS"},{pattern:/\bCVPR\b|Computer Vision and Pattern Recognition/i,canonical:"CVPR"},{pattern:/\bICCV\b|International Conference on Computer Vision/i,canonical:"ICCV"},{pattern:/\bECCV\b|European Conference on Computer Vision/i,canonical:"ECCV"},{pattern:/\bICML\b|International Conference on Machine Learning/i,canonical:"ICML"},{pattern:/\bICLR\b|International Conference on Learning Representations/i,canonical:"ICLR"},{pattern:/\bKDD\b|Knowledge Discovery and Data Mining/i,canonical:"KDD"},{pattern:/\bSIGIR\b/i,canonical:"SIGIR"},{pattern:/\bSIGMOD\b/i,canonical:"SIGMOD"},{pattern:/\bVLDB\b/i,canonical:"VLDB"},{pattern:/\bACL\b|Association for Computational Linguistics/i,canonical:"ACL"},{pattern:/\bEMNLP\b/i,canonical:"EMNLP"},{pattern:/\bAAAI\b/i,canonical:"AAAI"},{pattern:/\bIJCAI\b/i,canonical:"IJCAI"},{pattern:/\bCHI\b|Human Factors in Computing Systems/i,canonical:"CHI"},{pattern:/\bWWW\b|World Wide Web Conference/i,canonical:"WWW"},{pattern:/\bSOSP\b/i,canonical:"SOSP"},{pattern:/\bOSDI\b/i,canonical:"OSDI"},{pattern:/\bUSENIX\b/i,canonical:"USENIX"}],wf=[{pattern:/^Proc\.\s*ACM\s*Program\.\s*Lang\.$/i,journalName:"Proceedings of the ACM on Programming Languages-PACMPL",extraCandidates:["Proceedings of the ACM on Programming Languages","PACM PL"]},{pattern:/^Proc\.\s*ACM\s*Hum\.\s*Comput\.\s*Interact\.$/i,journalName:"Proceedings of the ACM on Human-Computer Interaction",extraCandidates:["PACMHCI"]},{pattern:/^Proc\.\s*VLDB\s*Endow\.$/i,journalName:"Proceedings of the VLDB Endowment"}];class Sf extends W{id="dblp";name="DBLP";matches=["*://dblp.org/*","*://dblp.uni-trier.de/*"];isSearchPage(){const e=location.pathname.replace(/\/+$/,"");return(e==="/search"||e==="/search/publ")&&new URLSearchParams(location.search).has("q")}isArticlePage(){return location.pathname.startsWith("/rec/")||document.body?.classList.contains("rec-page")}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseEntry(n);if(!r)continue;const i=r.sourceId??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[DblpAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){const e=this.getDetailHostElement();if(!e)return null;try{return this.parseEntry(e)}catch(t){return console.error("[DblpAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector("cite.data")??e.querySelector("cite");if(t)return{element:t,position:"after"};const n=e.querySelector(".title");return n?{element:n,position:"after"}:{element:e,position:"append"}}getResultsContainer(){return document.querySelector("#completesearch-publs .body")??document.querySelector("#publ-section")??document.querySelector("#main")??document.body}getPageInfo(){const t=document.querySelector("#completesearch-publs .metadata")?.getAttribute("data-matches")??"",n=Number.parseInt(t,10);return{pageNum:1,totalPages:Number.isFinite(n)&&n>0?Math.max(1,Math.ceil(n/30)):1,url:location.href,itemsPerPage:30,totalItems:Number.isFinite(n)?n:void 0}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(xf));return e.length>0?e:Array.from(document.querySelectorAll(Cf)).filter(t=>!t.closest("#publ-references-section, #publ-citations-section"))}getDetailHostElement(){return document.querySelector(Af)??document.querySelector("body.rec-page li.entry")??null}parseEntry(e){const t=this.cleanText(e.querySelector('.title[itemprop="name"], .title')?.textContent??"");if(!t)return null;const n=this.extractDblpKey(e),r=this.extractVenue(e),i=this.inferRecordKind(e,r,n),o=this.normalizeVenue(r,i),s=this.extractNativeFullTextUrl(e),l=this.extractDoi(e),c=this.extractRecordUrl(e,n);return{title:t,journalName:o.journalName,journalCandidates:o.candidates,authors:this.extractAuthors(e),year:this.extractYear(e),doi:l,sourceId:n?`dblp:${n}`:void 0,url:c,nativeFullTextUrl:s,hostElement:e,articleTypes:i.articleTypes,source:this.id,citationType:i.citationType,nativeExportUrls:this.extractNativeExportUrls(e,n)}}extractAuthors(e){return this.unique(Array.from(e.querySelectorAll('[itemprop="author"] [itemprop="name"], cite [itemprop="name"][title]')).map(t=>this.cleanText(t.getAttribute("title")??t.textContent??"")).filter(Boolean))}extractVenue(e){const t=e.querySelector("cite.data")??e;return Array.from(t.querySelectorAll('[itemprop="isPartOf"] [itemprop="name"]')).map(r=>this.cleanText(r.textContent??"")).filter(Boolean)[0]??""}inferRecordKind(e,t,n){const r=e.className,i=this.cleanText(e.querySelector(".box img[title]")?.getAttribute("title")??""),o=`${r} ${i} ${t} ${n}`;return/\b(?:informal|CoRR|arXiv)\b/i.test(o)?{articleTypes:["Preprint"],citationType:"misc",journalMetricsAllowed:!1}:/\b(?:article|Journal Articles)\b/i.test(o)||n.startsWith("journals/")?{articleTypes:["JournalArticle"],citationType:"article",journalMetricsAllowed:!0}:/\b(?:inproceedings|proceedings|Conference and Workshop Papers)\b/i.test(o)||n.startsWith("conf/")?{articleTypes:["Conference"],citationType:"inproceedings",journalMetricsAllowed:!1}:/\b(?:incollection|book chapter|Parts in Books or Collections)\b/i.test(o)?{articleTypes:["BookChapter"],citationType:"incollection",journalMetricsAllowed:!1}:/\b(?:book|Books and Theses)\b/i.test(o)?{articleTypes:["Book"],citationType:"book",journalMetricsAllowed:!1}:{articleTypes:["Publication"],citationType:"misc",journalMetricsAllowed:!1}}normalizeVenue(e,t){if(!e)return{journalName:"",candidates:void 0};if(t.citationType==="inproceedings"){const r=this.canonicalConference(e)||e;return{journalName:r,candidates:this.unique([e,r])}}const n=this.canonicalJournal(e);return t.journalMetricsAllowed&&n?{journalName:n.journalName,candidates:this.unique([e,n.journalName,...n.extraCandidates??[]])}:t.journalMetricsAllowed?{journalName:e,candidates:this.unique([e])}:{journalName:e,candidates:this.unique([e])}}canonicalConference(e){for(const n of vf)if(n.pattern.test(e))return n.canonical;const t=e.trim().match(/^([A-Z][A-Z0-9]{1,})(?:\s*(?:\([^)]*\)|[-:,]\s*.*|\d{4}|$))/);return t?.[1]?t[1]:""}canonicalJournal(e){for(const t of wf)if(t.pattern.test(e))return{journalName:t.journalName,extraCandidates:t.extraCandidates};return null}extractDblpKey(e){const t=this.cleanText(e.getAttribute("id")??"");if(t&&/^(?:conf|journals|books|series|reference|tr)\/.+/i.test(t))return t;const n=this.cleanText(e.querySelector(".select-on-click small")?.textContent??"");return n&&n.includes("/")?n:this.extractRecordUrl(e,"")?.match(/\/rec\/([^?#.]+(?:\/[^?#.]+)*)/)?.[1]??""}extractRecordUrl(e,t){const n=document.querySelector('link[rel="canonical"][href*="/rec/"]')?.href;if(n)return this.normalizeRecordUrl(n);const r=Array.from(e.querySelectorAll('a[href*="/rec/"]')).map(i=>this.absoluteUrl(i.getAttribute("href"))).find(i=>i&&/\/rec\//.test(i)&&!this.isExportRecordUrl(i));return r?this.normalizeRecordUrl(r):t?`https://dblp.org/rec/${t}`:void 0}extractNativeFullTextUrl(e){const t=Array.from(e.querySelectorAll('li.ee a[itemprop="url"]'));for(const n of t){const r=this.absoluteUrl(n.getAttribute("href"));if(r&&!/\/rec\/|dblp\.org\/db\//i.test(r))return r}}extractNativeExportUrls(e,t){const n=Array.from(e.querySelectorAll("a[href]")).map(o=>this.absoluteUrl(o.getAttribute("href"))).filter(o=>!!o),r=n.find(o=>/\.bib(?:$|[?#])/i.test(o))??(t?`https://dblp.org/rec/${t}.bib`:void 0),i=n.find(o=>/\.ris(?:$|[?#])/i.test(o))??(t?`https://dblp.org/rec/${t}.ris`:void 0);if(!(!r&&!i))return{bibtex:r,ris:i}}normalizeRecordUrl(e){const t=e.split("#")[0]??e;return(t.split("?")[0]??t).replace(/\.html$/i,"")}isExportRecordUrl(e){return/[?&]view=|\/rec\/.+\.(?:bib|ris|xml|rdf|nt|ttl|txt)(?:$|[?#])/i.test(e)}extractDoi(e){for(const t of Array.from(e.querySelectorAll('a[href*="doi.org/"]'))){const n=this.cleanDoi(t.getAttribute("href"));if(n)return n}return this.cleanDoi(e.textContent??"")}extractYear(e){const n=(e.querySelector('[itemprop="datePublished"]')?.textContent??e.textContent??"").match(yf);if(!n?.[1])return;const r=Number.parseInt(n[1],10);return Number.isFinite(r)?r:void 0}cleanDoi(e){if(!e)return;let t=e;try{t=decodeURIComponent(e)}catch{t=e}const n=t.match(gf);if(n?.[0])return n[0].replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/[)\].,;:]+$/g,"")}absoluteUrl(e){const t=e?.trim();if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){const t=[],n=new Set;for(const r of e){const i=this.cleanText(r??"");if(!i)continue;const o=i.toLowerCase();n.has(o)||(n.add(o),t.push(i))}return t}cleanText(e){return e.replace(/\s+/g," ").trim()}}const Tf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,Ef=/\b((?:19|20)\d{2})\b/,_f=[".List-results-items > *","xpl-document-card","[data-artnum]","[data-documentid]",".document-card",".result-item",".xpl-result",'[class*="ResultItem"]',"article"].join(","),Df=["#xplMainContent","main",".document-main",".document-container","#LayoutWrapper","body"].join(","),ml=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[data-test*="reference"]','[data-testid*="reference"]'].join(","),Ff=[{pattern:/\b(?:NIPS|NeurIPS|Neural Information Processing Systems)\b/i,canonical:"NeurIPS"},{pattern:/\bCVPR\b|Computer Vision and Pattern Recognition/i,canonical:"CVPR"},{pattern:/\bICCV\b|International Conference on Computer Vision/i,canonical:"ICCV"},{pattern:/\bECCV\b|European Conference on Computer Vision/i,canonical:"ECCV"},{pattern:/\bICML\b|International Conference on Machine Learning/i,canonical:"ICML"},{pattern:/\bICLR\b|International Conference on Learning Representations/i,canonical:"ICLR"},{pattern:/\bKDD\b|Knowledge Discovery and Data Mining/i,canonical:"KDD"},{pattern:/\bSIGIR\b/i,canonical:"SIGIR"},{pattern:/\bSIGMOD\b/i,canonical:"SIGMOD"},{pattern:/\bVLDB\b/i,canonical:"VLDB"},{pattern:/\bACL\b|Association for Computational Linguistics/i,canonical:"ACL"},{pattern:/\bEMNLP\b/i,canonical:"EMNLP"},{pattern:/\bAAAI\b/i,canonical:"AAAI"},{pattern:/\bIJCAI\b/i,canonical:"IJCAI"},{pattern:/\bCHI\b|Human Factors in Computing Systems/i,canonical:"CHI"},{pattern:/\bWWW\b|World Wide Web Conference/i,canonical:"WWW"},{pattern:/\bSOSP\b/i,canonical:"SOSP"},{pattern:/\bOSDI\b/i,canonical:"OSDI"},{pattern:/\bICSE\b|International Conference on Software Engineering/i,canonical:"ICSE"},{pattern:/\bINFOCOM\b|International Conference on Computer Communications/i,canonical:"INFOCOM"},{pattern:/\bICDE\b|International Conference on Data Engineering/i,canonical:"ICDE"},{pattern:/\bHPCA\b|High Performance Computer Architecture/i,canonical:"HPCA"},{pattern:/\bMICRO\b|International Symposium on Microarchitecture/i,canonical:"MICRO"},{pattern:/\bISCA\b|International Symposium on Computer Architecture/i,canonical:"ISCA"},{pattern:/\bRTSS\b|Real-Time Systems Symposium/i,canonical:"RTSS"}];class kf extends W{id="ieee-xplore";name="IEEE Xplore";matches=["*://ieeexplore.ieee.org/*"];isSearchPage(){return location.pathname.startsWith("/search/")||location.pathname==="/search/searchresult.jsp"||new URLSearchParams(location.search).has("queryText")}isArticlePage(){return/^\/(?:abstract\/)?document\/\d+\/?$/i.test(location.pathname)||!!this.getIeeeDocumentMetadata()}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[IeeeXploreAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){const e=document.querySelector(Df);if(!e)return null;try{const t=this.getIeeeDocumentMetadata();if(t){const n=this.metadataToArticle(t,e,location.href);if(n)return n}return this.parseDetailDom(e)}catch(t){return console.error("[IeeeXploreAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector('h1, h2, .document-title, .result-item-title, [class*="title"]');if(t)return{element:t,position:"after"};const n=e.querySelector('.description, .document-meta, .publication-title, [class*="metadata"], [class*="meta"]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".List-results-items")??document.querySelector("#xplMainContent")??document.querySelector("main")??document.body}getPageInfo(){const t=this.cleanText(document.querySelector('.results-display, .Showing, [class*="result"] [class*="count"]')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),n=t?Number.parseInt(t[1].replace(/,/g,""),10):void 0;return{pageNum:Number.parseInt(new URLSearchParams(location.search).get("pageNumber")??"1",10)||1,totalPages:n?Math.max(1,Math.ceil(n/25)):1,url:location.href,itemsPerPage:25,totalItems:n}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(_f)).filter(t=>this.looksLikeSearchResult(t));return this.uniqueElements(e)}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')?!1:e.querySelector('a[href*="/document/"], a[href*="/abstract/document/"]')||e.getAttribute("data-artnum")||e.getAttribute("data-documentid")?!0:/\b10\.\d{4,9}\//i.test(e.textContent??"")&&/IEEE|Conference|Transactions|Journal|Proceedings/i.test(e.textContent??"")}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('.document-title, .result-item-title, h2, h3, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.extractArticleNumber(e,t?.href),i=this.extractVenue(e),o=this.extractDoi(e),s=this.extractTypeText(e),l=this.inferRecordKind({isConference:/conference|proceedings|symposium|workshop/i.test(s),isJournal:/journal|transactions|letters|magazine/i.test(s),contentTypeDisplay:s,xploreDocumentType:s,publicationTitle:i}),c=this.normalizeVenue(i,l);return{title:n,journalName:c.journalName,journalCandidates:c.candidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:o,sourceId:r?`ieee:${r}`:void 0,url:this.toAbsoluteUrl(t?.href??"")??void 0,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,source:this.id,citationType:l.citationType}}parseDetailDom(e){const t=this.cleanText(document.querySelector('meta[property="og:title"]')?.getAttribute("content")??e.querySelector("h1, .document-title")?.textContent??document.title.replace(/\s*\|\s*IEEE Xplore\s*$/i,""));if(!t)return null;const n=this.extractVenue(e),r=this.extractTypeText(e),i=this.inferRecordKind({isConference:/conference|proceedings|symposium|workshop/i.test(r),isJournal:/journal|transactions|letters|magazine/i.test(r),contentTypeDisplay:r,publicationTitle:n}),o=this.normalizeVenue(n,i),s=this.extractArticleNumber(e,location.href);return{title:t,journalName:o.journalName,journalCandidates:o.candidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:this.extractDoi(e,{allowTextFallback:!1}),sourceId:s?`ieee:${s}`:void 0,url:this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:i.articleTypes,source:this.id,citationType:i.citationType}}metadataToArticle(e,t,n){const r=this.cleanText(e.title??e.displayDocTitle??e.formulaStrippedArticleTitle??"");if(!r)return null;const i=this.cleanText(e.publicationTitle??e.displayPublicationTitle??""),o=this.inferRecordKind(e),s=this.normalizeVenue(i,o),l=e.articleNumber?String(e.articleNumber):this.extractArticleNumber(t,n),c=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??(l?`/document/${l}`:n));return{title:r,journalName:s.journalName,journalCandidates:s.candidates,authors:this.extractAuthorsFromMetadata(e),year:this.extractMetadataYear(e),doi:this.cleanDoi(e.doi??e.doiLink??""),sourceId:l?`ieee:${l}`:void 0,url:c,nativeFullTextUrl:this.toNativeFullTextUrl(e.pdfUrl??e.pdfPath??""),abstractSnippet:this.cleanText(e.abstract??""),hostElement:t,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e){const t=[e.contentType,e.contentTypeDisplay,e.xploreDocumentType].filter(Boolean).join(" "),n=[e.publicationTitle,e.displayPublicationTitle].filter(Boolean).join(" ");return this.truthyFlag(e.isJournal)||/journal|journals|transactions|letters|magazine/i.test(t)||this.isJournalVenue(n)?{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}:this.truthyFlag(e.isConference)||/conference|proceedings|symposium|workshop/i.test(t)||this.isConferenceVenue(n)?{articleTypes:["Conference"],citationType:"inproceedings",metricsAllowed:!1}:this.truthyFlag(e.isBook)||this.truthyFlag(e.isChapter)||/book|chapter/i.test(`${t} ${n}`)?{articleTypes:["BookChapter"],citationType:"incollection",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}normalizeVenue(e,t){const n=this.cleanText(e),r=n?[n]:[];if(!t.metricsAllowed){const i=this.normalizeConferenceVenue(n);return i&&i!==n&&r.unshift(i),{journalName:i??n,candidates:this.unique(r)}}return{journalName:n,candidates:this.unique(r)}}normalizeConferenceVenue(e){return this.matchConferenceAlias(e)??(e||void 0)}isJournalVenue(e){return/\b(?:IEEE\s+)?(?:Transactions|Journal|Letters|Magazine)\b/i.test(e)||/^Proceedings of the IEEE$/i.test(e.trim())}isConferenceVenue(e){const t=this.cleanText(e);return!t||this.isJournalVenue(t)?!1:this.matchConferenceAlias(t)?!0:/conference|symposium|workshop/i.test(t)||/\bproceedings\b/i.test(t)}matchConferenceAlias(e){for(const t of Ff)if(t.pattern.test(e))return t.canonical}extractTypeText(e){const t=['[data-field="contentType"]','[data-field="documentType"]',".content-type",".document-type",".xpl-type",'[class*="content-type"]','[class*="document-type"]','[data-test*="content-type"]','[data-testid*="content-type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractVenue(e){const t=['[data-field="publicationTitle"]',".publication-title",".published-in",".document-publication-title",".stats-document-abstract-publishedIn",'[class*="publication"]','[class*="published"]'].join(",");for(const i of Array.from(e.querySelectorAll(t))){const o=this.cleanText(i.textContent??"").replace(/^Published in:\s*/i,"");if(o&&!/^(PDF|HTML|View|Abstract)$/i.test(o))return o}const r=this.cleanText(e.textContent??"").match(/Published in:\s*([^|]+?)(?:\s+(?:Date|Year|DOI|Pages):|$)/i);return r?this.cleanText(r[1]):""}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href*="/document/"], h3 a[href*="/document/"], .result-item-title a[href*="/document/"], a[href*="/document/"], a[href*="/abstract/document/"]')).find(n=>this.cleanText(n.textContent??"").length>0)??null}extractAuthorsFromMetadata(e){if(Array.isArray(e.authors))return this.unique(e.authors.map(n=>typeof n=="string"?n:n.name??n.fullName??n.preferredName??"").map(n=>this.cleanText(n)).filter(Boolean));const t=Array.isArray(e.authorNames)?e.authorNames:typeof e.authorNames=="string"?e.authorNames.split(/;|, and | and /i):[];return this.unique(t.map(n=>this.cleanText(n)).filter(Boolean))}extractAuthorsFromDom(e){const t=[".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(","),n=Array.from(e.querySelectorAll(t)).map(r=>this.cleanText(r.getAttribute("data-author-name")??r.textContent??"")).filter(r=>r&&!/^(Authors?|View|Show more)$/i.test(r));return this.unique(n)}extractYear(e){const t=['[data-field="publicationYear"]',".publication-year",".year",'[class*="year"]','[class*="date"]'].join(",");for(const n of Array.from(e.querySelectorAll(t))){const r=this.yearFromText(n.textContent??"");if(r)return r}return this.yearFromText(e.textContent??"")}extractMetadataYear(e){if(e.publicationYear){const t=Number.parseInt(String(e.publicationYear),10);if(Number.isFinite(t))return t}return this.yearFromText(e.publicationDate??"")}yearFromText(e){const t=e.match(Ef);return t?Number.parseInt(t[1],10):void 0}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="doi.ieeecomputersociety.org/"]'))){if(this.isExcludedDoiContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}cleanDoi(e){return e.match(Tf)?.[0].replace(/[),.;\s]+$/g,"")}extractArticleNumber(e,t){const n=e.getAttribute("data-artnum")??e.getAttribute("data-documentid")??e.getAttribute("data-article-number")??"";if(n)return n.trim();const r=t??"",i=r.match(/\/document\/(\d+)/i)??r.match(/[?&]arnumber=(\d+)/i);if(i)return i[1];const o=e.querySelector('a[href*="/document/"], a[href*="arnumber="]');return(o?.href.match(/\/document\/(\d+)/i)??o?.href.match(/[?&]arnumber=(\d+)/i))?.[1]}extractNativeFullTextUrl(e){const t=e.querySelector('a[href*="/stamp/stamp.jsp"], a[href*="arnumber="][href*="pdf"], a[href*="/ielx"]');return this.toNativeFullTextUrl(t?.getAttribute("href")??t?.href??"")??void 0}extractAbstract(e){return this.cleanText(e.querySelector('.abstract, [class*="abstract"], .description')?.textContent??"")||void 0}getIeeeDocumentMetadata(){const e=window.xplGlobal?.document?.metadata;return e?.title||e?.displayDocTitle?e:this.extractAssignedJson("xplGlobal.document.metadata=")??this.extractAssignedJson("window.xplGlobal.document.metadata=")}extractAssignedJson(e){for(const t of Array.from(document.scripts)){const n=t.textContent??"",r=n.indexOf(e);if(r<0)continue;const i=n.indexOf("{",r+e.length);if(i<0)continue;const o=this.readBalancedObject(n,i);if(o)try{return JSON.parse(o)}catch{continue}}return null}readBalancedObject(e,t){let n=0,r=!1,i="",o=!1;for(let s=t;s<e.length;s++){const l=e[s];if(r){o?o=!1:l==="\\"?o=!0:l===i&&(r=!1,i="");continue}if(l==='"'||l==="'"){r=!0,i=l;continue}if(l==="{"&&n++,l==="}"&&(n--,n===0))return e.slice(t,s+1)}return null}truthyFlag(e){return e===!0||e==="true"||e==="1"}isExcludedDoiContext(e){return!!e.closest(ml)}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(ml).forEach(n=>n.remove()),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t).hostname.toLowerCase();return n==="ieeexplore.ieee.org"||n.endsWith(".ieeexplore.ieee.org")?t:void 0}catch{return}}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}}const Lf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,Nf=/\b((?:19|20)\d{2})\b/,Rf=/\b\d{4}-?\d{3}[\dX]\b/i,Pf=/\/pii\/([^/?#]+)/i,If=["ol.search-results > li",".ResultItem","li.ResultItem",".result-item",'[data-testid*="result-item"]','[class*="ResultItem"]',"article"].join(","),Mf=["article","#article","main","#main-content","body"].join(","),bl=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class Bf extends W{id="sciencedirect";name="ScienceDirect";matches=["*://www.sciencedirect.com/*"];isSearchPage(){return location.pathname==="/search"||location.pathname.startsWith("/search/")}isArticlePage(){return/^\/science\/article\/(?:abs\/)?pii\//i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[ScienceDirectAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){const e=document.querySelector(Mf);if(!e)return null;try{return this.parseArticleMetadata(e)??this.parseArticleDom(e)}catch(t){return console.error("[ScienceDirectAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()&&!this.isSearchPage()){const r=this.findDetailTitle(e)??this.findDetailTitle(document.body);if(r)return{element:r,position:"after"};const i=e.querySelector('.author-group, .Authors, [class*="author-group"], [class*="authors"]');return i?{element:i,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector('h2, h3, .result-list-title-link, .title-text, [class*="title"]');if(t)return{element:t,position:"after"};const n=e.querySelector('.publication-title, .srctitle, .publication-volume, [class*="source"], [class*="publication"]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector("ol.search-results")??document.querySelector('[data-testid*="results"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("offset")??"0",10)||0,n=Math.floor(t/25)+1,i=this.cleanText(document.querySelector('[data-testid*="results-count"], .search-body-results-text, .ResultCount')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/25)):1,url:location.href,itemsPerPage:25,totalItems:o}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(If)).filter(t=>this.looksLikeSearchResult(t));return Array.from(new Set(e))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')?!1:!!this.findArticleLink(e)||/Book chapter|ScienceDirect|DOI:|\/science\/article\/pii\//i.test(e.textContent??"")}parseSearchHost(e){const t=this.findArticleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .result-list-title-link, .anchor, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.extractNativeFullTextUrl(e),o=this.extractPii(r??"")??this.extractPii(i??"")??this.extractPiiFromAttributes(e)??this.extractPiiFromText(this.textWithoutExcludedDoiContexts(e)),s=this.extractIssnFromPii(o)??this.extractIssn(e),l=this.extractVenue(e),c=this.inferRecordKind(this.extractTypeText(e),l,o),u=this.normalizeVenue(l,s,c);return{title:n,journalName:u.journalName,journalCandidates:u.candidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:this.extractDoi(e,{allowTextFallback:!1}),sourceId:o?`sciencedirect:${o}`:void 0,url:r,nativeFullTextUrl:i,abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:c.articleTypes,issn:s,source:this.id,citationType:c.citationType}}parseArticleMetadata(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??this.firstJsonLdValue(p=>p.headline??p.name)??"").replace(/\s*\|\s*ScienceDirect\s*$/i,"");if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??this.firstMetaContent(["citation_public_url","og:url"])??location.href),r=this.extractPii(n??location.href),i=this.extractIssnFromPii(r)??this.firstMetaContent(["citation_issn","prism.issn"])??this.firstJsonLdValue(p=>this.jsonLdIssn(p)),o=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??this.firstJsonLdValue(p=>p.isPartOf?.name)??""),s=[this.firstMetaContent(["citation_article_type","dc.type"]),this.firstJsonLdValue(p=>Array.isArray(p["@type"])?p["@type"].join(" "):p["@type"]),this.extractTypeText(e)].filter(Boolean).join(" "),l=this.inferRecordKind(s,o,r),c=this.normalizeVenue(o,i,l),u=this.extractMetadataPublicationDate(),d=this.extractAuthorsFromMetadata();return{title:t,journalName:c.journalName,journalCandidates:c.candidates,authors:d.length>0?d:this.extractAuthorsFromDom(e),year:this.yearFromText(u??"")??this.extractMetadataYear(),publicationDate:u,doi:this.extractMetadataDoi(),sourceId:r?`sciencedirect:${r}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["dc.description","description","citation_abstract"])??this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,issn:i,volume:this.firstMetaContent(["citation_volume","prism.volume"])??void 0,issue:this.firstMetaContent(["citation_issue","prism.number"])??void 0,pages:this.extractMetadataPages(),source:this.id,citationType:l.citationType}}parseArticleDom(e){const t=this.cleanText(e.querySelector("h1, .title-text")?.textContent??document.title.replace(/\s*\|\s*ScienceDirect\s*$/i,""));if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.extractPii(n??location.href),i=this.extractIssnFromPii(r)??this.extractIssn(e),o=this.extractVenue(e),s=this.inferRecordKind(this.extractTypeText(e),o,r),l=this.normalizeVenue(o,i,s);return{title:t,journalName:l.journalName,journalCandidates:l.candidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:this.extractDoi(e),sourceId:r?`sciencedirect:${r}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,issn:i,source:this.id,citationType:s.citationType}}inferRecordKind(e,t,n){const r=`${e} ${t} ${n??""}`;return/book chapter|chapter|book section|reference work|encyclopedia|\bB978/i.test(r)?{articleTypes:["BookChapter"],citationType:"incollection",metricsAllowed:!1}:/book\b/i.test(r)&&!/journal|article/i.test(r)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}normalizeVenue(e,t,n){const r=this.cleanVenue(e),i=r?[r]:[];return/^the\s+lancet$/i.test(r)&&i.push("Lancet"),n.metricsAllowed?{journalName:r||(t?"":r),candidates:this.unique(i)}:{journalName:r,candidates:this.unique(i)}}findArticleLink(e){const t=Array.from(e.querySelectorAll('h2 a[href*="/science/article/"], h3 a[href*="/science/article/"], a.result-list-title-link[href], a.anchor[href]')),n=Array.from(e.querySelectorAll('a[href*="/science/article/"]'));return[...t,...n.filter(i=>!t.includes(i))].find(i=>/\/science\/article\//i.test(i.href)&&!/\/(?:pdfft|pdf)\b|\.pdf(?:[?#]|$)/i.test(i.getAttribute("href")??i.href??"")&&this.cleanText(i.textContent??"").length>0&&!/^(?:View article|Abstract|Summary|Recommended articles?)$/i.test(this.cleanText(i.textContent??"")))??null}extractVenue(e){const t=[".publication-title",".publication-volume",".srctitle",".source-title",".sourceTitle",".journal-title",".journalTitle",".result-list-source-title",'a[href*="/journal/"]','[data-aa-name*="publication"]','[data-aa-name*="source"]','[data-aa-name*="journal"]','[data-testid*="publication"]','[data-testid*="source"]','[data-testid*="journal"]','[class*="publication"]','[class*="source"]','[class*="journal"]'].join(",");for(const i of Array.from(e.querySelectorAll(t))){const o=this.cleanVenue(i.textContent??"");if(o&&!/^(Article|Book chapter|PDF|View|Download|Open access)$/i.test(o))return o}const r=this.cleanText(e.textContent??"").match(/(?:Journal|Published in|Source)\s*:?\s*([^|•]+?)(?:\s*[|•]\s*|\s+(?:Volume|Issue|Pages|Year|DOI)\b|$)/i);return r?this.cleanVenue(r[1]):""}extractTypeText(e){const t=[".subtype",".article-type",".content-type",'[data-testid*="subtype"]','[data-testid*="type"]','[class*="subtype"]','[class*="article-type"]','[class*="content-type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}cleanVenue(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/^Journal\s*:?\s*/i,"").replace(/^Source\s*:?\s*/i,"").replace(/^Published in\s*:?\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}extractAuthorsFromMetadata(){const e=this.allMetaContent(["citation_author"]);if(e.length>0)return this.unique(e.map(n=>this.cleanText(n)));const t=this.allMetaContent(["dc.creator"]);return t.length>0?this.unique(t.map(n=>this.cleanText(n))):this.unique(this.getJsonLdArticles().flatMap(n=>this.jsonLdAuthors(n)).map(n=>this.cleanText(n)).filter(Boolean))}extractAuthorsFromDom(e){const t=["[data-author-name]",".author-group .author",".Authors .author",'[class*="author-group"] .author','[class*="author-list"] .author','.author a[href*="/author/"]',".author span.author",'[class*="author-name"]',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).filter(n=>n&&!/^(?:Authors?|View|Show more|Corresponding author)$/i.test(n)&&!/^\d+$/.test(n)))}extractYear(e){const t=[".publication-year",".date",'[class*="year"]','[class*="date"]',"time"].join(",");for(const n of Array.from(e.querySelectorAll(t))){const r=this.yearFromText(n.textContent??"");if(r)return r}return this.yearFromText(e.textContent??"")}extractMetadataYear(){return this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??this.firstJsonLdValue(e=>e.datePublished)??"")}extractMetadataDoi(){const e=this.allMetaContent(["citation_doi","prism.doi","dc.identifier","dc.identifier.doi"]);for(const t of e){const n=this.cleanDoi(t);if(n)return n}for(const t of this.getJsonLdArticles())for(const n of this.jsonLdIdentifiers(t)){const r=this.cleanDoi(n);if(r)return r}}extractMetadataPublicationDate(){return this.cleanText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??this.firstJsonLdValue(t=>t.datePublished)??"")||void 0}extractMetadataPages(){const e=this.firstMetaContent(["citation_pages","prism.pageRange","citation_firstpage"])??"",t=this.firstMetaContent(["citation_lastpage"])??"";return e&&t&&e!==t&&!e.includes("-")?`${e}-${t}`:e||t||void 0}yearFromText(e){const t=e.match(Nf);return t?Number.parseInt(t[1],10):void 0}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const i of Array.from(e.querySelectorAll('a[href*="doi.org/"]'))){if(this.isExcludedDoiContext(i))continue;const o=this.cleanDoi(i.href);if(o)return o}const r=this.extractLabeledDoi(this.textWithoutExcludedDoiContexts(e));if(r)return r;if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}cleanDoi(e){return e.match(Lf)?.[0].replace(/[),.;\s]+$/g,"")}extractIssn(e){const t=this.firstMetaContent(["citation_issn","prism.issn"]);if(t)return this.normalizeIssn(t);const n=(e.textContent??"").match(Rf);return n?this.normalizeIssn(n[0]):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}extractNativeFullTextUrl(e){const t=this.firstMetaContent(["citation_pdf_url"]),n=this.toNativeFullTextUrl(t??"");if(n)return n;const r=this.unique(Array.from(e.querySelectorAll('a[href*="/pdfft"], a[href*="/science/article/pii/"][href*="pdf"], a[href$=".pdf"], a[href*="/pdf"]')).filter(o=>!this.isExcludedDoiContext(o)).map(o=>this.toNativeFullTextUrl(o.getAttribute("href")??o.href??"")??"").filter(Boolean));return r.length===0?void 0:r.length===1||this.unique(r.map(o=>this.nativeFullTextIdentity(o))).length===1?r[0]:void 0}extractAbstract(e){return this.cleanText(e.querySelector('.abstract, [class*="abstract"], .result-list-description')?.textContent??"")||void 0}findDetailTitle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??this.firstJsonLdValue(o=>o.headline??o.name)??document.title.replace(/\s*\|\s*ScienceDirect\s*$/i,"")),n=Array.from(e.querySelectorAll('h1, #screen-reader-main-title, .title-text, [data-testid*="title"]'));if(!t)return n[0]??null;const r=t.toLowerCase().replace(/[^a-z0-9]+/g,"");return n.find(o=>this.cleanText(o.textContent??"").toLowerCase().replace(/[^a-z0-9]+/g,"")===r)??n[0]??null}extractPii(e){return e.match(Pf)?.[1]?.replace(/[^\w-]/g,"")}extractPiiFromText(e){return e.match(/\b(?:PII|pii)\s*:?\s*([A-Z]\d{10,}[A-Z0-9]*)\b/)?.[1]}extractLabeledDoi(e){return e.match(/\bDOI\b\s*:?\s*(10\.\d{4,9}\/[-._;()/:A-Z0-9]+)/i)?.[1]?.replace(/[),.;\s]+$/g,"")}extractPiiFromAttributes(e){const t=[e,...Array.from(e.querySelectorAll("[data-pii], [data-article-pii], [data-source-id], [data-eid]"))];for(const n of t){const r=n.getAttribute("data-pii")??n.getAttribute("data-article-pii")??n.getAttribute("data-source-id")??n.getAttribute("data-eid")??"",i=this.extractPiiValue(r);if(i)return i}}extractPiiValue(e){return this.extractPii(e)??this.extractPiiFromText(e)??e.trim().match(/^[A-Z]\d{10,}[A-Z0-9]*$/i)?.[0]?.toUpperCase()}extractIssnFromPii(e){const t=e?.match(/^S(\d{4})(\d{3}[\dX])/i);if(!(!t?.[1]||!t?.[2]))return`${t[1]}-${t[2].toUpperCase()}`}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}firstJsonLdValue(e){for(const t of this.getJsonLdArticles()){const n=this.cleanText(e(t)??"");if(n)return n}}getJsonLdArticles(){const e=[];for(const t of Array.from(document.querySelectorAll('script[type="application/ld+json"]')))try{const n=JSON.parse(t.textContent??""),r=Array.isArray(n)?n:[n,...n["@graph"]??[]];e.push(...r.filter(i=>this.isJsonLdArticle(i)))}catch{continue}return e}isJsonLdArticle(e){const t=Array.isArray(e["@type"])?e["@type"].join(" "):e["@type"]??"";return/Article|ScholarlyArticle|Chapter|CreativeWork/i.test(t)||!!e.headline}jsonLdAuthors(e){const t=e.author;return t?typeof t=="string"?[t]:Array.isArray(t)?t.map(n=>typeof n=="string"?n:n.name??"").filter(Boolean):t.name?[t.name]:[]:[]}jsonLdIssn(e){const t=e.isPartOf?.issn;return Array.isArray(t)?t[0]:t}jsonLdIdentifiers(e){const t=e.identifier;return t?typeof t=="string"?[t]:Array.isArray(t)?t.flatMap(n=>typeof n=="string"?[n]:[n.value??"",n.propertyID??""].filter(Boolean)):[]:[]}isExcludedDoiContext(e){return!!e.closest(bl)}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(bl).forEach(n=>n.remove()),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t).hostname.toLowerCase();return n==="www.sciencedirect.com"||n==="sciencedirect.com"||n==="reader.elsevier.com"?t:void 0}catch{return}}nativeFullTextIdentity(e){const t=this.extractPii(e);if(t)return`pii:${t}`;try{const n=new URL(e);return`${n.origin}${n.pathname}`}catch{return e}}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}}const jf=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,qf=/\b((?:19|20)\d{2})\b/,_i=['li[data-test="search-result-item"]','article[data-test="search-result-item"]','[data-test="search-result-item"]',".app-card-open",".app-card-open[data-test]",".c-search-result-list__item"].join(","),gl=["article",".c-card"].join(","),$f=["article","#main-content","main","body"].join(","),Bn=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class Of extends W{id="springerlink";name="SpringerLink";matches=["*://link.springer.com/*"];isSearchPage(){return location.pathname==="/search"||location.pathname.startsWith("/search/")}isArticlePage(){return/^\/(?:article|chapter|book|rwe|referenceworkentry)\//i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[SpringerLinkAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){const e=document.querySelector($f);if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[SpringerLinkAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(e.matches(_i)||e.classList.contains("app-card-open")){const o=e.querySelector(".app-card-open__meta");if(o)return{element:o,position:"after"};const s=Array.from(e.querySelectorAll('[data-test="published"]')).find(c=>!c.closest('[data-test="title"]'));if(s)return{element:s,position:"after"};const l=e.querySelector('.app-card-open__authors, [data-test="authors-list"], [data-test="authors"]');if(l)return{element:l,position:"after"}}const n=this.findDetailCitationLine(e);if(n)return{element:n,position:"after"};const r=e.querySelector('[data-test="title"], h1, h2, h3, .app-card-open__heading, .c-article-title');if(r)return{element:r,position:"after"};const i=e.querySelector('[data-test="authors-list"], .app-card-open__authors, .app-article-masthead__journal-title');return i?{element:i,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector('[data-test="darwin-search"]')??document.querySelector('[data-test="results-data"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"1",10)||1,n=this.cleanText(document.querySelector('[data-test="results-data-total"], .app-search-filter__result-count')?.textContent??""),r=n.match(/\b([\d,]+)\s*[-–]\s*([\d,]+)\s+of\s+([\d,]+)\s+results?\b/i),i=n.match(/\bof\s+([\d,]+)\s+results?\b/i),o=r?Number.parseInt(r[3].replace(/,/g,""),10):i?Number.parseInt(i[1].replace(/,/g,""),10):void 0,s=r?Math.max(1,Number.parseInt(r[2].replace(/,/g,""),10)-Number.parseInt(r[1].replace(/,/g,""),10)+1):20;return{pageNum:t,totalPages:o?Math.max(1,Math.ceil(o/s)):1,url:location.href,itemsPerPage:s,totalItems:o}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(_i)).filter(t=>this.looksLikeSearchResult(t));return e.length>0?this.uniqueElements(e):this.uniqueElements(Array.from(document.querySelectorAll(gl)).filter(t=>this.looksLikeSearchResult(t)))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||e.closest(Bn)||e.matches(gl)&&e.parentElement?.closest(_i)?!1:!!this.findTitleLink(e)}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('[data-test="title"], h2, h3, [class*="heading"]')?.textContent??"");if(!n)return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e,t),s=this.extractVenue(e),l=this.inferRecordKind(o,r,s),c=this.extractPublicationDate(e);return{title:n,journalName:s,journalCandidates:s?[s]:[],authors:this.extractSearchAuthors(e),year:this.extractYear(e),publicationDate:c,doi:i,sourceId:i?`springer:${i}`:r?`springer:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,source:this.id,citationType:l.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Springer(?: Nature)? Link\s*$/i,"");if(!t)return null;const n=this.toAbsoluteUrl(this.firstMetaContent(["citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(this.firstMetaContent(["citation_doi","DOI","dc.identifier","prism.doi"])??n??""),i=this.firstMetaContent(["citation_article_type","dc.type"])??"",o=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??""),s=this.inferRecordKind(i,n,o),l=this.allMetaContent(["citation_author","dc.creator"]),c=this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"]);return{title:t,journalName:o,journalCandidates:o?[o]:[],authors:l.length>0?l:this.extractDomAuthors(e),year:this.yearFromText(c??""),publicationDate:c??void 0,doi:r,sourceId:r?`springer:${r}`:n?`springer:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["dc.description"])??this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),volume:this.firstMetaContent(["citation_volume","prism.volume"])??void 0,issue:this.firstMetaContent(["citation_issue","prism.number"])??void 0,pages:this.extractMetaPages(),source:this.id,citationType:s.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector('h1, [data-test="title"]')?.textContent??document.title.replace(/\s*\|\s*Springer(?: Nature)? Link\s*$/i,""));if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.extractTypeText(e),o=this.extractVenue(e),s=this.inferRecordKind(i,n,o),l=this.extractPublicationDate(e);return{title:t,journalName:o,journalCandidates:o?[o]:[],authors:this.extractDomAuthors(e),year:this.extractYear(e),publicationDate:l,doi:r,sourceId:r?`springer:${r}`:n?`springer:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,source:this.id,citationType:s.citationType}}inferRecordKind(e,t,n){const r=`${e} ${t??""} ${n}`;return/conference paper|conference proceedings/i.test(r)?{articleTypes:["Conference"],citationType:"inproceedings",metricsAllowed:!1}:/\/(?:chapter|rwe|referenceworkentry)\//i.test(r)||/chapter|reference work entry|referenceworkentry/i.test(r)?{articleTypes:["BookChapter"],citationType:"incollection",metricsAllowed:!1}:/\/book\//i.test(r)||/\bbook\b|textbook|reference work/i.test(r)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}findDetailCitationLine(e){if(this.isSearchPage())return null;const t=e.querySelector(".c-article-identifiers.c-article-identifiers--cite-list, .c-article-identifiers--cite-list");if(t&&!t.closest(Bn)&&this.cleanText(t.textContent??""))return t;const n=e.querySelector('[data-test="journal-volume"]');if(n){const r=n.closest("li, div, p, section, ul, ol")??n;if(!r.closest(Bn))return r}for(const r of[".c-article-identifiers__item",".c-bibliographic-information__list-item",".app-article-masthead__meta li",".app-article-masthead__meta div"])for(const i of Array.from(e.querySelectorAll(r))){if(i.closest(Bn))continue;const o=this.cleanText(i.textContent??"");if(o&&/\b(?:volume|vol\.?|issue|article\s+number|pages?|pp\.?)\b/i.test(o))return i}return null}findTitleLink(e){return Array.from(e.querySelectorAll('[data-test="title"] a[href], a.app-card-open__link[href], a[data-test="title-link"][href], h2 a[href], h3 a[href], a[href*="/article/"], a[href*="/chapter/"], a[href*="/book/"], a[href*="/rwe/"], a[href*="/referenceworkentry/"]')).find(n=>this.cleanText(n.textContent??"").length>0)??null}extractTypeText(e,t){return[...Array.from(e.querySelectorAll('[data-test="content-type"], .c-meta__type')).map(r=>this.cleanText(r.textContent??"")),t?.getAttribute("data-track-action")??""].filter(Boolean).join(" ")}extractVenue(e){const t=e.querySelector('[data-test="parent"]');if(t)return this.cleanVenue(t.textContent??"");const n=e.querySelector('.app-card-open__authors a[href*="/journal/"], .app-card-open__authors a[href*="/book/"], .app-card-open__authors a[href*="/referencework"], .app-card-open__context a[href*="/journal/"], .app-card-open__context a[href*="/book/"], .app-card-open__context a[href*="/referencework"]');if(n){const s=this.cleanVenue(n.textContent??"");if(this.looksLikeVenue(s))return s}const r=this.extractVenueFromInlineContext(e);if(r)return r;const i=e.querySelector('[data-test="journal-title"], [data-testid="journal-title"], .app-card-open__context a[href*="/journal/"], .app-card-open__context, .c-search-result-list__item-meta');if(i){const s=this.cleanVenue(i.textContent??"");if(this.looksLikeVenue(s))return s}const o=e.querySelector(".app-article-masthead__journal-title");return o?this.cleanVenue(o.textContent??""):this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractSearchAuthors(e){const t=this.cleanText(e.querySelector('[data-test="authors"]')?.textContent??"");return t?this.unique(t.replace(/\s+in\s+.*$/i,"").split(/,|;|\band\b/i).map(n=>this.cleanText(n)).filter(n=>n&&n!=="...")):[]}extractDomAuthors(e){return this.unique(Array.from(e.querySelectorAll('[data-test="author-name"], .c-article-author-list__item a[data-author-search]')).map(t=>this.cleanText(t.getAttribute("data-author-search")??t.textContent??"")).filter(Boolean))}extractYear(e){for(const t of Array.from(e.querySelectorAll('[data-test="published"], time, [class*="date"], [class*="year"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractPublicationDate(e){return this.cleanText(e.querySelector('[data-test="published"], time, [class*="date"], [class*="year"]')?.textContent??"").replace(/^Published:\s*/i,"")||void 0}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/article/10."], a[href*="/chapter/10."]'))){if(this.isExcludedDoiContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll(this.getDoiTextSelector()))){if(this.isExcludedDoiContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e){const t=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(t)return t;const n=e.querySelector('a[data-test="pdf-link"], a[data-article-pdf="true"], a[href*="/content/pdf/"], a[href$=".pdf"]');return this.toNativeFullTextUrl(n?.getAttribute("href")??n?.href??"")??void 0}extractAbstract(e){return this.cleanText(e.querySelector('[data-test="description"], .c-article-section__content, .c-article-body__content')?.textContent??"")||void 0}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}cleanDoi(e){return e.match(jf)?.[0].replace(/[),.;\s]+$/g,"")}yearFromText(e){const t=e.match(qf);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}isExcludedDoiContext(e){return!!e.closest(Bn)}getDoiTextSelector(){return['[data-test="doi"]','[data-testid="doi"]','[data-test*="doi"]','[data-testid*="doi"]','[id*="doi"]','[class*="doi"]',".c-bibliographic-information__list-item",".c-article-identifiers__item"].join(",")}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Bn).forEach(n=>n.remove()),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t),r=n.hostname.toLowerCase();return n.protocol!=="https:"?void 0:r==="link.springer.com"||r.endsWith(".link.springer.com")||r==="media.springernature.com"?t:void 0}catch{return}}cleanVenue(e){return this.cleanText(e).replace(/^in\s+/i,"").replace(/\s*[•·|]\s*(?:Open Access|Published|Article|Chapter|PDF)\b[\s\S]*$/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/^Published:\s*/i,"").replace(/[,.;:\s]+$/g,"").trim()}extractMetaPages(){const e=this.firstMetaContent(["citation_pages","prism.pageRange","citation_firstpage"]),t=this.firstMetaContent(["citation_lastpage"]);if(e&&t&&e!==t&&!e.includes("-"))return`${e}-${t}`;if(e)return e;if(t)return t}extractVenueFromInlineContext(e){const t=Array.from(e.querySelectorAll(".app-card-open__authors, .app-card-open__context"));for(const n of t){const r=this.cleanText(n.textContent??"");if(!r)continue;const i=r.match(/\bin\s+(.+)$/i);if(!i?.[1])continue;const o=this.cleanVenue(i[1]);if(this.looksLikeVenue(o))return o}}looksLikeVenue(e){return!!(e&&!/^(?:Article|Chapter|Open Access|Published|PDF)$/i.test(e)&&!/^(?:Article|Chapter|Open Access|Published|PDF)\b/i.test(e)&&!/^(?:Authors?|By)\b/i.test(e))}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}}const Uf=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Hf=/\b((?:19|20)\d{2})\b/;function g(a){return(a??"").replace(/\s+/g," ").trim()}function _(a,e=document){for(const t of a){const n=yl(t),r=e.querySelector(`meta[name="${n}"], meta[property="${n}"]`)?.getAttribute("content"),i=g(r);if(i)return i}}function ct(a,e=document){const t=yl(a);return Y(Array.from(e.querySelectorAll(`meta[name="${t}"], meta[property="${t}"]`)).map(n=>g(n.getAttribute("content"))).filter(Boolean))}function H(a){const e=g(a);if(e)try{return new URL(e,location.href).toString()}catch{return}}function je(a){const t=g(a).replace(/^doi:\s*/i,"").replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/[),.;\]]+$/g,"").match(Uf);return t?t[0].replace(/[),.;\]]+$/g,""):void 0}function te(a){return je(a)}function Ze(a){const e=g(a).match(Hf);return e?Number.parseInt(e[1],10):void 0}function Y(a){return Array.from(new Set(a.filter(Boolean)))}const zf=['[data-test="article-description"]','[data-testid*="abstract"]','[data-test*="abstract"]',"[data-abstract-type]",".hlFld-Abstract",".abstract",".summary",".snippet",'[class*="abstract"]','[class*="Abstract"]','[class*="summary"]','[class*="Summary"]',".c-article-section__content",'[id*="abstract"]','[id*="Abstract"]','section[id*="abstract"]','div[id*="abstract"]',".search-result__body"].join(",");function Qe(a,e=zf){const t=new WeakMap,n=Jf(a,t);if(n)return n;for(const r of Array.from(a.querySelectorAll(e))){if(!ki(r,t))continue;const i=Di(r.textContent);if(Fi(i))return i}}function jn(){return H(document.querySelector('link[rel="canonical"]')?.getAttribute("href"))??H(_(["citation_public_url","citation_fulltext_html_url","og:url"]))??location.href}function Ae(){const a=g(document.title);return/just a moment|请稍候|请稍后|enable javascript and cookies|checking your browser|bot manager captcha|captcha/i.test(a)||!!document.querySelector(['script[src*="challenge-platform"]','script[src*="perfdrive.com"]','iframe[src*="challenges.cloudflare.com"]'].join(","))}function yl(a){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(a):a.replace(/["\\]/g,"\\$&")}function Jf(a,e){for(const t of Array.from(a.querySelectorAll('h2, h3, h4, [role="heading"]'))){if(!ki(t,e)||!/^abstract\b/i.test(g(t.textContent)))continue;const n=xl(t.nextElementSibling,e);if(n)return n;const r=xl(t.parentElement?.nextElementSibling??null,e);if(r)return r;const i=t.closest("section, div");if(i&&i!==a){const o=Di(i.textContent);if(Fi(o))return o}}}function xl(a,e){const t=[];let n=a;for(;n&&!Vf(n);){if(n instanceof HTMLElement&&!ki(n,e)){n=n.nextElementSibling;continue}const r=Di(n.textContent);Fi(r)&&t.push(r),n=n.nextElementSibling}return t.length?g(t.join(" ")):void 0}function Vf(a){const e=g(a.textContent),t=a.matches('h1, h2, h3, h4, [role="heading"]')?e:"",n=g(a.querySelector(':scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > [role="heading"]')?.textContent),r=t||n;if(r&&!/^abstract\b/i.test(r))return!0;const i=g([a.id,a.className,a.getAttribute("role"),a.getAttribute("aria-label"),a.getAttribute("data-test"),a.getAttribute("data-testid")].join(" "));return/\b(?:introduction|materials?|methods?|results?|discussion|references?|bibliography|acknowledg|supplement|figures?|tables?|metrics?|citations?|related)\b/i.test(i)}function Di(a){return g(a).replace(/^abstract\s*/i,"").replace(/^summary\s*/i,"").trim()}function Fi(a){return a.length>=12&&!/^(?:abstract|summary|figures?|tables?|references?|metrics?|citations?|related|authors?|article)(?:\s+(?:figures?|tables?|references?|metrics?|citations?|related|authors?|article))*$/i.test(a)}function ki(a,e){const t=e.get(a);if(t!==void 0)return t;let n=a;for(;n&&n!==document.body;){if(n.hidden||n.getAttribute("aria-hidden")==="true")return e.set(a,!1),!1;const r=n.getAttribute("style")??"";if(/display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:[;\s]|$)|clip\s*:\s*rect\(\s*0/i.test(r))return e.set(a,!1),!1;const i=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(n):null;if(i&&(i.display==="none"||i.visibility==="hidden"||i.opacity==="0"))return e.set(a,!1),!1;n=n.parentElement}return e.set(a,!0),!0}const Wf=/\b10\.\d{4,9}\/[^\s"'<>]+/i,Gf=/\b((?:19|20)\d{2})\b/,Al=["li.search__item",".search__item",".search-result",".search-result__item"].join(","),Yf=["article","#main-content","main","body"].join(","),Li=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[role="doc-bibliography"]','section[aria-label*="Reference"]','section[aria-labelledby*="reference"]',".article-section__references",".references-section",'[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class Zf extends W{id="wiley";name="Wiley Online Library";matches=["*://onlinelibrary.wiley.com/*","*://*.onlinelibrary.wiley.com/*"];isSearchPage(){return this.isChallengePage()?!1:location.pathname==="/action/doSearch"||location.pathname.startsWith("/action/doSearch")||new URLSearchParams(location.search).has("AllField")}isArticlePage(){return this.isChallengePage()?!1:/^\/doi\/(?:abs|full|pdf|epdf|book)?\/?10\./i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[WileyAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){const e=document.querySelector(Yf);if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[WileyAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(e.matches(Al)){const r=e.querySelector('.publication_meta, .search-result__meta, .search-result__info, .meta__citation, .meta__source, .journal-title, .source-title, .publication-year, time, [data-testid*="meta"], [data-testid*="citation"]');if(r)return{element:r,position:"after"};const i=e.querySelector('.authors, .citation__authors, .meta__authors, [class*="authors"]');if(i)return{element:i,position:"after"}}const t=e.querySelector('.citation__authors, .meta__authors, .publication_meta, [class*="authors"], [class*="meta"]');if(this.isArticlePage()&&t)return{element:t,position:"after"};const n=e.querySelector('h1, h2, h3, .citation__title, .hlFld-Title, .publication_title a, [class*="title"]');return n?{element:n,position:"after"}:t?{element:t,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".search-result__body")??document.querySelector(".search-results")??document.querySelector('[data-testid*="search"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("startPage")??e.get("page")??"0",10),n=Number.isFinite(t)?t+1:1,i=this.cleanText(document.querySelector('.result__count, .search-result__count, [class*="result-count"], [data-testid*="result-count"]')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/20)):1,url:location.href,itemsPerPage:20,totalItems:o}}getSearchResultHosts(){return this.isChallengePage()?[]:this.uniqueElements(Array.from(document.querySelectorAll(Al)).filter(e=>this.looksLikeSearchResult(e)))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||e.closest(Li)?!1:!!this.findTitleLink(e)}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .publication_title, .search-result__title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e),s=this.extractVenue(e),l=this.inferRecordKind(o,r,"",i);return{title:n,journalName:s,journalCandidates:s?this.journalCandidates(s):[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:i?`wiley:${i}`:r?`wiley:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,source:this.id,citationType:l.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Wiley Online Library\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""]),i=this.firstMetaContent(["citation_inbook_title","citation_book_title"])??"",o=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??i??""),s=this.firstMetaContent(["citation_article_type","dc.type"])??"",l=this.inferRecordKind(s,n,i,r);return{title:t,journalName:o,journalCandidates:o?this.journalCandidates(o):[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:r?`wiley:${r}`:n?`wiley:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),source:this.id,citationType:l.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector("h1, .citation__title, .hlFld-Title")?.textContent??document.title.replace(/\s*\|\s*Wiley Online Library\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.extractVenue(e),o=this.inferRecordKind(this.extractTypeText(e),n,"",r);return{title:t,journalName:i,journalCandidates:i?this.journalCandidates(i):[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:r?`wiley:${r}`:n?`wiley:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e,t,n="",r=""){const i=`${e} ${t??""} ${n}`;return/conference paper|conference proceeding/i.test(i)?{articleTypes:["Conference"],citationType:"inproceedings",metricsAllowed:!1}:/\/doi\/book\//i.test(t??"")&&!this.isChapterDoi(r)&&!/chapter|book section/i.test(e)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:/book chapter|chapter|book section|citation_inbook_title|citation_book_title/i.test(i)||this.cleanText(n).length>0?{articleTypes:["BookChapter"],citationType:"incollection",metricsAllowed:!1}:/\bbook\b/i.test(i)&&!/journal|article/i.test(i)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href], h3 a[href], .publication_title a[href], .search-result__title a[href], a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."]')).find(n=>this.isArticleLink(n)&&this.cleanText(n.textContent??"").length>0)??null}extractVenue(e){const t=[".publication_meta .journal",".publication_meta a[href]",".journal-title",".meta__journal",".meta__source",".citation__journal-title",".publication_meta",".search-result__meta",".search-result__info",".meta__citation",'[data-testid*="journal"]','[data-testid*="citation"]','[data-testid*="meta"]',".source-title",".meta__source"].join(",");for(const n of Array.from(e.querySelectorAll(t))){if(n instanceof HTMLAnchorElement&&/\/doi\/|doi\.org\//i.test(n.getAttribute("href")??""))continue;const r=this.cleanVenue(n.textContent??"");if(this.isLikelyVenueText(r))return r}for(const n of Array.from(e.querySelectorAll('.publication_meta, .search-result__meta, .search-result__info, .meta__citation, .meta__source, [data-testid*="citation"], [data-testid*="meta"], [class*="citation"], [class*="meta"], [class*="source"]'))){const r=this.extractVenueFromMetadataText(n.textContent??"");if(r)return r}return this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractTypeText(e){const t=[".publication-type",".content-type",".issue-item__type",'[data-testid*="type"]','[class*="type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractAuthorsFromDom(e){const t=[".author-name",".loa__author-name",".citation__author",".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).filter(n=>n&&!/^(Authors?|View|Show more)$/i.test(n)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time, .publication-year, .date, [class*="year"], [class*="date"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."]'))){if(this.isExcludedDoiContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .epub-doi'))){if(this.isExcludedDoiContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e){const t=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(t)return t;const n=e.querySelector('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href$=".pdf"], a[href*="/pdf"]');return this.toNativeFullTextUrl(n?.getAttribute("href")??n?.href??"")??void 0}extractAbstract(e){return Qe(e)}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}journalCandidates(e){const t=[e];return/^CA:\s*A Cancer Journal for Clinicians$/i.test(e)&&t.push("CA-A Cancer Journal for Clinicians"),this.unique(t)}cleanDoi(e){return this.decodeDoiSource(e).match(Wf)?.[0].replace(/[),.;\s]+$/g,"")}yearFromText(e){const t=e.match(Gf);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}isExcludedDoiContext(e){return!!e.closest(Li)||!!Array.from(e.parentElement?.children??[]).some(t=>/^References?$/i.test(this.cleanText(t.textContent??"")))}isChallengePage(){const e=document.title;return/Just a moment|Enable JavaScript and cookies|Access denied/i.test(e)||document.querySelector('.cf-turnstile, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]')?!0:/Enable JavaScript and cookies to continue|Checking if the site connection is secure/i.test(document.body?.textContent??"")}isChapterDoi(e){return/\b(?:\.ch\d+|_chap\d+|\.chapter\d+)$/i.test(e??"")}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Li).forEach(n=>n.remove()),t.textContent??""}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return/^\/doi\/(?:abs\/|full\/|pdf\/|epdf\/|book\/)?10\./i.test(t.pathname)||/^\/doi\/(?:abs\/|full\/)?no-visible-doi$/i.test(t.pathname)}catch{return!1}}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t),r=n.hostname.toLowerCase();if(n.protocol!=="https:")return;const i=r==="onlinelibrary.wiley.com"||r.endsWith(".onlinelibrary.wiley.com"),o=/^\/doi\/(?:pdf|epdf)\//i.test(n.pathname);return i&&o?t:void 0}catch{return}}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.searchParams.delete("af"),n.searchParams.delete("campaign"),n.href}catch{return t}}cleanVenue(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/^(?:Published in|Publication|Source)\s*:?\s*/i,"").replace(/^Journal\s*:?\s*/i,"").replace(/\s*(?:[•·|]|,\s+)(?:Wiley Online Library|Published online|First published)\b[\s\S]*$/i,"").replace(/\s+[•·|]\s*doi:\s*10\.\S+[\s\S]*$/i,"").replace(/\s*\bdoi:\s*10\.\S+[\s\S]*$/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}isLikelyVenueText(e){return!e||/^(?:Article|Chapter|PDF|Full text|Research Article)$/i.test(e)||/^(?:Wiley Online Library|Published online|First published)$/i.test(e)||/\b(?:published online|first published|volume|issue|research article)\b/i.test(e)?!1:!/^\d{4}$/.test(e)}extractVenueFromMetadataText(e){const t=this.cleanText(e);if(!t)return"";const n=t.replace(/\s*\bdoi:\s*10\.\S+[\s\S]*$/i,"").replace(/\s*\(?10\.\d{4,9}\/[^\s)]+[\s\S]*$/i,"").replace(/\s*[•·|]\s*/g," \u2022 ").trim(),r=[n,n.replace(/\s*[•·]\s*Wiley Online Library\b[\s\S]*$/i,"").trim(),n.replace(/,\s*(?:19|20)\d{2}\b[\s\S]*$/i,"").trim(),n.split("\u2022")[0]?.trim()??""];for(const i of r){const o=this.cleanVenue(i);if(this.isLikelyVenueText(o))return o}return""}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}}const Qf=/\b10\.\d{4,9}\/[^\s"'?#]+/i,Kf=/\b((?:19|20)\d{2})\b/,ln=["li.search__item",".search__item",".search-result__item",".resultItem",".search-result-card",'[data-testid*="searchResultItem"]','[data-testid*="search-result"]'].join(","),Xf=[ln,".art_title",".hlFld-Title",".publication_title"].join(","),Ni=[".search-results",".searchResultList",'[aria-label="Search results"]',".results-shell"].join(","),em=[Ni,'[data-testid*="search"]','[data-test*="search"]'].join(","),tm=["#main-content article","main article","#main-content","main","article","body"],Ri=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[class*="ref-list"]','[class*="refList"]','[class*="references-list"]','[role="doc-bibliography"]','section[aria-label*="Reference"]','section[aria-label*="reference"]','section[aria-labelledby*="Reference"]','section[aria-labelledby*="reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[id*="cited"]','[class*="cited"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class nm extends W{id="taylor-francis";name="Taylor & Francis Online";matches=["*://www.tandfonline.com/*"];isSearchPage(){return this.isChallengePage()?!1:location.pathname==="/action/doSearch"||location.pathname.startsWith("/action/doSearch")||new URLSearchParams(location.search).has("AllField")}isArticlePage(){return this.isChallengePage()?!1:/^\/doi\/(?:abs|full|pdf|epdf|book)?\/?10\./i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[TaylorFrancisAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isChallengePage())return null;const e=this.getDetailHostElement();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[TaylorFrancisAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector('.citation__authors, .publication_meta, [class*="authors"], [class*="meta"]');if(this.isArticlePage()&&t)return{element:t,position:"after"};const n=e.querySelector('h1, h2, h3, .citation__title, .hlFld-Title, .art_title a, [class*="title"]');return n?{element:n,position:"after"}:t?{element:t,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return this.getSearchResultLists()[0]??document.querySelector('[data-testid*="search"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("startPage")??e.get("page")??"0",10),n=Number.isFinite(t)?t+1:1,i=this.cleanText(document.querySelector('.result__count, .search-result__count, [class*="result-count"], [data-testid*="result-count"]')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/20)):1,url:location.href,itemsPerPage:20,totalItems:o}}getSearchResultHosts(){if(this.isChallengePage())return[];const e=this.getSearchResultLists(),t=e.length>0?e:[...Array.from(document.querySelectorAll(em)),...Array.from(document.querySelectorAll("main"))],n=t.length>0?t:[document.querySelector("main")??document];return this.uniqueElements(n.flatMap(r=>Array.from(r.querySelectorAll(Xf))).map(r=>this.toSearchResultHost(r)).filter(r=>!!r).filter(r=>this.looksLikeSearchResult(r)))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||this.isExcludedSearchContext(e)||e.closest(Ri)?!1:!!this.findTitleLink(e)}getSearchResultLists(){return Array.from(document.querySelectorAll(Ni)).filter(e=>!this.isExcludedSearchContext(e))}getDetailHostElement(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Taylor\s*&\s*Francis Online\s*$/i,""),t=this.uniqueElements(tm.flatMap(s=>Array.from(document.querySelectorAll(s))));if(e){const s=e.toLowerCase(),l=t.find(c=>(c===document.body||!this.isExcludedSearchContext(c))&&this.cleanText(c.textContent??"").toLowerCase().includes(s));if(l)return l}const n=this.cleanDoi(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href);if(n){const s=t.find(l=>l!==document.body&&!this.isExcludedSearchContext(l)&&this.extractDoi(l,{allowTextFallback:!1})===n);if(s)return s}const r=t.filter(s=>s!==document.body&&!this.isExcludedSearchContext(s)&&!!s.querySelector("h1, .citation__title, .hlFld-Title")),i=this.leafHeadingCandidates(r),o=n?i.find(s=>this.candidateDoi(s)===n)??i.find(s=>!this.candidateDoi(s)&&this.hasDetailArticleEvidence(s))??this.lastNoDoiCandidate(i):i.find(s=>!this.candidateDoi(s)&&this.hasDetailArticleEvidence(s))??this.lastNoDoiCandidate(i)??i[i.length-1];return o||(t.find(s=>s===document.body||!this.isExcludedSearchContext(s))??null)}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .art_title, .search-result__title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e),s=this.extractVenue(e),l=this.inferRecordKind(o,r,"",i);return{title:n,journalName:s,journalCandidates:s?[s]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:i?`taylor-francis:${i}`:r?`taylor-francis:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,source:this.id,citationType:l.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Taylor\s*&\s*Francis Online\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""]),i=this.firstMetaContent(["citation_inbook_title"])??"",o=this.firstMetaContent(["citation_book_title"])??"",s=i||(o&&this.cleanVenue(o).toLowerCase()!==this.cleanVenue(t).toLowerCase()?o:""),l=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])||i||o||s||""),c=this.firstMetaContent(["citation_article_type","dc.type"])??"",u=this.inferRecordKind(c,n,s,r);return{title:t,journalName:l,journalCandidates:l?[l]:[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:r?`taylor-francis:${r}`:n?`taylor-francis:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:u.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),source:this.id,citationType:u.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector("h1, .citation__title, .hlFld-Title")?.textContent??document.title.replace(/\s*\|\s*Taylor\s*&\s*Francis Online\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.extractVenue(e),o=this.inferRecordKind(this.extractTypeText(e),n,"",r);return{title:t,journalName:i,journalCandidates:i?[i]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:r?`taylor-francis:${r}`:n?`taylor-francis:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e,t,n="",r=""){const i=`${e} ${t??""} ${n}`,o=/\/doi\/book\//i.test(t??""),s=e.match(/\b(?:book|chapter)\s+reviews?\b/i);if(s)return{articleTypes:[this.toTitleCase(s[0])],citationType:"article",metricsAllowed:!1};const l=/book chapter|chapter|book section/i.test(i)||this.cleanText(n).length>0||o&&this.isChapterDoi(r);return/conference paper|conference proceeding/i.test(i)?{articleTypes:["Conference"],citationType:"inproceedings",metricsAllowed:!1}:l?{articleTypes:["BookChapter"],citationType:"incollection",metricsAllowed:!1}:o?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:/\bbook\b/i.test(i)&&!/journal|article/i.test(i)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href], h3 a[href], .art_title a[href], .art_title[href], .hlFld-Title a[href], .hlFld-Title[href], .publication_title a[href], .publication_title[href], .search-result__title a[href], .search-result__title[href], a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."]')).find(n=>this.isArticleLink(n)&&this.cleanText(n.textContent??"").length>0)??null}extractVenue(e){const t=[".publication_meta .journal",".publication_meta a[href]",".journal-title",".meta__journal",".meta__source",".citation__journal-title",".publication_meta",".search-result__meta",".search-result__info",".meta__citation",'[data-testid*="journal"]','[data-testid*="citation"]','[data-testid*="meta"]',".source-title",".meta__source"].join(",");for(const n of Array.from(e.querySelectorAll(t))){if(n instanceof HTMLAnchorElement&&/\/doi\/|doi\.org\//i.test(n.getAttribute("href")??""))continue;const r=this.cleanVenue(n.textContent??"");if(this.isLikelyVenueText(r))return r}for(const n of Array.from(e.querySelectorAll('.publication_meta, .search-result__meta, .search-result__info, .meta__citation, [data-testid*="citation"], [data-testid*="meta"], [class*="citation"], [class*="meta"]'))){const r=this.cleanText(n.textContent??""),i=this.cleanVenue(r.replace(/\s*[·•|]\s*Taylor\s*&\s*Francis(?:\s+Online)?\b[\s\S]*$/i,"").trim());if(this.isLikelyVenueText(i))return i}return this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractTypeText(e){const t=[".publication-type",".content-type",".issue-item__type",'[data-testid*="type"]','[class*="type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractAuthorsFromDom(e){const t=[".author-name",".loa__author-name",".citation__author",".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).filter(n=>n&&!/^(Authors?|View|Show more)$/i.test(n)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time, .publication-year, .date, [class*="year"], [class*="date"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."], a[href*="/doi/pdf/10."], a[href*="/doi/epdf/10."], a[href*="/doi/book/10."]'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .epub-doi'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e){const t=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(t)return t;for(const n of Array.from(e.querySelectorAll('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href$=".pdf"], a[href*="/pdf"]'))){if(this.isExcludedDoiContext(n)||this.isExcludedSearchContext(n))continue;const r=this.toNativeFullTextUrl(n.getAttribute("href")??n.href??"");if(r)return r}}extractAbstract(e){return Qe(e)}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}cleanDoi(e){const t=this.unique([this.pathnameFromPossibleUrl(e)??"",e]);for(const n of t){const i=this.decodeDoiSource(n).match(Qf),o=i?this.trimDoiTail(i[0]):void 0;if(o)return o}}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}yearFromText(e){const t=e.match(Kf);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}trimDoiTail(e){let t=e.replace(/[,.;\s]+$/g,"");for(;t.endsWith(")")&&this.countCharacter(t,")")>this.countCharacter(t,"(");)t=t.slice(0,-1).replace(/[,.;\s]+$/g,"");return t}countCharacter(e,t){return Array.from(e).filter(n=>n===t).length}isExcludedDoiContext(e){return!!e.closest(Ri)||!!this.closestExcludedSection(e)||this.isAfterExcludedModuleHeading(e)||!!Array.from(e.parentElement?.children??[]).some(t=>/^References?$/i.test(this.cleanText(t.textContent??"")))}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Ri).forEach(n=>n.remove()),Array.from(t.querySelectorAll("section, aside, nav, div")).forEach(n=>{this.hasExcludedSectionLabel(n)&&n.remove()}),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.protocol!=="https:"||n.hostname.toLowerCase()!=="www.tandfonline.com"?void 0:/^\/doi\/(?:pdf|epdf)\//i.test(n.pathname)?t:void 0}catch{return}}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.searchParams.delete("af"),n.searchParams.delete("campaign"),n.href}catch{return t}}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return/^\/doi\/(?:abs\/|full\/|pdf\/|epdf\/|book\/)?10\./i.test(t.pathname)||/^\/doi\/(?:abs\/|full\/)?no-visible-doi$/i.test(t.pathname)}catch{return!1}}isChapterDoi(e){return/\b(?:\.ch\d+|_chap\d+|\.chapter\d+|-\d+)$/i.test(e??"")}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}isChallengePage(){const e=document.title;return/Just a moment|Enable JavaScript and cookies|Access denied|Attention Required|Cloudflare/i.test(e)||document.querySelector('.cf-turnstile, .cf-error-code, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]')?!0:/Enable JavaScript and cookies to continue|Checking if the site connection is secure|Sorry, you have been blocked|Cloudflare Ray ID/i.test(document.body?.textContent??"")}cleanVenue(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/^(?:Published in|Publication|Source)\s*:?\s*/i,"").replace(/^Journal\s*:?\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}isLikelyVenueText(e){return!e||/^(?:Article|Chapter|PDF|Full text|Research Article)$/i.test(e)||/^(?:Taylor\s*&\s*Francis(?:\s+Online)?|Published online)$/i.test(e)||/\b(?:published online|first published|volume|issue|research article)\b/i.test(e)?!1:!/^\d{4}$/.test(e)}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}toTitleCase(e){return e.toLowerCase().replace(/\b\w/g,t=>t.toUpperCase())}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}toSearchResultHost(e){return e.matches(ln)?e:e.closest(ln)??e.closest("li, .search-result, .search-result__item, .issue-item, article")??e}isExcludedSearchContext(e){let t=e;for(;t&&t!==document.body;){if(/^(ASIDE|NAV|FOOTER)$/i.test(t.tagName)||t.getAttribute("role")==="complementary"||this.hasExcludedSectionLabel(t))return!0;t=t.parentElement}return!1}pathnameFromPossibleUrl(e){const t=e.trim();if(t)try{const n=new URL(t,location.origin);if(n.hostname.toLowerCase()==="doi.org"||n.pathname.includes("/doi/")||n.pathname.startsWith("/10."))return n.pathname}catch{return}}closestExcludedSection(e){let t=e.parentElement;for(;t&&t!==document.body;){if(!t.matches(ln)&&this.hasExcludedSectionLabel(t))return t;t=t.parentElement}return null}hasExcludedSectionLabel(e){const t=[e.getAttribute("aria-label")??"",e.getAttribute("aria-labelledby")??"",e.getAttribute("id")??"",e.getAttribute("class")??""].join(" ");return this.isExcludedModuleMarkerText(t)?!0:/^(ARTICLE|MAIN|BODY|HTML)$/i.test(e.tagName)||e.matches(ln)||!this.shouldScanSectionLabelText(e)?!1:this.sectionLabelTexts(e).some(n=>this.isExcludedModuleHeadingText(n))}isExcludedModuleMarkerText(e){return/(?:references?|bibliography|related|recommend(?:ed|ations?)?|cited(?:\s+by)?|most\s+read|most\s+viewed|popular|latest|recent|recently\s+viewed|also\s+read|trending|sidebar|side[-_\s]*bar|right[-_\s]*rail|layout__secondary|secondary[-_\s]*(?:rail|content|column|module)?)/i.test(e)}isExcludedModuleHeadingText(e){const t=this.cleanModuleHeadingText(e);return/^(?:references?|bibliography|related(?:\s+articles?)?|recommend(?:ed(?:\s+(?:articles?|for\s+you))?|ations?(?:\s+for\s+you)?)|cited(?:\s+by)?|most\s+read(?:\s+articles?)?|most\s+viewed(?:\s+articles?)?|popular(?:\s+articles?)?|latest(?:\s+(?:articles?|papers?|publications?|research))?|recent(?:\s+(?:articles?|papers?|publications?|research))?|recently\s+viewed|(?:people\s+)?also\s+read|you\s+may\s+also\s+like|trending(?:\s+articles?)?)$/i.test(t)}cleanModuleHeadingText(e){return this.cleanText(e).replace(/\s*(?:\(\s*\d+\s*\)|\[\s*\d+\s*\]|\{\s*\d+\s*\})\s*$/g,"").replace(/\s+\d+\s*$/g,"").trim()}candidateDoi(e){return this.extractDoi(e,{allowTextFallback:!1})}lastNoDoiCandidate(e){const t=e.filter(n=>!this.candidateDoi(n));return t[t.length-1]}leafHeadingCandidates(e){const t=e.filter(n=>!e.some(r=>r!==n&&n.contains(r)));return t.length>0?t:e}hasDetailArticleEvidence(e){return!!e.querySelector([".journal-title",".meta__journal",".citation__journal-title",'[data-testid*="journal"]',".source-title",".meta__source",".publication-year","time",".publication-type",".content-type",".abstract",'[class*="abstract"]',".citation__authors",".author-name",".loa__author-name","[data-author-name]"].join(","))}shouldScanSectionLabelText(e){return/^(SECTION|ASIDE|NAV)$/i.test(e.tagName)||Array.from(e.children).some(t=>(/^H[1-6]$/i.test(t.tagName)||t.getAttribute("role")==="heading")&&this.isExcludedModuleHeadingText(t.textContent??""))?!0:/(?:content[-_\s]*block|module|widget|rail|sidebar|recommend|related|latest|recent|reference|bibliography|cited)/i.test(`${e.getAttribute("id")??""} ${e.getAttribute("class")??""}`)||Array.from(e.children).some(t=>/(?:content[-_\s]*block|module[-_\s]*header|moduleHeader|section[-_\s]*title|sectionTitle)/i.test(`${t.getAttribute("id")??""} ${t.getAttribute("class")??""}`))}isAfterExcludedModuleHeading(e){let t=e;for(;t&&t!==document.body;){let n=t.previousElementSibling;for(;n;){if(this.isExcludedHeadingElement(n))return!0;n=n.previousElementSibling}if(/^(ARTICLE|MAIN)$/i.test(t.tagName))break;t=t.parentElement}return!1}isExcludedHeadingElement(e){return/^H[1-6]$/i.test(e.tagName)||e.getAttribute("role")==="heading"||e.matches('.section-title, .sectionTitle, .module-header, .moduleHeader, [class*="section-title"], [class*="sectionTitle"], [class*="module-header"], [class*="moduleHeader"]')?this.isExcludedModuleHeadingText(e.textContent??""):this.isExcludedModuleHeadingText(e.textContent??"")&&!e.querySelector("a[href], button, input, select, textarea")}sectionLabelTexts(e){const t=[],n=(r,i)=>{if(r.matches(ln))return;const o=Array.from(r.childNodes).filter(s=>s.nodeType===3).map(s=>this.cleanText(s.textContent??"")).filter(Boolean).join(" ");o&&t.push(o);for(const s of Array.from(r.children)){if(s.matches(ln)||s.matches(Ni)||/^(ASIDE|NAV|FOOTER)$/i.test(s.tagName)||s.getAttribute("role")==="complementary")continue;if(/^H[1-6]$/i.test(s.tagName)||s.getAttribute("role")==="heading"||s.matches('.section-title, .sectionTitle, .module-header, .moduleHeader, [class*="section-title"], [class*="sectionTitle"], [class*="module-header"], [class*="moduleHeader"]')){t.push(this.cleanText(s.textContent??""));continue}const l=this.cleanText(s.textContent??"");if(this.isExcludedModuleHeadingText(l)){t.push(l);continue}i<20&&n(s,i+1)}};return n(e,0),t.filter(Boolean)}}const rm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,am=/\b((?:19|20)\d{2})\b/,cn=["li.search-results__item",".search-results__item","li.search-result",".search-result",".searchResult",".article-card",".al-article-box",".al-article-item"].join(","),Pi=[".search-results",".search-results-list",".searchResultList",'[data-testid*="search-results"]'].join(","),im=[Pi,'[data-testid*="search"]','[data-test*="search"]',"main"].join(","),om=["#ContentColumn article","#main-content article","main article","#ContentColumn","#main-content","main","article","body"],Ii=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[class*="ref-list"]','[class*="refList"]','[role="doc-bibliography"]','section[aria-label*="Reference"]','section[aria-label*="reference"]','section[aria-labelledby*="Reference"]','section[aria-labelledby*="reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[id*="cited"]','[class*="cited"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class sm extends W{id="oxford-academic";name="Oxford Academic";matches=["*://academic.oup.com/*"];isSearchPage(){return this.isChallengePage()?!1:location.pathname==="/search-results"||location.pathname.startsWith("/search-results")||location.pathname==="/search"||location.pathname.startsWith("/search")&&new URLSearchParams(location.search).has("q")}isArticlePage(){return this.isChallengePage()?!1:/\/article(?:-abstract)?\//i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[OxfordAcademicAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isChallengePage())return null;const e=this.getDetailHostElement();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[OxfordAcademicAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector('.ww-citation-primary, .authors, [class*="authors"], [class*="meta"]');if(this.isArticlePage()&&t)return{element:t,position:"after"};const n=e.querySelector('h1, h2, h3, .wi-article-title, .article-title, .al-title, [class*="title"]');return n?{element:n,position:"after"}:t?{element:t,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return this.getSearchResultLists()[0]??document.querySelector('[data-testid*="search"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??e.get("startPage")??"1",10),n=Number.isFinite(t)&&t>0?t:1,i=this.cleanText(document.querySelector('.result-count, .search-result-count, [class*="result-count"], [data-testid*="result-count"]')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/20)):1,url:location.href,itemsPerPage:20,totalItems:o}}getSearchResultHosts(){if(this.isChallengePage())return[];const e=this.getSearchResultLists(),t=e.length>0?e:Array.from(document.querySelectorAll(im)),n=t.length>0?t:[document],r=n.flatMap(o=>Array.from(o.querySelectorAll(cn))),i=n.flatMap(o=>Array.from(o.querySelectorAll('a[href*="/article/"], a[href*="/article-abstract/"]'))).map(o=>this.toSearchResultHost(o)).filter(o=>!!o);return this.uniqueElements([...r,...i]).map(o=>this.toSearchResultHost(o)).filter(o=>!!o).filter(o=>this.looksLikeSearchResult(o))}getSearchResultLists(){return Array.from(document.querySelectorAll(Pi)).filter(e=>!this.isExcludedSearchContext(e))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||this.isExcludedSearchContext(e)||e.closest(Ii)?!1:!!this.findTitleLink(e)}getDetailHostElement(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Oxford Academic\s*$/i,""),t=this.uniqueElements(om.flatMap(c=>Array.from(document.querySelectorAll(c))));if(e){const c=e.toLowerCase(),u=t.find(d=>(d===document.body||!this.isExcludedSearchContext(d))&&this.cleanText(d.textContent??"").toLowerCase().includes(c));if(u)return u}const n=t.filter(c=>c!==document.body&&!this.isExcludedSearchContext(c)&&!!c.querySelector("h1, .wi-article-title, .article-title, .al-title")),r=this.leafHeadingCandidates(n),i=this.cleanDoi(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),o=i?r.find(c=>this.extractDoi(c,{allowTextFallback:!1})===i):void 0;if(o)return o;const s=r.find(c=>!this.extractDoi(c,{allowTextFallback:!1})&&this.hasDetailArticleEvidence(c));if(s)return s;const l=r.filter(c=>!this.extractDoi(c,{allowTextFallback:!1}));return l.length>0?l[l.length-1]:r.length>0?r[r.length-1]:t.find(c=>c===document.body||!this.isExcludedSearchContext(c))??null}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .article-title, .al-title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e),s=this.extractVenue(e),l=this.inferRecordKind(o,r,"",i),c=this.buildJournalInfo(s,r);return{title:n,journalName:c.journalName,journalCandidates:c.journalCandidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:this.sourceIdFor(i,r),url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,source:this.id,citationType:l.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Oxford Academic\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""]),i=this.firstMetaContent(["citation_inbook_title","citation_book_title"])??"",o=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??i??""),s=this.firstMetaContent(["citation_article_type","dc.type"])??"",l=this.inferRecordKind(s,n,i,r),c=this.buildJournalInfo(o,n);return{title:t,journalName:c.journalName,journalCandidates:c.journalCandidates,authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:this.sourceIdFor(r,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:l.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),source:this.id,citationType:l.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector("h1, .wi-article-title, .article-title, .al-title")?.textContent??document.title.replace(/\s*\|\s*Oxford Academic\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.extractVenue(e),o=this.inferRecordKind(this.extractTypeText(e),n,"",r),s=this.buildJournalInfo(i,n);return{title:t,journalName:s.journalName,journalCandidates:s.journalCandidates,authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:this.sourceIdFor(r,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e,t,n="",r=""){const i=`${e} ${t??""} ${n}`,o=/\/book\/[^/]+\/chapter\//i.test(t??""),s=/book chapter|chapter|book section/i.test(i)||this.cleanText(n).length>0||o&&/\b(?:\.ch\d+|_chap\d+|\.chapter\d+|-\d+)$/i.test(r);return/conference paper|conference proceeding|proceedings/i.test(i)?{articleTypes:["Conference"],citationType:"inproceedings"}:s?{articleTypes:["BookChapter"],citationType:"incollection"}:/\bbook\b/i.test(i)&&!/journal|article/i.test(i)?{articleTypes:["Book"],citationType:"book"}:{articleTypes:["JournalArticle"],citationType:"article"}}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href], h3 a[href], .article-title a[href], .al-title a[href], .item-title a[href], a[href*="/article/"], a[href*="/article-abstract/"]')).find(n=>this.isArticleLink(n)&&this.cleanText(n.textContent??"").length>0)??null}extractVenue(e){const t=[".journal-title",".citation-journal-title",".ww-citation-primary",".al-journal-title",".publication-title",".source-title",'[data-testid*="journal"]','[data-test*="journal"]','[class*="journal-title"]','[class*="source"]'].join(",");for(const n of Array.from(e.querySelectorAll(t))){const r=this.cleanVenue(n.textContent??"");if(r&&!/^(Article|Chapter|PDF|Full text)$/i.test(r))return r}return this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractTypeText(e){const t=[".publication-type",".content-type",".article-type",'[data-testid*="type"]','[data-test*="type"]','[class*="type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractAuthorsFromDom(e){const t=[".author-name",".loa__author-name",".al-authors-list a",".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).filter(n=>n&&!/^(Authors?|View|Show more)$/i.test(n)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time, .publication-year, .date, [class*="year"], [class*="date"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/lookup/doi/10."], a[href*="/doi/10."], a[href*="/doi/full/10."], a[href*="/doi/abs/10."], a[href*="/doi/pdf/10."]'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .epub-doi'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e){const t=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(t)return t;for(const n of Array.from(e.querySelectorAll('a[href*="/article-pdf/"], a[href$=".pdf"], a[href*=".pdf"], a[href*="/pdf/"], a[href*="DownloadFile"]'))){if(this.isExcludedDoiContext(n)||this.isExcludedSearchContext(n))continue;const r=this.toNativeFullTextUrl(n.getAttribute("href")??n.href??"");if(r)return r}}extractAbstract(e){return Qe(e)}buildJournalInfo(e,t){const n=this.cleanVenue(e),r=this.journalHintFromUrl(t??location.href),i=[],o=d=>{const p=this.cleanVenue(d??"");p&&i.push(p)},s=n.match(/^[A-Z][A-Z0-9&.\s-]{1,16}\s*[:\-]\s*(.+)$/)?.[1];s&&o(s);const l=/^JNCI(?:\s*[:\-]\s*Journal of the National Cancer Institute)?$/i.test(n);l&&(o("Journal of the National Cancer Institute"),o("JNCI-Journal of the National Cancer Institute")),r&&(this.isWeakVenue(n)||l||!n)&&(o(r.full),r.aliases.forEach(o)),n&&!this.isWeakVenue(n)&&o(n),r&&!i.some(d=>d.toLowerCase()===r.full.toLowerCase())&&(o(r.full),r.aliases.forEach(o));const c=this.unique(i);return{journalName:c.find(d=>!this.isWeakVenue(d)&&!/^JNCI-Journal/i.test(d))??c[0]??n,journalCandidates:c}}journalHintFromUrl(e){try{const t=new URL(e,location.origin);if(/^\/jnci(?:\/|$)/i.test(t.pathname))return{full:"Journal of the National Cancer Institute",aliases:["JNCI-Journal of the National Cancer Institute"]}}catch{return}}isWeakVenue(e){const t=this.cleanText(e);return!t||t.includes("...")||/^(Article|Chapter|PDF|Full text|Oxford Academic)$/i.test(t)?!0:/^[A-Z0-9&.\s-]{2,12}$/.test(t)}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}cleanDoi(e){const t=this.unique([this.pathnameFromPossibleUrl(e)??"",e]);for(const n of t){const i=this.decodeDoiSource(n).match(rm),o=i?this.trimDoiTail(i[0]):void 0;if(o)return o}}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}sourceIdFor(e,t){if(e)return`oxford-academic:${e}`;if(t)try{const n=new URL(t);return`oxford-academic:${this.normalizeArticlePathname(n.pathname)}`}catch{return`oxford-academic:${t}`}}normalizeArticlePathname(e){return e.replace(/\/article-abstract\//i,"/article/").replace(/\/+$/g,"")||"/"}yearFromText(e){const t=e.match(am);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}trimDoiTail(e){let t=e.replace(/[,.;\]\}\s]+$/g,"");for(;t.endsWith(")")&&this.countCharacter(t,")")>this.countCharacter(t,"(");)t=t.slice(0,-1).replace(/[,.;\]\}\s]+$/g,"");return t}countCharacter(e,t){return Array.from(e).filter(n=>n===t).length}isExcludedDoiContext(e){return!!e.closest(Ii)||!!this.closestExcludedSection(e)||this.isAfterExcludedModuleHeading(e)||!!Array.from(e.parentElement?.children??[]).some(t=>/^References?$/i.test(this.cleanText(t.textContent??"")))}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Ii).forEach(n=>n.remove()),Array.from(t.querySelectorAll("section, aside, nav, div")).forEach(n=>{this.hasExcludedSectionLabel(n)&&n.remove()}),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);if(n.protocol!=="https:")return;const r=n.hostname.toLowerCase(),i=n.pathname.toLowerCase();return(r==="academic.oup.com"||r==="oup.silverchair-cdn.com"||r==="watermark.silverchair.com")&&(r==="academic.oup.com"&&/^\/article-pdf\//i.test(n.pathname)||i.endsWith(".pdf")||i.includes("/pdf/")||i.includes("/article-pdf/"))?n.href:void 0}catch{return}}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.searchParams.delete("login"),n.searchParams.delete("redirectedFrom"),n.href}catch{return t}}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return t.hostname.toLowerCase()==="academic.oup.com"&&/\/article(?:-abstract)?\//i.test(t.pathname)}catch{return!1}}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}isChallengePage(){const e=document.title;return/Just a moment|Enable JavaScript and cookies|Access denied|Attention Required|Cloudflare/i.test(e)||document.querySelector('.cf-turnstile, .cf-error-code, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]')?!0:/Enable JavaScript and cookies to continue|Checking if the site connection is secure|Sorry, you have been blocked|Cloudflare Ray ID/i.test(document.body?.textContent??"")}cleanVenue(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/^Journal\s*:\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}toSearchResultHost(e){return e.matches(cn)?e:e.closest(cn)}isExcludedSearchContext(e){let t=e;for(;t&&t!==document.body;){if(/^(ASIDE|NAV|FOOTER)$/i.test(t.tagName)||t.getAttribute("role")==="complementary"||this.hasExcludedSectionLabel(t))return!0;t=t.parentElement}return!1}pathnameFromPossibleUrl(e){const t=e.trim();if(t)try{const n=new URL(t,location.origin);if(n.hostname.toLowerCase()==="doi.org"||n.pathname.includes("/doi/")||n.pathname.includes("/lookup/doi/")||n.pathname.startsWith("/10."))return n.pathname}catch{return}}closestExcludedSection(e){let t=e.parentElement;for(;t&&t!==document.body;){if(!t.matches(cn)&&this.hasExcludedSectionLabel(t))return t;t=t.parentElement}return null}hasExcludedSectionLabel(e){const t=[e.getAttribute("aria-label")??"",e.getAttribute("aria-labelledby")??"",e.getAttribute("id")??"",e.getAttribute("class")??""].join(" ");return this.isExcludedModuleMarkerText(t)?!0:/^(ARTICLE|MAIN|BODY|HTML)$/i.test(e.tagName)||e.matches(cn)||!this.shouldScanSectionLabelText(e)?!1:this.sectionLabelTexts(e).some(n=>this.isExcludedModuleHeadingText(n))}isExcludedModuleMarkerText(e){return/(?:references?|bibliography|related|recommend(?:ed|ations?)?|cited(?:\s+by)?|most\s+read|most\s+viewed|popular|latest|recent|recently\s+viewed|also\s+read|you\s+may\s+also\s+like|trending|sidebar|side[-_\s]*bar|right[-_\s]*rail|layout__secondary|secondary[-_\s]*(?:rail|content|column|module)?)/i.test(e)}isExcludedModuleHeadingText(e){const t=this.cleanModuleHeadingText(e);return/^(?:references?|bibliography|related(?:\s+articles?)?|recommend(?:ed(?:\s+(?:articles?|for\s+you))?|ations?(?:\s+for\s+you)?)|cited(?:\s+by)?|most\s+read(?:\s+articles?)?|most\s+viewed(?:\s+articles?)?|popular(?:\s+articles?)?|latest(?:\s+(?:articles?|papers?|publications?|research))?|recent(?:\s+(?:articles?|papers?|publications?|research))?|recently\s+viewed|(?:people\s+)?also\s+read|you\s+may\s+also\s+like|trending(?:\s+articles?)?)$/i.test(t)}cleanModuleHeadingText(e){return this.cleanText(e).replace(/\s*(?:\(\s*\d+\s*\)|\[\s*\d+\s*\]|\{\s*\d+\s*\})\s*$/g,"").replace(/\s+\d+\s*$/g,"").trim()}leafHeadingCandidates(e){const t=e.filter(n=>!e.some(r=>r!==n&&n.contains(r)));return t.length>0?t:e}hasDetailArticleEvidence(e){return!!e.querySelector([".journal-title",".citation-journal-title",".ww-citation-primary",".al-journal-title",".publication-title",".source-title",'[data-testid*="journal"]',".publication-year","time",".publication-type",".content-type",".article-type",".abstract",'[class*="abstract"]',".author-name",".loa__author-name","[data-author-name]"].join(","))}shouldScanSectionLabelText(e){return/^(SECTION|ASIDE|NAV)$/i.test(e.tagName)||Array.from(e.children).some(t=>(/^H[1-6]$/i.test(t.tagName)||t.getAttribute("role")==="heading")&&this.isExcludedModuleHeadingText(t.textContent??""))?!0:/(?:content[-_\s]*block|module|widget|rail|sidebar|recommend|related|latest|recent|reference|bibliography|cited)/i.test(`${e.getAttribute("id")??""} ${e.getAttribute("class")??""}`)||Array.from(e.children).some(t=>/(?:content[-_\s]*block|module[-_\s]*header|moduleHeader|section[-_\s]*title|sectionTitle)/i.test(`${t.getAttribute("id")??""} ${t.getAttribute("class")??""}`))}isAfterExcludedModuleHeading(e){let t=e;for(;t&&t!==document.body;){let n=t.previousElementSibling;for(;n;){if(this.isExcludedHeadingElement(n))return!0;n=n.previousElementSibling}if(/^(ARTICLE|MAIN)$/i.test(t.tagName))break;t=t.parentElement}return!1}isExcludedHeadingElement(e){return/^H[1-6]$/i.test(e.tagName)||e.getAttribute("role")==="heading"||e.matches('.section-title, .sectionTitle, .module-header, .moduleHeader, [class*="section-title"], [class*="sectionTitle"], [class*="module-header"], [class*="moduleHeader"]')?this.isExcludedModuleHeadingText(e.textContent??""):this.isExcludedModuleHeadingText(e.textContent??"")&&!e.querySelector("a[href], button, input, select, textarea")}sectionLabelTexts(e){const t=[],n=(r,i)=>{if(r.matches(cn))return;const o=Array.from(r.childNodes).filter(s=>s.nodeType===3).map(s=>this.cleanText(s.textContent??"")).filter(Boolean).join(" ");o&&t.push(o);for(const s of Array.from(r.children)){if(s.matches(cn)||s.matches(Pi)||/^(ASIDE|NAV|FOOTER)$/i.test(s.tagName)||s.getAttribute("role")==="complementary")continue;if(/^H[1-6]$/i.test(s.tagName)||s.getAttribute("role")==="heading"||s.matches('.section-title, .sectionTitle, .module-header, .moduleHeader, [class*="section-title"], [class*="sectionTitle"], [class*="module-header"], [class*="moduleHeader"]')){t.push(this.cleanText(s.textContent??""));continue}const l=this.cleanText(s.textContent??"");if(this.isExcludedModuleHeadingText(l)){t.push(l);continue}i<20&&n(s,i+1)}};return n(e,0),t.filter(Boolean)}}const lm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,cm=/\b((?:19|20)\d{2})\b/,Mi=[".representation.overview.search",'[data-test-id="searchItem"]'].join(","),Cl=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[class*="references"]','[role="doc-bibliography"]','section[aria-label*="Reference"]','section[aria-labelledby*="reference"]','[id*="related"]','[class*="related"]','[id*="recommend"]','[class*="recommend"]','[id*="cited"]','[class*="cited"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class um extends W{id="cambridge-core";name="Cambridge Core";matches=["*://www.cambridge.org/*"];isSearchPage(){return this.isBlockedPage()?!1:location.pathname==="/core/search"||location.pathname.startsWith("/core/search")||location.pathname==="/core/"&&new URLSearchParams(location.search).has("q")}isArticlePage(){return this.isBlockedPage()||!this.isArticleOrBookRecordPath(location.pathname)?!1:!!this.firstMetaContent(["citation_title","dc.title","og:title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[CambridgeCoreAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isBlockedPage())return null;const e=this.getDetailHostElement();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[CambridgeCoreAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=e.querySelector('.details, .author, [class*="meta"], [class*="author"]');if(this.isArticlePage()&&t)return{element:t,position:"after"};const n=e.querySelector('h1, h2, h3, .title, .heading_08, [class*="title"]');return n?{element:n,position:"after"}:t?{element:t,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".search-results-listing .results")??document.querySelector(".search-results-listing")??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("pageNum")??e.get("page")??"1",10),n=this.cleanText(document.querySelector('[data-test-id="textNoOfSearchResults"], .result-number')?.textContent??""),r=n.match(/\b([\d,]+)\s+results?\b/i)??n.match(/\b([\d,]+)\b/),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:Number.isFinite(t)&&t>0?t:1,totalPages:i?Math.max(1,Math.ceil(i/20)):1,url:location.href,itemsPerPage:20,totalItems:i}}getSearchResultHosts(){if(this.isBlockedPage())return[];const e=Array.from(document.querySelectorAll('[data-test-id="searchItem"]')),t=Array.from(document.querySelectorAll(".representation.overview.search")).filter(n=>!n.querySelector('[data-test-id="searchItem"]'));return[...e,...t].filter(n=>this.looksLikeSearchResult(n))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||this.isExcludedSearchContext(e)?!1:!!this.findTitleLink(e)}getDetailHostElement(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??""),t=this.uniqueElements([...Array.from(document.querySelectorAll("main article, #maincontent article, .article, main, #maincontent, body"))]);if(e){const n=e.toLowerCase(),r=t.find(i=>(i===document.body||!this.isExcludedSearchContext(i))&&this.cleanText(i.textContent??"").toLowerCase().includes(n));if(r)return r}return t.find(n=>n===document.body||!this.isExcludedSearchContext(n))??document.body}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.extractTypeText(e),o=this.inferRecordKind(i,r,this.extractInputProductType(e),this.extractVenueLabel(e)),s=this.extractVenue(e),l=this.extractDoi(e,{allowTextFallback:!1});return{title:n,journalName:s,journalCandidates:s?[s]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:l,sourceId:this.sourceIdFor(l,e,r),url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Cambridge Core\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""])??this.extractDoi(e,{allowTextFallback:!1}),i=this.firstMetaContent(["citation_inbook_title","citation_book_title"])??"",o=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??i??""),s=this.inferRecordKind(this.firstMetaContent(["citation_article_type","dc.type"])??"",n,"",o?i?"Book":"Journal":""),l=o||(s.citationType==="book"?t:"");return{title:t,journalName:l,journalCandidates:l?[l]:[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","dc.date"])??""),doi:r,sourceId:this.sourceIdFor(r,e,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),source:this.id,citationType:s.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector("h1, .heading_08 .title, .title")?.textContent??document.title.replace(/\s*\|\s*Cambridge Core\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.extractVenue(e),i=this.extractTypeText(e),o=this.inferRecordKind(i,n,this.extractInputProductType(e),this.extractVenueLabel(e)),s=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1});return{title:t,journalName:r,journalCandidates:r?[r]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:s,sourceId:this.sourceIdFor(s,e,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e,t,n="",r=""){const i=n.trim().toUpperCase(),o=this.bookRouteKind(t),s=`${e} ${t??""} ${i} ${r}`;return i==="BOOK_PART"||o==="chapter"||/\b(chapter|book chapter)\b/i.test(s)?{articleTypes:["BookChapter"],citationType:"incollection"}:i==="BOOK"||o==="book"||/\bbook\b/i.test(s)?{articleTypes:["Book"],citationType:"book"}:/journal_article|type article|\barticle\b|journal:/i.test(s)?{articleTypes:["JournalArticle"],citationType:"article"}:{articleTypes:["JournalArticle"],citationType:"article"}}bookRouteKind(e){try{const n=new URL(e??location.href,location.origin).pathname.split("/").filter(Boolean);return n[0]?.toLowerCase()!=="core"||n[1]?.toLowerCase()!=="books"||!/^[A-F0-9]{16,}$/i.test(n[n.length-1]??"")?void 0:n.slice(2).length>2?"chapter":"book"}catch{return}}findTitleLink(e){return Array.from(e.querySelectorAll('.title h3 a[href], li.title a[href], h1 a[href], h2 a[href], h3 a[href], a.part-link[href], a[href*="/core/journals/"], a[href*="/core/books/"]')).find(n=>this.isRecordLink(n)&&this.cleanText(n.textContent??"").length>0)??null}extractVenue(e){const t=this.extractVenueFromDefinitionList(e);return t||this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractVenueFromDefinitionList(e){for(const t of Array.from(e.querySelectorAll("dt.source"))){const n=t.nextElementSibling;if(!n)continue;const r=n.querySelector(".productParent")??n,i=this.cleanVenue(r.textContent??"");if(i)return i}return""}extractVenueLabel(e){return this.cleanText(Array.from(e.querySelectorAll("dt.source")).map(t=>t.textContent??"").join(" "))}extractTypeText(e){return this.cleanText([...Array.from(e.querySelectorAll('.access .type, li.type, [class*="type"]')).map(t=>t.textContent??""),this.extractInputProductType(e)].join(" "))}extractInputProductType(e){return this.cleanText(e.querySelector("input[data-prod-type]")?.getAttribute("data-prod-type")??"")}extractAuthorsFromDom(e){const t=Array.from(e.querySelectorAll(".author.chapter .author-name, li.author.chapter a.more-by-this-author")),n=Array.from(e.querySelectorAll('li.author:not(.chapter) > a.more-by-this-author, .citation_author a, [class*="author"] [data-author-name]')),r=t.length>0?t:n;return this.unique(r.map(i=>this.cleanText(i.getAttribute("data-author-name")??i.textContent??"")).filter(i=>i&&!/^(Authors?|Edited by|View|Show more)$/i.test(i)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time, .date, [class*="year"], [class*="date"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll("[data-doi]"))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.getAttribute("data-doi")??"");if(i)return i}for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/"], a[href*="/core/services/aop-cambridge-core/content/view/"]'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .meta-info'))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e){const t=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(t)return t;for(const n of Array.from(e.querySelectorAll('a[href*="/core/services/aop-cambridge-core/content/view/"], a[href$=".pdf"], a[href*=".pdf"]'))){if(this.isExcludedDoiContext(n)||this.isExcludedSearchContext(n))continue;const r=this.toNativeFullTextUrl(n.getAttribute("href")??n.href??"");if(r)return r}}extractAbstract(e){return Qe(e)}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=new Set(e.map(r=>r.toLowerCase())),n=[];for(const r of Array.from(document.querySelectorAll("meta[name], meta[property]"))){const i=(r.getAttribute("name")??r.getAttribute("property")??"").trim().toLowerCase();if(!t.has(i))continue;const o=this.cleanText(r.getAttribute("content")??"");o&&n.push(o)}return this.unique(n)}cleanDoi(e){const t=this.unique([this.pathnameFromPossibleUrl(e)??"",e]);for(const n of t){const i=this.decodeDoiSource(n).match(lm),o=i?this.trimDoiTail(i[0]):void 0;if(o)return o}}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}sourceIdFor(e,t,n){if(e)return`cambridge-core:${e}`;const r=this.scopedProductId(t)??this.productIdFromUrl(n);if(r)return`cambridge-core:${r}`;if(n)try{return`cambridge-core:${new URL(n).pathname.replace(/\/+$/g,"")||"/"}`}catch{return`cambridge-core:${n}`}}scopedProductId(e){if(e.matches(Mi))return e.querySelector("[data-prod-id]")?.getAttribute("data-prod-id")??e.getAttribute("data-prod-id")??void 0}yearFromText(e){const t=e.match(cm);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}trimDoiTail(e){let t=e.replace(/[,.;\]\}\s]+$/g,"");for(;t.endsWith(")")&&this.countCharacter(t,")")>this.countCharacter(t,"(");)t=t.slice(0,-1).replace(/[,.;\]\}\s]+$/g,"");return t}productIdFromUrl(e){if(e)try{const n=new URL(e,location.origin).pathname.split("/").filter(Boolean).pop()??"";return/^[A-F0-9]{16,}$/i.test(n)?n:void 0}catch{return}}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}countCharacter(e,t){return Array.from(e).filter(n=>n===t).length}isExcludedDoiContext(e){return!!e.closest(Cl)||!!this.closestExcludedSection(e)||this.isAfterExcludedModuleHeading(e)}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Cl).forEach(n=>n.remove()),Array.from(t.querySelectorAll("section, aside, nav, div")).forEach(n=>{this.hasExcludedSectionLabel(n)&&n.remove()}),t.textContent??""}toNativeFullTextUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.protocol!=="https:"||n.hostname.toLowerCase()!=="www.cambridge.org"||!/^\/core\/services\/aop-cambridge-core\/content\/view\//i.test(n.pathname)?void 0:n.pathname.toLowerCase().endsWith(".pdf")?n.href:void 0}catch{return}}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.searchParams.delete("fromSearch"),n.href}catch{return t}}isRecordLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return t.hostname.toLowerCase()==="www.cambridge.org"&&this.isArticleOrBookRecordPath(t.pathname)}catch{return!1}}isArticleOrBookRecordPath(e){return/^\/core\/journals\/[^/]+\/article\//i.test(e)?!0:this.bookRouteKind(`https://www.cambridge.org${e}`)!==void 0}isBlockedPage(){const e=document.title;return/Just a moment|Enable JavaScript and cookies|Access denied|Attention Required|Cloudflare|Sorry, an error occurred/i.test(e)||document.querySelector('.cf-turnstile, .cf-error-code, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]')?!0:/Enable JavaScript and cookies to continue|Checking if the site connection is secure|Sorry, you have been blocked|Sorry, an error occurred|Cloudflare Ray ID/i.test(document.body?.textContent??"")}cleanVenue(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/^Journal\s*:\s*/i,"").replace(/^Book\s*:\s*/i,"").replace(/\s*\/\s*(?:Volume|Issue|Spring|Summer|Autumn|Fall|Winter)\b[\s\S]*$/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)||t==="#"))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}isExcludedSearchContext(e){let t=e;for(;t&&t!==document.body;){if(/^(ASIDE|NAV|FOOTER)$/i.test(t.tagName)||t.getAttribute("role")==="complementary"||this.hasExcludedSectionLabel(t))return!0;t=t.parentElement}return!1}pathnameFromPossibleUrl(e){const t=e.trim();if(t)try{const n=new URL(t,location.origin);if(n.hostname.toLowerCase()==="doi.org"||n.pathname.includes("/doi/")||n.pathname.startsWith("/10."))return n.pathname}catch{return}}closestExcludedSection(e){let t=e.parentElement;for(;t&&t!==document.body;){if(!t.matches(Mi)&&this.hasExcludedSectionLabel(t))return t;t=t.parentElement}return null}hasExcludedSectionLabel(e){const t=[e.getAttribute("aria-label")??"",e.getAttribute("aria-labelledby")??"",e.getAttribute("id")??"",e.getAttribute("class")??""].join(" ");return this.isExcludedModuleMarkerText(t)?!0:/^(ARTICLE|MAIN|BODY|HTML)$/i.test(e.tagName)||e.matches(Mi)||e.matches('.article, #maincontent, [role="main"]')?!1:Array.from(e.children).some(n=>this.isExcludedModuleHeadingText(n.textContent??""))}isExcludedModuleMarkerText(e){return/(?:references?|bibliography|related|recommend(?:ed|ations?)?|cited(?:\s+by)?|most\s+read|most\s+viewed|popular|latest|recent|also\s+read|right[-_\s]*rail|sidebar)/i.test(e)}isExcludedModuleHeadingText(e){const t=this.cleanText(e).replace(/\s*(?:\(\s*\d+\s*\)|\[\s*\d+\s*\]|\{\s*\d+\s*\})\s*$/g,"").replace(/\s+\d+\s*$/g,"").trim();return/^(?:references?|bibliography|related(?:\s+articles?)?|recommend(?:ed(?:\s+(?:articles?|for\s+you))?|ations?)|cited(?:\s+by)?|most\s+read(?:\s+articles?)?|most\s+viewed(?:\s+articles?)?|latest(?:\s+(?:articles?|papers?|publications?))?|recent(?:\s+(?:articles?|papers?|publications?))?|(?:people\s+)?also\s+read)$/i.test(t)}isAfterExcludedModuleHeading(e){let t=e;for(;t&&t!==document.body;){let n=t.previousElementSibling;for(;n;){if(this.isExcludedHeadingElement(n))return!0;n=n.previousElementSibling}if(/^(ARTICLE|MAIN)$/i.test(t.tagName))break;t=t.parentElement}return!1}isExcludedHeadingElement(e){return/^H[1-6]$/i.test(e.tagName)||e.getAttribute("role")==="heading"||e.matches('.section-title, .module-header, [class*="section-title"], [class*="module-header"]')?this.isExcludedModuleHeadingText(e.textContent??""):this.isExcludedModuleHeadingText(e.textContent??"")&&!e.querySelector("a[href], button, input, select, textarea")}}const dm=/\b10\.\d{4,9}\/[^\s"'<>]+/i,pm=/\b((?:19|20)\d{2})\b/,kr=["li.search__item",".search__item",".search-result__item",".resultItem",".issue-item",".search-result-card",'[data-testid*="searchResultItem"]','[data-testid*="search-result"]'].join(","),hm=[kr,".art_title",".hlFld-Title",".publication_title"].join(","),vl=[".search-results",".searchResultList",'[aria-label="Search results"]',".results-shell"].join(","),fm=["#main-content article","main article","#main-content","main","article",".article","body"].join(","),Bi=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[class*="ref-list"]','[class*="refList"]','[role="doc-bibliography"]','section[aria-label*="Reference"]','section[aria-label*="reference"]','section[aria-labelledby*="Reference"]','section[aria-labelledby*="reference"]','[id*="related"]','[class*="related"]','[id*="recommend"]','[class*="recommend"]','[id*="cited"]','[class*="cited"]','[data-test*="reference"]','[data-testid*="reference"]'].join(",");class mm extends W{id="sage-journals";name="Sage Journals";matches=["*://journals.sagepub.com/*"];isSearchPage(){if(this.isChallengePage())return!1;const e=location.pathname.toLowerCase();return e==="/action/dosearch"||e.startsWith("/action/dosearch")||!e.startsWith("/doi/")&&new URLSearchParams(location.search).has("AllField")}isArticlePage(){return this.isChallengePage()||this.isSearchPage()||/^\/doi\/(?:pdf|epdf)\//i.test(location.pathname)?!1:/^\/doi\/(?:abs\/|full\/)?10\./i.test(location.pathname)||/^\/doi\/10\./i.test(location.pathname)||/^\/doi\/book\/10\./i.test(location.pathname)||!!this.firstMetaContent(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[SageJournalsAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isChallengePage()||/^\/doi\/(?:pdf|epdf)\//i.test(location.pathname))return null;const e=this.getDetailHostElement();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[SageJournalsAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(!this.isSearchPage()){const r=this.findDetailDoiLine(e);if(r)return{element:r,position:"after"}}const t=e.querySelector('h1, h2, h3, .citation__title, .hlFld-Title, .art_title a, [class*="title"]');if(t)return{element:t,position:"after"};const n=e.querySelector('.citation__authors, .publication_meta, [class*="authors"], [class*="meta"]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(vl)??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("startPage")??e.get("page")??"0",10),n=Number.isFinite(t)?t+1:1,r=this.cleanText(document.querySelector('.result__count, .search-result__count, [class*="result-count"], [data-testid*="result-count"]')?.textContent??""),i=r.match(/\b([\d,]+)\s+results?\b/i)??r.match(/\b([\d,]+)\b/),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/20)):1,url:location.href,itemsPerPage:20,totalItems:o}}getSearchResultHosts(){if(this.isChallengePage())return[];const e=this.getSearchResultLists(),t=document.querySelector("main")??document.body,n=e.length>0?e:t?[t]:[];return this.uniqueElements(n.flatMap(r=>Array.from(r.querySelectorAll(hm))).map(r=>this.toSearchResultHost(r)).filter(r=>!!r).filter(r=>this.looksLikeSearchResult(r)))}getSearchResultLists(){return Array.from(document.querySelectorAll(vl)).filter(e=>!this.isExcludedSearchContext(e))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||this.isExcludedSearchContext(e)||e.closest(Bi)||this.isIssueModuleSearchCard(e)?!1:!!this.findTitleLink(e)}isIssueModuleSearchCard(e){return e.matches(".issue-item")?Array.from(e.querySelectorAll('h1, h2, h3, h4, h5, h6, [role="heading"], .section-title, .module-header, [class*="section-title"], [class*="module-header"]')).some(t=>this.isExcludedModuleHeadingText(t.textContent??"")):!1}getDetailHostElement(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Sage Journals\s*$/i,""),t=this.uniqueElements(Array.from(document.querySelectorAll(fm)));if(e){const s=e.toLowerCase(),l=t.find(c=>(c===document.body||!this.isExcludedSearchContext(c))&&this.cleanText(c.textContent??"").toLowerCase().includes(s));if(l)return l}const n=this.cleanDoi(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href);if(n){const s=t.find(l=>l!==document.body&&!this.isExcludedSearchContext(l)&&this.extractDoi(l,{allowTextFallback:!1})===n);if(s)return s}const r=t.filter(s=>s!==document.body&&!this.isExcludedSearchContext(s)&&!!s.querySelector("h1, .citation__title, .hlFld-Title")),i=this.leafHeadingCandidates(r),o=n?i.find(s=>this.candidateDoi(s)===n)??i.find(s=>!this.candidateDoi(s)&&this.hasDetailArticleEvidence(s))??this.lastNoDoiCandidate(i):i.find(s=>!this.candidateDoi(s)&&this.hasDetailArticleEvidence(s))??this.lastNoDoiCandidate(i)??i[i.length-1];return o||(t.find(s=>s===document.body||!this.isExcludedSearchContext(s))??document.body)}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .art_title, .publication_title, .search-result__title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1,currentUrl:r}),o=this.extractVenue(e),s=this.inferRecordKind(this.extractTypeText(e),r);return{title:n,journalName:o,journalCandidates:o?[o]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:this.sourceIdFor(i,r),url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e,i,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,source:this.id,citationType:s.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Sage Journals\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""])??this.extractDoi(e,{allowTextFallback:!1,currentUrl:n}),i=this.firstMetaContent(["citation_inbook_title"])??"",o=this.firstMetaContent(["citation_book_title"])??"",s=this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])||i||o),l=this.firstMetaContent(["citation_article_type","dc.type"])??"",c=this.inferRecordKind(`${l} ${i}`,n,i,o);return{title:t,journalName:s,journalCandidates:s?[s]:[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:this.sourceIdFor(r,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r,n),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:c.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""),source:this.id,citationType:c.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector("h1, .citation__title, .hlFld-Title")?.textContent??document.title.replace(/\s*\|\s*Sage Journals\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1,currentUrl:n}),i=this.extractVenue(e),o=this.inferRecordKind(this.extractTypeText(e),n);return{title:t,journalName:i,journalCandidates:i?[i]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:this.sourceIdFor(r,n),url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r,n),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,source:this.id,citationType:o.citationType}}inferRecordKind(e,t,n="",r=""){const i=`${e} ${this.pathnameFromArticleUrl(t)}`;return/conference paper|conference proceeding/i.test(i)?{articleTypes:["Conference"],citationType:"inproceedings"}:this.cleanText(n).length>0||this.isBookTitleOnlyChapter(e,t,r)||/book chapter|chapter|inbook|book section/i.test(i)?{articleTypes:["BookChapter"],citationType:"incollection"}:/^\/doi\/book\//i.test(this.pathnameFromArticleUrl(t))?{articleTypes:["Book"],citationType:"book"}:this.isWholeBookType(e,t,r)?{articleTypes:["Book"],citationType:"book"}:/\bbook\b/i.test(i)&&!/book review|journal|article/i.test(i)?{articleTypes:["Book"],citationType:"book"}:{articleTypes:["JournalArticle"],citationType:"article"}}findDetailDoiLine(e){if(this.isSearchPage())return null;const t=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href]),n=[".epub-doi","[data-doi]",'[data-test*="doi"]','[data-testid*="doi"]','[id*="doi"]','[class*="doi"]','a[href*="doi.org/"]','a[href*="/doi/"]'].join(",");for(const r of Array.from(e.querySelectorAll(n))){if(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r))continue;const i=r.getAttribute("data-doi")??r.getAttribute("href")??r.textContent??"",o=this.cleanText(r.textContent??i);if(!o)continue;const s=this.cleanDoi(i)??this.cleanDoi(o);if(t&&(!s||s.toLowerCase()!==t.toLowerCase())&&!o.toLowerCase().includes(t.toLowerCase()))continue;const l=this.findDetailMetadataRowFromDoi(r,e,t);if(l)return l;const c=r instanceof HTMLElement?r:null,u=r.closest("div, p, li, section");if(!u)return c;if(this.isExcludedDoiContext(u)||this.isExcludedSearchContext(u)){if(c&&!this.isExcludedDoiContext(c)&&!this.isExcludedSearchContext(c))return c;continue}const d=this.cleanText(u.textContent??"");if(!d||d.length>240){if(c)return c;continue}if(!/\bdoi\b/i.test(d)&&!u.className.toLowerCase().includes("doi")&&!u.id.toLowerCase().includes("doi")){if(c)return c;continue}return u}return null}findDetailMetadataRowFromDoi(e,t,n){let r=e.parentElement,i=null;for(;r&&r!==t&&r!==document.body&&!(this.isExcludedDoiContext(r)||this.isExcludedSearchContext(r));){const o=this.cleanText(r.textContent??"");if(!o||o.length>420)break;if(n&&!o.toLowerCase().includes(n.toLowerCase())){r=r.parentElement;continue}if(r.querySelector("h1, h2, h3"))break;const s=!!(this.cleanDoi(o)||n&&o.toLowerCase().includes(n.toLowerCase())),l=/\b(?:volume|vol\.?|issue|first published|research article|restricted access)\b/i.test(o);s&&l&&(i=r),r=r.parentElement}return i}isWholeBookType(e,t,n=""){const r=`${e} ${this.pathnameFromArticleUrl(t)}`;return/\bbooks?\b/i.test(`${r} ${n}`)?!/book\s+chapter|chapter|inbook|book section|journal|article|review/i.test(r):!1}isBookTitleOnlyChapter(e,t,n=""){return!this.cleanText(n)||/\bbooks?\b/i.test(e)&&!/book\s+chapter|chapter|inbook|book section/i.test(e)?!1:!/^\/doi\/book\//i.test(this.pathnameFromArticleUrl(t))}pathnameFromArticleUrl(e){if(!e)return"";try{return new URL(e,location.origin).pathname}catch{return e}}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href], h3 a[href], .art_title a[href], .publication_title a[href], a.publication_title[href], .search-result__title a[href], a[href^="/doi/abs/"], a[href^="/doi/full/"], a[href^="/doi/book/"], a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."], a[href*="/doi/book/10."]')).find(n=>this.isArticleLink(n)&&this.cleanText(n.textContent??"").length>0)??null}leafHeadingCandidates(e){return e.filter(t=>!e.some(n=>n!==t&&t.contains(n)))}candidateDoi(e){return this.extractDoi(e,{allowTextFallback:!1})}hasDetailArticleEvidence(e){return e.querySelector("h1, .citation__title, .hlFld-Title")?!!e.querySelector([".abstract",'[class*="abstract"]',".authors",".citation__authors",".journal-title",".publication-title",".epub-doi","[data-doi]",'a[href*="doi.org/"]','a[href*="/doi/pdf/"]','a[href*="/doi/epdf/"]'].join(",")):!1}lastNoDoiCandidate(e){return[...e].reverse().find(t=>!this.candidateDoi(t)&&this.hasDetailArticleEvidence(t))}extractVenue(e){const t=[".journal-title",".publication-title",".meta__journal",".citation__journal-title",".source-title",".meta__source",'[data-testid*="journal-title"]','[data-testid*="source"]','[data-testid*="journal"]'].join(",");for(const n of Array.from(e.querySelectorAll(t))){const r=this.cleanVenue(n.textContent??"");if(r&&!/^(Article|Chapter|PDF|Full text)$/i.test(r))return r}return this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName","citation_inbook_title","citation_book_title"])??"")}extractTypeText(e){const t=[".publication-type",".content-type",".issue-item__type",'[data-testid*="type"]','[class*="type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractAuthorsFromDom(e){const t=[".author-name",".loa__author-name",".citation__author",".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).filter(n=>n&&!/^(Authors?|View|Show more)$/i.test(n)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time, .publication-year, .date, [class*="year"], [class*="date"]'))){const n=this.yearFromText(t.textContent??"");if(n)return n}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0,r=t.currentUrl;for(const i of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."], a[href*="/doi/pdf/10."], a[href*="/doi/epdf/10."]'))){if(this.isExcludedDoiContext(i)||this.isExcludedSearchContext(i)||!this.isMatchingArticleDoiLink(i.getAttribute("href")??i.href??"",r))continue;const o=this.cleanDoi(i.href);if(o)return o}for(const i of Array.from(e.querySelectorAll('[data-doi], [data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .epub-doi'))){if(this.isExcludedDoiContext(i)||this.isExcludedSearchContext(i))continue;const o=this.cleanDoi(i.getAttribute("data-doi")??i.textContent??"");if(o)return o}if(n)return this.cleanDoi(this.textWithoutExcludedDoiContexts(e))}extractNativeFullTextUrl(e,t,n){const r=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"",t,n);if(r)return r;for(const i of Array.from(e.querySelectorAll('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href$=".pdf"], a[href*="/pdf"]'))){if(this.isExcludedDoiContext(i)||this.isExcludedSearchContext(i))continue;const o=this.toNativeFullTextUrl(i.getAttribute("href")??i.href??"",t,n);if(o)return o}}extractAbstract(e){return Qe(e)}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=new Set(e.map(r=>r.toLowerCase())),n=[];for(const r of Array.from(document.querySelectorAll("meta[name], meta[property]"))){const i=(r.getAttribute("name")??r.getAttribute("property")??"").trim().toLowerCase();if(!t.has(i))continue;const o=this.cleanText(r.getAttribute("content")??"");o&&n.push(o)}return this.unique(n)}cleanDoi(e){const t=this.unique([this.pathnameFromPossibleUrl(e)??"",e]);for(const n of t){const i=this.decodeDoiSource(n).match(dm),o=i?this.trimDoiTail(i[0]):void 0;if(o)return o}}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}sourceIdFor(e,t){if(e)return`sage-journals:${e}`;if(t)try{const n=new URL(t);return`sage-journals:${this.normalizedArticlePath(n.pathname)}`}catch{return`sage-journals:${t}`}}normalizedArticlePath(e){return e.replace(/^\/doi\/(?:abs|full|pdf|epdf)\//i,"/doi/full/").replace(/\/+$/g,"")||"/"}expectedPdfPathForArticleUrl(e){if(!e)return;const t=this.normalizedArticlePath(this.pathnameFromArticleUrl(e));if(/^\/doi\/full\//i.test(t))return t.replace(/^\/doi\/full\//i,"/doi/pdf/")}yearFromText(e){const t=e.match(pm);return t?Number.parseInt(t[1],10):void 0}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}trimDoiTail(e){let t=e.replace(/[,.;\]\}\s]+$/g,"");for(;t.endsWith(")")&&this.countCharacter(t,")")>this.countCharacter(t,"(");)t=t.slice(0,-1).replace(/[,.;\]\}\s]+$/g,"");return t}toNativeFullTextUrl(e,t,n){const r=this.toAbsoluteUrl(e);if(r)try{const i=new URL(r);if(i.protocol!=="https:"||i.hostname.toLowerCase()!=="journals.sagepub.com"||!/^\/doi\/(?:pdf|epdf)\//i.test(i.pathname))return;if(t){const o=this.cleanDoi(i.href);if(!o||o.toLowerCase()!==t.toLowerCase())return}else if(n){const o=this.expectedPdfPathForArticleUrl(n);if(!o||i.pathname!==o)return}return i.href}catch{return}}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.searchParams.delete("af"),n.searchParams.delete("campaign"),n.href}catch{return t}}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return t.hostname.toLowerCase()==="journals.sagepub.com"&&(/^\/doi\/(?:abs\/|full\/|pdf\/|epdf\/|book\/)?10\./i.test(t.pathname)||/^\/doi\/(?:abs\/|full\/)[^/?#]+$/i.test(t.pathname))}catch{return!1}}isMatchingArticleDoiLink(e,t){if(!t)return!0;const n=this.toAbsoluteUrl(e);if(!n)return!1;try{const r=new URL(n);if(!/^\/doi\/(?:pdf|epdf)\//i.test(r.pathname))return!0;const i=this.expectedPdfPathForArticleUrl(t);return!!(i&&r.pathname===i)}catch{return!1}}isChallengePage(){const e=document.title,t=this.hasArticleMetadata(),n=document.body?.textContent??"";return this.isChallengeInterstitial(e,n)||/Just a moment|Enable JavaScript and cookies|Access(?:\s+denied|\s+to\s+this\s+page\s+has\s+been\s+denied)|Attention Required|Cloudflare|Imperva|Incapsula/i.test(e)&&!t||/(?:Please\s+)?Verify(?:ing)? you are human|Robot Check/i.test(e)&&!t||document.querySelector('.cf-error-code, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]')||!t&&document.querySelector('.cf-turnstile, iframe[src*="recaptcha"], .g-recaptcha, [data-sitekey]')||!t&&/Enable JavaScript and cookies to continue|Please make sure that JavaScript and cookies are enabled|Sorry, you have been blocked|Cloudflare Ray ID|Imperva|Incapsula/i.test(n)||/Checking if the site connection is secure|(?:Please\s+)?Verify(?:ing)? you are human|review the security of your connection|needs to review the security|Robot Check/i.test(n)&&!t?!0:!t&&/\b(?:reCAPTCHA|captcha)\b/i.test(n)&&/\b(?:verify|human|robot|security|challenge|blocked|access denied)\b/i.test(n)}isChallengeInterstitial(e,t){const n=this.cleanText(e),r=this.cleanText(t);return/Just a moment|Attention Required/i.test(n)&&/Enable JavaScript and cookies to continue|Sorry, you have been blocked|Cloudflare Ray ID/i.test(r)||/^(?:Please\s+)?Verify(?:ing)? you are human$/i.test(n)||/^Robot Check$/i.test(n)||/^Access(?:\s+Denied|\s+to\s+this\s+page\s+has\s+been\s+denied)[.!?]?$/i.test(n)||/(?:Please\s+)?Verify(?:ing)? you are human by completing the action below/i.test(r)||/Access\s+to\s+this\s+page\s+has\s+been\s+denied[.!?]?/i.test(r)||/Request unsuccessful/i.test(r)&&/Incapsula incident ID|Imperva/i.test(r)?!0:/Access Denied/i.test(r)&&/(?:do not|don't|don’t|does not|not) have permission|permission denied/i.test(r)}hasArticleMetadata(){if(this.firstMetaContent(["citation_title","citation_doi","prism.doi"]))return!0;const e=this.cleanText(this.firstMetaContent(["dc.title"])??"");return!!(e&&!/^SAGE\s+Journals?$/i.test(e))}isExcludedDoiContext(e){return!!e.closest(Bi)||!!this.closestExcludedSection(e)||this.isAfterExcludedModuleHeading(e)}textWithoutExcludedDoiContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Bi).forEach(n=>n.remove()),Array.from(t.querySelectorAll("section, aside, nav, div")).forEach(n=>{this.hasExcludedSectionLabel(n)&&n.remove()}),t.textContent??""}closestExcludedSection(e){let t=e.parentElement;for(;t&&t!==document.body;){if(!t.matches(kr)&&this.hasExcludedSectionLabel(t))return t;t=t.parentElement}return null}hasExcludedSectionLabel(e){const t=[e.getAttribute("aria-label")??"",e.getAttribute("aria-labelledby")??"",e.getAttribute("id")??"",e.getAttribute("class")??""].join(" ");return this.isExcludedModuleMarkerText(t)?!0:/^(ARTICLE|MAIN|BODY|HTML)$/i.test(e.tagName)||e.matches(kr)||e.matches('.article, #main-content, [role="main"]')?!1:Array.from(e.children).some(n=>this.isExcludedModuleHeadingText(n.textContent??""))}isAfterExcludedModuleHeading(e){let t=e;for(;t&&t!==document.body;){let n=t.previousElementSibling;for(;n;){if(this.isExcludedHeadingElement(n))return!0;n=n.previousElementSibling}if(/^(ARTICLE|MAIN)$/i.test(t.tagName))break;t=t.parentElement}return!1}isExcludedHeadingElement(e){return/^H[1-6]$/i.test(e.tagName)||e.getAttribute("role")==="heading"||e.matches('.section-title, .module-header, [class*="section-title"], [class*="module-header"]')?this.isExcludedModuleHeadingText(e.textContent??""):this.isExcludedModuleHeadingText(e.textContent??"")&&!e.querySelector("a[href], button, input, select, textarea")}isExcludedModuleMarkerText(e){return/(?:references?|bibliography|related|related\s+content|recommend(?:ed|ations?)?|article\s+recommendations?|recommended\s+content|we\s+also\s+recommend|similar\s+articles?|more\s+like\s+this|more\s+from\s+(?:this\s+)?(?:journal|sage(?:\s+journals?)?)|also\s+from\s+(?:this\s+)?(?:journal|sage(?:\s+journals?)?)|cited(?:\s+by)?|most\s+read|most\s+viewed|popular|latest|latest\s+issue|current\s+issue|browse\s+issue|issue\s+module|recent|also\s+read|you\s+may\s+also\s+like|may\s+also\s+like|trending|right[-_\s]*rail|secondary[-_\s]*(?:rail|content)|sidebar|captcha|recaptcha|imperva|incapsula)/i.test(e)}isExcludedModuleHeadingText(e){const t=this.normalizeModuleHeadingText(e);return/^(?:references?|bibliography|related(?:\s+(?:articles?|content))?|recommend(?:ed(?:\s+(?:articles?|for\s+you|content))?|ations?)|article\s+recommendations?|we\s+also\s+recommend|similar(?:\s+articles?)?|more\s+like\s+this|more\s+from\s+(?:this\s+)?(?:journal|sage(?:\s+journals?)?)|also\s+from\s+(?:this\s+)?(?:journal|sage(?:\s+journals?)?)|cited(?:\s+by)?|most\s+read(?:\s+articles?)?|most\s+viewed(?:\s+articles?)?|popular|trending|latest(?:\s+(?:articles?|papers?|publications?|issue))?|current\s+issue|browse\s+issue|issue\s+module|recent(?:\s+(?:articles?|papers?|publications?))?|(?:people\s+)?also\s+read|you\s+may\s+also\s+like|may\s+also\s+like)$/i.test(t)}normalizeModuleHeadingText(e){let t=this.cleanText(e);for(let n=0;n<3;n+=1){const r=t.replace(/\s*(?:\(\s*\d+\s*\)|\[\s*\d+\s*\]|\{\s*\d+\s*\})\s*$/g,"").replace(/\s+\d+\s*$/g,"").replace(/(?:\s+|(?=[A-Z]))(?:view|see|show|browse)\s*(?:all|more)(?:\s*(?:articles?|papers?|publications?|content|items?|references?))?\s*$/i,"").trim();if(r===t)break;t=r}return t}isExcludedSearchContext(e){let t=e;for(;t&&t!==document.body;){if(/^(ASIDE|NAV|FOOTER)$/i.test(t.tagName)||t.getAttribute("role")==="complementary"||this.hasExcludedSectionLabel(t))return!0;t=t.parentElement}return!1}pathnameFromPossibleUrl(e){const t=e.trim();if(t)try{const n=new URL(t,location.origin);if(n.hostname.toLowerCase()==="doi.org"||n.pathname.includes("/doi/")||n.pathname.startsWith("/10."))return n.pathname}catch{return}}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}countCharacter(e,t){return Array.from(e).filter(n=>n===t).length}cleanVenue(e){const t=this.cleanText(e).replace(/^Sage\s+Journals?\s*[·|]\s*/i,"").replace(/^Published\s+in\s*:?\s*/i,"").replace(/^Source\s*:?\s*/i,"").replace(/^In\s+/i,"").replace(/^Journal\s*:?\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim();return/^Published\s+online(?:\s*:?\s*.*)?$/i.test(t)?"":t}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)||t==="#"))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}toSearchResultHost(e){return e.matches(kr)?e:e.closest(kr)??e.closest("li, .search-result, .search-result__item, .issue-item, article")??e}}const bm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,gm=/\b((?:19|20)\d{2})\b/,wl=["li.app-article-list-row__item","article.c-card",'[data-test="search-result"]','[data-test="article-item"]'].join(","),Sl=["article","#content","#main-content","main","body"].join(","),ji=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[role="doc-bibliography"]','section[aria-label*="reference"]','section[aria-label*="Reference"]','section[aria-labelledby*="reference"]','section[aria-labelledby*="Reference"]','[aria-label*="reference"]','[aria-label*="Reference"]','[aria-labelledby*="reference"]','[aria-labelledby*="Reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[aria-label*="related"]','[aria-label*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[id*="further-reading"]','[class*="further-reading"]','[id*="more-on-this-story"]','[class*="more-on-this-story"]','[aria-label*="more on this story"]','[aria-label*="More on this story"]','[aria-label*="further reading"]','[aria-label*="Further reading"]','[data-test*="reference"]','[data-testid*="reference"]','[data-test*="supplementary"]','[data-testid*="supplementary"]','[aria-label*="supplementary"]','[aria-label*="Supplementary"]','[aria-labelledby*="supplementary"]','[aria-labelledby*="Supplementary"]',".c-article-supplementary__item",".c-article-associated-content",".c-reading-companion"].join(",");class ym extends W{id="nature";name="Nature.com";matches=["*://www.nature.com/*"];isSearchPage(){return this.isChallengePage()?!1:this.isSearchRoute()}isArticlePage(){if(this.isChallengePage()||this.isSearchRoute())return!1;if(/^\/articles\/[^/]+\/?$/i.test(location.pathname))return!0;const e=this.firstMetaContent(["citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??"";return!!(this.isNatureArticleUrl(e)&&this.hasArticleMetadata())}parseSearchResults(){if(this.isChallengePage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[NatureAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isChallengePage())return null;const e=this.getDetailHost();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[NatureAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isSearchPage()&&this.isSearchResultHost(e)){const r=this.findSearchContentAnchor(e)??this.findSearchMetaAnchor(e);if(r)return{element:r,position:"after"}}if(!this.isSearchPage()){const r=this.findDetailMetricsAnchor(e);if(r)return{element:r,position:"after"};const i=this.findDetailTitleAnchor(e);if(i)return{element:i,position:"after"}}const t=e.querySelector('h1, h2, h3, .c-article-title, .c-card__title, [itemprop="headline"], [itemprop="name"]');if(t)return{element:t,position:"after"};const n=e.querySelector(".c-article-author-list, .app-author-list, .c-card__section.c-meta, .c-meta");return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".app-article-list-row")??document.querySelector('[data-test="search-results"]')??document.querySelector('[data-test="search-result-list"]')??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"1",10)||1,r=this.cleanText(document.querySelector('[data-test="results-count"], .app-search-result-list__count, .c-list-results__count, .c-results-heading')?.textContent??"").match(/\b([\d,]+)\s+(?:results?|articles?)\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0,o=this.extractPaginationTotalPages();return{pageNum:t,totalPages:o??(i?Math.max(1,Math.ceil(i/20)):1),url:location.href,itemsPerPage:20,totalItems:i}}getSearchResultHosts(){return this.uniqueElements(Array.from(document.querySelectorAll(wl)).filter(e=>this.looksLikeSearchResult(e)))}isSearchResultHost(e){return e.matches(wl)||e.matches(".c-card")}findSearchContentAnchor(e){const t=e.querySelector('.app-author-list, .c-article-author-list, [data-test="authors"], [data-testid*="author"], [class*="author-list"]');return t||(e.querySelector('[data-test="journal-title-and-link"], [data-test="journal-title"], [data-testid*="journal"], .journal-title')??null)}findSearchMetaAnchor(e){const t=e.querySelector('h1, h2, h3, .c-article-title, .c-card__title, [itemprop="headline"], [itemprop="name"]'),n=[".c-card__section.c-meta",".c-meta",'[data-test*="article-metadata"], [data-testid*="article-metadata"], [data-test*="metadata"], [data-testid*="metadata"]','[class*="meta"]'];for(const o of n){const s=Array.from(e.querySelectorAll(o)).filter(c=>this.looksLikeSearchMeta(c)),l=this.pickTrailingMetaCandidate(s,t)??s[0];if(l)return l}const r=Array.from(e.querySelectorAll('time[datetime], time, [data-test*="date"], [data-testid*="date"], [data-test*="type"], [data-testid*="type"], .c-meta__type')).filter(o=>this.looksLikeSearchMeta(o));return this.pickTrailingMetaCandidate(r,t,"last")??r[r.length-1]??null}looksLikeSearchMeta(e){return this.cleanText(e.textContent??"")?e.matches('time, [data-test*="date"], [data-testid*="date"], [data-test*="type"], [data-testid*="type"], [data-test="journal-title-and-link"], [data-test="journal-title"], .c-meta__type')?!0:!!e.querySelector('time, [data-test*="date"], [data-testid*="date"], [data-test*="type"], [data-testid*="type"], [data-test="journal-title-and-link"], [data-test="journal-title"], .c-meta__type'):!1}followsElement(e,t){const n=t.ownerDocument?.defaultView?.Node;return n?!!(t.compareDocumentPosition(e)&n.DOCUMENT_POSITION_FOLLOWING):!1}pickTrailingMetaCandidate(e,t,n="first"){if(!t)return e[0]??null;const r=e.filter(i=>this.followsElement(i,t));return r.length===0?null:n==="last"?r[r.length-1]:r[0]}findDetailTitleAnchor(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??document.title).replace(/\s*\|\s*Nature\s*$/i,""),n=this.titleKey(t);if(!n)return e.querySelector('h1, .c-article-title, [itemprop="headline"]');const r=Array.from(e.querySelectorAll('h1, .c-article-title, [itemprop="headline"], h2, h3, .c-card__title')),i=r.find(o=>this.titleKey(o.textContent??"")===n);return i||(r.find(o=>{const s=this.titleKey(o.textContent??"");return s.length>=12&&(s.includes(n)||n.includes(s))})??null)}findDetailMetricsAnchor(e){const t=[".c-article-metrics-bar__wrapper",".c-article-metrics-bar",'[data-test="access-count"]','[data-test="citation-count"]','[data-test="altmetric-score"]','a[href$="/metrics"]','a[href*="/metrics?"]'];for(const n of t)for(const r of Array.from(e.querySelectorAll(n))){const i=r.closest(".c-article-metrics-bar__wrapper, .c-article-metrics-bar, header, .c-article-header");if(i&&!this.isExcludedContext(i)){if(i.matches(".c-article-header")){const o=i.querySelector(".c-article-metrics-bar__wrapper, .c-article-metrics-bar");if(o&&!this.isExcludedContext(o))return o}return i}}return null}getDetailHost(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??document.title).replace(/\s*\|\s*Nature\s*$/i,"");let t=null,n=-1;for(const r of Sl.split(","))for(const i of Array.from(document.querySelectorAll(r.trim()))){const o=this.getDetailHostScore(i,e);(o>n||o===n&&this.breaksDetailHostTie(i,t))&&(t=i,n=o)}return t??document.querySelector(Sl)}getDetailHostScore(e,t){let n=e.matches("article")?2:0;const r=this.titleKey(this.findDetailTitleAnchor(e)?.textContent??""),i=this.titleKey(t);return i&&r===i?n+=8:i&&r&&(r.includes(i)||i.includes(r))&&(n+=4),e.querySelector('[data-test="download-pdf"], a[data-article-pdf="true"], a[href$=".pdf"]')&&(n+=3),e.querySelector("h1, .c-article-title")&&(n+=2),e.querySelector('[data-test="journal-title-and-link"], .c-meta, .c-card__section.c-meta')&&(n+=1),n}breaksDetailHostTie(e,t){if(!t)return!0;const n=this.detailHostRank(e),r=this.detailHostRank(t);if(n!==r)return n<r;const i=this.cleanText(e.textContent??"").length,o=this.cleanText(t.textContent??"").length;return i<o}detailHostRank(e){return e.matches("article")?0:e.matches("#content, #main-content, main")?1:e===document.body?3:2}titleKey(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"")}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||e.closest(ji)||e.matches("article.c-card")&&e.parentElement?.closest("li.app-article-list-row__item")?!1:!!this.findTitleLink(e)}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .c-card__title, [itemprop="headline"], [itemprop="name"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.doiFromArticleUrl(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e),s=this.inferRecordKind(o,r,i),l=s.metricsAllowed?this.extractVenue(e):"";return{title:n,journalName:l,journalCandidates:l?[l]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:i?`nature:${i}`:r?`nature:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e,i,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:s.articleTypes,source:this.id,citationType:s.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Nature\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""]),i=this.firstMetaContent(["citation_article_type","dc.type","prism.section"])??"",o=this.inferRecordKind(i,n,r),s=o.metricsAllowed?this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??this.journalFromPageContext()??""):"";return{title:t,journalName:s,journalCandidates:s?[s]:[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:r?`nature:${r}`:n?`nature:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r,n),abstractSnippet:this.firstMetaContent(["citation_abstract","dc.description","description","og:description"])??this.extractAbstract(e),hostElement:e,articleTypes:o.articleTypes,issn:o.metricsAllowed?this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??""):void 0,source:this.id,citationType:o.citationType}}parseDetailDom(e){const t=this.cleanText(e.querySelector('h1, .c-article-title, [itemprop="headline"]')?.textContent??document.title.replace(/\s*\|\s*Nature\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.doiFromArticleUrl(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.inferRecordKind(this.extractTypeText(e),n,r),o=i.metricsAllowed?this.extractVenue(e):"";return{title:t,journalName:o,journalCandidates:o?[o]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:r?`nature:${r}`:n?`nature:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r,n),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:i.articleTypes,source:this.id,citationType:i.citationType}}inferRecordKind(e,t,n){const r=this.cleanText(`${e} ${t??""} ${n??""}`).toLowerCase();return/\b(?:news\s*&\s*views|news|research highlight|career feature|technology feature|books?\s*&\s*arts|nature briefing|where i work|world view|obituary)\b/.test(r)||/10\.1038\/d41586-/i.test(r)?{articleTypes:["News"],citationType:"misc",metricsAllowed:!1}:/\b(?:comment|opinion|editorial|correspondence)\b/.test(r)?{articleTypes:["Comment"],citationType:"misc",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}findTitleLink(e){return Array.from(e.querySelectorAll('h2 a[href], h3 a[href], .c-card__title a[href], a[itemprop="url"][href], a[href*="/articles/"]')).find(n=>this.isArticleLink(n)&&this.cleanText(n.textContent??"").length>0)??null}extractTypeText(e){const t=['[data-test="article.type"]','[data-test*="type"]','[data-testid*="type"]',".c-meta__type",".c-card__section.c-meta",'[class*="type"]'].join(",");return Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).join(" ")}extractVenue(e){const t=['[data-test="journal-title"]','[data-test="article.journal"]','[data-testid*="journal"]','.c-card__section [data-test*="journal"]',".journal-title",".c-meta__item--journal"].join(",");for(const n of Array.from(e.querySelectorAll(t))){const r=this.cleanVenue(n.textContent??"");if(r)return r}return this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??this.journalFromPageContext()??"")}extractAuthorsFromDom(e){const t=['[itemprop="author"]',".c-article-author-list__item",".app-author-list__item",'[data-test="author-name"]','[class*="author"] a','[class*="author"] span'].join(",");return this.unique(Array.from(e.querySelectorAll(t)).map(n=>this.cleanText(n.getAttribute("data-author-name")??n.textContent??"")).map(n=>n.replace(/^\s*(?:By|Author)\s+/i,"")).filter(n=>n&&!/^(Authors?|View author publications|PubMed|Google Scholar|Show more)$/i.test(n)))}extractYear(e){for(const t of Array.from(e.querySelectorAll('time[datetime], time, [data-test*="date"], .c-meta__item'))){const n=t.getAttribute("datetime")??"",r=this.yearFromText(n)??this.yearFromText(t.textContent??"");if(r)return r}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/articles/"]'))){if(this.isExcludedContext(r))continue;const i=this.cleanDoi(r.href)??this.doiFromArticleUrl(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .c-article-identifiers__item'))){if(this.isExcludedContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedContexts(e))}extractNativeFullTextUrl(e,t,n){const r=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"",t,n);if(r)return r;const i=Array.from(e.querySelectorAll('a[data-test="download-pdf"], a[data-article-pdf="true"], a[href$=".pdf"], a[href*="/articles/"][href*=".pdf"]')).find(o=>!this.isExcludedContext(o));return this.toNativeFullTextUrl(i?.getAttribute("href")??i?.href??"",t,n)}extractAbstract(e){return Qe(e)}isExcludedContext(e){if(e.closest(ji))return!0;const t=e.closest("section, aside, nav, div, article");if(!t||t===document.body)return!1;const n=t.getAttribute("aria-labelledby")??"",r=t.getAttribute("aria-label")??"",i=this.cleanText(Array.from(t.querySelectorAll(":scope > h1, :scope > h2, :scope > h3, :scope > header h1, :scope > header h2, :scope > header h3")).map(o=>o.textContent??"").join(" "));return this.isExcludedModuleText(`${r} ${n} ${i}`)}isChallengePage(){const e=document.title,t=this.cleanText(document.body?.textContent??"");return!!(/Client Challenge|Just a moment|Access denied|Robot Check|Verify you are human/i.test(e)||document.querySelector('.cf-turnstile, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"], script[src*="/_fs-ch-"]')||!this.hasArticleMetadata()&&/JavaScript is disabled in your browser|Please enable JavaScript to proceed|A required part of this site couldn't load|A required part of this site couldn’t load|Client Challenge/i.test(t))}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}firstDoi(e){for(const t of e){const n=this.cleanDoi(t)??this.doiFromArticleUrl(t);if(n)return n}}cleanDoi(e){return this.decodeDoiSource(e).match(bm)?.[0].replace(/[),.;\s]+$/g,"")}doiFromArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);if(n.hostname.toLowerCase()!=="www.nature.com")return;const r=n.pathname.match(/^\/articles\/([^/?#]+?)(?:\.pdf)?\/?$/i);if(!r)return;const i=r[1].replace(/\/+$/g,"");return/^(?:s\d|d\d|nature\d|n[a-z]+\.\d)/i.test(i)?`10.1038/${i}`:void 0}catch{return}}toNativeFullTextUrl(e,t,n){const r=this.toAbsoluteUrl(e);if(r)try{const i=new URL(r);if(i.protocol!=="https:"||i.hostname.toLowerCase()!=="www.nature.com"||!/^\/articles\/[^/]+\.pdf$/i.test(i.pathname))return;const o=t?.replace(/^10\.1038\//i,"")??this.articleSuffixFromUrl(n??"");return!o||!i.pathname.toLowerCase().includes(`/${o.toLowerCase()}.pdf`)?void 0:r}catch{return}}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return t.hostname.toLowerCase()==="www.nature.com"&&/^\/articles\/[^/]+\/?$/i.test(t.pathname)}catch{return!1}}isSearchRoute(){return location.pathname==="/search"||location.pathname.startsWith("/search/")||/^\/[a-z0-9-]+\/(?:articles|research-articles)\/?$/i.test(location.pathname)}isNatureArticleUrl(e){const t=this.toAbsoluteUrl(e);if(!t)return!1;try{const n=new URL(t);return n.hostname.toLowerCase()==="www.nature.com"&&/^\/articles\/[^/]+\/?$/i.test(n.pathname)}catch{return!1}}hasArticleMetadata(){return!!(this.firstMetaContent(["citation_title","dc.title"])&&(this.firstMetaContent(["citation_doi","prism.doi"])||this.firstMetaContent(["citation_article_type","prism.section"])||this.isNatureArticleUrl(this.firstMetaContent(["citation_fulltext_html_url","prism.url","og:url"])??"")))}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.hash="",n.searchParams.delete("error"),n.searchParams.delete("tracking_referrer"),n.href}catch{return t}}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}articleSuffixFromUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.hostname.toLowerCase()!=="www.nature.com"?void 0:n.pathname.match(/^\/articles\/([^/?#]+?)(?:\.pdf)?\/?$/i)?.[1]?.replace(/\/+$/g,"")}catch{return}}extractPaginationTotalPages(){const e=Array.from(document.querySelectorAll('[data-page], .c-pagination a[href*="page="], nav[aria-label*="pagination"] a[href*="page="]')).map(t=>{const n=t.getAttribute("data-page");if(n)return Number.parseInt(n,10);const r=t.getAttribute?.("href")??"";try{return Number.parseInt(new URL(r,location.href).searchParams.get("page")??"",10)}catch{return NaN}}).filter(t=>Number.isFinite(t)&&t>0);if(e.length!==0)return Math.max(...e)}journalFromPageContext(){const t=(document.querySelector('script[data-test="dataLayer"]')?.textContent??"").match(/"journal"\s*:\s*\{[\s\S]*?"title"\s*:\s*"([^"]+)"/);if(t)return this.cleanVenue(t[1]);const n=document.title.replace(/\s*\|\s*Nature\s*$/i,"");if(/^Articles$/i.test(this.cleanText(n)))return"Nature"}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}yearFromText(e){const t=e.match(gm);return t?Number.parseInt(t[1],10):void 0}cleanVenue(e){return this.cleanText(e).replace(/^Journal\s*:?\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}isExcludedModuleText(e){return/(?:references?|bibliography|related|recommend(?:ed|ations?)?|further\s+reading|more\s+on\s+this\s+story|supplementary|associated\s+content|additional\s+information|cited\s+by|metrics|figures|tables|right[-_\s]*rail|sidebar)/i.test(e)}textWithoutExcludedContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(ji).forEach(n=>n.remove()),t.textContent??""}cleanText(e){return e.replace(/\s+/g," ").trim()}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}}const xm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Am=/\b((?:19|20)\d{2})\b/,qi=["li.search__item",".search__item",".search-result__item",".resultItem",".search-result",".issue-item"].join(","),$i=[qi,".search-result__body"].join(","),Cm=["Science Translational Medicine","Science Signaling","Science Robotics","Science Immunology","Science Advances","Science"],vm=[["scitranslmed.","Science Translational Medicine"],["scisignal.","Science Signaling"],["scirobotics.","Science Robotics"],["sciimmunol.","Science Immunology"],["sciadv.","Science Advances"],["science.","Science"]],wm={"Science Translational Medicine":["1946-6234","1946-6242"],"Science Signaling":["1945-0877","1937-9145"],"Science Robotics":["2470-9476"],"Science Immunology":["2470-9468"],"Science Advances":["2375-2548"],Science:["0036-8075","1095-9203"]},Oi=[".search-results",".search__results",'[data-testid*="search-results"]','[data-test*="search-results"]'].join(","),Sm=["#pb-page-content article","#main-content article","main article","#pb-page-content","#main-content","main","article","body"],Ui=['[id*="reference"]','[id*="Reference"]','[class*="reference"]','[class*="Reference"]','[role="doc-bibliography"]','[role="complementary"]','section[aria-label*="reference"]','section[aria-label*="Reference"]','section[aria-labelledby*="reference"]','section[aria-labelledby*="Reference"]','[id*="related"]','[id*="Related"]','[class*="related"]','[class*="Related"]','[id*="recommend"]','[id*="Recommend"]','[class*="recommend"]','[class*="Recommend"]','[aria-label*="related"]','[aria-label*="Related"]','[aria-label*="recommended"]','[aria-label*="Recommended"]','[aria-label*="Current Issue"]','[aria-label*="current issue"]','[aria-label*="You may also like"]','[aria-label*="you may also like"]','[data-test*="reference"]','[data-testid*="reference"]','[data-test*="related"]','[data-testid*="related"]','[class*="current-issue"]','[class*="CurrentIssue"]','[class*="latestArticles"]','[class*="LatestArticles"]','[class*="recentArticles"]','[class*="RecentArticles"]','[class*="most-read"]','[class*="MostRead"]','[class*="trending"]','[class*="Trending"]','[class*="rightRail"]','[class*="RightRail"]','[class*="right_rail"]','[class*="Right_Rail"]','[class*="right-sidebar"]','[class*="left-sidebar"]','[class*="rail-sidebar"]','[data-widget*="RightRail"]','[data-widget*="rightRail"]','[data-widget*="right_rail"]','[data-widget*="right-rail"]','[data-widget*="Right-Rail"]','[data-testid*="RightRail"]','[data-testid*="rightRail"]','[data-testid*="right_rail"]','[data-testid*="right-rail"]','[data-test*="RightRail"]','[data-test*="rightRail"]','[data-test*="right_rail"]','[data-test*="right-rail"]',".related-content",".article__references",".references",".recommended",".right-rail",".sidebar"].join(",");class Tm extends W{id="science-org";name="Science.org";matches=["*://www.science.org/*"];isSearchPage(){if(this.isChallengePage())return!1;const e=location.pathname.toLowerCase();if(e==="/action/dosearch"||e.startsWith("/action/dosearch/"))return!0;if(e.startsWith("/doi/")||e.startsWith("/content/article/"))return!1;const t=this.hasSearchParam("AllField"),n=e.replace(/\/+$/,"")||"/";return t&&/^(?:\/|\/search|\/search-results)$/.test(n)}isArticlePage(){return this.isChallengePage()||this.isSearchPage()||/^\/doi\/(?:pdf|epdf)\//i.test(location.pathname)?!1:/^\/doi\/(?:abs\/|full\/)?10\./i.test(location.pathname)||/^\/content\/(?:article|webinar|blog-post)\//i.test(location.pathname)||!!this.hasArticleMetadata()}parseSearchResults(){if(this.isChallengePage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[ScienceOrgAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isChallengePage()||/^\/doi\/(?:pdf|epdf)\//i.test(location.pathname))return null;const e=this.getDetailHost();if(!e)return null;try{return this.parseMetadataArticle(e)??this.parseDetailDom(e)}catch(t){return console.error("[ScienceOrgAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=new WeakMap;if(!this.isSearchPage()){const i=this.findDetailMetadataLine(e,t);if(i)return{element:i,position:"after"};const o=this.firstVisibleElement(e,'.journal-title, .citation__journal-title, .publication_meta .journal, .publication-meta .journal, [data-testid*="journal"], [data-test*="journal"]',t);if(o)return{element:o,position:"before"}}const n=this.firstVisibleElement(e,'h1, h2, h3, .citation__title, .publication_title, .hlFld-Title, [class*="title"]',t);if(n)return{element:n,position:"after"};const r=this.firstVisibleElement(e,'.citation__authors, .authors, .loa, .publication-meta, .article__meta, [class*="meta"]',t);return r?{element:r,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){const e=this.getSearchContainers();return e.length===0?document.querySelector("main")??document.body:e.length===1?e[0]:this.getSharedSearchContainer(e)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("startPage")??e.get("page")??"0",10),n=Number.isFinite(t)?t+1:1,i=this.cleanText(document.querySelector('.result__count, .search-result__count, [class*="result-count"], [data-testid*="result-count"]')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),o=i?Number.parseInt(i[1].replace(/,/g,""),10):void 0;return{pageNum:n,totalPages:o?Math.max(1,Math.ceil(o/20)):1,url:location.href,itemsPerPage:20,totalItems:o}}getSearchResultHosts(){const e=new WeakMap,t=this.getSearchContainers().flatMap(r=>{const i=Array.from(r.querySelectorAll($i));return r.matches($i)&&i.unshift(r),i.map(o=>this.getCompleteSearchResultHost(o))}),n=this.getTitleLinkFallbackHosts(e);return this.uniqueElements([...t,...n].filter(r=>this.looksLikeSearchResult(r,e)))}getTitleLinkFallbackHosts(e){const t=document.querySelector("main")??document.body;return t?this.collectValidTitleLinks(t).map(n=>this.getSearchHostFromTitleLink(n,e)).filter(n=>!!n):[]}getSearchHostFromTitleLink(e,t){let n=e.closest("article, li, section, div")??e.parentElement;for(;n&&n!==document.body;){if(n===e){n=n.parentElement;continue}if(this.isExcludedContext(n)){n=n.parentElement;continue}if(this.looksLikeStandaloneSearchCard(n,e,t))return n;n=n.parentElement}return null}looksLikeStandaloneSearchCard(e,t,n){if(e===document.body||e===document.documentElement||!e.contains(t)||e.matches("main, form, nav, aside, header, footer")||this.isHiddenDomElement(e,n))return!1;const r=this.collectValidTitleLinks(e);if(r.length!==1||r[0]!==t)return!1;const i=this.cleanText([e.className,e.id,e.getAttribute("data-testid")??"",e.getAttribute("data-test")??"",e.getAttribute("aria-label")??""].join(" "));if(/\b(?:filters?|search(?:\s+results?)?|results?\s+found|refine|sort|pagination|toolbar|header)\b/i.test(i)&&!/\b(?:item|card|article|record|result|row)\b/i.test(i))return!1;const o=this.cleanText(e.textContent??"");return!o||o.length<=this.cleanText(t.textContent??"").length?!1:!!(e.querySelector("time, button")||/(?:^|•)\s*(?:Science(?: Advances| Immunology| Robotics| Signaling| Translational Medicine)?|Vol\.|Issue|NO\.|pp\.)/i.test(o)||/\bby\b/i.test(o))}getCompleteSearchResultHost(e){if(!e.matches(".search-result__body"))return e;const t=this.findTitleLink(e);let n=e.parentElement;for(;n&&n!==document.body;){if(this.looksLikeCompleteSearchResultWrapper(n,e,t))return n;n=n.parentElement}return e}looksLikeCompleteSearchResultWrapper(e,t,n){if(e===t||this.countVisibleResultBodies(e)!==1)return!1;const i=this.collectValidTitleLinks(e);if(i.length!==1||n&&i[0]!==n)return!1;const o=this.cleanText([e.className,e.id,e.getAttribute("data-testid")??"",e.getAttribute("data-test")??""].join(" ")),s=e.matches(qi)||/\b(?:search|result|item|row|issue)\b/i.test(o),l=!!e.querySelector(".journal-title, .search-result__meta, .publication-year, time, .authors, .doi-link");return s||l}getSearchContainers(){const e=new WeakMap,t=this.uniqueElements([...Array.from(document.querySelectorAll(Oi)),...Array.from(document.querySelectorAll("[aria-label], [aria-labelledby]")).filter(n=>/\bsearch\s+results?\b/i.test(this.accessibleLabelText(n)))]).filter(n=>!this.isHiddenDomElement(n,e)&&!this.isExcludedContext(n));return t.length>0?t:document.body?[document.body]:[]}getSharedSearchContainer(e){let t=e[0];for(;t;){if(e.every(n=>t&&t.contains(n)))return t;t=t.parentElement}return null}getDetailHost(){const e=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??document.title).replace(/\s*\|\s*Science\s*$/i,"");let t=null,n=0;const r=new WeakMap;for(const i of Sm)for(const o of Array.from(document.querySelectorAll(i))){const s=this.getDetailHostScore(o,e,r);(s>n||s===n&&s>0&&this.breaksDetailHostTie(o,t))&&(t=o,n=s)}return t}getDetailHostScore(e,t,n){if(this.isHiddenDomElement(e,n)||e!==document.body&&this.isExcludedContext(e)||e!==document.body&&this.isLikelyTeaserHost(e))return 0;const r=this.cleanText(this.firstVisibleElementText(e,"h1, .citation__title, .publication_title, .hlFld-Title",n)),i=e!==document.body&&this.hasCurrentArticleEvidence(e);if(!t||!r&&e!==document.body)return i?2:0;if(!r)return 1;const o=this.titleKey(t),s=this.titleKey(r);return o.length===0?i?2:1:s===o?e===document.body?3:this.isArticleHost(e)?5:4:!(o.length>=12&&s.length>=12&&(s.includes(o)||o.includes(s)))||!i?0:this.isArticleHost(e)?3:2}isArticleHost(e){return e.tagName.toLowerCase()==="article"}isLikelyTeaserHost(e){const t=this.cleanText([e.className,e.id,e.getAttribute("data-testid")??"",e.getAttribute("data-test")??""].join(" "));return/\b(?:teaser|promo|promotion|recommended|recommendation|related|sidebar|right[-_\s]*rail)\b/i.test(t)}breaksDetailHostTie(e,t){if(!t)return!0;const n=e!==document.body&&this.hasCurrentArticleEvidence(e),r=t!==document.body&&this.hasCurrentArticleEvidence(t);if(n!==r)return n;const i=this.cleanText(e.textContent??"").length,o=this.cleanText(t.textContent??"").length;return Math.abs(i-o)>40?i>o:!1}looksLikeSearchResult(e,t){return this.isHiddenDomElement(e,t)||e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||e.closest(Ui)&&!this.isAllowedSearchRegion(e)||this.isExcludedContext(e)||e.matches(qi)&&(this.countVisibleResultBodies(e)>1||this.collectValidTitleLinks(e).length>1)?!1:!!this.findTitleLink(e)}countVisibleResultBodies(e){const t=new WeakMap;return Array.from(e.querySelectorAll(".search-result__body")).filter(n=>!this.isHiddenElement(n,t)).length}parseSearchHost(e){const t=this.findTitleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .publication_title, .hlFld-Title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toArticleUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanDoi(r??"")??this.extractDoi(e,{allowTextFallback:!1}),o=this.extractTypeText(e)||this.extractTypeNearTitle(e),s=this.extractVenue(e,{allowGlobalFallback:!1}),l=this.scienceFamilyVenueFromDoi(i),c=this.inferRecordKind(o,r,n),u=c.metricsAllowed?l??s:"";return{title:n,journalName:u,journalCandidates:u?[u]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:i,sourceId:i?`science-org:${i}`:r?`science-org:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e,i),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:c.articleTypes,source:this.id,citationType:c.citationType}}parseMetadataArticle(e){const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??"").replace(/\s*\|\s*Science\s*$/i,"");if(!t)return null;const n=this.toArticleUrl(this.firstMetaContent(["citation_fulltext_html_url","prism.url","og:url"])??document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),n??""]),i=this.firstMetaContent(["citation_article_type","dc.type","prism.section"])||this.extractTypeText(e)||this.extractTypeNearTitle(e)||this.extractDetailArticleTypeText(e),o=this.inferRecordKind(i,n,t),s=this.scienceFamilyVenueFromDoi(r),l=o.metricsAllowed?s??this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??""):"",c=this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"])??"");return{title:t,journalName:l,journalCandidates:l?[l]:[],authors:this.allMetaContent(["citation_author","dc.creator"]),year:this.yearFromText(this.firstMetaContent(["citation_publication_date","citation_online_date","prism.publicationDate","dc.date"])??""),doi:r,sourceId:r?`science-org:${r}`:n?`science-org:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r),abstractSnippet:this.extractMetadataAbstract(e,t),hostElement:e,articleTypes:o.articleTypes,issn:o.metricsAllowed?this.scienceFamilyCompatibleIssn(l,c):void 0,source:this.id,citationType:o.citationType}}parseDetailDom(e){const t=this.cleanText(this.firstVisibleElementText(e,"h1, .citation__title, .publication_title, .hlFld-Title")||document.title.replace(/\s*\|\s*Science\s*$/i,""));if(!t)return null;const n=this.toArticleUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanDoi(n??"")??this.extractDoi(e,{allowTextFallback:!1}),i=this.inferRecordKind(this.extractTypeText(e)||this.extractTypeNearTitle(e),n,t),o=this.scienceFamilyVenueFromDoi(r),s=i.metricsAllowed?o??this.extractVenue(e):"";return{title:t,journalName:s,journalCandidates:s?[s]:[],authors:this.extractAuthorsFromDom(e),year:this.extractYear(e),doi:r,sourceId:r?`science-org:${r}`:n?`science-org:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:i.articleTypes,source:this.id,citationType:i.citationType}}inferRecordKind(e,t,n=""){const r=this.cleanText(e),i=this.cleanText(n),o=this.cleanText(`${r} ${t??""}`).toLowerCase(),s=/\b(?:news|news feature|editorial|opinion|commentary|books? et al\.?|book review|podcast|video|webinar|careers?|news at a glance|scienceinsider|in the pipeline|blog)\b/i,l=/^(?:news(?: feature| at a glance)?|editorial|opinion|commentary|books? et al\.?|book review)(?::|\s+-\s+|\s+\|)/i;return!r||/\/content\/(?:article|webinar|blog-post)\//i.test(o)||s.test(r)||l.test(i)?{articleTypes:[/editorial/i.test(r)||/^editorial/i.test(i)?"Editorial":/book review|books? et al\./i.test(r)||/^(?:book review|books? et al\.)/i.test(i)?"BookReview":"News"],citationType:"misc",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}findTitleLink(e){const t=new WeakMap,r=this.collectTitleLinks(e).find(o=>!this.isHiddenElement(o,t)&&this.isArticleLink(o)&&this.cleanText(o.textContent??"").length>0);return r||(Array.from(e.querySelectorAll('a[href*="/doi/10."], a[href*="/doi/abs/10."], a[href*="/doi/full/10."], a[href*="/content/article/"], a[href*="/content/webinar/"], a[href*="/content/blog-post/"]')).find(o=>!this.isHiddenElement(o,t)&&this.isArticleLink(o)&&this.cleanText(o.textContent??"").length>0)??null)}collectTitleLinks(e){return Array.from(e.querySelectorAll("h2 a[href], h3 a[href], .publication_title a[href], a.publication_title[href], .hlFld-Title a[href], a.hlFld-Title[href], .art_title a[href], a.art_title[href]"))}collectValidTitleLinks(e){const t=new WeakMap,n=new Set;return this.collectTitleLinks(e).filter(r=>{if(this.isHiddenElement(r,t)||!this.isArticleLink(r))return!1;const i=this.cleanText(r.textContent??"");if(!i)return!1;const o=`${r.href}::${i}`;return n.has(o)?!1:(n.add(o),!0)})}firstVisibleElementText(e,t,n){const r=this.firstVisibleElement(e,t,n);return r?this.cleanText(r.textContent??""):""}firstVisibleElement(e,t,n){for(const r of Array.from(e.querySelectorAll(t)))if(!this.isHiddenElement(r,n)&&this.cleanText(r.textContent??""))return r;return null}extractVenue(e,t={}){const n=new WeakMap,r=[".journal-title",".citation__journal-title",".publication_meta .journal",".publication-meta .journal",'[data-testid*="journal"]','[data-test*="journal"]',".source-title",".meta__source"].join(",");for(const o of Array.from(e.querySelectorAll(r))){if(o instanceof HTMLElement&&this.isHiddenElement(o,n))continue;const s=this.cleanVenue(o.textContent??"");if(s&&!/^(Article|Research Article|PDF|Full Text)$/i.test(s))return s}const i=[...Array.from(e.querySelectorAll("div, span, p, li, strong, em")),e];for(const o of i){if(o instanceof HTMLElement&&this.isHiddenElement(o,n))continue;const s=this.cleanText(o.textContent??"");if(!(!s||s.length>120))for(const l of Cm){const c=l.replace(/\s+/g,"\\s+");if(new RegExp(`^(?:\u2022\\s*)?${c}(?=$|[\u2022,:\\s])`,"i").test(s))return l}}return t.allowGlobalFallback===!1?"":this.cleanVenue(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??"")}extractTypeText(e){const t=new WeakMap,n=[".publication-type",".content-type",".issue-item__type",".article-type",".c-meta__type",'[data-testid*="type"]','[data-test*="type"]','[class*="type"]'].join(",");return Array.from(e.querySelectorAll(n)).filter(r=>!(r instanceof HTMLElement)||!this.isHiddenElement(r,t)).map(r=>this.cleanText(r.textContent??"")).filter(Boolean).join(" ")}extractTypeNearTitle(e){const t=new WeakMap,n=this.findTitleLink(e),r=n?.closest("h1, h2, h3, h4, h5, h6")??n;if(!r)return"";const i=[r.previousElementSibling,r.parentElement?.previousElementSibling??null,r.parentElement?.firstElementChild&&r.parentElement.firstElementChild!==r?r.parentElement.firstElementChild:null].filter(o=>!!o);for(const o of i){if(o instanceof HTMLElement&&this.isHiddenElement(o,t))continue;const s=this.cleanText(o.textContent??"");if(!(!s||s.length>48)&&s!==this.cleanText(n?.textContent??"")&&!/\b(?:by|vol\.?|issue|no\.|pp\.?|access|authors?)\b/i.test(s))return s}return""}extractDetailArticleTypeText(e){if(this.isSearchPage())return"";const t=new WeakMap,n=this.firstVisibleElement(e,"h1, .citation__title, .publication_title, .hlFld-Title",t),r=Array.from(e.querySelectorAll("div, span, p, li, section"));for(const i of r){if(this.isHiddenElement(i,t)||this.isExcludedContext(i)||n&&i.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING)continue;const o=this.cleanText(i.textContent??"");if(!o||o.length>180)continue;const s=o.match(/\b(?:research\s+article|research\s+articles?|perspective|report)\b/i);if(s)return s[0]}return""}findDetailMetadataLine(e,t){const n=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href]),r=Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."]')).find(l=>{if(this.isHiddenElement(l,t)||this.isExcludedContext(l)||!/\bDOI\b/i.test(this.cleanText(l.textContent??""))&&!(l.getAttribute("href")??l.href??"").includes("doi.org/"))return!1;if(!n)return!0;const c=this.cleanDoi(l.getAttribute("href")??l.href??"");return!!(c&&c.toLowerCase()===n.toLowerCase())});if(!r)return this.findPlainTextDetailDoiLine(e,n,t);const i=this.findDetailMetadataRowFromDoi(r,e,n,t);if(i)return i;const o=r.closest("p, div, section, li");if(!(o instanceof HTMLElement)||this.isHiddenElement(o,t)||this.isExcludedContext(o))return r;const s=this.cleanText(o.textContent??"");return n&&!s.toLowerCase().includes(n.toLowerCase())&&this.cleanDoi(s)?.toLowerCase()!==n.toLowerCase()?r:!/\bDOI\b/i.test(s)&&!/doi\.org\//i.test(r.getAttribute("href")??r.href??"")?null:s.length>240?r:o}findPlainTextDetailDoiLine(e,t,n){const r=["[data-doi]",'[data-test*="doi"]','[data-testid*="doi"]','[id*="doi"]','[class*="doi"]',".epub-doi","p","div","li","section"].join(",");for(const i of Array.from(e.querySelectorAll(r))){if(this.isHiddenElement(i,n)||this.isExcludedContext(i))continue;const o=this.cleanText([i.id,i.className,i.getAttribute("data-testid")??"",i.getAttribute("data-test")??""].join(" ")),s=i.getAttribute("data-doi")??i.textContent??"",l=this.cleanText(s);if(!l||l.length>240)continue;const c=this.cleanDoi(s);if(t&&(!c||c.toLowerCase()!==t.toLowerCase())&&!l.toLowerCase().includes(t.toLowerCase())||!/\bdoi\b/i.test(l)&&!/\bdoi\b/i.test(o)&&!i.hasAttribute("data-doi"))continue;const u=this.findDetailMetadataRowFromDoi(i,e,t,n);if(u)return u;const d=i.closest("p, div, section, li")??i;if(this.isHiddenElement(d,n)||this.isExcludedContext(d))continue;const p=this.cleanText(d.textContent??"");if(!(!p||p.length>240)&&!(t&&!p.toLowerCase().includes(t.toLowerCase())&&this.cleanDoi(p)?.toLowerCase()!==t.toLowerCase()))return d}return null}findDetailMetadataRowFromDoi(e,t,n,r){let i=e.parentElement,o=null;for(;i&&i!==t&&i!==document.body&&!(this.isHiddenElement(i,r)||this.isExcludedContext(i));){const s=this.cleanText(i.textContent??"");if(!s||s.length>420)break;if(n&&!s.toLowerCase().includes(n.toLowerCase())){i=i.parentElement;continue}if(i.querySelector("h1, h2, h3"))break;const l=!!(this.cleanDoi(s)||n&&s.toLowerCase().includes(n.toLowerCase())),c=/\b(?:science(?:\s+(?:advances|immunology|robotics|signaling|translational medicine))?|vol\.?|issue|first release|research article|perspective|report|date|apr|may|jun|jul|aug|sep|oct|nov|dec)\b/i.test(s);l&&c&&(o=i),i=i.parentElement}return o}extractAuthorsFromDom(e){const t=new WeakMap,n=[".author-name",".loa__author-name",".citation__author",".authors a",".authors span",'[class*="author"] a','[class*="author"] span',"[data-author-name]"].join(",");return this.unique(Array.from(e.querySelectorAll(n)).filter(r=>!(r instanceof HTMLElement)||!this.isHiddenElement(r,t)).map(r=>this.cleanText(r.getAttribute("data-author-name")??r.textContent??"")).filter(r=>r&&!/^(Authors?|View|Show more)$/i.test(r)))}extractYear(e){const t=new WeakMap;for(const n of Array.from(e.querySelectorAll('time, .publication-year, .date, [class*="year"], [class*="date"]'))){if(n instanceof HTMLElement&&this.isHiddenElement(n,t))continue;const r=this.yearFromText(n.getAttribute("datetime")??"")??this.yearFromText(n.textContent??"");if(r)return r}return this.yearFromText(e.textContent??"")}extractDoi(e,t={}){const n=t.allowTextFallback??!0;for(const r of Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."]'))){if(this.isExcludedContext(r))continue;const i=this.cleanDoi(r.href);if(i)return i}for(const r of Array.from(e.querySelectorAll('[data-test*="doi"], [data-testid*="doi"], [id*="doi"], [class*="doi"], .epub-doi'))){if(this.isExcludedContext(r))continue;const i=this.cleanDoi(r.textContent??"");if(i)return i}if(n)return this.cleanDoi(this.textWithoutExcludedContexts(e))}extractNativeFullTextUrl(e,t){const n=this.toNativeFullTextUrl(this.firstMetaContent(["citation_pdf_url"])??"",t);if(n)return n;for(const r of Array.from(e.querySelectorAll('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href$=".pdf"], a[href*="/pdf"]'))){if(this.isExcludedContext(r))continue;const i=this.toNativeFullTextUrl(r.getAttribute("href")??r.href??"",t);if(i)return i}}extractAbstract(e){const t=new WeakMap,n=this.extractAbstractByHeading(e,t);if(n)return n;const r=[".hlFld-Abstract",".abstract",'[class*="abstract"]','[data-test*="abstract"]','[data-testid*="abstract"]','section[id*="abstract"]','section[aria-labelledby*="abstract"]','div[id*="abstract"]',".search-result__body"];for(const i of r)for(const o of Array.from(e.querySelectorAll(i))){if(this.isHiddenElement(o,t)||this.isExcludedContext(o))continue;const s=this.cleanAbstractText(o.textContent??"");if(this.isUsableAbstractText(s))return s}}extractMetadataAbstract(e,t){const n=this.cleanAbstractText(this.firstMetaContent(["citation_abstract"])??"");if(this.isUsableAbstractText(n)&&!this.isTitleLikeAbstract(n,t))return n;const r=this.extractAbstract(e);if(r)return r;const i=this.cleanAbstractText(this.firstMetaContent(["dc.description","description","og:description","twitter:description"])??"");if(this.isUsableAbstractText(i)&&!this.isTitleLikeAbstract(i,t))return i}extractAbstractByHeading(e,t){const n=Array.from(e.querySelectorAll('h2, h3, h4, [role="heading"]'));for(const r of n){if(this.isHiddenElement(r,t)||this.isExcludedContext(r)||!/^abstract\b/i.test(this.cleanText(r.textContent??"")))continue;const i=this.collectFollowingAbstractText(r.nextElementSibling,t);if(i)return i;const o=this.collectFollowingAbstractText(r.parentElement?.nextElementSibling??null,t);if(o)return o;const s=r.closest("section, div");if(s&&s!==e){if(s instanceof HTMLElement&&this.isHiddenElement(s,t)||this.isExcludedContext(s))continue;const l=this.cleanAbstractText(s.textContent??"");if(this.isUsableAbstractText(l))return l}}}collectFollowingAbstractText(e,t){const n=[];let r=e;for(;r&&!this.isAbstractStopElement(r);){if(r instanceof HTMLElement&&this.isHiddenElement(r,t)){r=r.nextElementSibling;continue}if(this.isExcludedContext(r))break;const i=this.cleanAbstractText(r.textContent??"");this.isUsableAbstractText(i)&&n.push(i),r=r.nextElementSibling}return n.length?this.cleanText(n.join(" ")):void 0}isAbstractStopElement(e){const t=this.cleanText(e.textContent??""),n=e.matches('h1, h2, h3, h4, [role="heading"]')?t:"",r=this.cleanText(e.querySelector(':scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > [role="heading"]')?.textContent??""),i=n||r;if(i&&!/^abstract\b/i.test(i))return!0;const o=this.cleanText([e.id,e.className,e.getAttribute("role")??"",e.getAttribute("aria-label")??"",e.getAttribute("data-test")??"",e.getAttribute("data-testid")??""].join(" "));return/\b(?:introduction|materials?|methods?|results?|discussion|references?|bibliography|acknowledg|supplement|figures?|tables?|metrics?|citations?|related)\b/i.test(o)}cleanAbstractText(e){return this.cleanText(e).replace(/^abstract\s*/i,"").replace(/^summary\s*/i,"").trim()}isUsableAbstractText(e){return e.length>=12&&!/^(?:abstract|summary|figures?|tables?|references?|metrics?|citations?|related|authors?|article)(?:\s+(?:figures?|tables?|references?|metrics?|citations?|related|authors?|article))*$/i.test(e)}isTitleLikeAbstract(e,t){const n=this.titleKey(e.replace(/\s*\|\s*Science(?:\.org)?\s*$/i,"")),r=this.titleKey(t);return!!(n&&r&&(n===r||n.startsWith(r)&&e.length<=t.length+30))}isExcludedContext(e){if(e.closest(Ui)&&!this.isAllowedSearchRegion(e))return!0;const t=this.findContextSection(e);if(!t||t===document.body)return!1;if(t.matches("aside, nav")&&!/\bsearch\s+results?\b/i.test(this.accessibleLabelText(t)))return!0;const n=this.accessibleLabelText(t),r=this.cleanText(Array.from(t.querySelectorAll(":scope > h1, :scope > h2, :scope > h3")).map(c=>c.textContent??"").join(" ")),i=this.cleanText(`${n} ${r}`);if(/references?|bibliography|related|recommend(?:ed|ations?)?|you\s+may\s+also\s+like|current\s+issue|from\s+this\s+issue|in\s+this\s+issue|cited\s+by|right[-_\s]*rail|sidebar/i.test(i))return!0;const o=t===e||t.matches($i)?n:i;if(!/most\s+read|popular|latest|recent|trending/i.test(o))return!1;const s=/\bsearch\s+results?\b/i.test(o)||t.matches(Oi)||!!t.querySelector(Oi),l=!!t.closest('aside, nav, [role="complementary"], .right-rail, .sidebar, [class*="sidebar"], [class*="right-rail"], [class*="rightRail"], [class*="RightRail"], [class*="right_rail"], [class*="right-sidebar"], [class*="left-sidebar"], [class*="rail-sidebar"], [data-widget*="RightRail"], [data-widget*="rightRail"], [data-widget*="right_rail"], [data-widget*="right-rail"], [data-widget*="Right-Rail"], [data-testid*="RightRail"], [data-testid*="rightRail"], [data-testid*="right_rail"], [data-testid*="right-rail"], [data-test*="RightRail"], [data-test*="rightRail"], [data-test*="right_rail"], [data-test*="right-rail"]');return l&&!/\bsearch\s+results?\b/i.test(n)?!0:!s||l}isAllowedSearchRegion(e){const t=e.closest('.search-results, .search__results, [data-testid*="search-results"], [data-test*="search-results"], [aria-label], [aria-labelledby]');return!t||t.closest('aside, nav, [role="complementary"], .right-rail, .sidebar, [class*="sidebar"], [class*="right-rail"], [class*="rightRail"], [class*="RightRail"], [class*="right_rail"], [class*="right-sidebar"], [class*="left-sidebar"], [class*="rail-sidebar"]')?!1:/\bsearch\s+results?\b/i.test(this.accessibleLabelText(t))||t.matches('.search-results, .search__results, [data-testid*="search-results"], [data-test*="search-results"]')}findContextSection(e){const t=e.closest("section, aside, nav");if(t)return t;let n=e.closest("div");for(;n&&n!==document.body;){if(this.accessibleLabelText(n)||n.matches('[role="complementary"], .right-rail, .sidebar, [class*="sidebar"], [class*="right-rail"], [class*="rightRail"], [class*="RightRail"], [class*="right_rail"], [class*="right-sidebar"], [class*="left-sidebar"], [class*="rail-sidebar"], [data-widget*="RightRail"], [data-widget*="rightRail"], [data-widget*="right_rail"], [data-widget*="right-rail"], [data-widget*="Right-Rail"], [data-testid*="RightRail"], [data-testid*="rightRail"], [data-testid*="right_rail"], [data-testid*="right-rail"], [data-test*="RightRail"], [data-test*="rightRail"], [data-test*="right_rail"], [data-test*="right-rail"]'))return n;n=n.parentElement?.closest("div")??null}return e.closest("div")}isChallengePage(){const e=document.title,t=this.cleanText(document.body?.textContent??""),n=/Enable JavaScript and cookies to continue|Checking if the site connection is secure|Just a moment|Sorry,\s*you have been blocked|Cloudflare Ray ID|This website is using a security service|blocked from proceeding/i,r=this.hasRenderableContent();return!!(!r&&/Just a moment|Enable JavaScript and cookies|Access denied|Attention Required|Robot Check|Verif(?:y|ying) you are human/i.test(e)||this.hasVisibleChallengeWidget()||!r&&document.querySelector('script[src*="/cdn-cgi/challenge-platform/"]')||n.test(t)&&this.hasBodyChallengeCopy(n,r)||this.hasVerificationChallengeCopy())}hasSearchParam(e){const t=e.toLowerCase();return Array.from(new URLSearchParams(location.search).keys()).some(n=>n.toLowerCase()===t)}accessibleLabelText(e){const t=e.getAttribute("aria-label")??"",n=(e.getAttribute("aria-labelledby")??"").split(/\s+/).map(r=>r?document.getElementById(r)?.textContent??"":"").join(" ");return this.cleanText(`${t} ${n}`)}hasRenderableContent(){const e=new WeakMap;return Array.from(document.querySelectorAll(["article h1","article .citation__title","article .publication_title","article .hlFld-Title",'article a[href*="/doi/"]',"#pb-page-content h1",'#pb-page-content a[href*="/doi/"]',"#main-content h1",'#main-content a[href*="/doi/"]',"main h1",'main a[href*="/doi/"]',".search-results",".search__results",".search-result__item",".search-result__body","li.search__item"].join(","))).some(t=>!this.isHiddenElement(t,e))}hasBodyChallengeCopy(e,t){const n=document.body;if(!n)return!1;const r=/challenge|captcha|verify|robot|overlay|modal|dialog|turnstile|blocked|block|access|security|cloudflare|(?:^|\s)cf[-_]|(?:^|\s)cferror/i,i=new WeakMap;for(const o of this.visibleChallengeTextCandidates(n,i)){const{element:s,text:l}=o;if(!e.test(l))continue;if(!t)return!0;const c=s.closest("article, .search-results, .search__results, li.search__item, .search-result__item, .search-result__body");if(c){if(c instanceof HTMLElement&&this.hasBlockingOverlayContext(s,c))return!0;continue}if(this.hasChallengeContext(s,r))return!0}return!1}hasVerificationChallengeCopy(){const e=/verif(?:y|ying) (?:that )?you are (?:human|not a robot)|please verify (?:that )?you are (?:human|not a robot)|review the security of your connection|robot check|human verification/i,t=document.body;if(!t||!e.test(t.textContent??""))return!1;const n=/challenge|captcha|verify|robot|overlay|modal|dialog|turnstile|blocked|access|(?:^|\s)cf[-_]|(?:^|\s)cferror/i,r=this.hasRenderableContent(),i=new WeakMap;for(const o of this.visibleChallengeTextCandidates(t,i)){const{element:s,text:l}=o;if(!e.test(l))continue;if(!r)return!0;const c=s.closest("article, .search-results, .search__results, li.search__item, .search-result__item, .search-result__body");if(c){if(c instanceof HTMLElement&&this.hasBlockingOverlayContext(s,c))return!0;continue}if(this.hasChallengeContext(s,n))return!0}return!1}hasVisibleChallengeWidget(){const e=new WeakMap;return Array.from(document.querySelectorAll('.cf-turnstile, iframe[src*="challenges.cloudflare.com"]')).some(t=>!this.isHiddenElement(t,e))}hasChallengeContext(e,t){let n=e;for(;n&&n!==document.body;){const r=this.cleanText([n.id,n.className,n.getAttribute("role")??"",n.getAttribute("aria-label")??"",n.getAttribute("data-testid")??"",n.getAttribute("data-test")??""].join(" "));if(t.test(r)||this.isLikelyBlockingOverlay(n))return!0;n=n.parentElement}return!1}hasBlockingOverlayContext(e,t){let n=e;for(;n&&n!==t;){if(this.isLikelyBlockingOverlay(n))return!0;const r=this.cleanText([n.id,n.className,n.getAttribute("role")??"",n.getAttribute("aria-label")??"",n.getAttribute("data-testid")??"",n.getAttribute("data-test")??""].join(" "));if(/\b(?:modal|overlay|dialog|alertdialog|turnstile|blocked|access[-_\s]*blocked)\b|(?:^|\s)cf[-_]|(?:^|\s)cferror/i.test(r))return!0;n=n.parentElement}return!1}isLikelyBlockingOverlay(e){if(e.tagName.toLowerCase()==="dialog"&&e.hasAttribute("open"))return!0;const t=e.getAttribute("style")??"";if(/position\s*:\s*fixed/i.test(t)){const c=/inset\s*:\s*0(?:[;\s]|$)/i.test(t)||/top\s*:\s*0/i.test(t)&&/right\s*:\s*0/i.test(t)&&/bottom\s*:\s*0/i.test(t)&&/left\s*:\s*0/i.test(t),u=/z-index\s*:\s*(?:[1-9]\d{3,}|2147483647)/i.test(t);if(c||u)return!0}const n=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(e):null;if(!n||n.position!=="fixed")return!1;const r=Number.parseFloat(n.top||"0"),i=Number.parseFloat(n.right||"0"),o=Number.parseFloat(n.bottom||"0"),s=Number.parseFloat(n.left||"0"),l=Number.parseInt(n.zIndex||"0",10);return r===0&&i===0&&o===0&&s===0||l>=1e3}isHiddenDomElement(e,t){return e instanceof HTMLElement&&this.isHiddenElement(e,t)}isHiddenElement(e,t){let n=e;const r=[];for(;n&&n!==document.body;){const i=t?.get(n);if(i!==void 0)return r.forEach(c=>t?.set(c,i)),i;if(r.push(n),n.matches('.cf-turnstile, iframe[src*="challenges.cloudflare.com"]')&&n.getAttribute("data-size")==="invisible")return r.forEach(c=>t?.set(c,!0)),!0;if(n.hidden||n.getAttribute("aria-hidden")==="true")return r.forEach(c=>t?.set(c,!0)),!0;const s=n.getAttribute("style")??"";if(/display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:[;\s]|$)|clip\s*:\s*rect\(\s*0/i.test(s))return r.forEach(c=>t?.set(c,!0)),!0;const l=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(n):null;if(l){const c=Number.parseFloat(l.left||"0"),u=Number.parseFloat(l.top||"0"),d=Number.parseFloat(l.right||"0"),p=Number.parseFloat(l.bottom||"0"),m=l.clip??"",h=l.clipPath??"",y=l.transform??"",x=Number.parseFloat(l.width||"0"),T=Number.parseFloat(l.height||"0"),F=!!(m&&m!=="auto")||!!(h&&h!=="none"),w=["absolute","fixed"].includes(l.position)&&(Math.abs(c)>1e3||Math.abs(u)>1e3||Math.abs(d)>1e3||Math.abs(p)>1e3),b=/matrix\([^)]*(?:-?[1-9]\d{3,}|,\s*-?[1-9]\d{3,})|translate(?:3d|X|Y)?\([^)]*-?[1-9]\d{3,}/i.test(y),v=x<=1&&T<=1;if(l.display==="none"||l.visibility==="hidden"||l.opacity==="0"||F||w||b||v)return r.forEach(D=>t?.set(D,!0)),!0}n=n.parentElement}return r.forEach(i=>t?.set(i,!1)),!1}visibleTextNodes(e,t){const n=[],r=document.createTreeWalker(e,4);let i=r.nextNode();for(;i;){const o=i.parentElement;o&&!this.isHiddenElement(o,t)&&n.push(i),i=r.nextNode()}return n}visibleChallengeTextCandidates(e,t){const n=new Map;for(const r of this.visibleTextNodes(e,t)){const i=r.textContent??"";if(!i.trim())continue;let o=r.parentElement;for(;o;){const s=n.get(o)??[];if(s.push(i),n.set(o,s),o===e)break;o=o.parentElement}}return Array.from(n.entries()).map(([r,i])=>({element:r,text:this.cleanText(i.join(" "))})).filter(r=>r.text.length>0)}hasArticleMetadata(){return!!(this.firstMetaContent(["citation_title","dc.title"])&&(this.firstMetaContent(["citation_doi","prism.doi"])||this.firstMetaContent(["citation_article_type","dc.type","prism.section"])||this.firstMetaContent(["citation_fulltext_html_url","prism.url"])))}hasCurrentArticleEvidence(e){const t=this.firstDoi([...this.allMetaContent(["citation_doi","dc.identifier","prism.doi"]),document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href]);return t?Array.from(e.querySelectorAll('a[href*="doi.org/"], a[href*="/doi/10."], a[href*="/doi/pdf/"], a[href*="/doi/epdf/"]')).some(n=>{const r=n.getAttribute("href")??n.href??"";return this.cleanDoi(r)===t||!!this.toNativeFullTextUrl(r,t)}):!1}firstMetaContent(e){return this.allMetaContent(e)[0]}allMetaContent(e){const t=[];for(const n of e){const r=[`meta[name="${n}"]`,`meta[property="${n}"]`,`meta[name="${n.toLowerCase()}"]`,`meta[property="${n.toLowerCase()}"]`].join(",");for(const i of Array.from(document.querySelectorAll(r))){const o=this.cleanText(i.getAttribute("content")??"");o&&t.push(o)}}return this.unique(t)}firstDoi(e){for(const t of e){const n=this.cleanDoi(t);if(n)return n}}cleanDoi(e){return this.decodeDoiSource(e).match(xm)?.[0].replace(/[),.;/\s]+$/g,"").toLowerCase()}scienceFamilyVenueFromDoi(e){const t=e?.toLowerCase().match(/^10\.1126\/(.+)$/)?.[1];if(t){for(const[n,r]of vm)if(t.startsWith(n))return r}}normalizeIssn(e){const t=e.trim().toUpperCase().replace(/[^0-9X]/g,"");if(/^\d{7}[\dX]$/.test(t))return`${t.slice(0,4)}-${t.slice(4)}`}scienceFamilyCompatibleIssn(e,t){if(!t)return;const n=wm[e];return n?n.includes(t)?t:void 0:t}yearFromText(e){const t=e.match(Am);return t?Number.parseInt(t[1],10):void 0}isArticleLink(e){try{const t=new URL(e.getAttribute("href")??e.href,location.origin);return t.hostname.toLowerCase()==="www.science.org"&&(/^\/doi\/(?:abs\/|full\/)?10\./i.test(t.pathname)||/^\/content\/(?:article|webinar|blog-post)\//i.test(t.pathname))}catch{return!1}}toNativeFullTextUrl(e,t){const n=this.toAbsoluteUrl(e);if(n&&t)try{const r=new URL(n);if(r.protocol!=="https:"||r.hostname.toLowerCase()!=="www.science.org"||!/^\/doi\/(?:pdf|epdf)\//i.test(r.pathname))return;const i=this.extractDoiFromScienceFullTextPath(r.pathname);return!i||i!==t.toLowerCase()?void 0:n}catch{return}}extractDoiFromScienceFullTextPath(e){const n=this.decodeDoiSource(e).match(/^\/doi\/(?:pdf|epdf)\/(.+)$/i);return n?this.cleanDoi(n[1]):void 0}toArticleUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{const n=new URL(t);return n.hash="",n.searchParams.delete("af"),n.searchParams.delete("campaign"),n.href}catch{return t}}cleanVenue(e){return this.cleanText(e).replace(/^Journal\s*:?\s*/i,"").replace(/\b(?:Volume|Vol\.?|Issue|No\.?|Pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\b((?:19|20)\d{2})\b[\s\S]*$/i,"").replace(/[,.;:\s]+$/g,"").trim()}toAbsoluteUrl(e){const t=e.trim();if(!(!t||/^javascript:/i.test(t)||/^data:/i.test(t)))try{const n=new URL(t,location.origin);return/^https?:$/.test(n.protocol)?n.href:void 0}catch{return}}decodeDoiSource(e){try{return decodeURIComponent(e)}catch{return e}}textWithoutExcludedContexts(e){const t=e.cloneNode(!0);return t.querySelectorAll(Ui).forEach(n=>n.remove()),t.textContent??""}cleanText(e){return e.replace(/\s+/g," ").trim()}titleKey(e){return this.cleanText(e).toLowerCase().replace(/[^a-z0-9]+/g,"")}unique(e){return Array.from(new Set(e.filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}}const Tl=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Em=/\b((?:19|20)\d{2})\b/,Ca=[".highwire-search-results-list > li.search-result","li.search-result-highwire-citation","li.search-result"].join(","),_m=[".highwire-search-results",".highwire-search-results-list","#hw-advance-search-result"].join(","),Dm=["article",".highwire-article",".pane-content","main","#content"].join(",");class Fm extends W{id="preprint-servers";name="bioRxiv / medRxiv / arXiv";matches=["*://www.biorxiv.org/*","*://biorxiv.org/*","*://www.medrxiv.org/*","*://medrxiv.org/*","*://arxiv.org/*"];isSearchPage(){return this.isArxivHost()?/^\/search\/?$/i.test(location.pathname)||/^\/list\//i.test(location.pathname):this.isChallengePage()?!1:/^\/search(?:\/|$)/i.test(location.pathname)}isArticlePage(){return this.isArxivHost()?/^\/abs\//i.test(location.pathname):this.isChallengePage()||/\.full\.pdf$/i.test(location.pathname)?!1:/^\/content\/10\./i.test(location.pathname)||this.hasArticleMetadata()}parseSearchResults(){if(this.isChallengePage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchResultHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[PreprintServersAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(this.isArxivHost()){const t=this.getDetailHost();return t?this.parseArxivArticlePage(t):null}if(this.isChallengePage()||/\.full\.pdf$/i.test(location.pathname))return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.getServerInfo(),n=this.cleanTitle(this.queryText(e,["h1.highwire-cite-title","h1.article-title","h1",".highwire-cite-title"])),r=this.cleanTitle(n||this.firstMetaContent(["citation_title","dc.title","og:title"]));if(!r)return null;const i=this.extractDoiFromPath(location.pathname),o=this.cleanDoi(i??this.firstMetaContent(["citation_doi","dc.identifier","prism.doi"])??this.extractDoi(e)),s=this.getCanonicalUrl()??location.href,l=this.extractNativePdfUrl(e,o);return{title:r,journalName:t.name,journalCandidates:[],authors:this.extractDetailAuthors(e),year:this.extractYear(this.firstMetaContent(["citation_publication_date","citation_date","dc.date","prism.publicationDate"])??this.queryText(e,[".published",".highwire-cite-metadata","time"])),doi:o,sourceId:this.buildSourceId(t,o,s),url:s,nativeFullTextUrl:l,abstractSnippet:this.cleanAbstract(this.firstMetaContent(["citation_abstract","dc.description","description"])??this.queryText(e,[".section.abstract",".abstract",".abstract p",'[class*="abstract"]'])),hostElement:e,articleTypes:["Preprint"],source:this.id,citationType:"misc"}}catch(t){return console.error("[PreprintServersAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){const t=this.queryFirstForHost(e,["h1.title",".title",".title.is-5",".title.is-5.mathjax",".list-title",".list-title.mathjax","p.title","a.highwire-cite-linked-title",".highwire-cite-title a","h1.highwire-cite-title","h1.article-title","h1","h2","h3"]);if(t)return{element:t,position:"after"};const n=this.queryFirstForHost(e,[".authors",".list-authors",".tags",".is-size-7",".submitted-date",".highwire-cite-authors",".highwire-cite-metadata",".article-meta",".published"]);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return this.isArxivHost()?this.isArticlePage()?this.getDetailHost()??document.querySelector("main")??document.body:document.querySelector("ol.arxiv-results")??document.querySelector("ol.breathe-horizontal")??document.querySelector("#dlpage > dl")??document.querySelector("#dlpage")??document.querySelector("main")??document.body:this.isArticlePage()?this.getDetailHost()??document.body:document.querySelector(".highwire-search-results-list")??document.querySelector(".highwire-search-results")??document.querySelector("#hw-advance-search-result")??document.querySelector("main")??document.body}getPageInfo(){if(this.isArxivHost()){const i=new URLSearchParams(location.search),o=Number.parseInt(i.get("size")??"50",10),s=Number.parseInt(i.get("start")??"0",10),l=this.cleanText(document.body?.textContent??""),c=l.match(/\bof\s+([\d,]+)\s+results\b/i)??l.match(/\bTotal of\s+([\d,]+)\s+entries\b/i),u=c?.[1]?Number.parseInt(c[1].replace(/,/g,""),10):void 0,d=Number.isFinite(s)&&s>=0&&Number.isFinite(o)&&o>0?Math.floor(s/o)+1:1,p=u&&Number.isFinite(o)&&o>0?Math.max(1,Math.ceil(u/o)):1;return{pageNum:d,totalPages:p,totalItems:u,itemsPerPage:Number.isFinite(o)&&o>0?o:void 0,url:location.href}}const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"0",10),n=Number.isFinite(t)&&t>=0?t+1:1,r=Array.from(document.querySelectorAll(".pager a, .pager-current")).map(i=>this.cleanText(i.textContent??"")).map(i=>Number.parseInt(i.replace(/,/g,""),10)).filter(i=>Number.isFinite(i)&&i>0);return{pageNum:n,totalPages:Math.max(1,n,...r),url:location.href,itemsPerPage:10}}parseSearchResultHost(e){if(this.isArxivHost())return this.parseArxivSearchResultHost(e);const t=this.cloneWithoutNestedResults(e),n=this.getServerInfo(),r=this.queryFirstVisible(t,["a.highwire-cite-linked-title[href]",".highwire-cite-title a[href]","h3 a[href]","h2 a[href]"]),i=this.cleanTitle(r?.textContent??this.queryText(t,[".highwire-cite-title","h3","h2"]));if(!i)return null;const o=this.absoluteUrl(r?.getAttribute("href")??void 0),s=o?this.extractDoiFromPath(new URL(o).pathname):void 0,l=this.cleanDoi(s||this.queryText(t,[".highwire-cite-metadata-doi"])||this.queryText(t,[".doi"])||this.extractDoi(t));return{title:i,journalName:n.name,journalCandidates:[],authors:this.extractAuthors(t),year:this.extractYear(this.queryText(t,[".highwire-cite-metadata-pages",".highwire-cite-metadata","time"])),doi:l,sourceId:this.buildSourceId(n,l,this.extractStableToken(e)??o??i),url:o,nativeFullTextUrl:this.buildPdfUrlFromArticleUrl(o),abstractSnippet:this.cleanAbstract(this.queryText(t,[".highwire-cite-snippet",".highwire-cite-abstract",".abstract"])),hostElement:e,articleTypes:["Preprint"],source:this.id,citationType:"misc"}}getSearchResultHosts(){if(this.isArxivHost()){const r=location.pathname;return/^\/list\//i.test(r)?this.uniqueElements(Array.from(document.querySelectorAll("#dlpage > dl > dd, dl > dd"))).filter(s=>!this.isHiddenDomElement(s)).filter(s=>!!this.queryText(s,[".list-title",".meta > .list-title"])):this.uniqueElements(Array.from(document.querySelectorAll("li.arxiv-result"))).filter(o=>!this.isHiddenDomElement(o)).filter(o=>!!this.queryText(o,[".title",".title.is-5",".title.is-5.mathjax"]))}const e=Array.from(document.querySelectorAll(_m)),t=e.length>0?e:[document.body].filter(Boolean),n=this.uniqueElements(t.flatMap(r=>{const i=Array.from(r.querySelectorAll(Ca));return r.matches(Ca)&&i.unshift(r),i})).filter(r=>!this.isHiddenDomElement(r)).filter(r=>!!this.queryText(r,[".highwire-cite-title","h3","h2"]));return n.filter(r=>!n.some(i=>i!==r&&i.contains(r)))}cloneWithoutNestedResults(e){const t=e.cloneNode(!0);return t.querySelectorAll(Ca).forEach(n=>n.remove()),t}getDetailHost(){if(this.isArxivHost())return this.uniqueElements(Array.from(document.querySelectorAll("main, article, #abs"))).filter(r=>!this.isHiddenDomElement(r)).find(r=>!!this.queryText(r,["h1.title",".title"]))??document.querySelector("main")??document.body;const e=this.extractDoiFromPath(location.pathname),t=this.uniqueElements(Array.from(document.querySelectorAll(Dm))).filter(r=>!this.isHiddenDomElement(r)),n=e?t.find(r=>this.elementContainsDoi(r,e)):void 0;return n||(t.find(r=>!!this.queryText(r,["h1.highwire-cite-title","h1.article-title","h1",".highwire-cite-title"]))??t[0]??document.body)}hasArticleMetadata(){return!!(this.firstMetaContent(["citation_title"])&&(this.firstMetaContent(["citation_doi"])||this.firstMetaContent(["citation_pdf_url"])))}isChallengePage(){if(this.isArxivHost())return!1;const e=this.hasUsableContent();if(this.hasBlockingChallenge(e))return!0;if(e)return!1;const t=this.getVisibleDetailHeading();if(t&&this.isChallengeText(t))return!0;const n=document.title??"";if(/just a moment|attention required|cloudflare/i.test(n)||document.querySelector('.g-recaptcha, [class*="captcha" i], [id*="captcha" i]'))return!0;const r=document.documentElement?.innerHTML??"";return/_cf_chl_opt|Enable JavaScript and cookies to continue|Verifying you are human|verify you are human|Checking if the site connection is secure|article access|verify access|verification required|security check|complete security check|access denied|forbidden|sorry, you have been blocked|you do not have permission|not a robot|recaptcha|captcha/i.test(r)}hasBlockingChallenge(e=this.hasUsableContent()){return!!(document.querySelector("#challenge-error-text, .cf-error-details, .cf-browser-verification")||this.hasCloudflareChallengeSignature(e)||document.querySelector('form.access-check, [class*="access-check" i], [id*="access-check" i]')||this.hasBlockingTurnstile()||this.hasBlockingCaptcha())}hasCloudflareChallengeSignature(e=this.hasUsableContent()){const t=document.documentElement?.innerHTML??"";if(/_cf_chl_opt|cf_chl_|cf_clearance/i.test(t)||!e&&document.querySelector('script[src*="challenges.cloudflare.com/turnstile"], script[src*="/cdn-cgi/challenge-platform/"]'))return!0;const n=this.cleanText(`${document.title??""} ${document.body?.textContent??""}`);return!e&&/checking if the site connection is secure|verifying you are human|cloudflare ray id|enable javascript and cookies to continue/i.test(n)?!0:Array.from(document.querySelectorAll('iframe[src*="challenges.cloudflare.com"]')).some(r=>this.isBlockingChallengeElement(r))}hasBlockingTurnstile(){return Array.from(document.querySelectorAll('#cf-turnstile, .cf-turnstile, iframe[src*="challenges.cloudflare.com"]')).some(e=>this.isBlockingChallengeElement(e))}hasBlockingCaptcha(){return Array.from(document.querySelectorAll('.g-recaptcha, [class*="captcha" i], [id*="captcha" i]')).some(t=>this.isBlockingChallengeElement(t))}isBlockingChallengeElement(e){return this.isHiddenDomElement(e)?!1:!e.closest([".email-forward",".email-form","#forward-form",".pane-forward-form",'[class*="email-forward" i]','[class*="email-form" i]','[class*="forward-form" i]','form[class*="email" i]','form[id*="email" i]','form[class*="forward" i]','form[id*="forward" i]'].join(","))}hasUsableContent(){const e=this.getVisibleDetailHeading(),t=!!this.extractDoiFromPath(location.pathname),n=this.cleanTitle(this.firstMetaContent(["citation_title"])),r=!!(e&&n&&this.cleanTitle(e).toLowerCase()===n.toLowerCase()&&(this.firstMetaContent(["citation_doi"])||this.firstMetaContent(["citation_pdf_url"])||t)),i=!!(e&&(!this.isChallengeText(e)||r));return!!(this.getSearchResultHosts().length>0||i&&(r||t))}getVisibleDetailHeading(){const e=this.getDetailHost();return e?this.queryText(e,["h1.highwire-cite-title","h1.article-title","h1",".highwire-cite-title"]):""}isChallengeText(e){const t=this.cleanText(e).toLowerCase();return/^(?:article access|access denied|forbidden|security check|verify access|verification required|sorry, you have been blocked|verifying you are human|checking if the site connection is secure)$/.test(t)||/^(?:please\s+)?(?:verify|complete)\s+(?:your\s+)?(?:access|security check|captcha)(?:\s+before continuing)?\.?$/.test(t)?!0:/you do not have permission to access|sorry, you have been blocked|enable javascript and cookies to continue/i.test(e)}getServerInfo(){const e=location.hostname.toLowerCase();return e.includes("arxiv.org")?{name:"arXiv",slug:"arxiv"}:e.includes("medrxiv")?{name:"medRxiv",slug:"medrxiv"}:{name:"bioRxiv",slug:"biorxiv"}}isArxivHost(){return/(^|\.)arxiv\.org$/i.test(location.hostname)}extractAuthors(e){const t=Array.from(e.querySelectorAll(".highwire-citation-author"));return t.length>0?this.unique(t.map(n=>this.cleanText(n.textContent??""))):this.splitAuthors(this.queryText(e,[".highwire-cite-authors",".authors"]))}extractStableToken(e){const t=e.matches("[data-pisa-master], [data-pisa], [data-apath]")?e:e.querySelector("[data-pisa-master], [data-pisa], [data-apath]");return t?.getAttribute("data-pisa-master")??t?.getAttribute("data-pisa")??t?.getAttribute("data-apath")??void 0}extractDetailAuthors(e){if(this.isArxivHost())return this.extractArxivAuthors(e);const t=this.metaContents("citation_author");return t.length>0?this.unique(t):this.extractAuthors(e)}extractNativePdfUrl(e,t){const n=this.buildPdfUrlFromArticleUrl(location.href),r=this.unique([n,this.firstMetaContent(["citation_pdf_url"]),...Array.from(e.querySelectorAll("a[href]")).filter(i=>/\.full\.pdf(?:$|[?#])|\/content\/10\.[^"'\s]+\.pdf(?:$|[?#])|pdf/i.test(`${i.href} ${i.textContent??""}`)).map(i=>i.getAttribute("href")??"")]);for(const i of r){const o=this.absoluteUrl(i);if(!(!o||!this.isNativePreprintUrl(o))&&(!t||this.urlContainsDoi(o,t)))return o}}buildPdfUrlFromArticleUrl(e){if(e)try{const t=new URL(e,location.href);if(this.isArxivAbsoluteUrl(t.href)){const i=this.extractArxivIdFromPath(t.pathname)??this.extractArxivIdFromText(t.pathname);return i?(t.pathname=`/pdf/${i}.pdf`,t.search="",t.hash="",t.href):void 0}if(!this.isNativePreprintUrl(t.href)||!/^\/content\/10\./i.test(t.pathname))return;const n=t.pathname.replace(/\/+$/,"");if(/\.full\.pdf$/i.test(n))return t.href;const r=this.stripContentRouteSuffix(n);return t.pathname=/\.full$/i.test(r)?r.replace(/\.full$/i,".full.pdf"):r+".full.pdf",t.search="",t.hash="",t.href}catch{return}}isNativePreprintUrl(e){try{const t=new URL(e,location.href).hostname.toLowerCase();return/(^|\.)biorxiv\.org$/i.test(t)||/(^|\.)medrxiv\.org$/i.test(t)||/(^|\.)arxiv\.org$/i.test(t)}catch{return!1}}urlContainsDoi(e,t){const n=this.cleanDoi(t);if(!n)return!1;try{const r=new URL(e,location.href);return(this.extractDoiFromPath(r.pathname)??this.cleanDoi(decodeURIComponent(r.href)))===n}catch{return this.cleanDoi(decodeURIComponent(e))===n}}elementContainsDoi(e,t){return this.extractDoi(e)===t?!0:Array.from(e.querySelectorAll("a[href]")).some(n=>this.urlContainsDoi(n.href,t))}extractDoi(e){const t=this.cleanText(e.textContent??"").match(Tl);return t?this.cleanDoi(t[0]):void 0}extractDoiFromPath(e){const t=decodeURIComponent(e).match(/^\/content\/(10\.\d{4,9}\/[^/?#]+)/i);return t?this.cleanDoi(this.stripContentRouteSuffix(t[1])):void 0}stripContentRouteSuffix(e){return e.replace(/(?:\.article-info|\.figures-only|\.full(?:\.pdf)?)$/i,"")}cleanDoi(e){if(!e)return;const t=e.replace(/^doi:\s*/i,"").match(Tl);if(t)return t[0].replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/(?:\.full)?\.pdf$/i,"").replace(/[.,;)\]]+$/g,"").replace(/v\d+$/i,"").toLowerCase()}buildSourceId(e,t,n){const r=t||n;return`preprint-servers:${e.slug}:${this.cleanText(r).toLowerCase()}`}extractYear(e){const t=e?.match(Em);return t?Number.parseInt(t[1],10):void 0}cleanTitle(e){return this.cleanText(e??"").replace(/\s*\|\s*(?:bioRxiv|medRxiv)\s*$/i,"").replace(/\s*\|\s*arXiv\s*$/i,"").replace(/^Title:\s*/i,"").replace(/^\[PDF\]\s*/i,"")}cleanAbstract(e){return this.cleanText(e??"").replace(/^Abstract\s*:?\s*/i,"")||void 0}parseArxivSearchResultHost(e){const t=this.extractArxivIdForHost(e),n=this.extractArxivAbsUrl(e)??(t?this.absoluteUrl(`/abs/${t}`):void 0),r=this.cleanTitle(this.queryText(e,[".title.is-5.mathjax",".title.is-5",".title",".list-title.mathjax",".list-title"]));if(!r||!n)return null;const i=this.extractArxivPdfUrl(e,t,n),o=this.buildArxivDoi(t),s=this.extractYear(this.queryText(e,[".is-size-7",".submitted-date",".list-date"]))??this.extractYearFromArxivId(t);return{title:r,journalName:"arXiv",journalCandidates:[],authors:this.extractArxivAuthors(e),year:s,doi:o,sourceId:this.buildSourceId(this.getServerInfo(),t,n),url:n,nativeFullTextUrl:i,abstractSnippet:this.cleanAbstract(this.queryText(e,[".abstract-full.has-text-grey-dark.mathjax",".abstract-full.mathjax",".abstract-full",".mathjax"])),hostElement:e,articleTypes:["Preprint"],source:this.id,citationType:"misc"}}parseArxivArticlePage(e){const t=this.extractArxivIdFromPath(location.pathname)??this.extractArxivIdFromText(this.cleanText(e.textContent??"")),n=this.cleanTitle(this.firstMetaContent(["citation_title","dc.title","og:title"])??this.queryText(e,["h1.title",".title.mathjax",".title"]));if(!n)return null;const r=this.getCanonicalUrl()??(t?this.absoluteUrl(`/abs/${t}`):location.href)??location.href,i=this.cleanDoi(this.firstMetaContent(["citation_doi","dc.identifier","prism.doi"])??this.queryFirstVisible(e,['a[href*="doi.org/10.48550/arXiv."]'])?.getAttribute("href")??this.buildArxivDoi(t));return{title:n,journalName:"arXiv",journalCandidates:[],authors:this.extractArxivAuthors(e),year:this.extractYear(this.queryText(e,[".dateline",".submission-history",".is-size-7"]))??this.extractYearFromArxivId(t),doi:i,sourceId:this.buildSourceId(this.getServerInfo(),t,r),url:r,nativeFullTextUrl:this.extractArxivPdfUrl(e,t,r),abstractSnippet:this.cleanAbstract(this.queryText(e,["blockquote.abstract.mathjax","blockquote.abstract",".abstract.mathjax",".abstract"])),hostElement:e,articleTypes:["Preprint"],source:this.id,citationType:"misc"}}extractArxivAuthors(e){return this.unique(Array.from(e.querySelectorAll(".authors a, .list-authors a, p.authors a")).map(t=>this.cleanText(t.textContent??"")).filter(Boolean))}extractArxivIdForHost(e){const t=e.matches("dd")?e.previousElementSibling:e;return this.extractArxivIdFromText(this.queryText(t??e,[".list-title.is-inline-block",".list-identifier",'a[href*="/abs/"]']))??this.extractArxivIdFromPath(this.extractArxivAbsUrl(e,t??void 0)?new URL(this.extractArxivAbsUrl(e,t??void 0),location.href).pathname:"")}extractArxivAbsUrl(e,t){const n=this.queryFirstVisible(t??e,['a[href^="/abs/"]','a[href*="arxiv.org/abs/"]']);return this.absoluteUrl(n?.getAttribute("href")??n?.href)}extractArxivPdfUrl(e,t,n){const r=this.queryFirstVisible(e.matches("dd")&&e.previousElementSibling?e.previousElementSibling:e,['a[title*="Download PDF" i]','a[href^="/pdf/"]','a[href*="arxiv.org/pdf/"]']),i=this.absoluteUrl(r?.getAttribute("href")??r?.href);if(i&&this.isArxivAbsoluteUrl(i)){if(/\.pdf(?:$|[?#])/i.test(i))return i;const o=this.buildPdfUrlFromArticleUrl(i);if(o)return o}if(n){const o=this.buildPdfUrlFromArticleUrl(n);if(o)return o}return t?this.absoluteUrl(`/pdf/${t}.pdf`):void 0}buildArxivDoi(e){return e?`10.48550/arXiv.${e}`.toLowerCase():void 0}extractArxivIdFromPath(e){const t=decodeURIComponent(e),n=t.match(/^\/abs\/([^/?#]+)/i);if(n?.[1])return n[1].replace(/v\d+$/i,"");const r=t.match(/^\/pdf\/([^/?#]+?)(?:\.pdf)?$/i);if(r?.[1])return r[1].replace(/v\d+$/i,"")}extractArxivIdFromText(e){const t=this.cleanText(e??""),n=t.match(/\barXiv:\s*([A-Za-z.\-]+\/\d{7}|\d{4}\.\d{4,5})(?:v\d+)?\b/i);return n?.[1]?n[1].replace(/v\d+$/i,""):t.match(/\b([A-Za-z.\-]+\/\d{7}|\d{4}\.\d{4,5})(?:v\d+)?\b/)?.[1]?.replace(/v\d+$/i,"")}extractYearFromArxivId(e){if(!e)return;const t=e.match(/^(\d{2})(\d{2})\.\d{4,5}$/);if(!t)return;const n=Number.parseInt(t[1],10);return n>=91?1900+n:2e3+n}isArxivAbsoluteUrl(e){try{return/(^|\.)arxiv\.org$/i.test(new URL(e,location.href).hostname)}catch{return!1}}queryFirstVisible(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n)).find(i=>!this.isHiddenDomElement(i));if(r)return r}return null}queryFirstForHost(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n));for(const i of r){if(this.isHiddenDomElement(i))continue;const o=i.closest(Ca);if(!o||o===e)return i}}return null}queryText(e,t){for(const n of t){const r=this.cleanText(this.queryFirstVisible(e,[n])?.textContent??"");if(r)return r}return""}isHiddenDomElement(e){if(!(e instanceof HTMLElement))return!1;let t=e;for(;t&&t!==document.body;){if(t.hidden||t.getAttribute("aria-hidden")==="true")return!0;const n=t.getAttribute("style")??"";if(/display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:[;\s]|$)|clip\s*:\s*rect\(\s*0/i.test(n)||/clip-path\s*:\s*(?!none\b)[^;]+/i.test(n)||/(?:position\s*:\s*(?:absolute|fixed)[^;]*;?|(?:left|right|top|bottom)\s*:\s*-?[1-9]\d{3,}px)/i.test(n)&&/(?:left|right|top|bottom)\s*:\s*-?[1-9]\d{3,}px/i.test(n)||/transform\s*:\s*(?:matrix\([^)]*(?:-?[1-9]\d{3,}|,\s*-?[1-9]\d{3,})|translate(?:3d|x|y)?\([^)]*-?[1-9]\d{3,})/i.test(n)||/width\s*:\s*0(?:px)?(?:[;\s]|$)/i.test(n)&&/height\s*:\s*0(?:px)?(?:[;\s]|$)/i.test(n)&&/overflow\s*:\s*hidden/i.test(n))return!0;const r=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(t):null;if(r){const i=Number.parseFloat(r.left||"0"),o=Number.parseFloat(r.top||"0"),s=Number.parseFloat(r.right||"0"),l=Number.parseFloat(r.bottom||"0"),c=r.clip??"",u=r.clipPath??"",d=r.transform??"",p=Number.parseFloat(r.width||""),m=Number.parseFloat(r.height||""),h=!!(c&&c!=="auto")||!!(u&&u!=="none"),y=["absolute","fixed"].includes(r.position)&&(Math.abs(i)>1e3||Math.abs(o)>1e3||Math.abs(s)>1e3||Math.abs(l)>1e3),x=/matrix\([^)]*(?:-?[1-9]\d{3,}|,\s*-?[1-9]\d{3,})|translate(?:3d|X|Y)?\([^)]*-?[1-9]\d{3,}/i.test(d),T=Number.isFinite(p)&&Number.isFinite(m)&&p<=1&&m<=1&&r.overflow==="hidden";if(r.display==="none"||r.visibility==="hidden"||r.opacity==="0"||h||y||x||T)return!0}t=t.parentElement}return!1}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`)?.content,r=this.cleanText(n??"");if(r)return r}}metaContents(e){return this.unique(Array.from(document.querySelectorAll(`meta[name="${e}"], meta[property="${e}"]`)).map(t=>this.cleanText(t.content)).filter(Boolean))}getCanonicalUrl(){return this.absoluteUrl(document.querySelector('link[rel="canonical"]')?.href)}absoluteUrl(e){const t=this.cleanText(e??"");if(!(!t||t==="#"))try{return new URL(t,location.href).href}catch{return}}splitAuthors(e){const t=this.cleanText(e??"");return t?this.unique(t.split(/\s*(?:,|;|\band\b)\s*/i).map(n=>this.cleanText(n)).filter(Boolean)):[]}unique(e){const t=new Set;return e.filter(n=>t.has(n)?!1:(t.add(n),!0))}uniqueElements(e){const t=new Set;return e.filter(n=>t.has(n)?!1:(t.add(n),!0))}cleanText(e){return e.replace(/\s+/g," ").trim()}}const km=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Lm=/\b((?:19|20)\d{2})\b/,Nm="dt.search-results-title";class Rm extends W{id="plos";name="PLOS";matches=["*://journals.plos.org/*"];isSearchPage(){return/^\/[^/]+\/search\/?$/i.test(location.pathname)}isArticlePage(){return/^\/[^/]+\/article(?:\/|$)/i.test(location.pathname)?!!(location.search.includes("id=")||this.firstMetaContent(["citation_title","citation_journal_title"])||document.querySelector("h1")):!1}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultTitleHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[PlosAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??e.querySelector("h1")?.textContent??"");if(!t)return null;const n=this.cleanJournalName(this.firstMetaContent(["citation_journal_title"])??this.extractJournalFromDetailDom(e)??this.getJournalNameFromPath()),r=this.cleanDoi(this.firstMetaContent(["citation_doi"])??this.extractDoi(e)??new URLSearchParams(location.search).get("id")??void 0),i=this.cleanText(this.firstMetaContent(["citation_date","citation_publication_date"])??this.findDetailMetaList(e)?.textContent??""),o=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href);return{title:t,journalName:n,journalCandidates:this.unique([n,this.getJournalNameFromPath()].filter(Boolean)),authors:this.extractMetadataAuthors().length>0?this.extractMetadataAuthors():this.extractAuthorsFromText(e.querySelector(".authors, .article-authors, .author-list")?.textContent??""),year:this.extractYear(i),publicationDate:i||void 0,doi:r,sourceId:this.buildSourceId(r,o),url:o,nativeFullTextUrl:this.extractNativeFullTextUrl(r,o),abstractSnippet:this.cleanAbstract(this.firstMetaContent(["citation_abstract","description","og:description"])??this.extractDetailAbstract(e)),hostElement:e,articleTypes:this.extractDetailTypes(e),issn:this.normalizeIssn(this.firstMetaContent(["citation_issn"])),volume:this.cleanText(this.firstMetaContent(["citation_volume"])??""),issue:this.cleanText(this.firstMetaContent(["citation_issue"])??""),pages:this.extractPagesFromMetadata(),source:this.id,citationType:"article"}}catch(t){return console.error("[PlosAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDetailMetaList(e)??this.findDetailMetaList(document.body);if(r)return{element:r,position:"after"};const i=e.querySelector("h1");return i?{element:i,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector("p:nth-of-type(2), .search-results-details, .search-results-meta");if(t)return{element:t,position:"after"};const n=e.previousElementSibling;return n?.matches("dt.search-results-title")?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector("#search-results")??document.querySelector("article.searchResults")??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"1",10)||1,r=this.cleanText(document.querySelector(".search-results-total, .results-total, .search-results-header, .search-results-controls, main")?.textContent??"").match(/\b([\d,]+)\s+results?\s+for\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/10)):1,url:location.href,itemsPerPage:10,totalItems:i}}getSearchResultTitleHosts(){return Array.from(document.querySelectorAll(Nm)).filter(e=>e.nextElementSibling?.matches("dd"))}parseSearchHost(e){const t=e.nextElementSibling;if(!t?.matches("dd"))return null;const n=e.querySelector('a[href*="/article?id="]'),r=this.cleanText(n?.textContent??e.textContent??"");if(!r)return null;const i=this.toAbsoluteUrl(n?.getAttribute("href")??n?.href??""),o=this.cleanDoi(t.querySelector('a[href*="doi.org/"]')?.textContent??t.querySelector('a[href*="doi.org/"]')?.getAttribute("href")??e.getAttribute("data-doi")??void 0),s=this.extractAuthorsFromText(t.querySelector("p:nth-of-type(1)")?.textContent??""),l=this.cleanText(t.querySelector("p:nth-of-type(2)")?.textContent??""),c=this.parseSearchDetailLine(l),u=c.articleType??"Research Article",d=this.cleanJournalName(c.journalName??this.getJournalNameFromPath()),p=c.publicationDate;return{title:r,journalName:d,journalCandidates:this.unique([d,this.getJournalNameFromPath()].filter(Boolean)),authors:s,year:this.extractYear(p??l),publicationDate:p,doi:o,sourceId:this.buildSourceId(o,i),url:i,nativeFullTextUrl:this.extractNativeFullTextUrl(o,i),hostElement:t,articleTypes:[u],source:this.id,citationType:"article"}}parseSearchDetailLine(e){if(!e)return{};const[t,n]=e.split("|").map(l=>this.cleanText(l)),r=n??e,i=r.match(/(PLOS(?:\s+[A-Za-z0-9&.-]+)+)\s*$/i),o=i?.[1],s=this.cleanText(r.replace(/^published\s*/i,"").replace(i?.[0]??"",""));return{articleType:t||void 0,publicationDate:s||void 0,journalName:this.cleanJournalName(o??"")}}findDetailMetaList(e){const t=["ul.articleinfo",".articleinfo","ul","p","div"];for(const n of t){const r=Array.from(e.querySelectorAll(n)).find(i=>!!i.querySelector('a[href*="doi.org/"]'));if(r)return r}return null}getDetailHost(){return document.querySelector("main")??document.querySelector("article")??document.body}extractDetailAbstract(e){const t=e.querySelector("#abstract0, .abstract, section.abstract");return this.cleanText(t?.textContent??"")}extractDetailTypes(e){const t=this.cleanText(this.firstMetaContent(["citation_article_type"])??e.querySelector('#artType, .type-article, [class*="article-type"]')?.textContent??"");return t?[t]:[]}extractMetadataAuthors(){const e=Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(t=>this.cleanText(t.content)).filter(Boolean);return this.unique(e)}extractAuthorsFromText(e){const t=this.cleanText(e).replace(/\bet al\.?$/i,"").trim();return t?this.unique(t.split(/\s*,\s*|\s+and\s+/i).map(n=>this.cleanText(n)).filter(Boolean)):[]}extractNativeFullTextUrl(e,t){const n=this.toAbsoluteUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(n&&this.isNativePlosUrl(n))return n;const r=e??this.cleanDoi(new URLSearchParams(new URL(t??location.href,location.href).search).get("id")??void 0);if(!r)return;const i=this.getJournalSlug(t);if(i)return`https://journals.plos.org/${i}/article/file?id=${encodeURIComponent(r)}&type=printable`}extractPagesFromMetadata(){const e=this.cleanText(this.firstMetaContent(["citation_firstpage"])??""),t=this.cleanText(this.firstMetaContent(["citation_lastpage"])??"");if(e)return t&&t!==e?`${e}-${t}`:e}extractJournalFromDetailDom(e){return this.cleanText(e.querySelector('.header p, .articleinfo, [class*="journal"]')?.textContent??"").match(/\b(PLOS(?:\s+[A-Za-z0-9&.-]+)+)\b/i)?.[1]??null}extractDoi(e){const t=e.querySelector('a[href*="doi.org/"]');return this.cleanDoi(t?.textContent??t?.getAttribute("href")??void 0)}getJournalSlug(e){try{return new URL(e??location.href,location.href).pathname.split("/").filter(Boolean)[0]||null}catch{return null}}getJournalNameFromPath(){const e=this.getJournalSlug();if(!e)return"PLOS";const t=e.replace(/^plos/i,"").trim();return t?t.toLowerCase()==="one"?"PLOS ONE":`PLOS ${t.replace(/([a-z])([A-Z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}`.trim():"PLOS"}buildSourceId(e,t){return e?`plos:${e.toLowerCase()}`:t?`plos:${t}`:void 0}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}normalizeIssn(e){const t=this.cleanText(e??"");if(!t)return;const n=t.match(/\b\d{4}-?\d{3}[\dX]\b/i);if(!n)return;const r=n[0].replace(/-/g,"");return`${r.slice(0,4)}-${r.slice(4)}`}cleanJournalName(e){const t=this.cleanText(e);return t?t.replace(/\bPLOS One\b/i,"PLOS ONE"):"PLOS"}cleanAbstract(e){return this.cleanText(e).replace(/^Abstract\s*:?\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(km)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}extractYear(e){const t=this.cleanText(e??"").match(Lm);return t?Number.parseInt(t[1],10):void 0}isNativePlosUrl(e){try{return new URL(e,location.href).hostname==="journals.plos.org"}catch{return!1}}toAbsoluteUrl(e){const t=this.cleanText(e);if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const Pm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Im=/\b((?:19|20)\d{2})\b/,Hi=/^(official\s+(?:review|comment|decision)|reviewer\s|public comment|author response|rebuttal)/i;class Mm extends W{id="openreview";name="OpenReview";matches=["*://openreview.net/*"];isSearchPage(){return/^\/search\/?$/i.test(location.pathname)}isArticlePage(){return/^\/forum\/?$/i.test(location.pathname)&&!!(new URLSearchParams(location.search).get("id")||this.firstMetaContent(["citation_title"])||document.querySelector("main .note, main .legacy-forum, main h2.note_content_title, main h2.citation_title"))}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[OpenReviewAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.cleanText(this.firstMetaContent(["citation_title","og:title"])??e.querySelector("h2.note_content_title, h2.citation_title, h2")?.textContent??"");if(!t)return null;const n=this.extractForumId(location.href),r=this.cleanText(this.firstMetaContent(["citation_conference_title"])??""),i=this.extractDetailVenue(e),o=this.cleanDoi(this.extractOpenWebsiteLink(e)?.getAttribute("href")??this.firstMetaContent(["citation_doi"])??void 0),s=this.inferRecordKind(t,[i,r].filter(Boolean),o),l=this.resolveVenueInfo([i,r].filter(Boolean),s,o),c=this.extractDetailPublicationDate(e)??this.cleanText(this.firstMetaContent(["citation_online_date"])??"");return{title:t,journalName:l.journalName,journalCandidates:l.candidates,authors:this.extractMetadataAuthors().length>0?this.extractMetadataAuthors():this.extractDetailAuthors(e),year:this.extractYear(c||l.journalName),publicationDate:c||void 0,doi:o,sourceId:n?`openreview:${n}`:void 0,url:this.toAbsoluteUrl(location.href),nativeFullTextUrl:this.extractNativePdfUrl(e,n),abstractSnippet:this.cleanAbstract(this.firstMetaContent(["citation_abstract","description","og:description"])??this.extractDetailAbstract(e)),hostElement:e,articleTypes:s.articleTypes,source:this.id,citationType:s.citationType}}catch(t){return console.error("[OpenReviewAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const i=e.querySelector(".meta_row");if(i)return{element:i,position:"after"};const o=e.querySelector("h2.note_content_title, h2.citation_title, h2");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector(".note-meta-info, .note-metadata, ul");if(t)return{element:t,position:"after"};const n=e.querySelector(".note-authors");if(n)return{element:n,position:"after"};const r=e.querySelector("h4");return r?{element:r,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return this.findSearchResultsContainer()??document.querySelector("main")??document.body}getPageInfo(){const e=this.cleanText(document.querySelector('[aria-current="page"], .ant-pagination-item-active, .pagination li.active')?.textContent??""),t=Number.parseInt(e,10)||1,n=this.getSearchResultHosts().length||void 0;return{pageNum:t,totalPages:1,itemsPerPage:n,url:location.href}}getSearchResultHosts(){const t=this.findSearchResultsContainer()??document.querySelector("main")??document.body;return Array.from(t.querySelectorAll("li")).filter(n=>this.looksLikePaperSearchResult(n))}findSearchResultsContainer(){return Array.from(document.querySelectorAll("ul")).find(e=>!!e.querySelector('div.note h4 a[href^="/forum?id="]'))??null}looksLikePaperSearchResult(e){const t=e.querySelector('h4 a[href^="/forum?id="]'),n=this.cleanText(t?.textContent??"");return!n||Hi.test(n)||!e.querySelector(".note-authors")?!1:!!e.querySelector(".note-meta-info li, .note-metadata li, ul li")}parseSearchHost(e){const t=e.querySelector('h4 a[href^="/forum?id="]'),n=this.cleanText(t?.textContent??"");if(!n||Hi.test(n))return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.extractForumId(r),o=e.querySelector("a.pdf-link[href]"),s=e.querySelector("a.html-link[href]"),l=Array.from(e.querySelectorAll(".note-meta-info li, .note-metadata li, ul li")).map(h=>this.cleanText(h.textContent??"")).filter(Boolean),c=l.find(h=>!/^Published:/i.test(h)&&!/^Readers:/i.test(h))??"",u=l.find(h=>/^Published:/i.test(h))?.replace(/^Published:\s*/i,""),d=this.cleanDoi(s?.getAttribute("href")??void 0),p=this.inferRecordKind(n,[c],d),m=this.resolveVenueInfo([c],p,d);return{title:n,journalName:m.journalName,journalCandidates:m.candidates,authors:this.extractSearchAuthors(e),year:this.extractYear(u??c),publicationDate:u||void 0,doi:d,sourceId:i?`openreview:${i}`:void 0,url:r,nativeFullTextUrl:this.toAbsoluteUrl(o?.getAttribute("href")??"")??this.buildPdfUrl(i),hostElement:e,articleTypes:p.articleTypes,source:this.id,citationType:p.citationType}}getDetailHost(){return document.querySelector("main .note")??document.querySelector("main .legacy-forum .note")??document.querySelector("main")??document.body}extractSearchAuthors(e){const t=Array.from(e.querySelectorAll(".note-authors a")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractMetadataAuthors(){const e=Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(t=>this.cleanText(t.content)).filter(Boolean);return this.unique(e)}extractDetailAuthors(e){const t=Array.from(e.querySelectorAll(".meta_row .signatures a, .meta_row .author a, h3.signatures a")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractDetailVenue(e){return Array.from(e.querySelectorAll(".meta_row .item")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).find(n=>!/^Published:/i.test(n)&&!/^Readers:/i.test(n))??""}extractDetailPublicationDate(e){return this.cleanText(e.querySelector(".meta_row .date, .meta_row .item.date")?.textContent??"").replace(/^Published:\s*/i,"")||void 0}extractDetailAbstract(e){const t=Array.from(e.querySelectorAll(".note_content_field")).filter(n=>/^Abstract:/i.test(this.cleanText(n.textContent??"")));for(const n of t){const r=n.parentElement;if(!r)continue;const i=r.cloneNode(!0);i.querySelectorAll(".note_content_field").forEach(s=>s.remove());const o=this.cleanText(i.textContent??"");if(o)return o}return""}extractNativePdfUrl(e,t){const n=this.toAbsoluteUrl(this.firstMetaContent(["citation_pdf_url"])??"");if(n)return n;const r=e.querySelector('a[href^="/pdf?id="], a.pdf-link[href]');return this.toAbsoluteUrl(r?.getAttribute("href")??"")??this.buildPdfUrl(t)}extractOpenWebsiteLink(e){return e.querySelector('a.html-link[href], a[href*="doi.org/"], a[href*="arxiv.org/"]')}buildPdfUrl(e){return e?`https://openreview.net/pdf?id=${encodeURIComponent(e)}`:void 0}inferRecordKind(e,t,n){if(Hi.test(e))return{articleTypes:["Reply"],citationType:"misc",metricsAllowed:!1};const r=this.cleanText([e,...t,n??""].join(" ")).toLowerCase();return/corr|arxiv|preprint/.test(r)||/^10\.48550\/arxiv\./i.test(n??"")?{articleTypes:["Preprint"],citationType:"misc",metricsAllowed:!1}:/conference|workshop|poster|oral|submission|neurips|iclr|icml|kdd|cvpr|eccv|aaai|acl|emnlp|coling|corl/.test(r)?{articleTypes:["Conference Paper"],citationType:"inproceedings",metricsAllowed:!1}:{articleTypes:["JournalArticle"],citationType:"article",metricsAllowed:!0}}resolveVenueInfo(e,t,n){const r=e.map(o=>this.cleanText(o)).filter(Boolean);if(t.citationType==="misc"){const o=this.unique([...r.map(s=>this.normalizePreprintVenue(s)),/^10\.48550\/arxiv\./i.test(n??"")?"arXiv":""].filter(Boolean));return{journalName:o[0]??"CoRR",candidates:o}}if(t.citationType==="inproceedings"){const o=this.unique(r.map(s=>this.normalizeConferenceVenue(s)));return{journalName:o[0]??"OpenReview",candidates:o}}const i=this.unique(r.map(o=>this.normalizeJournalVenue(o)));return{journalName:i[0]??"OpenReview",candidates:i}}normalizePreprintVenue(e){const t=this.cleanText(e);return/corr/i.test(t)?"CoRR":/arxiv/i.test(t)?"arXiv":t||"CoRR"}normalizeConferenceVenue(e){let t=this.cleanText(e);return t&&(t=t.replace(/\b\d{4}\b/g," ").replace(/\b(?:poster|oral|spotlight|workshop|demo|submission)\b/gi," ").replace(/\b\d+\b/g," ").replace(/\s+/g," ").trim(),t=t.replace(/^\d+(?:st|nd|rd|th)\s+Annual\s+/i,""),t=t.replace(/\bConference on Robot Learning\b/i,"CoRL"),t=t.replace(/\bNeural Information Processing Systems\b/i,"NeurIPS"),/^KDD$/i.test(t)?"SIGKDD":/^NIPS$/i.test(t)?"NeurIPS":t)}normalizeJournalVenue(e){return this.cleanText(e).replace(/\b\d{4}\b/g," ").replace(/\s+/g," ").trim()}extractForumId(e){if(e)try{return new URL(e,location.href).searchParams.get("id")??void 0}catch{return}}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}cleanAbstract(e){return this.cleanText(e).replace(/^Abstract:\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(Pm)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}extractYear(e){const t=this.cleanText(e??"").match(Im);return t?Number.parseInt(t[1],10):void 0}toAbsoluteUrl(e){const t=this.cleanText(e);if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const El=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Bm=/\b((?:19|20)\d{2})\b/,jm=/\/(?:fulltext|abstract)\/([^/?#]+)/i,qm=/^S?(\d{4})-?(\d{3}[\dX])/i,_l=["li.search__item",".search__item",".search-result__item",".resultItem","ol.search-results > li","li.search-result-item",".search-result-item",".search-result","article.search-result",'[data-e2e*="search-result"]',".issue-item"].join(","),$m=[_l,".art_title",".hlFld-Title",".publication_title"].join(","),Dl=[".search-results",".searchResultList",".search__list",'[aria-label="Search results"]',".results-shell"].join(",");class Om extends W{id="cell-com";name="Cell.com";matches=["*://www.cell.com/*"];isSearchPage(){if(this.isChallengePage())return!1;const e=location.pathname.toLowerCase();return e==="/action/dosearch"||e.startsWith("/action/dosearch")||e==="/search"||e==="/search/"||!/^\/[^/]+\/(?:fulltext|abstract)\/[^/]+/i.test(location.pathname)&&(new URLSearchParams(location.search).has("text1")||new URLSearchParams(location.search).has("text"))}isArticlePage(){return this.isChallengePage()?!1:/^\/[^/]+\/(?:fulltext|abstract)\/[^/]+/i.test(location.pathname)?!0:!!this.firstMetaContent(["citation_title"])}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[CellComAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??e.querySelector("h1")?.textContent??"");if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??this.firstMetaContent(["citation_public_url","citation_fulltext_html_url","prism.url","og:url"])??location.href),r=this.toAbsoluteUrl(this.firstMetaContent(["citation_pdf_url"])??e.querySelector('a[href$=".pdf"], a[href*="/pdf"], a[data-track-action*="pdf"]')?.getAttribute("href")??""),i=this.extractPii(n??"")??this.extractPii(r??""),o=this.deriveJournalCandidatesFromUrl(n??location.href),s=this.cleanText(this.firstMetaContent(["citation_publication_date","citation_online_date","citation_date"])??this.extractDetailMetaText(e)??""),l=this.cleanDoi(this.firstMetaContent(["citation_doi","prism.doi"])??this.extractDoi(e)??void 0),c=this.sanitizeJournalCandidate(this.firstMetaContent(["citation_journal_title","prism.publicationName"])??this.extractDetailJournal(e)??"",t),u=this.extractIssnFromPii(i)??this.normalizeIssn(this.firstMetaContent(["citation_issn","prism.issn"]));return{title:t,journalName:c||o[0]||"",journalCandidates:this.unique([c,...o].filter(Boolean)),authors:this.extractMetadataAuthors().length>0?this.extractMetadataAuthors():this.extractDomAuthors(e),year:this.extractYear(s),publicationDate:s||void 0,doi:l,sourceId:i?`cell-com:${i}`:l?`cell-com:${l}`:void 0,url:n,nativeFullTextUrl:r??n,abstractSnippet:this.cleanAbstract(this.firstMetaContent(["citation_abstract","description","og:description"])??this.extractDetailAbstract(e)),hostElement:e,articleTypes:this.extractDetailTypes(e),issn:u,volume:this.cleanText(this.firstMetaContent(["citation_volume"])??""),issue:this.cleanText(this.firstMetaContent(["citation_issue"])??""),pages:this.extractPagesFromMetadata(),source:this.id,citationType:"article"}}catch(t){return console.error("[CellComAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const i=this.findDetailIssueAnchor(e)??this.findDetailIssueAnchor(document.body);if(i)return{element:i,position:"after"};const o=this.findDetailMetaAnchor(e)??this.findDetailMetaAnchor(document.body);if(o)return{element:o,position:"after"};const s=e.querySelector("h1");return s?{element:s,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector('.result-meta, .search-result__meta, .journal-title, .publication-title, .meta, [class*="meta"]');if(t)return{element:t,position:"after"};const n=e.querySelector('.authors, .author-list, [class*="author"]');if(n)return{element:n,position:"after"};const r=e.querySelector('h2, h3, [class*="title"]');return r?{element:r,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(Dl)??document.querySelector("ol.search-results")??document.querySelector(".search-results")??document.querySelector("#search-results")??document.querySelector("main")??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"1",10)||1,r=this.cleanText(document.querySelector('.search-results-count, .results-found, .result__count, .search-result__count, [data-e2e="results-count"], main')?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0,o=this.getSearchResultHosts().length||void 0;return{pageNum:t,totalPages:i&&o?Math.max(1,Math.ceil(i/o)):1,itemsPerPage:o,totalItems:i,url:location.href}}getSearchResultHosts(){if(this.isChallengePage())return[];const e=Array.from(document.querySelectorAll(Dl)),t=e.length>0?e:[document.querySelector("main")??document.body];return this.uniqueElements(t.flatMap(n=>Array.from(n.querySelectorAll($m))).map(n=>this.toSearchResultHost(n)).filter(n=>!!n).filter(n=>this.looksLikeSearchResult(n)))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||e.closest('[id*="reference"], [class*="reference"], [id*="related"], [class*="related"]')?!1:!!this.findArticleLink(e)&&!!this.cleanText(e.textContent??"")}parseSearchHost(e){const t=this.findArticleLink(e),n=this.cleanText(t?.textContent??e.querySelector('h2, h3, .art_title, .hlFld-Title, .publication_title, [class*="title"]')?.textContent??"");if(!n)return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.toAbsoluteUrl(e.querySelector('a[href$=".pdf"], a[href*="/pdf"], a[data-track-action*="pdf"], a[href*="/pdf?"]')?.getAttribute("href")??""),o=this.extractPii(r??"")??this.extractPii(i??""),s=this.deriveJournalCandidatesFromUrl(r??""),l=this.cleanText(e.querySelector('time, .publication-date, .meta__epubDate, .epub-date, [class*="date"]')?.textContent??""),c=this.cleanDoi(e.querySelector('a[href*="doi.org/"]')?.getAttribute("href")??e.querySelector('a[href*="doi.org/"]')?.textContent??this.extractDoi(e)??void 0),u=this.cleanText(e.querySelector('.article-type, .publication-type, .result-type, .meta__type, [class*="type"]')?.textContent??""),d=this.sanitizeJournalCandidate(e.querySelector('.journal-title, .publication-title, .publication_title, .source-title, .meta__title, [class*="journal"]')?.textContent??"",n),p=l||this.cleanText(e.textContent??""),m=this.extractIssnFromPii(o);return{title:n,journalName:d||s[0]||"",journalCandidates:this.unique([d,...s].filter(Boolean)),authors:this.extractDomAuthors(e),year:this.extractYear(p),publicationDate:l||void 0,doi:c,sourceId:o?`cell-com:${o}`:c?`cell-com:${c}`:void 0,url:r,nativeFullTextUrl:i??r,hostElement:e,articleTypes:u?[u]:[],issn:m,source:this.id,citationType:"article"}}getDetailHost(){return document.querySelector("main")??document.querySelector("article")??document.body}findDetailMetaAnchor(e){const t=[".article-header__meta",".article-identifiers",".article-source",".publication-details",".doi","ul","p","div"];for(const n of t){const r=Array.from(e.querySelectorAll(n)).find(i=>/doi/i.test(this.cleanText(i.textContent??""))||!!i.querySelector('a[href*="doi.org/"]'));if(r)return r}return null}findDetailIssueAnchor(e){const t=this.uniqueElements([e instanceof Element?e:document.body,...Array.from(document.querySelectorAll("article, header, .article-header, .article-header__meta, .article-header__journal, .publication-details, .article-source, .article-identifiers"))]),n=[".publication-details",".article-header__meta",".article-source",".article-header__journal",".journal-reference",".article-citation",".article-identifiers",".article-source","li","p","div","span"];for(const r of t){for(const i of n){const o=Array.from(r.querySelectorAll(i)).find(s=>this.looksLikeIssueLine(s));if(o)return o}if(r instanceof Element&&this.looksLikeIssueLine(r))return r}return e instanceof Element&&this.looksLikeIssueLine(e)?e:null}findArticleLink(e){return e.querySelector('a[href*="/fulltext/"], a[href*="/abstract/"], .art_title a, .hlFld-Title a, .publication_title a, a[data-e2e*="title-link"]')}extractDomAuthors(e){const t=Array.from(e.querySelectorAll('.authors a, .author-list a, .meta__authors a, [class*="author"] a, .authors span, .author-list span, .meta__authors span')).map(r=>this.cleanText(r.textContent??"")).filter(Boolean).filter(r=>!/^and$/i.test(r));if(t.length>0)return this.unique(t);const n=this.cleanText(e.querySelector('.authors, .author-list, [class*="author"]')?.textContent??"");return n?this.unique(n.split(/\s*,\s*|\s+and\s+/i).map(r=>this.cleanText(r)).filter(Boolean)):[]}extractMetadataAuthors(){const e=Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(t=>this.cleanText(t.content)).filter(Boolean);return this.unique(e)}extractDetailJournal(e){const t=[".article-source",".journal__title",".journal-name",".journal-title",".publication-title",'[class*="journal"]'];for(const n of t){const r=this.cleanText(e.querySelector(n)?.textContent??"");if(r)return r}return null}extractDetailMetaText(e){return this.cleanText(e.querySelector(".article-header__meta, .publication-details, .article-identifiers")?.textContent??"")||null}extractDetailAbstract(e){return this.cleanText(e.querySelector('.abstract, .section-paragraph, [data-title="Abstract"], section[aria-labelledby*="abstract"]')?.textContent??"")}extractDetailTypes(e){const t=this.cleanText(this.firstMetaContent(["citation_article_type"])??e.querySelector('.article-type, .publication-type, .type, [class*="article-type"]')?.textContent??"");return t?[t]:[]}extractPagesFromMetadata(){const e=this.cleanText(this.firstMetaContent(["citation_firstpage"])??""),t=this.cleanText(this.firstMetaContent(["citation_lastpage"])??"");if(e)return t&&t!==e?`${e}-${t}`:e}extractPii(e){return this.cleanText(e).match(jm)?.[1]??void 0}extractIssnFromPii(e){const n=this.cleanText(e??"").match(qm);if(n)return`${n[1]}-${n[2].toUpperCase()}`}extractDoi(e){return this.cleanText(e.textContent??"").match(El)?.[0]}normalizeIssn(e){const n=this.cleanText(e??"").match(/\b\d{4}-?\d{3}[\dX]\b/i);if(!n)return;const r=n[0].replace(/-/g,"");return`${r.slice(0,4)}-${r.slice(4)}`}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}cleanJournalName(e){return this.cleanText(e).replace(/\b\d{4}\b/g," ").replace(/\s+/g," ").trim()}sanitizeJournalCandidate(e,t){const n=this.cleanJournalName(e);return n?n.toLowerCase()===this.cleanText(t).toLowerCase()?"":n:""}cleanAbstract(e){return this.cleanText(e).replace(/^Abstract\s*:?\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(El)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}extractYear(e){const t=this.cleanText(e??"").match(Bm);return t?Number.parseInt(t[1],10):void 0}toAbsoluteUrl(e){const t=this.cleanText(e);if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}toSearchResultHost(e){return e.closest(_l)??e.closest("article")??e}isChallengePage(){const e=this.cleanText(document.title);if(/^just a moment/i.test(e)||/请稍候/i.test(e)||document.querySelector('.cf-error-code, .cf-turnstile, iframe[src*="challenges.cloudflare.com"], script[src*="/cdn-cgi/challenge-platform/"]'))return!0;const t=this.cleanText(document.body?.textContent??"");return t.length>0&&/\b(?:enable javascript and cookies to continue|verify you are human|security check|access denied)\b/i.test(t)}looksLikeIssueLine(e){const t=this.cleanText(e.textContent??"");if(!t||t.length>240||/doi:/i.test(t)||e.querySelector('a[href*="doi.org/"]'))return!1;const n=this.cleanText(this.firstMetaContent(["citation_volume"])??""),r=this.cleanText(this.firstMetaContent(["citation_issue"])??""),i=this.cleanText(this.firstMetaContent(["citation_firstpage"])??""),o=this.cleanText(this.firstMetaContent(["citation_lastpage"])??""),s=o&&o!==i?`${i}-${o}`:i,l=n?new RegExp(`\\b(?:volume|vol\\.?)\\s*${this.escapeRegExp(n)}\\b`,"i").test(t):!1,c=r?new RegExp(`\\b(?:issue|no\\.?|number)\\s*${this.escapeRegExp(r)}\\b`,"i").test(t):!1,u=s?t.toLowerCase().includes(s.toLowerCase())||t.toLowerCase().includes(i.toLowerCase()):!1;return l&&c||l&&u||c&&u?!0:/\b(?:volume|vol\.?)\s*\d+/i.test(t)||/\bissue\s*\d+/i.test(t)||/\be\d{3,}\b/i.test(t)||/\b\d+\s*\(\d+\)\b/.test(t)}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}deriveJournalCandidatesFromUrl(e){const t=this.cleanText(e);if(!t)return[];try{const r=new URL(t,location.href).pathname.split("/").filter(Boolean),i=r.findIndex(s=>/^(?:fulltext|abstract)$/i.test(s)),o=i>0?r.slice(0,i):r.slice(0,1);return o.length===0?[]:o[0]?.toLowerCase()==="trends"&&o[1]?[`Trends in ${this.titleCaseSlug(o[1])}`]:[o.map(s=>this.titleCaseSlug(s)).join(" ")]}catch{return[]}}titleCaseSlug(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const Um=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,Hm=/\b((?:19|20)\d{2})\b/,zm=["li.search__item","article.search__item",".search__item","li.issue-item","article.issue-item",".issue-item",'[data-testid*="search-item"]','[data-test*="search-item"]',"article","li"].join(","),Jm=["main","article","#skip-to-main-content","body"].join(","),Vm=['a[href*="/doi/proceedings/"]','a[href*="/proceedings/"]','a[href*="/journal/"]','a[href*="/magazine/"]','a[href*="/doi/book/"]','a[href*="/book/"]'].join(",");class Wm extends W{id="acm-dl";name="ACM Digital Library";matches=["*://dl.acm.org/*"];isSearchPage(){return/^\/action\/doSearch\/?$/i.test(location.pathname)}isArticlePage(){return/^\/doi\/(?:abs\/)?10\.\d{4,9}\//i.test(location.pathname)?!0:/^\/doi\/(?:proceedings|book)\//i.test(location.pathname)?!1:!!this.firstMetaContent(["citation_title"])&&!!this.findDetailTitle()}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[AcmDigitalLibraryAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=document.querySelector(Jm);if(!e)return null;try{const t=this.cleanText(this.firstMetaContent(["citation_title","dc.title","og:title"])??this.findDetailTitle(e)?.textContent??"").replace(/\s*\|\s*ACM Digital Library\s*$/i,"");if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??this.firstMetaContent(["citation_public_url","og:url"])??location.href),r=this.cleanDoi(this.firstMetaContent(["citation_doi"])??this.findDoiLink(e)?.getAttribute("href")??this.findDoiLink(e)?.textContent??n??""),i=this.cleanText(this.findVenueLink(e)?.textContent??this.extractDetailVenueFromText(e)??""),o=this.cleanText(this.firstMetaContent(["citation_journal_title","citation_conference_title"])??i??""),s=this.cleanText(this.firstMetaContent(["citation_article_type"])??this.extractTopQualifier(e)??""),l=this.inferRecordKind(s,o,n??location.href),c=this.resolveVenueInfo(o,l),u=i||o,d=this.cleanText(this.firstMetaContent(["citation_publication_date","citation_online_date","dc.date"])??this.findPublicationLine(e)?.textContent??"");return{title:t,journalName:c.journalName,journalCandidates:c.candidates,authors:this.extractMetadataAuthors().length>0?this.extractMetadataAuthors():this.extractDetailAuthors(e),year:this.extractYear(d||o||s),publicationDate:d||void 0,doi:r,sourceId:r?`acm:${r}`:n?`acm:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.firstMetaContent(["description","og:description","dc.description"])??this.extractDetailAbstract(e)),hostElement:e,articleTypes:l.articleTypes,issn:this.normalizeIssn(this.firstMetaContent(["citation_issn"])),volume:this.extractVolume(u),issue:this.extractIssue(u),pages:this.extractPages(e),source:this.id,citationType:l.citationType}}catch(t){return console.error("[AcmDigitalLibraryAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDoiContainer(e);if(r)return{element:r,position:"after"};const i=this.findPagesContainer(e);if(i)return{element:i,position:"after"};const o=this.findVenueLink(e);if(o)return{element:o,position:"after"};const s=this.findDetailTitle(e);return s?{element:s,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector(".issue-item__detail, .search__item__meta, .meta, .publication_meta");if(t)return{element:t,position:"after"};const n=this.findSearchTitleLink(e);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".search-results, .search-result-list, .issue-items, main")??document.querySelector("main")??document.body}getPageInfo(){const t=this.cleanText(document.querySelector("main")?.textContent??"").match(/\b([\d,]+)\s+Results?\s+for\b/i),n=t?Number.parseInt(t[1].replace(/,/g,""),10):void 0,r=this.parseSearchResults().length||void 0;return{pageNum:1,totalPages:n&&r?Math.max(1,Math.ceil(n/r)):1,itemsPerPage:r,totalItems:n,url:location.href}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(zm)).filter(t=>this.looksLikeSearchResult(t));return this.uniqueElements(e)}looksLikeSearchResult(e){if(e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||!this.findSearchTitleLink(e))return!1;const n=this.cleanText(e.textContent??"");return/export citation|view online with ereader|pages?\s+\d|research-article|acm transactions|proceedings/i.test(n)}parseSearchHost(e){const t=this.findSearchTitleLink(e),n=this.cleanText(t?.textContent??"");if(!n)return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanText(this.findVenueLink(e)?.textContent??this.extractSearchVenueFromText(e)??""),o=this.cleanText(this.extractSearchType(e)??""),s=this.inferRecordKind(o,i,r??""),l=this.resolveVenueInfo(i,s),c=this.cleanText(this.extractSearchPublicationDate(e)??""),u=this.cleanDoi(e.querySelector('a[href*="doi.org/10."]')?.getAttribute("href")??e.querySelector('a[href*="doi.org/10."]')?.textContent??r??"");return{title:n,journalName:l.journalName,journalCandidates:l.candidates,authors:this.extractSearchAuthors(e),year:this.extractYear(c||i||o),publicationDate:c||void 0,doi:u,sourceId:u?`acm:${u}`:r?`acm:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.extractSearchAbstract(e)),hostElement:e,articleTypes:s.articleTypes,volume:this.extractVolume(i),issue:this.extractIssue(i),pages:this.extractPages(e),source:this.id,citationType:s.citationType}}findSearchTitleLink(e){const t=['h2 a[href^="/doi/10."]','h3 a[href^="/doi/10."]','h4 a[href^="/doi/10."]','h5 a[href^="/doi/10."]','.issue-item__title a[href^="/doi/10."]','.art_title a[href^="/doi/10."]','.hlFld-Title a[href^="/doi/10."]','a[href^="/doi/10."]'];for(const n of t){const r=e.querySelector(n);if(r&&!/^https?:\/\/doi\.org\//i.test(r.href)&&!/epdf|pdf/i.test(r.getAttribute("href")??""))return r}return null}findDetailTitle(e=document){return e.querySelector("h1")??e.querySelector(".citation__title, .article__title, .issue-item__title")}findVenueLink(e){return e.querySelector(Vm)}findDoiLink(e){return e.querySelector('a[href*="doi.org/10."]')}findDoiContainer(e){return this.findDoiLink(e)?.parentElement??null}findPagesContainer(e){return Array.from(e.querySelectorAll("div, p, li, span")).find(t=>/^Pages?\b/i.test(this.cleanText(t.textContent??"")))??null}findPublicationLine(e){return Array.from(e.querySelectorAll("div, p, li, span")).find(t=>/^Published\s*:/i.test(this.cleanText(t.textContent??"")))??null}extractTopQualifier(e){return Array.from(e.querySelectorAll("div, p, span")).map(n=>this.cleanText(n.textContent??"")).find(n=>/^(research|review|editorial|case|short|article|book)/i.test(n))||void 0}extractDetailVenueFromText(e){return Array.from(e.querySelectorAll("div, p, span")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).find(n=>/(?:proceedings|conference|transactions|computing surveys|journal|magazine)/i.test(n))}extractSearchVenueFromText(e){return Array.from(e.querySelectorAll("div, p, span")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).find(n=>/(?:proceedings|conference|transactions|computing surveys|journal|magazine|volume\s+\d+)/i.test(n))}extractSearchType(e){return Array.from(e.querySelectorAll("div, p, span")).map(n=>this.cleanText(n.textContent??"")).find(n=>/^(research-article|review-article|article|editorial|magazine article|book chapter|chapter|book)/i.test(n))||void 0}extractSearchPublicationDate(e){return Array.from(e.querySelectorAll("div, p, span")).map(n=>this.cleanText(n.textContent??"")).filter(Boolean).find(n=>/\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec|January|February|March|April|June|July|August|September|October|November|December)\b/i.test(n))}extractSearchAuthors(e){const t=Array.from(e.querySelectorAll('a[href*="/profile/"], a[href*="/author/"], .authors a, .issue-item__authors a, .author a')).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractMetadataAuthors(){return this.unique(Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(e=>this.cleanText(e.content)).filter(Boolean))}extractDetailAuthors(e){const t=Array.from(e.querySelectorAll('a[href*="/profile/"], a[href*="/author/"], .author-name, .authors a, button')).map(n=>this.cleanText(n.textContent??"")).filter(n=>!!n&&!/^(authors?\s*:|authors info & claims|share on)$/i.test(n));return this.unique(t)}extractSearchAbstract(e){return this.cleanText(e.querySelector(".abstract, .issue-item__abstract, .summary, p")?.textContent??"")}extractDetailAbstract(e){const t=Array.from(e.querySelectorAll("h2, h3, strong")).find(n=>/^abstract$/i.test(this.cleanText(n.textContent??"")));return t?.parentElement?this.cleanText(t.parentElement.textContent??""):this.cleanText(e.querySelector('.abstractSection, .abstract, [id*="abstract"]')?.textContent??"")}extractPages(e){return this.cleanText(this.findPagesContainer(e)?.textContent??"").match(/Pages?\s+(.+)$/i)?.[1]?.trim()||void 0}extractNativeFullTextUrl(e){const t=e.querySelector('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href*="/doi/reader/"], a[href*="/doi/full/"], a[href*="/doi/fullHtml/"]');if(t)return this.toAbsoluteUrl(t.getAttribute("href")??t.href??"");const n=Array.from(e.querySelectorAll("a")).find(r=>/^(?:download\s+pdf|pdf|view online with ereader|get access)$/i.test(this.cleanText(r.textContent??"")));return this.toAbsoluteUrl(n?.getAttribute("href")??n?.href??"")}resolveVenueInfo(e,t){const n=this.cleanVenue(e);if(!n)return{journalName:"",candidates:[]};const r=[n],i=n.match(/^(.*?)(?:,\s*Vol(?:ume)?\.?\s*\d+.*)$/i),o=i?.[1]?this.cleanVenue(i[1]):"";o&&r.push(o);const s=this.cleanVenue((o||n).replace(/\s*\(([^)]+)\)\s*/g," ").trim());if(s&&s!==o&&r.push(s),t.citationType==="inproceedings"){const l=n.match(/^([A-Z][A-Z0-9+&/-]{1,20})(?:\s*'\d{2})?\s*:/);l?.[1]&&r.unshift(this.cleanText(l[1]));const c=n.match(/\b(?:ACM\s+)?(SIG[A-Z0-9]+)\b/i);c?.[1]&&(r.unshift(c[1].toUpperCase()),r.push(`ACM ${c[1].toUpperCase()}`));const u=n.replace(/^[^:]+:\s*/,"");u&&u!==n&&r.push(this.cleanVenue(u))}return{journalName:t.metricsAllowed&&o||n,candidates:this.unique(r)}}inferRecordKind(e,t,n){const r=`${e} ${t} ${n}`.toLowerCase();return/proceedings|conference|symposium|workshop|sig(ir|kdd|mod|chi|graph|plan)|\b[kicnrvw][a-z]{1,8}\s*'\d{2}\b/.test(r)?{articleTypes:["Conference"],citationType:"inproceedings",metricsAllowed:!1}:/book chapter|chapter/.test(r)?{articleTypes:["Book Chapter"],citationType:"incollection",metricsAllowed:!1}:/\bbook\b/.test(r)?{articleTypes:["Book"],citationType:"book",metricsAllowed:!1}:/magazine/.test(r)?{articleTypes:["Magazine Article"],citationType:"article",metricsAllowed:!1}:{articleTypes:[this.cleanText(e)||"Journal Article"],citationType:"article",metricsAllowed:!0}}extractVolume(e){return this.cleanText(e).match(/\bVol(?:ume)?\.?\s*([A-Za-z0-9.-]+)/i)?.[1]}extractIssue(e){return this.cleanText(e).match(/\bIssue\s*([A-Za-z0-9.-]+)/i)?.[1]}cleanVenue(e){return this.cleanText(e).replace(/\s{2,}/g," ").replace(/\s+\|\s+.*$/i,"").trim()}normalizeIssn(e){const t=this.cleanText(e??"").toUpperCase();if(!(!t||t==="N/A"))return t}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}cleanAbstract(e){return this.cleanText(e).replace(/^Abstract\s*:?\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(Um)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}extractYear(e){const t=this.cleanText(e??"").match(Hm);return t?Number.parseInt(t[1],10):void 0}toAbsoluteUrl(e){const t=this.cleanText(e);if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const Gm=/\b10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i,Ym=/\b((?:18|19|20)\d{2})\b/;class Zm extends W{id="jstor";name="JSTOR";matches=["*://www.jstor.org/*","*://jstor.org/*"];isSearchPage(){return/^\/action\/doBasicSearch\/?$/i.test(location.pathname)}isArticlePage(){return!/^\/stable\/[^/?#]+/i.test(location.pathname)||/\/stable\/pdf\//i.test(location.pathname)?!1:!!(this.getStructuredRecord()||document.querySelector("main h1, article h1"))}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[JstorAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.getStructuredRecord(),n=this.cleanText(this.firstMetaContent(["citation_title","og:title"])??t?.headline??t?.name??e.querySelector("h1")?.textContent??"");if(!n)return null;const r=this.cleanText(this.firstMetaContent(["citation_article_type"])??this.extractDetailType(e)??this.structuredType(t)??""),i=this.structuredPartType(t),o=this.cleanText(this.structuredPartName(t)??""),s=this.cleanText(this.firstMetaContent(["citation_journal_title","citation_journal_abbrev"])??""),l=this.cleanText(this.extractDetailSourceLine(e)??""),c=this.cleanText(this.extractDetailVenueContext(e)??s??o??l),u=this.inferRecordKind(r,i,c||l),d=this.resolveVenueInfo(c||l,u),p=this.parseSourceMetadata(l||c),m=this.cleanText(this.firstMetaContent(["citation_publication_date","prism.publicationDate"])??t?.datePublished??this.extractDetailPublicationDate(e)??""),h=this.normalizeStableUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??t?.url??location.href),y=this.cleanDoi(this.firstMetaContent(["citation_doi"])??this.extractDoi(e)??this.extractStructuredDoi(t)??void 0),x=this.extractStableId(h??location.href);return{title:n,journalName:d.journalName||p.title,journalCandidates:d.candidates,authors:this.extractStructuredAuthors(t).length>0?this.extractStructuredAuthors(t):this.extractDetailAuthors(e),year:this.extractYear(m||l||c),publicationDate:m||void 0,doi:y,sourceId:x?`jstor:${x}`:void 0,url:h,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.firstMetaContent(["description","og:description"])??t?.description??this.extractDetailAbstract(e)),hostElement:e,articleTypes:u.articleTypes,issn:this.normalizeIssn(this.extractStructuredIssn(t)),volume:this.cleanText(this.structuredVolume(t)??p.volume??""),issue:this.cleanText(this.structuredIssue(t)??p.issue??""),pages:this.cleanText(t?.pagination??p.pages??""),source:this.id,citationType:u.citationType}}catch(t){return console.error("[JstorAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDoiContainer(e);if(r)return{element:r,position:"after"};const i=this.findDetailSourceElement(e);if(i)return{element:i,position:"after"};const o=e.querySelector("h1");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=this.findSearchSourceElement(e);if(t)return{element:t,position:"after"};const n=this.findSearchTitleLink(e);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector('[data-testid="search-results"], .search-results, .result-list, main')??document.querySelector("main")??document.body}getPageInfo(){const t=this.cleanText(document.querySelector("main")?.textContent??"").match(/\b([\d,]+)\s+results?\b/i),n=t?Number.parseInt(t[1].replace(/,/g,""),10):void 0,r=this.parseSearchResults().length||void 0;return{pageNum:1,totalPages:n&&r?Math.max(1,Math.ceil(n/r)):1,itemsPerPage:r,totalItems:n,url:location.href}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll('a[href*="/stable/"]')).filter(t=>this.isStableTitleLink(t)).map(t=>this.findSearchResultHost(t)).filter(t=>!!t).filter(t=>this.looksLikeSearchResult(t));return this.uniqueElements(e)}findSearchResultHost(e){const t=e.closest('article, li, .search-result, .result-item, [data-result], [data-result-item], [data-search-result], [role="listitem"]');if(t)return t;const n=this.getResultsContainer()??document.body;let r=e.parentElement,i=null;for(;r&&r!==document.body&&r!==document.documentElement;){if(this.isLikelySearchResultHost(r)&&(i??=r,this.findSearchActionContainer(r)))return r;if(r===n)break;r=r.parentElement}return i??e.parentElement}isLikelySearchResultHost(e){if(Array.from(e.querySelectorAll('a[href*="/stable/"]')).filter(i=>this.isStableTitleLink(i)).length!==1)return!1;if(this.findSearchActionContainer(e))return!0;const n=this.findBestSearchSourceElement(e);if(n&&n!==e)return!0;const r=this.cleanText(e.textContent??"");return/(journal article|book chapter|research report|read online|download|save to workspace|cite)/i.test(r)}looksLikeSearchResult(e){if(e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||!this.findSearchTitleLink(e))return!1;const t=this.cleanText(e.textContent??"");return/(journal article|book chapter|research report|book|read online|download|save to workspace|cite)/i.test(t)}parseSearchHost(e){const t=this.findSearchTitleLink(e),n=this.cleanText(t?.textContent??"");if(!n)return null;const r=this.normalizeStableUrl(t?.getAttribute("href")??t?.href??""),i=this.extractStableId(r??""),o=this.cleanText(this.extractSearchType(e)??""),s=this.cleanText(this.extractSearchSourceLine(e)??""),l=this.cleanText(this.extractSearchVenueContext(e)??s),c=this.inferRecordKind(o,"",l||s),u=this.resolveVenueInfo(l||s,c),d=this.parseSourceMetadata(s||l);return{title:n,journalName:u.journalName||d.title,journalCandidates:u.candidates,authors:this.extractSearchAuthors(e),year:this.extractYear(s||l),doi:this.cleanDoi(e.getAttribute("data-doi")??e.querySelector('a[href*="doi.org/10."]')?.href??e.querySelector('a[href*="doi.org/10."]')?.textContent??void 0),sourceId:i?`jstor:${i}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.extractSearchAbstract(e)),hostElement:e,articleTypes:c.articleTypes,volume:d.volume,issue:d.issue,pages:d.pages,source:this.id,citationType:c.citationType}}inferRecordKind(e,t,n){const r=`${e} ${t} ${n}`.toLowerCase();return/journal article|scholarlyarticle|periodical/.test(r)?{articleTypes:["Journal Article"],citationType:"article"}:/book chapter|chapter/.test(r)?{articleTypes:["Book Chapter"],citationType:"incollection"}:/research report|report/.test(r)?{articleTypes:["Research Report"],citationType:"misc"}:/\bbook\b/.test(r)?{articleTypes:["Book"],citationType:"book"}:/article/.test(r)?{articleTypes:["Journal Article"],citationType:"article"}:{articleTypes:[this.toTitleLabel(e||"Item")],citationType:"misc"}}resolveVenueInfo(e,t){const n=this.parseSourceMetadata(e),r=this.unique(n.candidates);return{journalName:t.citationType==="article"?n.title:n.title||this.cleanText(e),candidates:t.citationType==="article"?r:[]}}parseSourceMetadata(e){const t=this.cleanText(e).replace(/\s+,/g,",").replace(/\s+\)/g,")").replace(/https?:\/\/\S+/gi,"").replace(/<[^>]+>/g,"").replace(/\bnull\s*\(\d+\s+pages?\)/gi,"").replace(/\bPublished By:\s*/gi,"").trim();if(!t)return{title:"",candidates:[]};const n=this.cleanSourceTitle(t.replace(/,\s*Vol(?:ume)?\.?.*$/i,"").replace(/,\s*No\.?.*$/i,"").replace(/,\s*pp\.?.*$/i,"").replace(/\(\s*(?:Spring|Summer|Fall|Winter|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec|\d{4}).*$/i,"").trim()),r=[n];n.includes(":")&&(r.push(n.replace(/\s*:\s*/g,"-")),r.push(n.replace(/^.*?:\s*/,"")));const i=t.match(/\bVol(?:ume)?\.?\s*([A-Za-z0-9.-]+)/i)?.[1],o=t.match(/\bNo\.?\s*([A-Za-z0-9.-]+)/i)?.[1],s=t.match(/(?:^|,\s*)pp?\.?\s*([A-Za-z0-9.\-–—]+)/i)?.[1];return{title:n,candidates:this.unique(r.filter(Boolean)),volume:i,issue:o,pages:s}}cleanSourceTitle(e){return this.cleanText(e).replace(/^In\s+/i,"").replace(/\s+[|•·].*$/i,"").trim()}findSearchTitleLink(e){return Array.from(e.querySelectorAll('a[href*="/stable/"]')).find(t=>this.isStableTitleLink(t))??null}isStableTitleLink(e){const t=e.getAttribute("href")??e.href??"";return!/\/stable\/[^/?#]+/i.test(t)||/\/stable\/pdf\//i.test(t)?!1:this.cleanText(e.textContent??"").length>0}extractSearchType(e){return Array.from(e.querySelectorAll("div, p, span, li")).map(t=>this.cleanText(t.textContent??"")).find(t=>/^(journal article|book chapter|research report|book)$/i.test(t))}extractSearchSourceLine(e){return this.cleanText(this.findBestSearchSourceElement(e,{preferJournalLink:!1})?.textContent??"")||void 0}extractSearchVenueContext(e){return this.cleanText(this.findJournalLink(e)?.textContent??this.extractPublishedByText(e)??this.findBestSearchSourceElement(e)?.textContent??"")||void 0}findSearchSourceElement(e){return this.findJournalLink(e)??this.findBestSearchSourceElement(e,{preferJournalLink:!1})}extractSearchAuthors(e){const t=Array.from(e.querySelectorAll('.authors a, .result-authors a, [data-testid="authors"] a, a[href*="/action/doBasicSearch?Query=au:"]')).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractSearchAbstract(e){const t=e.querySelector(".abstract, .snippet, .summary, .item-snippet");return t?this.cleanText(t.textContent??""):this.cleanText(Array.from(e.querySelectorAll("p")).map(n=>this.cleanText(n.textContent??"")).find(n=>n.length>80)??"")}findBestSearchSourceElement(e,t){if(t?.preferJournalLink){const i=this.findJournalLink(e);if(i)return i}const n=e.querySelector('.source-line, .result-source, .citation, .item-details, .result-details, .item-meta, .src-line, [data-testid="source-line"]');return n||(Array.from(e.querySelectorAll("div, p, span, li")).map(i=>({element:i,text:this.cleanText(i.textContent??"")})).filter(({text:i})=>this.isLikelySearchSourceText(i)).sort((i,o)=>i.text.length-o.text.length)[0]?.element??null)}isLikelySearchSourceText(e){return!e||/(read online|save to workspace|cite|download)/i.test(e)||e.length>240?!1:/(?:\bVol\.?\b|\bNo\.?\b|\bpp?\.?\b|^In\b|^From:\b|Open Access\b|Published By:|Journal\b|Medical Journal\b|Press\b|University\b|Report\b|Corporation\b)/i.test(e)}findSearchActionContainer(e){const t=e.querySelector('.actions, .result-actions, .search-result__actions, .item-actions, [data-testid*="actions"], [class*="actions"]');if(t&&this.countSearchActionItems(t)>0)return t;const n=Array.from(e.querySelectorAll("button, a, span, div, li")).filter(o=>this.isSearchActionItem(o));if(n.length===0)return null;const r=n[0]?.parentElement;if(r&&n.every(o=>o.parentElement===r)&&r!==e)return r;let i=n[0]??null;for(;i?.parentElement&&i.parentElement!==e;){const o=i.parentElement;if(this.countSearchActionItems(o)!==n.length)break;i=o}return i&&i!==e?i:null}countSearchActionItems(e){return Array.from(e.querySelectorAll("button, a, span, div, li")).filter(t=>this.isSearchActionItem(t)).length}isSearchActionItem(e){const t=this.cleanText(e.textContent??"");return!t||t.length>48?!1:/^(read online|download|save(?: to workspace)?|cite|this content is not available for download)$/i.test(t)}getDetailHost(){return document.querySelector("main article")??document.querySelector("article")??document.querySelector("main")??document.body}extractDetailType(e){return Array.from(e.querySelectorAll("div, p, span")).map(t=>this.cleanText(t.textContent??"")).find(t=>/^(journal article|book chapter|research report|book)$/i.test(t))}extractDetailSourceLine(e){return this.cleanText(this.findBestDetailSourceElement(e,{preferJournalLink:!1})?.textContent??"")||void 0}extractDetailVenueContext(e){return this.cleanText(this.firstMetaContent(["citation_journal_title","citation_journal_abbrev"])??this.findJournalLink(e)?.textContent??this.extractPublishedByText(e)??this.findBestDetailSourceElement(e)?.textContent??"")||void 0}findDetailSourceElement(e){return this.findJournalLink(e)??this.findBestDetailSourceElement(e,{preferJournalLink:!1})}extractDetailPublicationDate(e){return Array.from(e.querySelectorAll("div, p, span, time")).map(t=>this.cleanText(t.textContent??"")).find(t=>/\b(?:18|19|20)\d{2}\b/.test(t))}extractDetailAuthors(e){const t=Array.from(e.querySelectorAll('.authors a, .contributors a, [data-testid="authors"] a, a[href*="/action/doBasicSearch?Query=au:"]')).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractDetailAbstract(e){return this.cleanText(e.querySelector('.abstract, .item-description, [data-testid="abstract"], .summary')?.textContent??"")}extractDoi(e){const t=e.querySelector('a[href*="doi.org/10."]');if(t)return this.cleanDoi(t.href)??this.cleanDoi(t.textContent??"");const n=this.cleanText(e.textContent??"");return this.cleanDoi(n)}findDoiContainer(e){const t=e.querySelector('a[href*="doi.org/10."]');return t?t.parentElement:Array.from(e.querySelectorAll("div, p, span, li")).find(n=>!!this.cleanDoi(n.textContent??""))??null}extractNativeFullTextUrl(e){const t=Array.from(e.querySelectorAll("a[href]")).find(n=>{const r=n.getAttribute("href")??n.href??"",i=this.cleanText(n.textContent??"");return/\/stable\/pdf\//i.test(r)||/^(download|read online)$/i.test(i)});return this.normalizeStableUrl(t?.getAttribute("href")??t?.href??"")}findBestDetailSourceElement(e,t){if(t?.preferJournalLink){const i=this.findJournalLink(e);if(i)return i}const n=e.querySelector('.source-line, .item-details, .citation, .item-meta, .src-line, [data-testid="source-line"]');return n||(Array.from(e.querySelectorAll("div, p, span, li, a")).map(i=>({element:i,text:this.cleanText(i.textContent??"")})).filter(({text:i})=>this.isLikelyDetailSourceText(i)).sort((i,o)=>i.text.length-o.text.length)[0]?.element??null)}isLikelyDetailSourceText(e){return!e||/(download|read online|save to workspace|cite|abstract|references)/i.test(e)||e.length>240?!1:/(?:\bVol\.?\b|\bNo\.?\b|\bpp?\.?\b|Published By:|Journal\b|Medical Journal\b|Review\b|Reports\b|Quarterly\b|Transactions\b|Press\b|University\b|Corporation\b)/i.test(e)}extractPublishedByText(e){const t=Array.from(e.querySelectorAll("div, p, span, li")).map(n=>this.cleanText(n.textContent??"")).find(n=>n.length<=160&&/Published By:/i.test(n));if(t)return this.cleanText(t.replace(/^.*?Published By:\s*/i,""))||void 0}findJournalLink(e){return Array.from(e.querySelectorAll('a[href*="/journal/"]')).find(t=>{const n=this.cleanText(t.textContent??"");return!!n&&!/^https?:\/\//i.test(n)&&!/\/journal\//i.test(n)})??null}getStructuredRecord(){for(const e of document.querySelectorAll('script[type="application/ld+json"]'))try{const t=JSON.parse(e.textContent??""),r=(Array.isArray(t)?t:[t,...t["@graph"]??[]]).find(i=>this.isStructuredRecord(i));if(r)return r}catch{continue}return null}isStructuredRecord(e){const t=this.structuredType(e);return/Article|ScholarlyArticle|Chapter|Book|Report|CreativeWork/i.test(t)||!!e.headline||!!e.name}structuredType(e){const t=e?.["@type"];return Array.isArray(t)?t.join(" "):t??""}structuredPartType(e){const t=e?.isPartOf;if(!t||typeof t=="string")return"";const n=t["@type"];return Array.isArray(n)?n.join(" "):n??""}structuredPartName(e){const t=e?.isPartOf;if(t)return typeof t=="string"?t:t.name}structuredVolume(e){const t=e?.isPartOf;if(!(!t||typeof t=="string"))return t.volumeNumber?String(t.volumeNumber):void 0}structuredIssue(e){const t=e?.isPartOf;if(!(!t||typeof t=="string"))return t.issueNumber?String(t.issueNumber):void 0}extractStructuredIssn(e){const t=e?.isPartOf;if(!t||typeof t=="string")return;const n=t.issn;return Array.isArray(n)?n[0]:n}extractStructuredAuthors(e){const t=e?.author;if(!t)return[];const n=Array.isArray(t)?t:[t];return this.unique(n.map(r=>typeof r=="string"?r:r.name??"").filter(Boolean))}extractStructuredDoi(e){const t=e?.identifier;if(!t)return;const n=Array.isArray(t)?t:[t];for(const r of n){if(typeof r=="string"){const o=this.cleanDoi(r);if(o)return o;continue}const i=this.cleanDoi(r.value??r.propertyID??"");if(i)return i}}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}extractStableId(e){const t=this.normalizeStableUrl(e);if(t)try{return new URL(t).pathname.match(/^\/stable\/([^/?#]+)/i)?.[1]}catch{return}}normalizeStableUrl(e){const t=this.cleanText(e??"");if(t)try{const n=new URL(t,location.href);return n.hash="",/\/stable\/pdf\//i.test(n.pathname)||/^\/stable\//i.test(n.pathname)&&(n.search=""),n.href}catch{return}}cleanAbstract(e){return this.cleanText(e??"").replace(/^abstract\s*:?\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(Gm)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}normalizeIssn(e){const t=this.cleanText(e??"").toUpperCase();if(!(!t||t==="N/A"))return t}toTitleLabel(e){const t=this.cleanText(e);return t?t.toLowerCase().replace(/\b\w/g,n=>n.toUpperCase()):""}extractYear(e){const t=this.cleanText(e??"").match(Ym);return t?Number.parseInt(t[1],10):void 0}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const Qm=/\b10\.\d{4,9}\/[^\s"'<>?#]+/i,Fl=/\b((?:19|20)\d{2})\b/;class Km extends W{id="mdpi";name="MDPI";matches=["*://www.mdpi.com/*"];isSearchPage(){return/^\/search\/?$/i.test(location.pathname)}isArticlePage(){return/^\/\d{4}-\d{4}\/\d+\/\d+\/\d+\/?$/i.test(location.pathname)&&!!(this.firstMetaContent(["citation_title","citation_journal_title"])||document.querySelector("main h1, article h1"))}parseSearchResults(){if(!this.isSearchPage())return[];const e=[],t=new Set;for(const n of this.getSearchResultHosts())try{const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;if(t.has(i))continue;t.add(i),e.push(r)}catch(r){console.error("[MdpiAdapter] Failed to parse search result:",r)}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.getDetailHost();if(!e)return null;try{const t=this.cleanText(this.firstMetaContent(["citation_title","og:title"])??e.querySelector("h1")?.textContent??"");if(!t)return null;const n=this.toAbsoluteUrl(document.querySelector('link[rel="canonical"]')?.getAttribute("href")??location.href),r=this.cleanText(this.queryText(e,[".source-line",".bib-identity",".html-published",".entry-meta",".article-citation"])??""),i=this.parseCitationLine(r),o=this.cleanDoi(this.firstMetaContent(["citation_doi"])??i.doi??this.queryText(e,['a[href*="doi.org/10."]'])??void 0),s=this.cleanText(this.firstMetaContent(["citation_journal_title"])??this.queryText(e,[".journal-title",".belongsTo a",".breadcrumb a"])??i.journalName),l=this.cleanText(this.firstMetaContent(["citation_publication_date","citation_online_date"])??this.extractPublicationDate(e)??"");return{title:t,journalName:s,journalCandidates:this.unique([s,i.journalName].filter(Boolean)),authors:this.extractMetadataAuthors().length>0?this.extractMetadataAuthors():this.extractDetailAuthors(e),year:i.year??this.extractYear(l),publicationDate:l||void 0,doi:o,sourceId:o?`mdpi:${o}`:n?`mdpi:${new URL(n).pathname}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.firstMetaContent(["citation_abstract","description","og:description"])??this.queryText(e,[".abstract","#abstract",".art-abstract"])??""),hostElement:e,articleTypes:[this.cleanTypeLabel(this.firstMetaContent(["citation_article_type"])??this.queryText(e,[".article-type",".type-label",".pubhistory .label"])??"Article")],issn:this.normalizeIssn(this.firstMetaContent(["citation_issn"])??this.extractIssnFromUrl(n??location.href)),volume:this.cleanText(this.firstMetaContent(["citation_volume"])??i.volume??""),issue:this.cleanText(this.firstMetaContent(["citation_issue"])??i.issue??""),pages:this.cleanText(this.firstMetaContent(["citation_firstpage"])??i.pages??""),source:this.id,citationType:"article"}}catch(t){return console.error("[MdpiAdapter] Failed to parse article page:",t),null}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=e.querySelector(".source-line, .bib-identity, .html-published, .entry-meta, .article-citation");if(r)return{element:r,position:"after"};const i=e.querySelector("h1");return i?{element:i,position:"after"}:{element:e,position:"prepend"}}const t=e.querySelector(".source-line, .entry-meta, .article-citation, .belongsTo");if(t)return{element:t,position:"after"};const n=this.findSearchTitleLink(e);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(".search-results, .article-list, main")??document.querySelector("main")??document.body}getPageInfo(){const t=this.cleanText(document.querySelector("main")?.textContent??"").match(/\(([\d,]+)\)/),n=t?Number.parseInt(t[1].replace(/,/g,""),10):void 0,r=this.parseSearchResults().length||void 0;return{pageNum:1,totalPages:n&&r?Math.max(1,Math.ceil(n/r)):1,itemsPerPage:r,totalItems:n,url:location.href}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll('a[href^="/"][href*="/"]')).filter(t=>this.isMdpiArticleLink(t)).map(t=>t.closest("article, li, .article-content, .entry, [data-result]")??t.parentElement).filter(t=>!!t).filter(t=>this.looksLikeSearchResult(t));return this.uniqueElements(e)}looksLikeSearchResult(e){if(e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||!this.findSearchTitleLink(e))return!1;const t=this.cleanText(e.textContent??"");return/(article pdf|https:\/\/doi\.org\/10\.|open access|article|review|editorial)/i.test(t)}parseSearchHost(e){const t=this.findSearchTitleLink(e),n=this.cleanText(t?.textContent??"");if(!n)return null;const r=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??""),i=this.cleanText(this.queryText(e,[".source-line",".entry-meta",".article-citation",".belongsTo"])??""),o=this.parseCitationLine(i),s=this.normalizeIssn(this.extractIssnFromUrl(r??"")),l=this.cleanText(this.queryText(e,[".article-type",".type-label",".oa",".label"])??"Article"),c=this.cleanDoi(o.doi??this.queryText(e,['a[href*="doi.org/10."]'])??void 0);return{title:n,journalName:this.cleanText(o.journalName),journalCandidates:this.unique([o.journalName].filter(Boolean)),authors:this.extractSearchAuthors(e),year:o.year,doi:c,sourceId:c?`mdpi:${c}`:r?`mdpi:${new URL(r).pathname}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e),abstractSnippet:this.cleanAbstract(this.queryText(e,[".abstract",".snippet",".summary"])??""),hostElement:e,articleTypes:[this.cleanTypeLabel(l)],issn:s,volume:o.volume,issue:o.issue,pages:o.pages,source:this.id,citationType:"article"}}findSearchTitleLink(e){return Array.from(e.querySelectorAll("a[href]")).find(t=>this.isMdpiArticleLink(t)&&this.cleanText(t.textContent??"").length>0)??null}isMdpiArticleLink(e){const t=e.getAttribute("href")??e.href??"";return/^\/\d{4}-\d{4}\/\d+\/\d+\/\d+\/?$/i.test(t)||/^https?:\/\/(?:www\.)?mdpi\.com\/\d{4}-\d{4}\/\d+\/\d+\/\d+\/?$/i.test(t)}getDetailHost(){return document.querySelector("main article")??document.querySelector("article")??document.querySelector("main")??document.body}extractSearchAuthors(e){const t=Array.from(e.querySelectorAll('.authors a, .author-list a, [class*="author"] a')).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractMetadataAuthors(){return this.unique(Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(e=>this.cleanText(e.content)).filter(Boolean))}extractDetailAuthors(e){const t=Array.from(e.querySelectorAll('.authors a, .art-authors a, .author-list a, [class*="author"] a')).map(n=>this.cleanText(n.textContent??"")).filter(Boolean);return this.unique(t)}extractPublicationDate(e){return Array.from(e.querySelectorAll("div, p, span, time")).map(t=>this.cleanText(t.textContent??"")).find(t=>/^published\s*:/i.test(t)||/^\d{1,2}\s+\w+\s+\d{4}$/i.test(t))}extractNativeFullTextUrl(e){const t=Array.from(e.querySelectorAll("a[href]")).find(r=>{const i=r.getAttribute("href")??r.href??"",o=this.cleanText(r.textContent??"");return/\/pdf$/i.test(i)||/^article pdf$/i.test(o)||/^download$/i.test(o)}),n=this.toAbsoluteUrl(t?.getAttribute("href")??t?.href??"");if(n)try{const r=new URL(n).hostname.toLowerCase();return r==="www.mdpi.com"||r==="mdpi.com"?n:void 0}catch{return}}extractIssnFromUrl(e){const t=this.toAbsoluteUrl(e);if(t)try{return new URL(t).pathname.match(/^\/(\d{4}-\d{4})\//)?.[1]}catch{return}}parseCitationLine(e){const t=this.cleanText(e).replace(/\s*;\s*/g,"; ").trim();if(!t)return{journalName:""};const n=this.cleanDoi(t),r=t.match(Fl),i=r?Number.parseInt(r[1],10):void 0,o=this.cleanText(r?t.slice(0,r.index).replace(/[,\s]+$/,""):t),s=r?t.slice((r.index??0)+r[0].length).trim():"",l=s.match(/^,\s*([A-Za-z0-9.-]+)/)?.[1],c=s.match(/\(\s*([A-Za-z0-9.-]+)\s*\)/)?.[1],u=s.match(/\)\s*,\s*([^;]+?)(?:;|$)/)?.[1]??s.match(/^,\s*[A-Za-z0-9.-]+\s*,\s*([^;]+?)(?:;|$)/)?.[1];return{journalName:o,year:i,volume:l,issue:c,pages:this.cleanText(u??""),doi:n}}firstMetaContent(e){for(const t of e){const n=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`),r=this.cleanText(n?.getAttribute("content")??"");if(r)return r}return null}queryText(e,t){for(const n of t){const r=e.querySelector(n),i=this.cleanText(r?.textContent??"");if(i)return i}}cleanTypeLabel(e){return this.cleanText(e).replace(/^open access\s*/i,"").replace(/\s+/g," ").trim()||"Article"}cleanAbstract(e){return this.cleanText(e).replace(/^abstract\s*:?\s*/i,"")||void 0}cleanDoi(e){const t=this.cleanText(e??"");return t?t.match(Qm)?.[0]?.replace(/[)>.,;]+$/,"").toLowerCase():void 0}normalizeIssn(e){const t=this.cleanText(e??"").toUpperCase();if(!(!t||t==="N/A"))return t}extractYear(e){const t=this.cleanText(e??"").match(Fl);return t?Number.parseInt(t[1],10):void 0}toAbsoluteUrl(e){const t=this.cleanText(e);if(t)try{return new URL(t,location.href).href}catch{return}}unique(e){return Array.from(new Set(e.map(t=>this.cleanText(t)).filter(Boolean)))}uniqueElements(e){return Array.from(new Set(e))}cleanText(e){return e.replace(/\u00a0/g," ").replace(/\s+/g," ").trim()}}const Xm=['a[href*="/journals/"][href*="/article/"]','a[href*="/article/"][href*="/abstract"]','a[href*="/article/"][href*="/fulltext"]'].join(","),zi=["li.search__item",".search__item",".search-result__item",".resultItem",".search-result","li.search-result-item","article"].join(","),kl=[".search-results",".searchResultList",'[aria-label="Search results"]',"main"].join(","),eb=["main article","#main-content article","article","main","#main-content","body"].join(","),tb=['[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','[class*="author" i], .authors','.article-header__meta, .publication-meta, [class*="ArticleHeader"], [class*="publication-meta" i]'],nb=['[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','[class*="author" i], .authors','.publication-title, [class*="journal-title" i], [class*="publication" i], [class*="meta" i], [class*="date" i]'],rb={ebiom:"eBioMedicine",eclinm:"eClinicalMedicine",lanafr:"The Lancet Regional Health \u2013 Africa",lanam:"The Lancet Regional Health \u2013 Americas",lancet:"The Lancet",lanchi:"The Lancet Child & Adolescent Health",landia:"The Lancet Diabetes & Endocrinology",landig:"The Lancet Digital Health",lanepe:"The Lancet Regional Health \u2013 Europe",langas:"The Lancet Gastroenterology & Hepatology",langlo:"The Lancet Global Health",lanhae:"The Lancet Haematology",lanhl:"The Lancet Healthy Longevity",lanhiv:"The Lancet HIV",laninf:"The Lancet Infectious Diseases",lanmic:"The Lancet Microbe",laneur:"The Lancet Neurology",lanogw:"The Lancet Obstetrics, Gynaecology, & Women's Health",lanonc:"The Lancet Oncology",lanplh:"The Lancet Planetary Health",lanprc:"The Lancet Primary Care",lanpsy:"The Lancet Psychiatry",lanpub:"The Lancet Public Health",lanres:"The Lancet Respiratory Medicine",lanrhe:"The Lancet Rheumatology",lansea:"The Lancet Regional Health \u2013 Southeast Asia",lanwpc:"The Lancet Regional Health \u2013 Western Pacific"};class ab extends W{id="lancet";name="The Lancet";matches=["*://www.thelancet.com/*","*://thelancet.com/*","*://www.lancet.com/*","*://lancet.com/*"];isSearchPage(){if(Ae())return!1;const e=location.pathname.toLowerCase();return e.startsWith("/action/dosearch")||e.startsWith("/search")||!this.isArticlePath(e)&&new URLSearchParams(location.search).has("searchText")}isArticlePage(){return Ae()||this.isSearchPage()?!1:this.isArticlePath(location.pathname)||!!_(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts()){const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;t.has(i)||(t.add(i),e.push(r))}return e}parseArticlePage(){if(Ae())return null;const e=document.querySelector(eb);if(!e)return null;const t=g(_(["citation_title","dc.title","og:title"])??e.querySelector("h1")?.textContent).replace(/\s*\|\s*The Lancet.*$/i,"");if(!t)return null;const n=jn(),r=this.extractPii(n??location.href),i=je(_(["citation_doi","prism.doi"]))??this.doiFromPii(r)??te(e.textContent),o=g(_(["citation_publication_date","citation_online_date","prism.publicationDate","article:published_time"])),s=this.journalFromUrl(n??location.href),l=g(_(["citation_journal_title","prism.publicationName"]))||s||this.extractJournalFromDom(e)||"The Lancet",c=this.extractPdfUrl(e,n);return{title:t,journalName:l,journalCandidates:this.buildJournalCandidates(l,s),authors:ct("citation_author"),year:Ze(o),publicationDate:o||void 0,doi:i,sourceId:r?`lancet:${r}`:i?`lancet:${i}`:void 0,url:n,nativeFullTextUrl:c,abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),issn:g(_(["citation_issn","prism.issn"])),volume:g(_(["citation_volume"])),issue:g(_(["citation_issue"])),pages:this.extractPages(),source:this.id,citationType:"article"}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findAnchorByPriority(e,tb);if(r)return{element:r,position:"after"};const i=e.querySelector("h1");return i?{element:i,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchorByPriority(e,nb);if(t)return{element:t,position:"after"};const n=e.querySelector('h2, h3, .hlFld-Title, .art_title, [class*="title"]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(kl)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??e.get("startPage")??"1",10)||1,r=g(document.querySelector('[class*="result-count"], [class*="results-count"], main')?.textContent).match(/\b([\d,]+)\s+results?\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/20)):1,url:location.href,itemsPerPage:20,totalItems:i}}isArticlePath(e){return/\/journals\/[^/]+\/article\//i.test(e)}getSearchResultHosts(){return Y(Array.from(document.querySelectorAll(zi)).map(e=>this.toSearchHost(e)).filter(e=>!!e).filter(e=>this.looksLikeSearchResult(e)))}toSearchHost(e){return e.matches(zi)&&this.looksLikeSearchResult(e,!1)?e:e.closest(zi)}looksLikeSearchResult(e,t=!0){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||t&&!e.closest(kl)?!1:!!this.findArticleLink(e)}parseSearchHost(e){const t=this.findArticleLink(e),n=g(t?.textContent??e.querySelector('h2, h3, .hlFld-Title, .art_title, [class*="title"]')?.textContent);if(!n)return null;const r=H(t?.getAttribute("href")),i=this.extractPii(r??"")??this.extractPii(e.textContent??""),o=te(e.textContent)??this.doiFromPii(i),s=this.journalFromUrl(r??""),l=this.extractJournalFromDom(e)||s||"The Lancet";return{title:n,journalName:l,journalCandidates:this.buildJournalCandidates(l,s),authors:this.extractAuthorsFromDom(e),year:Ze(e.textContent),doi:o,sourceId:i?`lancet:${i}`:o?`lancet:${o}`:void 0,url:r,nativeFullTextUrl:this.extractPdfUrl(e,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),source:this.id,citationType:"article"}}findArticleLink(e){return Array.from(e.querySelectorAll(Xm)).find(t=>!/\.pdf(?:[?#]|$)|\/pdfs\//i.test(t.href))??null}extractPii(e){const t=e.match(/\bPII([A-Z0-9()\-]+)\b/i)??e.match(/\b(S\d{4}-?\d{3}[\dX]\(\d{2}\)\d{5}-\d)\b/i);return t?(t[1].toUpperCase().startsWith("PII")?t[1]:`PII${t[1]}`).replace(/\.pdf$/i,""):void 0}doiFromPii(e){if(!e)return;const t=e.replace(/^PII/i,"");return/^S/i.test(t)?`10.1016/${t}`:void 0}journalFromUrl(e){if(/\/medical-imaging-theranostics(?:\/|$)/i.test(e))return"The Lancet Medical Imaging & Theranostics";if(/\/regional-health\/eastern-mediterranean(?:\/|$)/i.test(e))return"The Lancet Regional Health \u2013 Eastern Mediterranean";const t=e.match(/\/journals\/([^/]+)\//i)?.[1]?.toLowerCase();return t?rb[t]:void 0}extractPdfUrl(e,t){const n=H(_(["citation_pdf_url"]));if(n)return n;const r=H(e.querySelector('a[href*="/pdfs/"], a[href$=".pdf"]')?.getAttribute("href"));if(r)return r;const i=this.extractPii(t??location.href),o=(t??location.href).match(/\/journals\/([^/]+)\//i)?.[1];if(!(!i||!o))return H(`/pdfs/journals/${o}/${i}.pdf`)}extractJournalFromDom(e){return g(e.querySelector('[class*="journal-title"], [class*="journalTitle"], .publication-title, [data-test*="journal"]')?.textContent)||void 0}extractAuthorsFromDom(e){return Y(Array.from(e.querySelectorAll('[class*="author"] a, [class*="author-name"], .authors a')).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|view/i.test(t)))}extractAbstract(e){return g(_(["citation_abstract","description","og:description"])??Qe(e))||void 0}extractArticleTypes(e){const t=g(e.querySelector('[class*="article-type"], [class*="ArticleType"], [data-test*="article-type"]')?.textContent);return t?[t]:[]}extractPages(){const e=g(_(["citation_firstpage"])),t=g(_(["citation_lastpage"]));return e&&t&&e!==t?`${e}-${t}`:e||void 0}buildJournalCandidates(...e){const t=[],n=r=>{const i=g(r);i&&(t.push(i),/^the\s+lancet\b/i.test(i)&&t.push(i.replace(/^the\s+/i,"")))};return e.forEach(n),Y(t)}findAnchorByPriority(e,t){for(const n of t){const i=Array.from(e.querySelectorAll(n)).filter(o=>!o.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(o=>g(o.textContent).length>0||o instanceof HTMLAnchorElement).at(-1);if(i)return i}return null}}const ib=['a[href*="/content/"]','a[href*="/lookup/doi/"]'].join(","),Ji=[".highwire-article-citation",".search-result",".search-results__item","li.search-result",".result-item","article"].join(","),Ll=[".search-results","#search-results",".highwire-search-results",'[aria-label="Search results"]',"main"].join(","),ob=["main article","#main-content article","article","#content","main","body"].join(","),sb=['[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','.article-metadata, .highwire-cite-metadata, [class*="article-meta" i]'],lb=[".contrib-group",".contrib-list",".contributor-list",".contributors-list",".highwire-cite-authors",".highwire-citation-authors",".contributors",".authors",".article-authors",".loa-authors",'[class*="author-list" i]','[class*="authors" i]','[class*="contrib-group" i]','[class*="contrib-list" i]','[class*="contributor-list" i]','[class*="contributors" i]',".highwire-citation-author",'[class*="author-name" i]'].join(","),cb=['[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','.highwire-citation-authors, .contributors, .authors, [class*="author" i]','.highwire-cite-metadata, .search-result__meta, [class*="citation" i], [class*="meta" i]'],ub={adc:"Archives of Disease in Childhood",ard:"Annals of the Rheumatic Diseases",bjsm:"British Journal of Sports Medicine",bmj:"The BMJ",bmjopen:"BMJ Open",bmjmedicine:"BMJ Medicine",bmjmilitaryhealth:"BMJ Military Health",bmjophth:"BMJ Open Ophthalmology",bmjpaedsopen:"BMJ Paediatrics Open",casereports:"BMJ Case Reports",ebm:"BMJ Evidence-Based Medicine",emj:"Emergency Medicine Journal",fg:"Frontline Gastroenterology",gut:"Gut",heart:"Heart",jech:"Journal of Epidemiology & Community Health",jme:"Journal of Medical Ethics",jnnp:"Journal of Neurology, Neurosurgery & Psychiatry",openheart:"Open Heart",rapm:"Regional Anesthesia & Pain Medicine",sti:"Sexually Transmitted Infections",thorax:"Thorax",tobaccocontrol:"Tobacco Control"};class db extends W{id="bmj";name="BMJ Journals";matches=["*://www.bmj.com/content/*","*://www.bmj.com/search*","*://*.bmj.com/content/*","*://*.bmj.com/search*"];isSearchPage(){if(Ae())return!1;const e=location.pathname.toLowerCase();return e.startsWith("/search")||!this.isArticlePagePath(e)&&new URLSearchParams(location.search).has("query")}isArticlePage(){return Ae()||this.isSearchPagePath(location.pathname)?!1:this.isArticlePagePath(location.pathname)||!!_(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts()){const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;t.has(i)||(t.add(i),e.push(r))}return e}parseArticlePage(){if(Ae())return null;const e=document.querySelector(ob);if(!e)return null;const t=g(_(["citation_title","dc.title","og:title"])??e.querySelector("h1")?.textContent).replace(/\s*\|\s*BMJ.*$/i,"");if(!t)return null;const n=jn(),r=g(_(["citation_publication_date","citation_online_date","article:published_time","dc.Date"])),i=je(_(["citation_doi","dc.Identifier","prism.doi"]))??this.doiFromArticleUrl(n??location.href)??te(e.textContent),o=this.journalFromHost(location.hostname),s=g(_(["citation_journal_title","prism.publicationName"]))||this.extractJournalFromDom(e)||o||"BMJ Journals",l=this.extractPdfUrl(e,n);return{title:t,journalName:s,journalCandidates:this.buildJournalCandidates(s,o),authors:ct("citation_author").length>0?ct("citation_author"):this.extractAuthorsFromDom(e),year:Ze(r),publicationDate:r||void 0,doi:i,sourceId:i?`bmj:${i}`:n?`bmj:${n}`:void 0,url:n,nativeFullTextUrl:l,abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),issn:g(_(["citation_issn","prism.issn"])),volume:g(_(["citation_volume"])),issue:g(_(["citation_issue"])),pages:this.extractPages(),source:this.id,citationType:"article"}}getMetricBarAnchor(e){if(this.isArticlePage()){if(this.isMainSiteHost(location.hostname)){const s=this.findMainSiteAcceptedAnchor(e);if(s)return{element:s,position:"after"}}const r=this.findDetailAuthorAnchor(e);if(r)return{element:r,position:"after"};const i=this.findAnchorByPriority(e,sb);if(i)return{element:i,position:"after"};const o=e.querySelector("h1");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchorByPriority(e,cb);if(t)return{element:t,position:"after"};const n=e.querySelector('h2, h3, .highwire-cite-title, [class*="title"]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(Ll)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??"1",10)||1,r=g(document.querySelector('[class*="result-count"], [class*="results-count"], main')?.textContent).match(/\b([\d,]+)\s+results?\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/10)):1,url:location.href,itemsPerPage:10,totalItems:i}}isSearchPagePath(e){return e.toLowerCase().startsWith("/search")}isArticlePagePath(e){return/^\/content\//i.test(e)&&!/\.pdf$/i.test(e)}getSearchResultHosts(){return Y(Array.from(document.querySelectorAll(Ji)).map(e=>this.toSearchHost(e)).filter(e=>!!e).filter(e=>this.looksLikeSearchResult(e)))}toSearchHost(e){return e.matches(Ji)&&this.looksLikeSearchResult(e,!1)?e:e.closest(Ji)}looksLikeSearchResult(e,t=!0){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||t&&!e.closest(Ll)?!1:!!this.findArticleLink(e)}parseSearchHost(e){const t=this.findArticleLink(e),n=g(t?.textContent??e.querySelector('h2, h3, .highwire-cite-title, [class*="title"]')?.textContent);if(!n)return null;const r=H(t?.getAttribute("href")),i=te(e.textContent)??this.doiFromArticleUrl(r??""),o=this.journalFromHost(r?new URL(r).hostname:location.hostname),s=this.extractJournalFromDom(e)||o||"BMJ Journals";return{title:n,journalName:s,journalCandidates:this.buildJournalCandidates(s,o),authors:this.extractAuthorsFromDom(e),year:Ze(e.textContent),doi:i,sourceId:i?`bmj:${i}`:r?`bmj:${r}`:void 0,url:r,nativeFullTextUrl:this.extractPdfUrl(e,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),source:this.id,citationType:"article"}}findArticleLink(e){return Array.from(e.querySelectorAll(ib)).find(t=>!/\.pdf(?:[?#]|$)/i.test(t.href))??null}doiFromArticleUrl(e){const t=H(e);if(!t)return;const r=new URL(t).pathname.split("/").filter(Boolean).at(-1);if(!(!r||r.includes(".")||/^\d+$/.test(r)))return/^10\./i.test(r)?je(r):/^[a-z][a-z0-9-]+-\d{4}-\d+/i.test(r)?`10.1136/${r}`:void 0}extractPdfUrl(e,t){const n=H(_(["citation_pdf_url"]));if(n)return n;const r=H(e.querySelector('a[href*=".full.pdf"], a[href$=".pdf"], a[href*="/content/"][href*="pdf"]')?.getAttribute("href"));if(r)return r;const i=H(t);if(!i)return;const o=new URL(i);if(!(!/^\/content\//i.test(o.pathname)||/\.pdf$/i.test(o.pathname)))return`${o.origin}${o.pathname}.full.pdf`}journalFromHost(e){const t=e.replace(/^www\./,"").replace(/\.bmj\.com$/i,"").toLowerCase();return this.isMainSiteHost(e)?"The BMJ":ub[t]??this.titleCaseSubdomain(t)}isMainSiteHost(e){return e.replace(/^www\./,"").toLowerCase()==="bmj.com"}titleCaseSubdomain(e){if(!(!e||e==="journals")&&/^bmj/.test(e))return e.replace(/^bmj/,"BMJ ").replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase())}extractJournalFromDom(e){return g(e.querySelector('.journal-title, .highwire-cite-journal, [class*="journal-title"], [class*="journalTitle"]')?.textContent)||void 0}extractAuthorsFromDom(e){return Y(Array.from(e.querySelectorAll([".highwire-citation-author",".highwire-cite-authors a",".highwire-citation-authors a",".contributors a",".authors a",'[class*="author-name" i]'].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|view/i.test(t)))}extractAbstract(e){return g(_(["citation_abstract","description","og:description"])??Qe(e))||void 0}extractArticleTypes(e){const t=g(e.querySelector('.article-type, .highwire-cite-metadata-article-type, [class*="article-type"]')?.textContent);return t?[t]:[]}extractPages(){const e=g(_(["citation_firstpage"])),t=g(_(["citation_lastpage"]));return e&&t&&e!==t?`${e}-${t}`:e||void 0}findDetailAuthorAnchor(e){const t=e.querySelector("h1"),n=this.findAnchorByPriority(e,['[class*="doi" i], [id*="doi" i], a[href*="doi.org"]']);return Y(Array.from(e.querySelectorAll(lb)).map(i=>this.normalizeAuthorAnchor(i)).filter(i=>!i.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(i=>g(i.textContent).length>0).filter(i=>!t||this.isAfter(i,t)).filter(i=>!n||this.isBefore(i,n))).at(-1)??null}findMainSiteAcceptedAnchor(e){const t=e.querySelector("h1");return Y(Array.from(e.querySelectorAll("p, li, div, span, dd, dt")).filter(r=>!r.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(r=>this.isAcceptedDateText(g(r.textContent))).map(r=>this.normalizeAcceptedAnchor(r,e)).filter(r=>!t||this.isAfter(r,t)).filter(r=>this.isAcceptedAnchorCandidate(r))).sort((r,i)=>this.scoreAcceptedAnchor(i)-this.scoreAcceptedAnchor(r)).at(0)??null}normalizeAcceptedAnchor(e,t){let n=e;for(;n.parentElement&&n.parentElement!==t;){const r=n.parentElement,i=g(r.textContent);if(!this.isAcceptedDateText(i)||i.length>180||!this.isInlineElement(n)&&!/^accepted\b/i.test(i))break;n=r}return n}isAcceptedAnchorCandidate(e){const t=g(e.textContent);return t.length===0||t.length>180||e.querySelector("h1, h2, h3, h4, h5, h6, nav, table")?!1:this.isAcceptedDateText(t)}scoreAcceptedAnchor(e){const t=g(e.textContent);let n=0;return/^accepted\b/i.test(t)&&(n+=100),/^(p|li|div|dd|dt)$/i.test(e.tagName)&&(n+=30),this.isInlineElement(e)&&(n-=20),n-=Math.min(t.length,180)/10,n}isAcceptedDateText(e){return/\baccepted\s+(?:\d{1,2}\s+[A-Za-z]+\s+\d{4}|[A-Za-z]+\s+\d{1,2},?\s+\d{4}|\d{4}[-/]\d{1,2}[-/]\d{1,2})\b/i.test(e)}isInlineElement(e){return/^(a|span|strong|em|b|i|small|sup|sub)$/i.test(e.tagName)}normalizeAuthorAnchor(e){return e.closest([".contrib-group",".contrib-list",".contributor-list",".contributors-list",".highwire-cite-authors",".highwire-citation-authors",".contributors",".authors",".article-authors",".loa-authors",'[class*="author-list" i]','[class*="authors" i]','[class*="contrib-group" i]','[class*="contrib-list" i]','[class*="contributor-list" i]','[class*="contributors" i]'].join(","))??e}isBefore(e,t){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)}isAfter(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}buildJournalCandidates(...e){const t=[],n=r=>{const i=g(r);i&&(t.push(i),(/^the\s+bmj$/i.test(i)||/^bmj$/i.test(i))&&(t.push("BMJ"),t.push("BMJ-British Medical Journal"),t.push("British Medical Journal")))};return e.forEach(n),Y(t)}findAnchorByPriority(e,t){for(const n of t){const i=Array.from(e.querySelectorAll(n)).filter(o=>!o.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(o=>g(o.textContent).length>0||o instanceof HTMLAnchorElement).at(-1);if(i)return i}return null}}const pb=['a[href*="/doi/full/"]','a[href*="/doi/abs/"]','a[href*="/doi/"]'].join(","),Vi=["article",".search-result",".search-results__item",".result-item",'li[class*="result" i]','[class*="search-result" i]'].join(","),Nl=[".search-results","#search-results",'[aria-label="Search results"]',"main"].join(","),hb=["main article","#main-content article","article","main","#main-content","body"].join(","),fb=[".article-citation",'[data-testid*="citation" i]','[data-test*="citation" i]','[class*="citation"]','[class*="citation" i]','[class*="article-meta" i]','[class*="article-info" i]','[class*="metadata" i]','[class*="doi" i], [id*="doi" i], a[href*="doi.org"]'],mb=[".search-result__meta, .article-citation",'[class*="citation"], [class*="meta"], [class*="publication"], [class*="date"]','[class*="citation" i], [class*="meta" i], [class*="publication" i], [class*="date" i]','[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','[class*="author" i], .authors'];class bb extends W{id="nejm";name="NEJM";matches=["*://www.nejm.org/*","*://nejm.org/*"];isSearchPage(){if(Ae())return!1;const e=location.pathname.toLowerCase();return e.startsWith("/search")||e.startsWith("/action/dosearch")}isArticlePage(){return Ae()||this.isSearchPage()?!1:this.isArticlePath(location.pathname)||!!_(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts()){const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;t.has(i)||(t.add(i),e.push(r))}return e}parseArticlePage(){if(Ae())return null;const e=document.querySelector(hb);if(!e)return null;const t=g(_(["citation_title","dc.title","DC.Title","og:title"])??e.querySelector("h1")?.textContent).replace(/\s*\|\s*(?:NEJM|New England Journal of Medicine).*$/i,"");if(!t)return null;const n=jn(),r=je(_(["citation_doi","dc.Identifier","DC.Identifier","prism.doi"]))??this.doiFromUrl(n??location.href)??te(e.textContent),i=g(_(["citation_publication_date","citation_online_date","prism.publicationDate","article:published_time"])),o=g(_(["citation_journal_title","prism.publicationName","og:site_name"]))||this.extractJournalFromDom(e)||"New England Journal of Medicine";return{title:t,journalName:o,journalCandidates:this.buildJournalCandidates(o),authors:ct("citation_author").length>0?ct("citation_author"):this.extractAuthorsFromDom(e),year:Ze(i||e.textContent),publicationDate:i||void 0,doi:r,sourceId:r?`nejm:${r}`:n?`nejm:${n}`:void 0,url:n,nativeFullTextUrl:this.extractPdfUrl(e,n),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),issn:g(_(["citation_issn","prism.issn"])),volume:g(_(["citation_volume"])),issue:g(_(["citation_issue"])),pages:this.extractPages(),source:this.id,citationType:"article"}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDetailCitationAnchor(e);if(r)return{element:r,position:"after"};const i=this.findAnchorByPriority(e,fb);if(i)return{element:i,position:"after"};const o=e.querySelector("h1");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchorByPriority(e,mb);if(t)return{element:t,position:"after"};const n=e.querySelector('h2, h3, [class*="title" i]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(Nl)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??e.get("startPage")??"1",10)||1,r=g(document.querySelector('[class*="result-count" i], [class*="results-count" i], main')?.textContent).match(/\b([\d,]+)\s+results?\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/20)):1,url:location.href,itemsPerPage:20,totalItems:i}}isArticlePath(e){return/^\/doi\/(?:full|abs|pdf|epdf)?\/?10\./i.test(e)}getSearchResultHosts(){return Y(Array.from(document.querySelectorAll(Vi)).map(e=>this.toSearchHost(e)).filter(e=>!!e).filter(e=>this.looksLikeSearchResult(e)))}toSearchHost(e){return e.matches(Vi)&&this.looksLikeSearchResult(e,!1)?e:e.closest(Vi)}looksLikeSearchResult(e,t=!0){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||t&&!e.closest(Nl)?!1:!!this.findArticleLink(e)}parseSearchHost(e){const t=this.findArticleLink(e),n=g(t?.textContent??e.querySelector('h2, h3, [class*="title" i]')?.textContent);if(!n)return null;const r=H(t?.getAttribute("href")),i=this.doiFromUrl(r??"")??te(e.textContent),o=this.extractJournalFromDom(e)||"New England Journal of Medicine";return{title:n,journalName:o,journalCandidates:this.buildJournalCandidates(o),authors:this.extractAuthorsFromDom(e),year:Ze(e.textContent),doi:i,sourceId:i?`nejm:${i}`:r?`nejm:${r}`:void 0,url:r,nativeFullTextUrl:this.extractPdfUrl(e,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),source:this.id,citationType:"article"}}findArticleLink(e){return Array.from(e.querySelectorAll(pb)).find(t=>!/\/doi\/(?:pdf|epdf)\//i.test(t.href))??null}doiFromUrl(e){const t=H(e);if(!t)return;const r=new URL(t).pathname.match(/\/doi\/(?:full|abs|pdf|epdf)?\/?(10\.\d{4,9}\/.+)$/i);if(r)try{return je(decodeURIComponent(r[1]))}catch{return je(r[1])}}extractPdfUrl(e,t){const n=H(_(["citation_pdf_url"]));if(n)return n;const r=H(e.querySelector('a[href*="/doi/pdf/"], a[href*="/doi/epdf/"], a[href$=".pdf"]')?.getAttribute("href"));if(r)return r;const i=this.doiFromUrl(t??location.href)??te(e.textContent);return i?H(`/doi/pdf/${i}`):void 0}extractJournalFromDom(e){const t=g(e.querySelector(['[class*="journal-title" i]','[class*="journalTitle" i]','[data-testid*="journal" i]','[data-test*="journal" i]','[class*="publication" i]','[class*="citation" i]','[class*="meta" i]'].join(","))?.textContent),n=this.extractJournalFromCitationText(t)??this.extractJournalFromCitationText(e.textContent);if(n)return n;if(t)return/^nejm$/i.test(t)?"New England Journal of Medicine":t}extractJournalFromCitationText(e){const t=g(e);if(/\bN\s*Engl\s*J\s*Med\b/i.test(t))return"N Engl J Med";if(/\bNew\s+England\s+Journal\s+of\s+Medicine\b/i.test(t)||/^NEJM\b/i.test(t))return"New England Journal of Medicine"}extractAuthorsFromDom(e){return Y(Array.from(e.querySelectorAll(['[class*="author" i] a','[class*="author-name" i]','[data-testid*="author" i]',".authors a"].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|view/i.test(t)))}extractAbstract(e){return g(_(["citation_abstract","description","og:description"])??Qe(e))||void 0}extractArticleTypes(e){const t=g(e.querySelector('[class*="article-type" i], [data-test*="article-type" i]')?.textContent);return t?[t]:[]}extractPages(){const e=g(_(["citation_firstpage"])),t=g(_(["citation_lastpage"]));return e&&t&&e!==t?`${e}-${t}`:e||void 0}findDetailCitationAnchor(e){const t=e.querySelector("h1");return Y(Array.from(e.querySelectorAll("p, div, section, header, span")).map(r=>this.normalizeCitationAnchor(r,e)).filter(r=>!r.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(r=>!t||this.isAfter(r,t)).filter(r=>this.isCitationAnchorCandidate(r))).sort((r,i)=>this.scoreCitationAnchor(i)-this.scoreCitationAnchor(r)).at(0)??null}normalizeCitationAnchor(e,t){let n=e;for(;n.parentElement&&n.parentElement!==t;){const r=n.parentElement;if(r.matches("article, main, body"))break;const i=g(r.textContent);if(i.length>260||!this.hasCitationSignals(i))break;n=r}return n}isCitationAnchorCandidate(e){const t=g(e.textContent);return e.matches("article, main, body")||!t||t.length>260||e.querySelector("h1, h2, h3, h4, h5, h6, nav, table")?!1:this.hasCitationSignals(t)}scoreCitationAnchor(e){const t=g(e.textContent);let n=0;return(/\bdoi\b/i.test(t)||te(t))&&(n+=80),(/\bdoi\b/i.test(t)||te(t))&&/\b(?:vol(?:ume)?|no\.?|issue)\b/i.test(t)&&(n+=60),/\bN\s*Engl\s*J\s*Med\b/i.test(t)&&(n+=70),/\b(?:19|20)\d{2}\s*;\s*\d+/i.test(t)&&(n+=40),/\b(?:vol(?:ume)?|issue)\b/i.test(t)&&(n+=20),/(citation|article-meta|article-info|metadata|doi)/i.test(e.getAttribute("class")??"")&&(n+=25),/^(p|div|section|header)$/i.test(e.tagName)&&(n+=15),n-=Math.min(t.length,260)/20,n}hasCitationSignals(e){return!!(te(e)||/\bdoi\b/i.test(e)||/\bN\s*Engl\s*J\s*Med\b/i.test(e)||/\bNEJM\b/i.test(e))}buildJournalCandidates(...e){const t=[],n=r=>{const i=g(r);i&&(t.push(i),/^(?:nejm|n\s*engl\s*j\s*med|new england journal of medicine)$/i.test(i)&&(t.push("New England Journal of Medicine"),t.push("N Engl J Med"),t.push("NEJM")))};return e.forEach(n),Y(t)}findAnchorByPriority(e,t){for(const n of t){const i=Array.from(e.querySelectorAll(n)).map(o=>this.normalizeCitationAnchor(o,e)).filter(o=>!o.matches("article, main, body")).filter(o=>!o.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(o=>g(o.textContent).length>0||o instanceof HTMLAnchorElement).at(-1);if(i)return i}return null}isAfter(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}}const gb=['a[href*="/journals/"][href*="/fullarticle/"]','a[href*="/journals/"][href*="/article-abstract/"]'].join(","),Wi=["li.article.search-result","li.search-result",".article.search-result",".search-result","article"].join(","),Rl=[".search-results-list",".search-results",'[aria-label="Search results"]',"main"].join(","),yb=["main article","#main-content article",".article-full-text",".article-main-content",".article-page-content","article","main","body"].join(","),xb=[".article--citation","cite.article--citation",'[class*="citation" i]','[class*="doi" i], [id*="doi" i], a[href*="doi.org"]','[class*="article-meta" i]','[class*="article-info" i]'],Ab=[".article--citation","cite.article--citation",".article--information",'[class*="citation" i]','[class*="meta" i]','[class*="publication" i]','[class*="date" i]',".article--authors",'[class*="author" i]'],Pl={jama:"JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION",jamanetworkopen:"JAMA Network Open","jama-health-forum":"JAMA Health Forum",jamahealthforum:"JAMA Health Forum",jamacardiology:"JAMA Cardiology",jamadermatology:"JAMA Dermatology",jamainternalmedicine:"JAMA Internal Medicine",jamaneurology:"JAMA Neurology",jamaoncology:"JAMA Oncology",jamaophthalmology:"JAMA Ophthalmology",jamaotolaryngology:"JAMA Otolaryngology-Head & Neck Surgery",jamapediatrics:"JAMA Pediatrics",jamapsychiatry:"JAMA Psychiatry",jamasurgery:"JAMA Surgery",archneurpsyc:"Archives of Neurology & Psychiatry"},Cb={"JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION":["JAMA","Journal of the American Medical Association","JAMA Journal of the American Medical Association"],"JAMA Network Open":["JAMA Netw Open"],"JAMA Cardiology":["JAMA Cardiol"],"JAMA Dermatology":["JAMA Dermatol"],"JAMA Health Forum":["JAMA Health Forum"],"JAMA Internal Medicine":["JAMA Intern Med"],"JAMA Neurology":["JAMA Neurol"],"JAMA Oncology":["JAMA Oncol"],"JAMA Ophthalmology":["JAMA Ophthalmol"],"JAMA Otolaryngology-Head & Neck Surgery":["JAMA Otolaryngol Head Neck Surg","JAMA Otolaryngology Head Neck Surgery"],"JAMA Pediatrics":["JAMA Pediatr"],"JAMA Psychiatry":["JAMA Psychiatry"],"JAMA Surgery":["JAMA Surg"],"Archives of Neurology & Psychiatry":["Archives of Neurology and Psychiatry","Arch Neurol Psychiatry"]},Il=[[/\bJAMA\s+Netw\s+Open\b/i,"JAMA Network Open"],[/\bJAMA\s+Cardiol\b/i,"JAMA Cardiology"],[/\bJAMA\s+Dermatol\b/i,"JAMA Dermatology"],[/\bJAMA\s+Health\s+Forum\b/i,"JAMA Health Forum"],[/\bJAMA\s+Intern\s+Med\b/i,"JAMA Internal Medicine"],[/\bJAMA\s+Neurol\b/i,"JAMA Neurology"],[/\bJAMA\s+Oncol\b/i,"JAMA Oncology"],[/\bJAMA\s+Ophthalmol\b/i,"JAMA Ophthalmology"],[/\bJAMA\s+Otolaryngol(?:\s+Head\s+Neck\s+Surg)?\b/i,"JAMA Otolaryngology-Head & Neck Surgery"],[/\bJAMA\s+Pediatr\b/i,"JAMA Pediatrics"],[/\bJAMA\s+Psychiatry\b/i,"JAMA Psychiatry"],[/\bJAMA\s+Surg\b/i,"JAMA Surgery"],[/\bJAMA\b/i,"JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION"]];class vb extends W{id="jama-network";name="JAMA Network";matches=["*://jamanetwork.com/*","*://www.jamanetwork.com/*"];isSearchPage(){if(Ae())return!1;const e=location.pathname.toLowerCase();return e.startsWith("/search")||e.startsWith("/searchresults")}isArticlePage(){return Ae()||this.isSearchPage()?!1:this.isArticlePath(location.pathname)||!!_(["citation_title"])}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts()){const r=this.parseSearchHost(n);if(!r)continue;const i=r.sourceId??r.doi??r.url??r.title;t.has(i)||(t.add(i),e.push(r))}return e}parseArticlePage(){if(Ae())return null;const e=this.findDetailHost();if(!e)return null;const t=g(_(["citation_title","dc.title","DC.Title","og:title"])??e.querySelector("h1")?.textContent).replace(/\s*\|\s*(?:JAMA Network|JAMA).*$/i,"");if(!t)return null;const n=jn(),r=je(_(["citation_doi","dc.Identifier","DC.Identifier","prism.doi"]))??te(e.textContent),i=g(_(["citation_publication_date","citation_online_date","publish_date","prism.publicationDate","article:published_time"])),o=this.journalFromUrl(n??location.href),s=g(_(["citation_journal_title","prism.publicationName","og:site_name"]))||this.extractJournalFromDom(e)||o||"JAMA Network";return{title:t,journalName:s,journalCandidates:this.buildJournalCandidates(s,o),authors:ct("citation_author").length>0?ct("citation_author"):this.extractAuthorsFromDom(e),year:Ze(i||e.textContent),publicationDate:i||void 0,doi:r,pmid:g(_(["citation_pmid"]))||void 0,sourceId:r?`jama-network:${r}`:n?`jama-network:${n}`:void 0,url:n,nativeFullTextUrl:this.extractPdfUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),issn:g(_(["citation_issn","prism.issn"])),volume:g(_(["citation_volume"])),issue:g(_(["citation_issue"])),pages:this.extractPages(),source:this.id,citationType:"article"}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDetailCitationAnchor(e),i=this.findDetailHeaderAnchor(e);if(r&&this.isPreferredDetailCitationAnchor(r,i))return{element:r,position:"after"};if(i)return{element:i,position:"after"};const o=this.findAnchorByPriority(e,xb);if(o)return{element:o,position:"after"};const s=e.querySelector("h1");return s?{element:s,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchorByPriority(e,Ab);if(t)return{element:t,position:"after"};const n=e.querySelector('h2, h3, [class*="title" i]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(Rl)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??e.get("startPage")??"1",10)||1,n=g(document.querySelector('.sr-statistics, [class*="result-count" i], [class*="results-count" i], main')?.textContent),r=n.match(/\bof\s+([\d,]+)\b/i)??n.match(/\b([\d,]+)\s+results?\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/20)):1,url:location.href,itemsPerPage:20,totalItems:i}}isArticlePath(e){return/^\/journals\/[^/]+\/(?:fullarticle|article-abstract)\/\d+/i.test(e)}findDetailHost(){const e=g(_(["citation_title","dc.title","DC.Title","og:title"])).replace(/\s*\|\s*(?:JAMA Network|JAMA).*$/i,""),t=this.findCurrentTitleElement(e);if(t){const n=this.findTitleScopedHost(t);if(n)return n}return Array.from(document.querySelectorAll(yb)).find(n=>this.looksLikeDetailHost(n,e))??document.body}findCurrentTitleElement(e){const t=Array.from(document.querySelectorAll(["h1.meta-article-title",".meta-article-title",'h1[class*="title" i]',"h1"].join(","))).filter(n=>!this.isHiddenUiElement(n)).filter(n=>!this.isSupplementaryUiElement(n)).filter(n=>g(n.textContent).length>0);if(e){const n=this.normalizeTitleForCompare(e),r=t.find(o=>this.normalizeTitleForCompare(g(o.textContent))===n);if(r)return r;const i=t.find(o=>{const s=this.normalizeTitleForCompare(g(o.textContent));return s.includes(n)||n.includes(s)});if(i)return i}return t.at(0)??null}normalizeTitleForCompare(e){return g(e).replace(/\s*\|\s*(?:JAMA Network|JAMA).*$/i,"").replace(/[^\p{L}\p{N}]+/gu," ").toLowerCase().trim()}findTitleScopedHost(e){let t=e;for(;t&&t!==document.body;){if(!this.isHiddenUiElement(t)&&!this.isSupplementaryUiElement(t)&&this.containsDetailHeaderSignals(t))return t;t=t.parentElement}return e.closest('article, main, [role="main"]')??document.querySelector("main")??document.body}containsDetailHeaderSignals(e){if(e.matches("h1, h2, h3"))return!1;const t=g(e.textContent);return t?!!(e.querySelector('.meta-authors, .article--authors, [class*="authors" i], [class*="author-list" i]')||e.querySelector('a[href*="/articlepdf/"], [data-article-url*="/articlepdf/"]')||te(t)):!1}looksLikeDetailHost(e,t){return this.isHiddenUiElement(e)||this.isSupplementaryUiElement(e)||t&&!g(e.textContent).includes(t)?!1:!!e.querySelector("h1, .meta-article-title, .meta-authors, .article--authors")}getSearchResultHosts(){return Y(Array.from(document.querySelectorAll(Wi)).map(e=>this.toSearchHost(e)).filter(e=>!!e).filter(e=>this.looksLikeSearchResult(e)))}toSearchHost(e){return e.matches(Wi)&&this.looksLikeSearchResult(e,!1)?e:e.closest(Wi)}looksLikeSearchResult(e,t=!0){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')||t&&!e.closest(Rl)?!1:!!this.findArticleLink(e)}parseSearchHost(e){const t=this.findArticleLink(e),n=g(t?.textContent??e.querySelector('h2, h3, [class*="title" i]')?.textContent);if(!n)return null;const r=H(t?.getAttribute("href")),i=te(e.textContent),o=g(e.querySelector('.article--pub-date, [class*="pub-date" i], [class*="date" i]')?.textContent),s=this.journalFromUrl(r),l=this.extractJournalFromDom(e)||s||"JAMA Network";return{title:n,journalName:l,journalCandidates:this.buildJournalCandidates(l,s),authors:this.extractAuthorsFromDom(e),year:Ze(o||e.textContent),publicationDate:o||void 0,doi:i,sourceId:i?`jama-network:${i}`:r?`jama-network:${r}`:void 0,url:r,nativeFullTextUrl:this.extractPdfUrl(e),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),source:this.id,citationType:"article"}}findArticleLink(e){return Array.from(e.querySelectorAll(gb)).find(t=>!/\/articlepdf\/|\.pdf(?:[?#]|$)/i.test(t.href))??null}extractPdfUrl(e){const t=H(_(["citation_pdf_url"],e))??H(_(["citation_pdf_url"]));if(t)return t;const n=H(e.querySelector('[data-article-url*="/articlepdf/"]')?.dataset.articleUrl);return n||H(e.querySelector('a[href*="/articlepdf/"], a[href$=".pdf"]')?.getAttribute("href"))}journalFromUrl(e){const t=H(e);if(!t)return;const n=new URL(t).pathname.match(/\/journals\/([^/]+)/i);if(n)return Pl[n[1].toLowerCase()]}extractJournalFromDom(e){const t=g(e.querySelector([".article--journal",'[class*="journal-title" i]','[class*="journalTitle" i]','[data-testid*="journal" i]','[data-test*="journal" i]'].join(","))?.textContent);if(t)return this.normalizeJournalName(t);const n=g(e.querySelector("cite.article--citation i, .article--citation i, cite i")?.textContent);if(n)return this.normalizeJournalName(n)}normalizeJournalName(e){const t=g(e).replace(/\.$/,"");if(!t)return;const n=Object.values(Pl).find(r=>r.toLowerCase()===t.toLowerCase());if(n)return n;for(const[r,i]of Il)if(r.test(t))return i;return t}extractJournalFromCitationText(e){const t=g(e);for(const[n,r]of Il)if(n.test(t))return r}extractAuthorsFromDom(e){return Y(Array.from(e.querySelectorAll([".article--authors a",".article--authors",".meta-authors a",'[class*="author" i] a','[class*="author-name" i]','[data-testid*="author" i]'].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|view|affiliation/i.test(t)))}extractAbstract(e){return g(_(["citation_abstract","description","og:description"])??e.querySelector(".article--excerpt")?.textContent??Qe(e))||void 0}extractArticleTypes(e){return Y(Array.from(e.querySelectorAll([".article--article-type",".article--superclassification",'[class*="article-type" i]','[data-test*="article-type" i]'].join(","))).map(t=>g(t.textContent)).filter(Boolean))}extractPages(){const e=g(_(["citation_firstpage"])),t=g(_(["citation_lastpage"]));return e&&t&&e!==t?`${e}-${t}`:e||void 0}findDetailCitationAnchor(e){const t=e.querySelector("h1");return Y(Array.from(e.querySelectorAll("p, div, section, header, span, cite")).map(r=>this.normalizeCitationAnchor(r,e)).filter(r=>!this.isHiddenUiElement(r)).filter(r=>!r.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(r=>!t||this.isAfter(r,t)).filter(r=>this.isCitationAnchorCandidate(r))).sort((r,i)=>this.scoreCitationAnchor(i)-this.scoreCitationAnchor(r)).at(0)??null}normalizeCitationAnchor(e,t){let n=e;for(;n.parentElement&&n.parentElement!==t;){const r=n.parentElement;if(r.matches("article, main, body"))break;const i=g(r.textContent);if(i.length>300||!this.hasCitationSignals(i))break;n=r}return n}findDetailHeaderAnchor(e){const t=this.findFirstVisible(e,[".meta-authors",".article--authors",'[class*="authors" i]','[class*="author-list" i]']);return t||this.findFirstVisible(e,[".meta-article-title-wrap",".article-title-wrap","h1"])}findFirstVisible(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n)).find(i=>g(i.textContent).length>0&&!this.isHiddenUiElement(i));if(r)return r}return null}isPreferredDetailCitationAnchor(e,t){if(e.matches(".article--citation, cite.article--citation")||e.closest(".article--citation")||!t)return!0;if(this.isSupplementaryUiElement(e))return!1;const n=e.parentElement,r=t.parentElement;return!n||!r?!1:!!(n===r||n.contains(t)&&g(n.textContent).length<1600||r.contains(e)&&g(r.textContent).length<1600)}isCitationAnchorCandidate(e){const t=g(e.textContent);return e.matches("article, main, body")||this.isHiddenUiElement(e)||!t||t.length>300||e.querySelector("h1, h2, h3, h4, h5, h6, nav, table")?!1:this.hasCitationSignals(t)}scoreCitationAnchor(e){const t=g(e.textContent);let n=0;return(/\bdoi\b/i.test(t)||te(t))&&(n+=90),this.extractJournalFromCitationText(t)&&(n+=70),(/\bdoi\b/i.test(t)||te(t))&&/\b(?:vol(?:ume)?|no\.?|issue|\d+\(\d+\)|\d+;?\d*)\b/i.test(t)&&(n+=35),/\b(?:19|20)\d{2}\s*;?\s*\d+/i.test(t)&&(n+=30),/(article--citation|citation|article-meta|article-info|metadata|doi)/i.test(e.getAttribute("class")??"")&&(n+=30),/^(cite|p|div|section|header)$/i.test(e.tagName)&&(n+=15),n-=Math.min(t.length,300)/20,n}hasCitationSignals(e){return!!(te(e)||/\bdoi\b/i.test(e)||this.extractJournalFromCitationText(e))}buildJournalCandidates(...e){const t=[],n=r=>{const i=g(r);if(!i)return;const o=this.normalizeJournalName(i)??i;t.push(i),t.push(o),t.push(...Cb[o]??[])};return e.forEach(n),Y(t)}findAnchorByPriority(e,t){for(const n of t){const i=Array.from(e.querySelectorAll(n)).map(o=>this.normalizeCitationAnchor(o,e)).filter(o=>!this.isHiddenUiElement(o)).filter(o=>!o.matches("article, main, body")).filter(o=>!o.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(o=>g(o.textContent).length>0||o instanceof HTMLAnchorElement).at(-1);if(i)return i}return null}isHiddenUiElement(e){return!!e.closest(["[hidden]",'[aria-hidden="true"]',".hide",".hidden",".reveal-modal",".flyout",".get-citation",".citation-download-wrap",".content-scroll-bar",".content-scroll-bar-item",".social-share-wrap",".toolbar",'[role="dialog"]','[role="menu"]'].join(","))}isSupplementaryUiElement(e){return!!e.closest([".personalized-content",'[class*="personalized" i]','[class*="related" i]','[class*="recommend" i]','[class*="sidebar" i]','[class*="right-rail" i]','[class*="rail" i]','[class*="widget" i]','[class*="toc" i]','[id*="article-information" i]','[class*="article-information" i]','[class*="article-info" i]'].join(","))}isAfter(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}}const Ml=['a[href*="/fulltext/"]','a[href*="/abstract/"]','a[href^="/10."]','a[href*="journals.lww.com/10."]','a[href*="doi.org/10."]'].join(","),Bl=[".search-results li",".sr-list li",".result-list li",".searchResult",".search-result",".result-item",".article-list-item",".article-listing","article","li"].join(","),wb=[".search-results",".sr-list",".result-list",'[id*="search" i]','[class*="search" i]',"main"].join(","),Sb=["main article","#main-content article",".article-page",".article__content",".article-content",".articleBody",".main-content","article","main","body"].join(","),Tb=['[class*="citation" i]','[class*="doi" i]','a[href*="doi.org/10."]',"#article-journal-info",".ej-journal-info",'[class*="published" i]','[class*="accepted" i]','[class*="article-meta" i]','[class*="article-info" i]','[class*="authors" i]','[class*="author" i]'],Eb=['[class*="citation" i]','[class*="meta" i]','[class*="journal" i]','[class*="source" i]','[class*="date" i]','[class*="publication" i]'],_b={"anesthesia-analgesia":"Anesthesia & Analgesia",aacr:"A&A Practice"},jl={"Anesthesia & Analgesia":["Anesthesia and Analgesia","ANESTHESIA AND ANALGESIA","Anesth Analg"],"A&A Practice":["A A Practice","A and A Practice","A A Pract"]},Db=/^\/(?:10\.\d{4,9}\/.+|[^/]+\/(?:abstract|fulltext)\/(?:\d{4}|9900)\/[^/]+\/[^/]+\.aspx)$/i;class Fb extends W{id="lww";name="LWW / Ovid";matches=["*://journals.lww.com/*","*://*.ovid.com/*"];isSearchPage(){if(Ae())return!1;const e=location.hostname.toLowerCase(),t=location.pathname.toLowerCase(),n=new URLSearchParams(location.search);if(e==="journals.lww.com")return t.endsWith("/pages/results.aspx")||n.has("txtKeywords")||n.has("txtKeyword")||n.has("q");if(e.endsWith(".ovid.com")){const r=n.get("PAGE")?.toLowerCase()??"";return r==="results"||r==="mainsearch"||r==="search"}return!1}isArticlePage(){if(Ae()||this.isSearchPage())return!1;const e=location.hostname.toLowerCase(),t=location.pathname;if(e==="journals.lww.com")return Db.test(t)||!!_(["citation_title","dc.title","DC.Title","wkhealth_title"]);if(e.endsWith(".ovid.com")){const n=new URLSearchParams(location.search).get("PAGE")?.toLowerCase()??"";return n==="fulltext"||n==="article"||!!_(["citation_title","dc.title","DC.Title"])}return!1}parseSearchResults(){const e=[],t=new Set;for(const n of this.getSearchResultHosts()){const r=this.parseSearchHost(n);if(!r)continue;const i=r.doi??r.sourceId??r.url??r.title;t.has(i)||(t.add(i),e.push(r))}return e}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.findDetailHost();if(!e)return null;const t=this.extractTitle(e);if(!t)return null;const n=jn(),r=je(_(["citation_doi","dc.Identifier","DC.Identifier","prism.doi","wkhealth_doi"]))??this.extractDoiFromUrl(n??location.href)??te(e.textContent),i=g(_(["citation_publication_date","citation_online_date","prism.publicationDate","article:published_time","wkhealth_article_publication_date","wkhealth_date"])),o=this.journalFromUrl(n??location.href),s=g(_(["citation_journal_title","prism.publicationName","wkhealth_journal_title","wkhealth_journal_title_legacy","og:site_name"]))||this.extractJournalFromDom(e)||o||"LWW Journal";return{title:t,journalName:s,journalCandidates:this.buildJournalCandidates(s,o),authors:this.extractMetaAuthors().length>0?this.extractMetaAuthors():this.extractAuthors(e),year:Ze(i||e.textContent),publicationDate:i||void 0,doi:r,sourceId:r?`lww:${r}`:n?`lww:${n}`:void 0,url:n,nativeFullTextUrl:this.extractNativeFullTextUrl(e,n??location.href),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),issn:g(_(["citation_issn","prism.issn","wkhealth_issn"]))||void 0,volume:g(_(["citation_volume","wkhealth_volume"]))||this.extractVolumeIssuePages(e).volume,issue:g(_(["citation_issue","wkhealth_issue"]))||this.extractVolumeIssuePages(e).issue,pages:this.extractPages(e),source:this.id,citationType:"article",nativeExportUrls:this.extractNativeExportUrls(e)}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.findDetailCitationAnchor(e);if(r)return{element:r,position:"after"};const i=this.findFirstVisible(e,['[class*="authors" i]','[class*="author" i]']);if(i)return{element:i,position:"after"};const o=this.findFirstVisible(e,["h1"]);return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchorByPriority(e,Eb);if(t)return{element:t,position:"after"};const n=this.findFirstVisible(e,['h2, h3, h4, [class*="title" i]']);return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(wb)??document.body}getPageInfo(){const e=new URLSearchParams(location.search),t=Number.parseInt(e.get("page")??e.get("pg")??"1",10)||1,r=g(document.querySelector('[class*="result" i], main')?.textContent).match(/\b([\d,]+)\s+(?:results?|articles?)\b/i),i=r?Number.parseInt(r[1].replace(/,/g,""),10):void 0;return{pageNum:t,totalPages:i?Math.max(1,Math.ceil(i/20)):1,url:location.href,itemsPerPage:20,totalItems:i}}getSearchResultHosts(){const e=Array.from(document.querySelectorAll(Ml)).map(n=>this.toSearchHost(n)).filter(n=>!!n),t=Array.from(document.querySelectorAll(Bl)).filter(n=>this.looksLikeSearchResult(n));return Y([...e,...t].filter(n=>this.looksLikeSearchResult(n)))}toSearchHost(e){return e.closest(Bl)??e.parentElement}looksLikeSearchResult(e){if(e.closest('[class^="paperlens-"], [class*=" paperlens-"]'))return!1;const t=this.findArticleLink(e);if(!t)return!1;const n=g(t.textContent);return n.length>8&&!/login|register|subscribe|alerts?|download citation/i.test(n)}parseSearchHost(e){const t=this.findArticleLink(e),n=g(t?.textContent??e.querySelector('h2, h3, h4, [class*="title" i]')?.textContent);if(!n)return null;const r=H(t?.getAttribute("href")),i=this.extractDoiFromUrl(r)??te(e.textContent),o=this.journalFromUrl(r),s=this.extractJournalFromDom(e)||this.extractJournalFromCitationText(e.textContent)||o||"LWW Journal",l=g(e.querySelector('[class*="pub" i], [class*="date" i], [class*="citation" i], [class*="meta" i]')?.textContent);return{title:n,journalName:s,journalCandidates:this.buildJournalCandidates(s,o),authors:this.extractAuthors(e),year:Ze(l||e.textContent),publicationDate:l||void 0,doi:i,sourceId:i?`lww:${i}`:r?`lww:${r}`:void 0,url:r,nativeFullTextUrl:this.extractNativeFullTextUrl(e,r),abstractSnippet:this.extractAbstract(e),hostElement:e,articleTypes:this.extractArticleTypes(e),source:this.id,citationType:"article",nativeExportUrls:this.extractNativeExportUrls(e)}}findArticleLink(e){return Array.from(e.querySelectorAll(Ml)).find(t=>{const n=t.getAttribute("href")??"";return!/\.pdf(?:[?#]|$)|download|citation|endnote|procite|referencemanager/i.test(n)})??null}findDetailHost(){const e=this.normalizeTitle(_(["citation_title","dc.title","DC.Title","wkhealth_title","og:title"])),t=this.findTitleElement(e);if(t){const n=t.closest('article, main, [role="main"], .article-page, .article-content');if(n)return n}return Array.from(document.querySelectorAll(Sb)).find(n=>this.looksLikeDetailHost(n,e))??document.body}looksLikeDetailHost(e,t){return this.isHiddenUiElement(e)||t&&!this.normalizeTitle(e.textContent).includes(t)?!1:!!e.querySelector('h1, [class*="title" i], [class*="authors" i], [class*="doi" i]')||!!te(e.textContent)}findTitleElement(e){const t=Array.from(document.querySelectorAll(["h1",'[class*="article-title" i]','[class*="ArticleTitle" i]','[class*="title" i]'].join(","))).filter(n=>!this.isHiddenUiElement(n)).filter(n=>g(n.textContent).length>0);if(e){const n=t.find(i=>this.normalizeTitle(i.textContent)===e);if(n)return n;const r=t.find(i=>{const o=this.normalizeTitle(i.textContent);return o.includes(e)||e.includes(o)});if(r)return r}return t.at(0)??null}extractTitle(e){return this.normalizeTitle(_(["citation_title","dc.title","DC.Title","wkhealth_title","og:title"])??e.querySelector("h1")?.textContent??e.querySelector('[class*="article-title" i], [class*="ArticleTitle" i]')?.textContent,!1)}normalizeTitle(e,t=!0){const n=g(e).replace(/\s*:\s*(?:Anesthesia\s*(?:&|and)\s*Analgesia|A\s*&\s*A\s*Practice|LWW|Ovid|Wolters Kluwer).*$/i,"").replace(/\s*\|\s*(?:LWW|Ovid|Wolters Kluwer).*$/i,"");return t?n.replace(/[^\p{L}\p{N}]+/gu," ").toLowerCase().trim():n}extractAuthors(e){return Y(Array.from(e.querySelectorAll(['[class*="authors" i] a','[class*="authors" i]','[class*="author-list" i] a','[class*="author" i] a','[class*="author-name" i]'].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|affiliation|correspondence|view all/i.test(t)))}extractMetaAuthors(){const e=ct("citation_author");if(e.length>0)return e;const t=g(_(["wkhealth_authors"]));return t?Y(t.split(";").map(n=>g(n)).filter(Boolean)):[]}extractJournalFromDom(e){const t=g(e.querySelector(['[class*="journal-title" i]','[class*="journalTitle" i]','[class*="publication-title" i]',".ej-journal-name",'[data-testid*="journal" i]',"cite i"].join(","))?.textContent);return t?this.normalizeJournalName(t):this.extractJournalFromCitationText(e.textContent)}extractJournalFromCitationText(e){const t=g(e);if(!t)return;const n=Object.keys(jl).find(i=>new RegExp(`\\b${this.escapeRegExp(i).replace(/&/g,"(?:&|and)")}\\b`,"i").test(t));if(n)return n;const r=t.match(/\b([A-Z][A-Za-z&' -]+(?:\s+[A-Z][A-Za-z&' -]+)*)\.?\s+\d{1,4}\s*\(\d+\)\s*:\s*(?:p\s*)?\d+/);return r?this.normalizeJournalName(r[1]):void 0}normalizeJournalName(e){const t=g(e).replace(/\.$/,"").replace(/\s*\|\s*.*$/,"");if(t)return/^anesthesia\s*(?:&|and)\s*analgesia$/i.test(t)?"Anesthesia & Analgesia":/^a\s*&\s*a\s+practice$/i.test(t)?"A&A Practice":t}buildJournalCandidates(...e){const t=[],n=r=>{const i=g(r);if(!i)return;const o=this.normalizeJournalName(i)??i;t.push(i),t.push(o),t.push(...jl[o]??[])};return e.forEach(n),Y(t)}journalFromUrl(e){const t=H(e);if(!t)return;const n=new URL(t);if(n.hostname!=="journals.lww.com")return;const r=n.pathname.split("/").filter(Boolean).at(0)?.toLowerCase();if(!(!r||r.startsWith("10.")))return _b[r]??this.slugToTitle(r)}slugToTitle(e){return e.split("-").filter(Boolean).map(t=>t.length<=3?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}extractDoiFromUrl(e){const t=H(e);if(!t)return;const n=new URL(t);return n.hostname==="journals.lww.com"&&/^\/10\./i.test(n.pathname)?je(decodeURIComponent(n.pathname.slice(1))):je(n.pathname)}extractNativeFullTextUrl(e,t){const n=H(_(["citation_pdf_url"],e))??H(_(["citation_pdf_url","wkhealth_pdf_url"]));if(n)return n;const r=H(e.querySelector("[data-pdf-url]")?.dataset.pdfUrl);if(r)return r;const i=H(e.querySelector('a[href$=".pdf"], a[href*=".pdf?"]')?.getAttribute("href"));if(i)return i;const o=H(e.querySelector('a[href*="/fulltext/"]')?.getAttribute("href"));if(o)return o;const s=H(_(["wkhealth_fulltext_html_url","citation_fulltext_html_url"]));if(s)return s;const l=H(t);if(!l)return;const c=new URL(l);if(c.hostname==="journals.lww.com"){if(/\/fulltext\//i.test(c.pathname)||/^\/10\./i.test(c.pathname))return c.href;if(/\/abstract\//i.test(c.pathname))return c.pathname=c.pathname.replace(/\/abstract\//i,"/fulltext/"),c.href}}extractNativeExportUrls(e){const t=H(Array.from(e.querySelectorAll("a[href]")).find(n=>/end\s*note|procite|reference\s*manager|ris/i.test(g(n.textContent)+" "+n.href))?.getAttribute("href"));return t?{ris:t}:void 0}extractAbstract(e){return g(_(["citation_abstract","description","og:description"])??_(["Description"])??Qe(e))||void 0}extractArticleTypes(e){return Y(Array.from(e.querySelectorAll([".ejp-r-article-subsection__text",'[class*="article-type" i]','[class*="ArticleType" i]','[class*="classification" i]','[class*="category" i]'].join(","))).map(t=>g(t.textContent)).concat([g(_(["wkhealth_toc_section"])),g(_(["wkhealth_toc_sub_section"]))]).filter(t=>t.length>0&&t.length<80))}extractPages(e){const t=g(_(["citation_firstpage","wkhealth_firstpage"])),n=g(_(["citation_lastpage"]));return t&&n&&t!==n?`${t}-${n}`:this.extractVolumeIssuePages(e).pages??(t||void 0)}extractVolumeIssuePages(e){const t=g(e.textContent),n=t.match(/\b\d{4}\s*;\s*(\d+)\s*\(([^)]+)\)\s*:\s*(?:p\s*)?([A-Za-z0-9-]+)\b/)??t.match(/\b(\d+)\s*\(([^)]+)\)\s*:\s*(?:p\s*)?([A-Za-z0-9-]+)\b/);return{volume:n?.[1],issue:n?.[2],pages:n?.[3]}}findDetailCitationAnchor(e){const t=this.findFirstVisible(e,["#article-journal-info",".ej-journal-info"]);if(t)return t;const n=e.querySelector("h1");return Y(Array.from(e.querySelectorAll("p, div, span, cite, header, section")).map(i=>this.normalizeAnchorElement(i,e)).filter(i=>!this.isHiddenUiElement(i)).filter(i=>!i.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(i=>!n||this.isAfter(i,n)).filter(i=>this.isDetailAnchorCandidate(i))).sort((i,o)=>this.scoreDetailAnchor(o)-this.scoreDetailAnchor(i)).at(0)??this.findAnchorByPriority(e,Tb)}isDetailAnchorCandidate(e){const t=g(e.textContent);return e.matches("article, main, body")||!t||t.length>360||e.querySelector("h1, h2, h3, h4, nav, table, form")?!1:!!(te(t)||/\bdoi\b/i.test(t)||/\b(?:accepted|published)\b/i.test(t)||this.extractJournalFromCitationText(t))}scoreDetailAnchor(e){const t=g(e.textContent);let n=0;return(te(t)||/\bdoi\b/i.test(t))&&(n+=100),this.extractJournalFromCitationText(t)&&(n+=70),/\b(?:accepted|published)\b/i.test(t)&&(n+=45),/\b\d{4}\s*;\s*\d+\s*\([^)]+\)\s*:/i.test(t)&&(n+=35),/(citation|doi|accepted|published|article-meta|article-info)/i.test(e.getAttribute("class")??"")&&(n+=30),n-=Math.min(t.length,360)/30,n}findAnchorByPriority(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n)).map(i=>this.normalizeAnchorElement(i,e)).filter(i=>!this.isHiddenUiElement(i)).filter(i=>!i.matches("article, main, body")).filter(i=>!i.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(i=>g(i.textContent).length>0).at(-1);if(r)return r}return null}normalizeAnchorElement(e,t){let n=e;for(;n.parentElement&&n.parentElement!==t;){const r=n.parentElement;if(r.matches("article, main, body"))break;const i=g(r.textContent);if(i.length>360)break;const o=g(n.textContent);if(!o||!i.includes(o))break;n=r}return n}findFirstVisible(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n)).find(i=>!this.isHiddenUiElement(i)&&g(i.textContent).length>0);if(r)return r}return null}isHiddenUiElement(e){return!!e.closest(["[hidden]",'[aria-hidden="true"]',".hide",".hidden",".modal",".reveal-modal",".flyout",".popup",".toolbar",".sidebar",".right-rail",".related",".advertisement",'[role="dialog"]','[role="menu"]'].join(","))}isAfter(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}const ql=/10\.\d{4,9}\/[^?#\s"'<>]+/i,$l=[{key:"frontiers",name:"Frontiers",hosts:["frontiersin.org","www.frontiersin.org"],articlePath:/\/(?:journals\/[^/]+\/)?articles\/10\.\d{4,9}\/[^/]+\/full/i,searchPath:/\/search/i,searchQueryParams:["query","q"]},{key:"acs",name:"ACS Publications",hosts:["pubs.acs.org"],articlePath:/\/doi\/(?:full\/|abs\/|epdf\/|pdf\/)?10\.\d{4,9}\//i,searchPath:/\/action\/doSearch|\/toc\//i,searchQueryParams:["AllField","text1"],pdfUrl:a=>`https://pubs.acs.org/doi/pdf/${a}`},{key:"rsc",name:"Royal Society of Chemistry",hosts:["pubs.rsc.org"],articlePath:/\/en\/content\/article(?:landing|html|pdf)\/\d{4}\//i,searchPath:/\/en\/results|\/en\/search/i,searchQueryParams:["searchtext","q"]},{key:"aps",name:"American Physical Society",hosts:["journals.aps.org","link.aps.org"],articlePath:/\/(?:prl|pra|prb|prc|prd|pre|prresearch|prx|rmp|physics|prper)\/(?:abstract|pdf)\/10\.1103\/|\/doi\/10\.1103\//i,searchPath:/\/search/i,searchQueryParams:["q","query"],pdfUrl:(a,e)=>{const n=new URL(e).pathname.split("/").filter(Boolean).at(0);return n?`https://journals.aps.org/${n}/pdf/${a}`:void 0}},{key:"aip",name:"AIP Publishing",hosts:["pubs.aip.org"],articlePath:/\/[^/]+\/[^/]+\/article(?:-abstract|-pdf)?\/|\/doi\/(?:full\/|abs\/|pdf\/)?10\.1063\//i,searchPath:/\/search-results|\/action\/doSearch/i,searchQueryParams:["AllField","q"],pdfUrl:a=>`https://pubs.aip.org/doi/pdf/${a}`},{key:"iop",name:"IOPscience",hosts:["iopscience.iop.org"],articlePath:/\/article\/10\.\d{4,9}\//i,searchPath:/\/(?:nsearch|search)/i,searchQueryParams:["q","searchTerm","terms"],pdfUrl:a=>`https://iopscience.iop.org/article/${a}/pdf`},{key:"karger",name:"Karger",hosts:["karger.com","www.karger.com"],articlePath:/\/article\/doi\/10\.1159\//i,searchPath:/\/search-results|\/search/i,searchQueryParams:["q","search"],pdfUrl:a=>{const e=a.match(/10\.1159\/(\d+)/i)?.[1];return e?`https://karger.com/article-pdf/${e}`:void 0}},{key:"thieme",name:"Thieme Connect",hosts:["www.thieme-connect.de","thieme-connect.de","www.thieme-connect.com","thieme-connect.com"],articlePath:/\/products\/ejournals\/(?:abstract|html|pdf)\/10\.1055\//i,searchPath:/\/products\/ejournals\/search|\/search/i,searchQueryParams:["query","q"],pdfUrl:(a,e)=>`${new URL(e).origin}/products/ejournals/pdf/${a}.pdf`},{key:"jmir",name:"JMIR Publications",hosts:["jmir.org","www.jmir.org","mhealth.jmir.org","formative.jmir.org","medinform.jmir.org"],matches:["*://jmir.org/*","*://www.jmir.org/*","*://*.jmir.org/*"],defaultJournal:"Journal of Medical Internet Research",articlePath:/\/\d{4}\/\d+\/e\d+/i,searchPath:/\/search/i,searchQueryParams:["query","q"],pdfUrl:(a,e)=>`${new URL(e).origin}/api/download?alt_name=${a.replace("/","-")}.pdf`},{key:"annual-reviews",name:"Annual Reviews",hosts:["www.annualreviews.org","annualreviews.org"],articlePath:/\/content\/journals\/10\.1146\//i,searchPath:/\/search/i,searchQueryParams:["AllField","q"],pdfUrl:a=>`https://www.annualreviews.org/content/journals/${a}/pdf`},{key:"elife",name:"eLife",hosts:["elifesciences.org"],defaultJournal:"eLife",articlePath:/\/articles\/\d+/i,searchPath:/\/search/i,searchQueryParams:["q","for"],pdfUrl:(a,e)=>`${new URL(e).origin}${new URL(e).pathname}.pdf`},{key:"pnas",name:"PNAS",hosts:["pnas.org","www.pnas.org"],defaultJournal:"PROCEEDINGS OF THE NATIONAL ACADEMY OF SCIENCES OF THE UNITED STATES OF AMERICA",articlePath:/\/doi\/(?:full\/|abs\/|pdf\/)?10\.1073\/pnas\./i,searchPath:/\/action\/doSearch|\/search/i,searchQueryParams:["AllField","q"],pdfUrl:a=>`https://www.pnas.org/doi/pdf/${a}`},{key:"rup",name:"Rockefeller University Press",hosts:["rupress.org","www.rupress.org"],matches:["*://rupress.org/*","*://www.rupress.org/*","*://*.rupress.org/*"],articlePath:/\/(?:jcb|jem|rupress)\/article\/|\/doi\/10\.1083\//i,searchPath:/\/search-results|\/search/i,searchQueryParams:["q","AllField"],pdfUrl:a=>`https://rupress.org/jcb/article-pdf/doi/${a}`},{key:"csh-perspectives",name:"Cold Spring Harbor Perspectives",hosts:["cshperspectives.cshlp.org"],defaultJournal:"Cold Spring Harbor Perspectives in Biology",articlePath:/\/content\/|\/lookup\/doi\/10\.1101\/cshperspect\./i,searchPath:/\/search/i,searchQueryParams:["q","fulltext"],pdfUrl:(a,e)=>`${new URL(e).origin}${new URL(e).pathname}.full.pdf`},{key:"genes-dev",name:"Genes & Development",hosts:["genesdev.cshlp.org"],defaultJournal:"GENES & DEVELOPMENT",articlePath:/\/content\/|\/lookup\/doi\/10\.1101\/gad\./i,searchPath:/\/search/i,searchQueryParams:["q","fulltext"],pdfUrl:(a,e)=>`${new URL(e).origin}${new URL(e).pathname}.full.pdf`}],Ol=['a[href*="/doi/"]','a[href*="/abstract/10."]','a[href*="/article-abstract/"]','a[href*="/article-pdf/"]','a[href*="/articles/"]','a[href*="/article/"]','a[href*="/content/article"]','a[href*="/content/"]','a[href*="/20"][href*="/e"]','a[href*="/products/ejournals/abstract/"]','a[href*="/lookup/doi/"]'].join(","),Ul=["article",'li[class*="result" i]',".search-result",".search__item",".result-item",'[class*="search-result" i]'].join(","),kb=[".search-results","#search-results",'[aria-label*="Search" i]','[class*="results" i]',"main"].join(","),Lb=[".ArticleDetailsV4__main",".ArticleDetailsV4",".ArticlePage","#main-content",'[role="main"]',"main article","main","article","body"],Nb=['[class*="citation" i]','[class*="article-meta" i]','[class*="metadata" i]','[class*="publication" i]','[class*="doi" i]','a[href*="doi.org/10."]','[data-test*="citation" i]','[data-testid*="citation" i]'],Rb=['[class*="citation" i]','[class*="meta" i]','[class*="journal" i]','[class*="publication" i]','[class*="date" i]','[class*="author" i]'];class Pb extends W{id="publisher-network";name="Publisher Network";matches=$l.flatMap(e=>e.matches??e.hosts.map(t=>`*://${t}/*`));isSearchPage(){if(Ae())return!1;const e=this.currentConfig();if(!e)return!1;const t=location.pathname.toLowerCase(),n=new URLSearchParams(location.search);return e.searchPath.test(t)||!!e.searchQueryParams?.some(r=>n.has(r))}isArticlePage(){if(Ae()||this.isSearchPage())return!1;const e=this.currentConfig();if(!e)return!1;const t=location.pathname;return e.articlePath.test(t)||!!(this.metaTitle()&&(this.metaDoi()||this.doiFromUrl(location.href)))}parseSearchResults(){const e=this.currentConfig();if(!e)return[];const t=[],n=new Set;for(const r of this.searchHosts()){const i=this.parseSearchHost(r,e);if(!i)continue;const o=i.doi??i.sourceId??i.url??i.title;n.has(o)||(n.add(o),t.push(i))}return t}parseArticlePage(){if(!this.isArticlePage())return null;const e=this.currentConfig();if(!e)return null;const t=this.detailHostElement(e);if(!t)return null;const n=this.cleanTitle(this.metaTitle()??t.querySelector("h1")?.textContent);if(!n)return null;const r=jn(),i=this.metaDoi()??this.doiFromUrl(r??location.href)??te(t.textContent),o=g(_(["citation_publication_date","citation_online_date","prism.publicationDate","article:published_time","dc.Date","DC.Date"])),s=this.journalName(e,r,t);return{title:n,journalName:s,journalCandidates:this.journalCandidates(s,e),authors:this.metaAuthors().length?this.metaAuthors():this.extractAuthors(t),year:Ze(o||t.textContent),publicationDate:o||void 0,doi:i,sourceId:i?`${e.key}:${i}`:r?`${e.key}:${r}`:void 0,url:r,nativeFullTextUrl:this.fullTextUrl(e,t,i,r??location.href),abstractSnippet:this.abstract(t),hostElement:t,articleTypes:this.articleTypes(t),issn:g(_(["citation_issn","prism.issn","dc.Identifier","DC.Identifier"]))||void 0,volume:g(_(["citation_volume","prism.volume"]))||void 0,issue:g(_(["citation_issue","prism.number"]))||void 0,pages:this.pages(),source:this.id,citationType:"article"}}getMetricBarAnchor(e){if(this.isArticlePage()){const r=this.currentConfig(),i=this.detailAnchor(e,r);if(i)return{element:i,position:"after"};const o=e.querySelector("h1");return o?{element:o,position:"after"}:{element:e,position:"prepend"}}const t=this.findAnchor(e,Rb);if(t)return{element:t,position:"after"};const n=e.querySelector('h2, h3, h4, [class*="title" i]');return n?{element:n,position:"after"}:{element:e,position:"prepend"}}getResultsContainer(){return document.querySelector(kb)??document.body}getPageInfo(){return{pageNum:Number.parseInt(new URLSearchParams(location.search).get("page")??"1",10)||1,totalPages:1,url:location.href}}currentConfig(){const e=location.hostname.toLowerCase();return $l.find(t=>t.hosts.some(n=>e===n||e.endsWith(`.${n}`)))}detailHostElement(e){if(e&&["csh-perspectives","genes-dev"].includes(e.key)){const t=this.coldSpringHarborArticleRoot();if(t)return t}for(const t of Lb){const n=document.querySelector(t);if(n)return n}return null}coldSpringHarborArticleRoot(){const e=[".article.fulltext-view",".article.abstract-view",".highwire-article","#content-block .article","#main-content .article","#article",".article"];return Array.from(document.querySelectorAll(e.join(","))).filter(t=>!this.isHidden(t)).find(t=>!!t.querySelector("h1, .article-title, #abstract-1, .section.abstract, .abstract"))??null}metaTitle(){return g(_(["citation_title","dc.title","DC.Title","og:title","twitter:title"]))||void 0}metaDoi(){return je(_(["citation_doi","prism.doi","dc.Identifier","DC.Identifier","doi"]))}metaAuthors(){return Y([...ct("citation_author"),...ct("dc.Creator"),...ct("DC.Creator")])}doiFromUrl(e){const t=H(e);if(!t)return;const n=new URL(t),r=(n.pathname.match(ql)?.[0]??n.search.match(ql)?.[0])?.replace(/\/(?:full|abstract|html|pdf)$/i,"");return je(r?decodeURIComponent(r):void 0)}journalName(e,t,n){const r=g(_(["citation_journal_title","prism.publicationName","dc.Source","DC.Source"]));if(r)return this.normalizeJournal(r,e);const i=H(t);if(i&&e.journalFromUrl){const s=e.journalFromUrl(new URL(i));if(s)return s}const o=g(n.querySelector(['[class*="journal-title" i]','[class*="publication-title" i]','[data-testid*="journal" i]',"cite i"].join(","))?.textContent);return o?this.normalizeJournal(o,e):e.defaultJournal??e.name}normalizeJournal(e,t){const n=g(e).replace(/^Frontiers\s+\|\s*/i,"").replace(/\s*\|\s*.*$/,"").replace(/&amp;/g,"&");return/^pnas$/i.test(n)?"PROCEEDINGS OF THE NATIONAL ACADEMY OF SCIENCES OF THE UNITED STATES OF AMERICA":/^jcb$/i.test(n)?"JOURNAL OF CELL BIOLOGY":/^jmir$/i.test(n)?"Journal of Medical Internet Research":n||t.defaultJournal||t.name}journalCandidates(e,t){const n=[e,t.defaultJournal];return t.key==="pnas"&&n.push("PNAS"),t.key==="rup"&&n.push("Journal of Cell Biology","JCB"),t.key==="genes-dev"&&n.push("Genes and Development"),t.key==="acs"&&n.push("J Am Chem Soc","Journal of the American Chemical Society"),t.key==="iop"&&n.push("JOURNAL OF PHYSICS D-APPLIED PHYSICS"),t.key==="annual-reviews"&&n.push("Annual Review of Medicine"),t.key==="rsc"&&n.push("Chemical Science"),Y(n.filter(Boolean))}fullTextUrl(e,t,n,r){const i=H(_(["citation_pdf_url","citation_fulltext_html_url"]));if(i)return i;const o=H(t.querySelector(['a[href$=".pdf"]','a[href*=".pdf?"]','a[href*="/pdf/"]','a[href*="articlepdf"]','a[href*="downloadpdf"]'].join(","))?.getAttribute("href"));if(o)return o;if(n&&e.pdfUrl)return e.pdfUrl(n,r)}abstract(e){return g(_(["citation_abstract","description","og:description"])??Qe(e))||void 0}articleTypes(e){return Y(Array.from(e.querySelectorAll(['[class*="article-type" i]','[class*="classification" i]','[data-testid*="article-type" i]'].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>0&&t.length<80))}pages(){const e=g(_(["citation_firstpage","prism.startingPage"])),t=g(_(["citation_lastpage","prism.endingPage"]));return e&&t&&e!==t?`${e}-${t}`:e||void 0}searchHosts(){const e=Array.from(document.querySelectorAll(Ol)).map(n=>n.closest(Ul)??n.parentElement).filter(n=>!!n),t=Array.from(document.querySelectorAll(Ul));return Y([...e,...t].filter(n=>this.looksLikeSearchResult(n)))}looksLikeSearchResult(e){return e.closest('[class^="paperlens-"], [class*=" paperlens-"]')?!1:!!this.findArticleLink(e)}parseSearchHost(e,t){const n=this.findArticleLink(e),r=this.cleanTitle(n?.textContent??e.querySelector('h2, h3, h4, [class*="title" i]')?.textContent);if(!r)return null;const i=H(n?.getAttribute("href")),o=this.doiFromUrl(i)??te(e.textContent),s=this.journalName(t,i,e);return{title:r,journalName:s,journalCandidates:this.journalCandidates(s,t),authors:this.extractAuthors(e),year:Ze(e.textContent),doi:o,sourceId:o?`${t.key}:${o}`:i?`${t.key}:${i}`:void 0,url:i,nativeFullTextUrl:this.fullTextUrl(t,e,o,i??location.href),abstractSnippet:this.abstract(e),hostElement:e,articleTypes:this.articleTypes(e),source:this.id,citationType:"article"}}findArticleLink(e){return Array.from(e.querySelectorAll(Ol)).find(t=>{const n=t.getAttribute("href")??"",r=g(t.textContent);return r.length>4&&!/\.pdf(?:[?#]|$)|download|citation|subscribe|login/i.test(n+" "+r)})??null}extractAuthors(e){return Y(Array.from(e.querySelectorAll(['[class*="authors" i] a','[class*="author" i] a','[class*="author-name" i]','[data-testid*="author" i]'].join(","))).map(t=>g(t.textContent)).filter(t=>t.length>1&&!/author information|affiliation|view all|correspondence/i.test(t)))}cleanTitle(e){return g(e).replace(/^Frontiers\s+\|\s*/i,"").replace(/\s*\|\s*(?:Frontiers|ACS Publications|RSC Publishing|eLife|PNAS|Annual Reviews).*$/i,"").replace(/\s*-\s*(?:Chemical Science|Thieme E-Journals).*$/i,"")}detailAnchor(e,t){const n=t?this.siteSpecificDetailAnchor(e,t):null;if(n)return n;const r=e.querySelector("h1");return Y(Array.from(e.querySelectorAll("p, div, span, section, header")).filter(o=>!this.isHidden(o)).filter(o=>!o.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(o=>!r||!!(r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)).filter(o=>this.isCitationCandidate(o))).sort((o,s)=>this.scoreAnchor(s)-this.scoreAnchor(o)).map(o=>this.blockAnchor(o,e)).at(0)??this.findAnchor(e,Nb)}siteSpecificDetailAnchor(e,t){switch(t.key){case"aps":return this.findDoiLineAnchor(e,[/10\.1103\//i])??this.findPublicationLineAnchor(e);case"pnas":return this.findTitleAnchor(e)??this.findPnasMetaAnchor(e)??this.findPublicationLineAnchor(e)??null;case"thieme":return this.findTitleAnchor(e);case"frontiers":return this.findFrontiersHeaderAnchor(e)??this.findTitleAnchor(e);case"acs":case"elife":return this.findTitleAnchor(e)??this.findDoiLineAnchor(e)??this.findPublicationLineAnchor(e);case"aip":case"iop":case"annual-reviews":case"rup":return this.findDoiLineAnchor(e)??this.findPublicationLineAnchor(e)??this.findTitleAnchor(e);case"csh-perspectives":case"genes-dev":return this.findColdSpringHarborHeaderAnchor(e)??this.findDoiLineAnchor(e,[/10\.1101\//i])??this.findPublicationLineAnchor(e)??this.findTitleAnchor(e);default:return null}}findPnasMetaAnchor(e){const t=this.findDoiLineAnchor(e,[/10\.1073\/pnas\./i]);if(!t)return null;const n=t.closest("p, div, section, header, li");return!n||n===e||n.matches("article, main, body")?t:n}findColdSpringHarborHeaderAnchor(e){const t=e.querySelector("#abstract-1, .section.abstract, .abstract, h2"),n=this.findTitleAnchor(e);return Array.from(e.querySelectorAll("p, div")).filter(i=>!this.isHidden(i)).filter(i=>!i.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(i=>!(n&&!(n.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING)||t&&!(t.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_PRECEDING))).filter(i=>{const o=g(i.textContent);return!o||o.length>320||i.querySelector("h1, h2, h3, h4, nav, form")?!1:/10\.1101\/|doi\s*:|Genes\s*&?\s*Development|Cold Spring Harb|Cold Spring Harbor|Correspondence/i.test(o)}).map(i=>this.blockAnchor(i,e)).filter((i,o,s)=>s.indexOf(i)===o).at(-1)??null}findFrontiersHeaderAnchor(e){const t=e.querySelector("h1"),n=Array.from(e.querySelectorAll(['[class*="doiVolume" i]','[class*="doi-volume" i]','[class*="ArticleLayoutHeader__info__doi" i]','a[href*="doi.org/10.3389/"]'].join(","))).filter(r=>!this.isHidden(r)).filter(r=>!t||!!(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING)).map(r=>this.blockAnchor(r,e)).find(r=>/10\.3389\//i.test(g(r.textContent)));return n||this.findTextLineAnchor(e,r=>/10\.3389\//i.test(r),{relativeToTitle:"before"})}findTitleAnchor(e){return Array.from(e.querySelectorAll(["h1",'[class*="article-title" i]','[class*="ArticleTitle" i]','[data-testid*="title" i]'].join(","))).filter(t=>!this.isHidden(t)).find(t=>g(t.textContent).length>0)??null}findDoiLineAnchor(e,t=[]){const n=t.length>0?t:[/10\.\d{4,9}\//i,/\bdoi\b/i];return this.findTextLineAnchor(e,(r,i)=>{if(!n.some(o=>o.test(r)))return!1;if(/download|citation|export|references|share|permissions|metrics/i.test(r)){const o=i.getAttribute("class")??"";if(!/(doi|citation|article-meta|publication|meta)/i.test(o))return!1}return!0},{preferInnermost:!0})}findPublicationLineAnchor(e){return this.findTextLineAnchor(e,(t,n)=>{if(!/\b(?:vol(?:ume)?|issue|published|accepted)\b/i.test(t)||t.length>420)return!1;const r=n.getAttribute("class")??"";return/(citation|article-meta|metadata|publication|date|history|volume|issue)/i.test(r)||/\b(?:published|accepted)\b/i.test(t)})}findTextLineAnchor(e,t,n={}){const r=n.relativeToTitle??"after",i=e.querySelector("h1"),o=Array.from(e.querySelectorAll("p, div, span, section, header, li")).filter(l=>!this.isHidden(l)).filter(l=>!l.closest('[class^="paperlens-"], [class*=" paperlens-"]')).filter(l=>!l.matches("article, main, body, nav, aside, form")).filter(l=>{if(!i||r==="any")return!0;const c=i.compareDocumentPosition(l);return r==="before"?!!(c&Node.DOCUMENT_POSITION_PRECEDING):!!(c&Node.DOCUMENT_POSITION_FOLLOWING)}).map(l=>this.blockAnchor(l,e)).filter((l,c,u)=>u.indexOf(l)===c).filter(l=>{const c=g(l.textContent);return!c||c.length>520||l.querySelector("h1, h2, h3, h4, nav, form")?!1:t(c,l)});return(n.preferInnermost?o.filter(l=>!o.some(c=>c!==l&&l.contains(c))):o).sort((l,c)=>this.scoreAnchor(c)-this.scoreAnchor(l)).at(0)??null}blockAnchor(e,t){if(!/^(a|span|strong|em|b|i|small|sup|sub)$/i.test(e.tagName)||e.matches('span[class*="doi" i], span[class*="citation" i], span[class*="meta" i]'))return e;const n=e.closest("p, div, section, header, li");return!n||n===t||n.matches("article, main, body")?e:n}isCitationCandidate(e){const t=g(e.textContent);return!t||t.length>360||e.matches("article, main, body")||e.querySelector("h1, h2, h3, h4, nav, form")?!1:!!(te(t)||/\bdoi\b/i.test(t)||/\b(?:vol(?:ume)?|issue|published|accepted)\b/i.test(t))}scoreAnchor(e){const t=g(e.textContent);let n=0;return(te(t)||/\bdoi\b/i.test(t))&&(n+=90),/\b(?:vol(?:ume)?|issue|\d+\(\d+\)|published|accepted)\b/i.test(t)&&(n+=45),/(citation|doi|meta|publication|volume|issue)/i.test(e.getAttribute("class")??"")&&(n+=30),n-=Math.min(t.length,360)/30,n}findAnchor(e,t){for(const n of t){const r=Array.from(e.querySelectorAll(n)).filter(i=>!this.isHidden(i)).filter(i=>g(i.textContent).length>0).at(-1);if(r)return r}return null}isHidden(e){return!!e.closest(["[hidden]",'[aria-hidden="true"]',".hidden",".hide",".modal",".popup",".toolbar",'[role="dialog"]','[role="menu"]'].join(","))}}const Ib={nejm:"New England Journal of Medicine","n engl j med":"New England Journal of Medicine","new engl j med":"New England Journal of Medicine",jama:"JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION",bmj:"BMJ","br med j":"BMJ","nat commun":"Nature Communications","nat med":"Nature Medicine","nat genet":"Nature Genetics","nat methods":"Nature Methods","nat biotechnol":"Nature Biotechnology","nat cell biol":"Nature Cell Biology","nat immunol":"Nature Immunology","nat neurosci":"Nature Neuroscience","nat rev cancer":"Nature Reviews Cancer","nat rev immunol":"Nature Reviews Immunology","nat rev drug discov":"Nature Reviews Drug Discovery","nat rev genet":"Nature Reviews Genetics","nat rev mol cell biol":"Nature Reviews Molecular Cell Biology","nat rev microbiol":"Nature Reviews Microbiology","nat rev clin oncol":"Nature Reviews Clinical Oncology","nat rev endocrinol":"Nature Reviews Endocrinology","nat struct mol biol":"Nature Structural & Molecular Biology","nat protoc":"Nature Protocols","nat chem biol":"Nature Chemical Biology","nat microbiol":"Nature Microbiology","nat aging":"Nature Aging","nat cancer":"Nature Cancer","sci adv":"Science Advances","sci transl med":"Science Translational Medicine","cell metab":"Cell Metabolism","cell stem cell":"Cell Stem Cell","mol cell":"Molecular Cell","cancer cell":"Cancer Cell","cell rep":"Cell Reports","cell rep med":"Cell Reports Medicine","cancer res":"Cancer Research","cancer discov":"Cancer Discovery","cancer prev res":"Cancer Prevention Research","j clin oncol":"Journal of Clinical Oncology",jco:"Journal of Clinical Oncology","ann oncol":"Annals of Oncology","ca cancer j clin":"CA-A Cancer Journal for Clinicians","clin cancer res":"Clinical Cancer Research","j natl cancer inst":"JNCI-Journal of the National Cancer Institute","br j cancer":"British Journal of Cancer","eur j cancer":"European Journal of Cancer","j egypt natl canc inst":"Journal of the Egyptian National Cancer Institute","j egypt natl cancer inst":"Journal of the Egyptian National Cancer Institute","mol cancer":"Molecular Cancer",oncogene:"Oncogene","j hematol oncol":"Journal of Hematology & Oncology","am j gastroenterol":"American Journal of Gastroenterology","lancet gastroenterol hepatol":"Lancet Gastroenterology & Hepatology","aliment pharmacol ther":"Alimentary Pharmacology & Therapeutics","inflamm bowel dis":"Inflammatory Bowel Diseases","lancet oncol":"Lancet Oncology","lancet neurol":"Lancet Neurology","lancet psychiatry":"Lancet Psychiatry","lancet diab endocrinol":"Lancet Diabetes & Endocrinology","lancet respir med":"Lancet Respiratory Medicine","lancet infect dis":"Lancet Infectious Diseases","lancet glob health":"Lancet Global Health","lancet public health":"Lancet Public Health","int j epidemiol":"International Journal of Epidemiology","am j epidemiol":"American Journal of Epidemiology","am j public health":"American Journal of Public Health","j exp med":"Journal of Experimental Medicine","j immunol":"Journal of Immunology","j am coll cardiol":"Journal of the American College of Cardiology","eur heart j":"European Heart Journal",circulation:"Circulation",blood:"Blood","am j respir crit care med":"American Journal of Respiratory and Critical Care Medicine",chest:"Chest",thorax:"Thorax",brain:"Brain","diabetes care":"Diabetes Care","j clin invest":"Journal of Clinical Investigation",jci:"Journal of Clinical Investigation",pnas:"PNAS","proc natl acad sci u s a":"PNAS","proc natl acad sci":"PNAS","plos med":"PLOS Medicine","plos one":"PLOS ONE","plos biol":"PLOS Biology","bmc med":"BMC Medicine","sci rep":"Scientific Reports",elife:"eLife","front med":"Frontiers in Medicine","int j mol sci":"International Journal of Molecular Sciences","genome med":"Genome Medicine","gut microbes":"Gut Microbes",hepatology:"Hepatology","j hepatol":"Journal of Hepatology",ebiomedicine:"EBioMedicine",theranostics:"Theranostics","signal transduct target ther":"Signal Transduction and Targeted Therapy","ann intern med":"Annals of Internal Medicine","jama oncol":"JAMA Oncology","jama intern med":"JAMA Internal Medicine","jama cardiol":"JAMA Cardiology","jama neurol":"JAMA Neurology","pharmacol rev":"Pharmacological Reviews","physiol rev":"Physiological Reviews"};function qn(a){return a.toLowerCase().replace(/[.,;:'\-&]/g," ").replace(/\s+/g," ").replace(/^the\s+/,"").trim()}function Mb(a){const e=qn(a);return Ib[e]??null}const Bb="paperlens-journals",jb=1,$n="journals",qb="__meta__",Hl="__data__",Lr="http://47.102.208.204/api/v1".replace(/\/+$/,""),$b=10080*60*1e3,Ob=[["science"],["jncijournalofthenationalcancerinstitute","journalofthenationalcancerinstitute"],["surgicalclinicsofnorthamerica"]];function Gi(){return typeof globalThis.indexedDB<"u"}function zl(){return new Promise((a,e)=>{if(!Gi()){e(new Error("IndexedDB is not available"));return}const t=globalThis.indexedDB.open(Bb,jb);t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains($n)||n.createObjectStore($n)},t.onsuccess=()=>a(t.result),t.onerror=()=>e(t.error)})}function Ub(a){return Gi()?zl().then(e=>new Promise((t,n)=>{const o=e.transaction($n,"readonly").objectStore($n).get(a);o.onsuccess=()=>t(o.result),o.onerror=()=>n(o.error)})):Promise.resolve(void 0)}function Jl(a,e){return Gi()?zl().then(t=>new Promise((n,r)=>{const s=t.transaction($n,"readwrite").objectStore($n).put(e,a);s.onsuccess=()=>n(),s.onerror=()=>r(s.error)})):Promise.resolve()}function Hb(){return Lr.startsWith("http://")&&typeof window<"u"&&window.location.protocol==="https:"&&typeof $<"u"&&!!$.runtime?.sendMessage}async function Vl(a,e){if(!Lr)return null;if(Hb()){const n=await $.runtime.sendMessage({type:"FETCH_BACKEND_JSON",payload:{path:a,timeoutMs:e}});return!n?.success||!n.data?null:n.data}const t=await fetch(`${Lr}${a}`,{headers:{Accept:"application/json"},signal:AbortSignal.timeout(e)});return t.status===304?{ok:t.ok,status:t.status,data:null}:{ok:t.ok,status:t.status,data:await t.json()}}async function zb(){if(!Lr)return null;try{const a=await Vl("/journals/meta",5e3);return!a?.ok||!a.data?null:a.data}catch{return null}}async function Jb(){if(!Lr)return null;try{const a=await zb();if(!a)return null;const e=await Wl();if(e&&e.versionHash===a.version_hash)return{version_hash:a.version_hash,journals:e.journals};const t=await Vl(`/journals?version_hash=${encodeURIComponent(a.version_hash)}`,3e4);if(!t)return null;if(t.status===304)return e?{version_hash:a.version_hash,journals:e.journals}:null;if(!t.ok)return null;const n=t.data;if(!n)return null;const r=Array.isArray(n)?n:n.journals??[];return await Jl(Hl,{versionHash:a.version_hash,journals:r,cachedAt:Date.now()}),await Jl(qb,{versionHash:a.version_hash,total:a.total,updatedAt:a.updated_at}),{version_hash:a.version_hash,journals:r}}catch{return null}}async function Vb(){const a=$.runtime.getURL("/data/journals.json");return{journals:(await(await fetch(a)).json()).journals}}async function Wl(){return Ub(Hl)}function Gl(a){return qn(a??"").replace(/\s+/g,"")}function Yl(a){const e=new Set;for(const t of a)e.add(Gl(t.normalizedName)),e.add(Gl(t.journalName));return Ob.every(t=>t.some(n=>e.has(n)))}async function Wb(){const a=await Jb();if(a&&a.journals.length>0&&Yl(a.journals))return{source:"server",journals:a.journals};const e=await Wl();if(e&&e.journals.length>0&&Date.now()-e.cachedAt<$b&&Yl(e.journals))return{source:"cache",journals:e.journals};try{return{source:"builtin",journals:(await Vb()).journals}}catch{return e&&e.journals.length>0?{source:"cache",journals:e.journals}:{source:"builtin",journals:[]}}}function Gb(a,e){if(a===e)return 0;if(a.length===0)return e.length;if(e.length===0)return a.length;a.length>e.length&&([a,e]=[e,a]);const t=a.length,n=e.length;let r=Array.from({length:t+1},(i,o)=>o);for(let i=1;i<=n;i++){const o=new Array(t+1);o[0]=i;for(let s=1;s<=t;s++){const l=a[s-1]===e[i-1]?0:1;o[s]=Math.min(o[s-1]+1,r[s]+1,r[s-1]+l)}r=o}return r[t]}let Yi=null,Nr=null,Rr=null;const Yb=new Set(["a","an","and","de","for","in","of","the"]);function On(a){return a.toLowerCase().replace(/[^a-z0-9]+/g," ").split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0&&!Yb.has(e))}function Zb(a){return qn(a).replace(/\s+/g,"")}function Qb(a){return On(a).join(" ")}function Kb(a){return On(a).join("")}function va(a){const e=a.trim().toUpperCase(),t=e.replace(/[^0-9X]/g,""),n=new Set;return e&&n.add(e),/^\d{7}[\dX]$/.test(t)&&(n.add(t),n.add(`${t.slice(0,4)}-${t.slice(4)}`)),[...n]}function Zl(a,e){return a===e?!0:(a.length===1,e.startsWith(a))}function Xb(a,e){const t=On(a);if(t.length===0)return!1;const n=On(e);return t.length!==n.length?!1:t.length===1?t[0]===n[0]:t.every((r,i)=>Zl(r,n[i]))}function eg(a){const e=[],t=a.match(/^([A-Z0-9]{2,10})\s*[-–—:]\s*(.+)$/);return t?.[2]&&e.push(t[2]),t?.[1]&&t[1].length<=4&&e.push(t[1]),e}function Pr(a){const e=new Set,t=qn(a);t&&e.add(t);const n=Zb(a);n&&e.add(n);const r=Qb(a);r&&e.add(r);const i=Kb(a);return i&&e.add(i),[...e]}function Zi(a,e,t,n){if(!t||e.has(t))return;const r=a.get(t);if(!r){a.set(t,n);return}r.journalName!==n.journalName&&(a.delete(t),e.add(t))}function Ql(a,e,t){if(!e)return;const n=a.get(e)??new Set;n.add(t.journalName),a.set(e,n)}function tg(a){const e=new Map;for(const t of a){Ql(e,t.normalizedName,t);for(const n of Pr(t.journalName))Ql(e,n,t)}return e}function ng(a,e,t){const n=t.get(a);return n?n.size>1||!n.has(e.journalName):!1}function Kl(a){let e=a.replace(/\s+/g," ").trim();if(!e)return"";const t=e.split(/\s[-–—]\s/).map(n=>n.trim()).filter(Boolean);return t.length>=2&&(e=t[1]),e=e.replace(/\b(?:19|20)\d{2}\b[\s\S]*$/,"").replace(/\b(?:vol(?:ume)?|issue|no\.?|number|pages?|pp\.?)\b[\s\S]*$/i,"").replace(/\s+\d+\s*(?:\([^)]*\))?[\s\S]*$/,"").replace(/[,.;:\s]+$/,"").trim(),e}function rg(a){return a.trim().match(/^[A-Z0-9]{2,10}\s*[-–—:]\s*(.+)$/)?.[1]?.trim()||null}function ag(a){const e=a.trim().replace(/\s+\([A-Za-z][A-Za-z .'-]{1,40}\)\s*$/,"").trim();return e&&e!==a.trim()?e:null}function ig(a){const e=new Set,t=n=>{const r=n?.replace(/\s+/g," ").trim();r&&e.add(r)};t(a),t(Kl(a));for(const n of[...e])t(rg(n)),t(ag(n));return[...e]}function og(a,e){const t=On(a);if(t.length<2)return!1;const n=On(e);return t.length>=n.length?!1:t.every((r,i)=>Zl(r,n[i]))}function sg(a,e){const t=[],n=new Set;for(const r of e)og(a,r.journalName)&&(n.has(r.journalName)||(n.add(r.journalName),t.push(r)));return t.length===1?t[0]:null}function lg(a){const e=new Map,t=new Map,n=new Set,r=tg(a);for(const i of a){Zi(e,n,i.normalizedName,i);for(const s of Pr(i.journalName))Zi(e,n,s,i);for(const s of eg(i.journalName))for(const l of Pr(s))ng(l,i,r)||Zi(e,n,l,i);const o=i.issn;if(Array.isArray(o))for(const s of o)for(const l of va(s))t.set(l,i);else if(typeof o=="string"&&o)for(const s of va(o))t.set(s,i)}return{nameMap:e,issnMap:t}}async function Un(){return Yi||Rr||(Rr=(async()=>{try{const{journals:a}=await Wb(),{nameMap:e,issnMap:t}=lg(a);return Yi=e,Nr=t,e}finally{Rr=null}})(),Rr)}const Xl=2;function cg(a){return/[\u3400-\u9fff]/.test(a)}function ug(a){return!a||cg(a)?!1:a.replace(/[^a-z0-9]/gi,"").length>=4}async function Ir(a,e){const t=qn(a),n=e?.trim();if(!t&&!n)return null;const r=await Un();if(e&&Nr)for(const c of va(e)){const u=Nr.get(c);if(u)return{journal:u,confidence:"exact",matchMethod:"issn"}}if(Nr)for(const c of va(a)){const u=Nr.get(c);if(u)return{journal:u,confidence:"exact",matchMethod:"issn"}}const i=ig(a);for(const c of i)for(const u of Pr(c)){const d=r.get(u);if(d)return{journal:d,confidence:"exact",matchMethod:"normalizedName"}}for(const c of i){const u=Mb(c);if(u)for(const d of Pr(u)){const p=r.get(d);if(p)return{journal:p,confidence:"exact",matchMethod:"abbreviation"}}}for(const c of i)for(const u of new Set(r.values()))if(Xb(c,u.journalName))return{journal:u,confidence:"exact",matchMethod:"abbreviation"};for(const c of i){const u=sg(c,new Set(r.values()));if(u)return{journal:u,confidence:"exact",matchMethod:"shortTitle"}}const o=qn(Kl(a)||a);if(!ug(o))return null;let s=null,l=1/0;for(const[c,u]of r){if(Math.abs(c.length-o.length)>Xl)continue;const d=Gb(o,c);if(d<=Xl&&d<l&&(l=d,s=u,d===1))break}return s?{journal:s,confidence:"fuzzy",matchMethod:"levenshtein",levenshteinDistance:l}:null}async function wa(a){await Un();const e=new Map;for(const t of a){const n=t.journal?.trim();if(!n&&!t.issn)continue;const r=await Ir(n??"",t.issn);r&&e.set(t.id,r)}return e}const qe=`/**
 * PaperLens Design Tokens
 *
 * \u4EE5 CSS Custom Properties \u5F62\u5F0F\u5B9A\u4E49\u7684\u8BBE\u8BA1\u53D8\u91CF\uFF0C\u7EDF\u4E00\u4F7F\u7528 --pl- \u524D\u7F00\u3002
 * \u8FD9\u4E9B token \u88AB\u6CE8\u5165\u5230 Shadow DOM \u5185\u90E8\uFF0C\u4E0E\u5BBF\u4E3B\u9875\u9762\u6837\u5F0F\u5B8C\u5168\u9694\u79BB\u3002
 *
 * \u547D\u540D\u89C4\u8303\uFF1A--pl-{category}-{variant}
 */

:host {
  /* \u2500\u2500 Safari color-scheme support \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  color-scheme: light;

  /* \u2500\u2500 \u54C1\u724C\u8272 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-color-primary:        #2563eb;
  --pl-color-primary-hover:  #1d4ed8;
  --pl-color-primary-light:  #dbeafe;
  --pl-color-secondary:      #4f46e5;
  --pl-color-accent:         #0ea5e9;

  /* \u2500\u2500 \u529F\u80FD\u8272 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-color-success:        #10b981;
  --pl-color-success-light:  #d1fae5;
  --pl-color-warning:        #f59e0b;
  --pl-color-warning-light:  #fef3c7;
  --pl-color-error:          #ef4444;
  --pl-color-error-light:    #fee2e2;
  --pl-color-info:           #3b82f6;
  --pl-color-info-light:     #dbeafe;

  /* \u2500\u2500 \u4E2D\u6027\u8272 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-color-white:          #ffffff;
  --pl-color-gray-50:        #f9fafb;
  --pl-color-gray-100:       #f3f4f6;
  --pl-color-gray-200:       #e5e7eb;
  --pl-color-gray-300:       #d1d5db;
  --pl-color-gray-400:       #9ca3af;
  --pl-color-gray-500:       #6b7280;
  --pl-color-gray-600:       #4b5563;
  --pl-color-gray-700:       #374151;
  --pl-color-gray-800:       #1f2937;
  --pl-color-gray-900:       #111827;

  /* \u2500\u2500 \u5B57\u53F7\u5C42\u7EA7 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-font-xs:    11px;
  --pl-font-sm:    12px;
  --pl-font-base:  14px;
  --pl-font-lg:    16px;
  --pl-font-xl:    20px;

  /* \u2500\u2500 \u5B57\u91CD \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-weight-normal:    400;
  --pl-weight-medium:    500;
  --pl-weight-semibold:  600;
  --pl-weight-bold:      700;

  /* \u2500\u2500 \u5B57\u4F53\u65CF \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  --pl-font-mono:  'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', 'Droid Sans Mono', 'Source Code Pro', monospace;

  /* \u2500\u2500 \u95F4\u8DDD\u5C42\u7EA7 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-space-xxs:  2px;
  --pl-space-xs:   4px;
  --pl-space-sm:   8px;
  --pl-space-md:   12px;
  --pl-space-lg:   16px;
  --pl-space-xl:   24px;

  /* \u2500\u2500 \u5706\u89D2 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-radius-sm:   4px;
  --pl-radius-md:   8px;
  --pl-radius-lg:   12px;
  --pl-radius-full: 9999px;

  /* \u2500\u2500 \u9634\u5F71 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-shadow-sm:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --pl-shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --pl-shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  /* \u2500\u2500 \u8FC7\u6E21\u65F6\u95F4 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-transition-fast:   150ms ease;
  --pl-transition-normal: 250ms ease;
  --pl-transition-slow:   350ms ease;

  /* \u2500\u2500 Semantic color tokens (light mode only) \u2500\u2500 */
  --pl-color-bg:            #ffffff;
  --pl-color-surface:       #f9fafb;
  --pl-color-text:          #1f2937;
  --pl-color-text-secondary:#6b7280;
  --pl-color-border:        #e5e7eb;
  --pl-color-shadow:        rgba(0, 0, 0, 0.05);

  /* \u2500\u2500 Z-index \u5C42\u7EA7\uFF08Shadow DOM \u5185\u90E8\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
  --pl-z-base:     1;
  --pl-z-dropdown:  10;
  --pl-z-sticky:    20;
  --pl-z-modal:     30;
  --pl-z-tooltip:   40;
}
`,dg=`/**
 * Metric Bar Styles \u2014 injected into each metric bar's Shadow DOM
 *
 * \u6BCF\u4E2A Metric Bar \u5BBF\u4E3B\u5143\u7D20\u62E5\u6709\u72EC\u7ACB Shadow DOM\uFF0C
 * \u6837\u5F0F\u5B8C\u5168\u9694\u79BB\u4E8E PubMed \u9875\u9762\u3002
 *
 * Design Token \u4F9D\u8D56\uFF1A
 *   --pl-color-* / --pl-font-* / --pl-space-* / --pl-radius-*
 *   \u7531 tokens.css \u5728\u540C\u4E00 Shadow DOM \u5185\u901A\u8FC7 :host \u5B9A\u4E49
 */

/* \u2500\u2500 \u5BBF\u4E3B\u5143\u7D20\uFF08PubMed DOM \u4E2D\u7684 div\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
:host {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 4px 0 5px;
  font: inherit;
}

:host([data-pl-layout="compact"]) {
  font-size: 13px;
}

/* \u2500\u2500 \u6307\u6807\u6761\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-bar {
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: min(100%, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--pl-metric-border);
  border-radius: var(--pl-radius-sm);
  background: var(--pl-metric-bg);
  box-shadow: var(--pl-shadow-sm);
  font: inherit;
  line-height: 1;
}

/* \u2500\u2500 \u5355\u884C\u5206\u6BB5\u57FA\u7840\u6837\u5F0F \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-cell {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 1.45em;
  padding: 0 0.48em;
  border-right: 1px solid color-mix(in srgb, var(--pl-metric-border), transparent 35%);
  color: var(--pl-metric-text);
  font: inherit;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
}

:host([data-pl-layout="compact"]) .pl-metric-cell {
  min-height: 1.32em;
  padding: 0 0.34em;
}

.pl-metric-cell:last-child {
  border-right: 0;
}

.pl-metric-journal {
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(var(--pl-metric-journal-max, 24ch), 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--pl-metric-journal-bg);
  cursor: help;
  white-space: nowrap;
}

:host([data-pl-layout="compact"]) .pl-metric-journal {
  max-width: min(var(--pl-metric-journal-max, 24ch), 100%);
}

.pl-metric-if,
.pl-metric-date {
  background: var(--pl-metric-soft-bg);
}

.pl-metric-oa {
  background: #dcfce7;
  color: #166534;
}

.pl-metric-type {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.58);
  color: var(--pl-color-gray-700);
}

/* \u2500\u2500 JCR \u5206\u533A badges (Q1 \u2192 Q4) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-q1 {
  background-color: #b91c1c;
  color: #ffffff;
}

.pl-metric-q2 {
  background-color: #15803d;
  color: #ffffff;
}

.pl-metric-q3 {
  background-color: #b45309;
  color: #ffffff;
}

.pl-metric-q4 {
  background-color: #475569;
  color: #ffffff;
}

/* \u2500\u2500 \u4E2D\u79D1\u9662\u5206\u533A badges (1\u533A \u2192 4\u533A) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-cas-1 {
  background-color: rgba(185, 28, 28, 0.1);
  color: #7f1d1d;
}

.pl-metric-cas-2 {
  background-color: rgba(21, 128, 61, 0.1);
  color: #14532d;
}

.pl-metric-cas-3 {
  background-color: rgba(180, 83, 9, 0.11);
  color: #78350f;
}

.pl-metric-cas-4 {
  background-color: rgba(71, 85, 105, 0.1);
  color: #334155;
}

.pl-metric-bar--q1 {
  --pl-metric-bg: #fff7ed;
  --pl-metric-soft-bg: #ffedd5;
  --pl-metric-journal-bg: #fed7aa;
  --pl-metric-border: #fdba74;
  --pl-metric-text: #7c2d12;
}

.pl-metric-bar--q2 {
  --pl-metric-bg: #f0fdf4;
  --pl-metric-soft-bg: #dcfce7;
  --pl-metric-journal-bg: #bbf7d0;
  --pl-metric-border: #86efac;
  --pl-metric-text: #14532d;
}

.pl-metric-bar--q3 {
  --pl-metric-bg: #fffbeb;
  --pl-metric-soft-bg: #fef3c7;
  --pl-metric-journal-bg: #fde68a;
  --pl-metric-border: #fcd34d;
  --pl-metric-text: #78350f;
}

.pl-metric-bar--q4 {
  --pl-metric-bg: #f8fafc;
  --pl-metric-soft-bg: #e2e8f0;
  --pl-metric-journal-bg: #cbd5e1;
  --pl-metric-border: #94a3b8;
  --pl-metric-text: #1e293b;
}

@media (max-width: 760px) {
  .pl-metric-cell {
    padding: 0 0.36em;
  }
}

/* \u2500\u2500 Warning badges \u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-warnings {
  gap: 2px;
  padding: 0 4px;
  background: rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

/* \u2500\u2500 Shimmer / Skeleton \u9AA8\u67B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-metric-shimmer {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  padding: 2px 0;
  margin-top: 2px;
  height: 20px;
}

.pl-shimmer-bar {
  display: inline-block;
  height: 16px;
  border-radius: var(--pl-radius-sm);
  background: linear-gradient(
    90deg,
    var(--pl-color-gray-100) 25%,
    var(--pl-color-gray-200) 50%,
    var(--pl-color-gray-100) 75%
  );
  background-size: 200% 100%;
  animation: pl-shimmer 1.5s ease-in-out infinite;
}

.pl-shimmer-bar--if {
  width: 60px;
}

.pl-shimmer-bar--q {
  width: 28px;
}

@keyframes pl-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
`;function ec(a){const e=document.createDocumentFragment();return a.casWarning&&e.appendChild(Qi("\u26A0","#C53030","\u4E2D\u79D1\u9662\u9884\u8B66\u671F\u520A",hg(a))),a.wosStatus==="delisted"?e.appendChild(Qi("\u{1F6AB}","#C53030","\u5DF2\u4ECE Web of Science \u79FB\u9664","\u8BE5\u671F\u520A\u5DF2\u4ECE Clarivate Web of Science \u79FB\u9664\uFF0C<br/>\u4E0D\u518D\u83B7\u5F97\u5F71\u54CD\u56E0\u5B50\u3002")):a.wosStatus==="on_hold"&&e.appendChild(Qi("\u23F8","#C05621","Web of Science \u6682\u505C\u6536\u5F55","\u8BE5\u671F\u520A\u88AB Clarivate \u6682\u505C\u6536\u5F55\uFF0C<br/>\u5F71\u54CD\u56E0\u5B50\u53EF\u80FD\u6682\u505C\u66F4\u65B0\u3002")),e}function tc(a){if(a.querySelector(".pl-warn-badge-style"))return;const e=document.createElement("style");e.className="pl-warn-badge-style",e.textContent=fg,a.appendChild(e)}function pg(){if(document.getElementById("pl-warn-popover-global-style"))return;const a=document.createElement("style");a.id="pl-warn-popover-global-style",a.textContent=mg,document.head.appendChild(a)}function hg(a){return`\u8BE5\u671F\u520A\u88AB\u5217\u5165\u4E2D\u79D1\u9662\u56FD\u9645\u671F\u520A\u9884\u8B66\u540D\u5355\u3002<br/><br/><b>\u9884\u8B66\u5E74\u4EFD\uFF1A</b>${a.casWarningYears?.map(String).join("\u3001")||"\u672A\u77E5"}<br/>\u88AB\u9884\u8B66\u671F\u520A\u53EF\u80FD\u5F71\u54CD\u804C\u79F0\u8BC4\u5BA1<br/>\u53CA\u79D1\u7814\u7ECF\u8D39\u8BA4\u53EF\uFF0C\u6295\u7A3F\u9700\u8C28\u614E\u8BC4\u4F30\u3002`}let he=null;function un(){he&&(he.popover.classList.remove("pl-warn-popover--visible"),he.trigger.setAttribute("aria-expanded","false"),he.popover.remove(),he=null)}function nc(a,e){const t=e.getBoundingClientRect(),n=220,r=a.offsetHeight||120;let i=t.top-r-6,o=t.left+t.width/2-n/2;i<4&&(i=t.bottom+6);const s=4;o<s&&(o=s),o+n>window.innerWidth-s&&(o=window.innerWidth-s-n),a.style.top=`${i}px`,a.style.left=`${o}px`}function rc(a,e){un(),pg(),document.body.appendChild(a),nc(a,e),requestAnimationFrame(()=>a.classList.add("pl-warn-popover--visible")),e.setAttribute("aria-expanded","true"),he={popover:a,trigger:e}}function Qi(a,e,t,n){const r=document.createElement("button");r.type="button",r.className="pl-warn-badge",r.style.color=e,r.setAttribute("aria-label",t),r.setAttribute("aria-haspopup","dialog"),r.setAttribute("aria-expanded","false"),r.textContent=a;let i=null;function o(){return i||(i=document.createElement("span"),i.className="pl-warn-popover",i.setAttribute("role","tooltip"),i.innerHTML=`<b class="pl-warn-popover-title" style="color:${e}">${a} ${t}</b><div class="pl-warn-popover-body">${n}</div>`),i}r.addEventListener("click",l=>{l.stopPropagation(),he&&he.trigger===r?un():rc(o(),r)}),r.addEventListener("keydown",l=>{l.key==="Escape"&&(un(),r.focus())}),r.addEventListener("mouseenter",()=>{(!he||he.trigger===r)&&rc(o(),r)}),r.addEventListener("mouseleave",()=>{he?.trigger===r&&setTimeout(()=>{he?.trigger===r&&!r.matches(":focus-within")&&un()},200)});const s=new MutationObserver(()=>{document.contains(r)||(he?.trigger===r&&un(),s.disconnect(),i=null)});return s.observe(r.parentNode||document.body,{childList:!0,subtree:!0}),r}document.addEventListener("click",a=>{he&&!he.trigger.contains(a.target)&&!he.popover.contains(a.target)&&un()}),document.addEventListener("keydown",a=>{a.key==="Escape"&&he&&un()});const ac=()=>{he&&nc(he.popover,he.trigger)};window.addEventListener("scroll",ac,{passive:!0}),window.addEventListener("resize",ac,{passive:!0});const fg=`
.pl-warn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: transform 0.15s ease;
  padding: 0 1px;
  background: none;
  border: none;
  font-family: inherit;
}
.pl-warn-badge:hover {
  transform: scale(1.25);
}
.pl-warn-badge:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
  border-radius: 2px;
}
`,mg=`
.pl-warn-popover {
  position: fixed;
  width: 220px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: #334155;
  z-index: 2147483647;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.pl-warn-popover--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.pl-warn-popover-title {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.pl-warn-popover-body {
  font-weight: 400;
  color: #475569;
}
.pl-warn-popover-body b {
  color: #334155;
  font-weight: 500;
}
`,bg=new Set(["","undefined","null","none","n/a","na","-","--","?"]);function Mr(a){const e=String(a??"").trim();if(bg.has(e.toLowerCase()))return null;const t=e.match(/[1-4]/)?.[0];return t?{value:t,label:`${t}\u533A`}:null}function gg(a){return Mr(a)?.value}const ut=340,zt=180,Ce={top:24,right:16,bottom:30,left:42},yg=3,xg=5;function mt(a,e){return getComputedStyle(document.documentElement).getPropertyValue(a).trim()||e}function Sa(a,e,t={}){const n=a.getContext("2d");if(!n)return;const r=window.devicePixelRatio||1;if(a.width=ut*r,a.height=zt*r,a.style.width=`${ut}px`,a.style.height=`${zt}px`,n.scale(r,r),!e||e.length===0){Ag(n);return}const i=ut-Ce.left-Ce.right,o=zt-Ce.top-Ce.bottom,s=e.map(R=>R.year),l=e.map(R=>R.if),c=Math.min(...s),u=Math.max(...s),d=Math.ceil(Math.max(...l)*1.15),p=R=>Ce.left+(R-c)/(u-c||1)*i,m=R=>Ce.top+o-R/(d||1)*o,h=mt("--pl-color-primary","#2563eb"),y=mt("--pl-color-text-secondary","#6b7280"),x=mt("--pl-color-border","#e5e7eb"),T=mt("--pl-color-bg","#ffffff"),F=mt("--pl-color-primary","#2563eb"),w=mt("--pl-color-gray-800","#1f2937"),b=mt("--pl-color-white","#ffffff");n.clearRect(0,0,ut,zt);const v=4;n.strokeStyle=x,n.lineWidth=.5,n.font="10px -apple-system, BlinkMacSystemFont, sans-serif",n.fillStyle=y,n.textAlign="right",n.textBaseline="middle";for(let R=0;R<=v;R++){const E=d/v*R,I=m(E);n.beginPath(),n.moveTo(Ce.left,I),n.lineTo(ut-Ce.right,I),n.stroke(),n.fillText(E.toFixed(E>=100?0:1),Ce.left-4,I)}n.textAlign="center",n.textBaseline="top";const D=wg(n,s,i);for(const R of D){const E=p(e[R].year);n.fillText(String(e[R].year),E,zt-Ce.bottom+6)}n.strokeStyle=h,n.lineWidth=2,n.lineJoin="round",n.lineCap="round",n.beginPath();for(let R=0;R<e.length;R++){const E=p(e[R].year),I=m(e[R].if);R===0?n.moveTo(E,I):n.lineTo(E,I)}n.stroke();for(const R of e){const E=p(R.year),I=m(R.if);n.beginPath(),n.arc(E,I,yg,0,Math.PI*2),n.fillStyle=F,n.fill(),n.strokeStyle=T,n.lineWidth=1.5,n.stroke()}t.showPointValueLabels&&Cg(n,e.map((R,E)=>({index:E,value:R.if,x:p(R.year),y:m(R.if)})),y,T);const B={data:e,minYear:c,maxYear:u,maxIF:d,xScale:p,yScale:m,tooltipBg:w,tooltipText:b,textColor:y,bgColor:T,showPointValueLabels:!!t.showPointValueLabels},U=a._trendHandler;U&&(a.removeEventListener("mousemove",U),a.removeEventListener("mouseleave",U));const L=vg(a,B);a._trendHandler=L,a.addEventListener("mousemove",L),a.addEventListener("mouseleave",L)}function Ag(a){const e=mt("--pl-color-text-secondary","#6b7280");a.clearRect(0,0,ut,zt),a.font="13px -apple-system, BlinkMacSystemFont, sans-serif",a.fillStyle=e,a.textAlign="center",a.textBaseline="middle",a.fillText("\u6682\u65E0\u5386\u5E74 IF \u6570\u636E",ut/2,zt/2)}function ic(a){return a>=10?a.toFixed(1):a.toFixed(2).replace(/\.?0+$/,"")}function Cg(a,e,t,n){a.save(),a.font="10px -apple-system, BlinkMacSystemFont, sans-serif",a.textAlign="center",a.textBaseline="middle";const r=[];for(const i of e){const o=ic(i.value),s=a.measureText(o).width;let l=i.x;l-s/2<Ce.left&&(l=Ce.left+s/2),l+s/2>ut-Ce.right&&(l=ut-Ce.right-s/2);const c=i.index%2===1||i.y-Ce.top<14,u=[c?i.y+13:i.y-11,c?i.y-11:i.y+13,c?i.y+24:i.y-23].map(m=>Math.max(Ce.top+7,Math.min(zt-Ce.bottom-7,m)));let d=u[0],p=!1;for(const m of u){const h={left:l-s/2-2,right:l+s/2+2,top:m-7,bottom:m+7};if(!r.some(y=>h.left<y.right&&h.right>y.left&&h.top<y.bottom&&h.bottom>y.top)){d=m,r.push(h),p=!0;break}}p||r.push({left:l-s/2-2,right:l+s/2+2,top:d-7,bottom:d+7}),a.strokeStyle=n,a.lineWidth=3,a.strokeText(o,l,d),a.fillStyle=t,a.fillText(o,l,d)}a.restore()}function vg(a,e){let t=-1;return n=>{if(!a.getContext("2d"))return;const i=a.getBoundingClientRect(),o=n.clientX-i.left,s=n.clientY-i.top;if(n.type==="mouseleave"){t=-1,Sa(a,e.data,{showPointValueLabels:e.showPointValueLabels});return}let l=-1,c=1/0;for(let w=0;w<e.data.length;w++){const b=e.xScale(e.data[w].year),v=e.yScale(e.data[w].if),D=Math.hypot(o-b,s-v);D<c&&(c=D,l=w)}if(c>30||l<0){t!==-1&&(t=-1,Sa(a,e.data,{showPointValueLabels:e.showPointValueLabels}));return}if(l===t)return;t=l,Sa(a,e.data,{showPointValueLabels:e.showPointValueLabels});const u=a.getContext("2d");if(!u)return;u.save();const d=e.data[l],p=e.xScale(d.year),m=e.yScale(d.if);u.beginPath(),u.arc(p,m,xg,0,Math.PI*2),u.fillStyle=mt("--pl-color-primary","#2563eb"),u.fill(),u.strokeStyle=mt("--pl-color-bg","#ffffff"),u.lineWidth=2,u.stroke();const h=`${d.year}: IF ${ic(d.if)}`;u.font="11px -apple-system, BlinkMacSystemFont, sans-serif";const y=u.measureText(h).width+12,x=20;let T=p-y/2,F=m-x-8;F<2&&(F=m+10),T<2&&(T=2),T+y>ut-2&&(T=ut-y-2),u.fillStyle=e.tooltipBg,u.beginPath(),u.roundRect(T,F,y,x,3),u.fill(),u.fillStyle=e.tooltipText,u.textAlign="center",u.textBaseline="middle",u.fillText(h,T+y/2,F+x/2),u.restore()}}function wg(a,e,t){if(e.length<=2)return e.map((s,l)=>l);const n=e.reduce((s,l)=>Math.max(s,a.measureText(String(l)).width),0),r=Math.max(2,Math.floor(t/Math.max(1,n+12)));if(e.length<=r)return e.map((s,l)=>l);const i=Math.max(1,Math.ceil((e.length-1)/Math.max(1,r-1))),o=new Set([0,e.length-1]);for(let s=i;s<e.length-1;s+=i)o.add(s);return Array.from(o).sort((s,l)=>s-l)}const Sg="paperlens-journal-trend-popover",oc="paperlens-journal-trend-popover-style",sc="data-paperlens-trend-hover-bound";let Ki=null,Ta=null;function Hn(a,e){if(!e.journalName||a.getAttribute(sc)==="1")return;a.setAttribute(sc,"1");let t=null,n=!1,r=0;const i=()=>{t&&(clearTimeout(t),t=null)},o=l=>{n=!0;const c=++r;i(),t=setTimeout(()=>{Tg(a,e,()=>n&&c===r)},l)},s=()=>{n=!1,r++,i(),cc()};a.addEventListener("mouseenter",()=>{o(e.delayMs??280)}),a.addEventListener("mouseleave",s),a.addEventListener("focus",()=>{o(0)}),a.addEventListener("blur",s)}async function Tg(a,e,t){let n;try{n=await Promise.resolve(e.getTrendData())}catch{n=[]}if(n.length<2&&!e.journal||!t()||!a.isConnected)return;_a(),Ng(),uc();const r=document.createElement("div");r.id=Sg,r.className="paperlens-journal-trend-popover",r.setAttribute("role","dialog"),r.setAttribute("aria-label",`${e.journalName} \u671F\u520A\u8BE6\u60C5`),r.appendChild(Eg(e,n)),document.body.appendChild(r),Ki=r,Lg(r,a);const i=r.querySelector(".paperlens-journal-trend-canvas");i&&n.length>=2&&requestAnimationFrame(()=>Sa(i,n,{showPointValueLabels:!0})),r.addEventListener("mouseenter",_a),r.addEventListener("mouseleave",cc)}function Eg(a,e){const t=document.createElement("div");t.className="paperlens-journal-preview";const n=a.journal,r=e[0],i=e[e.length-1],o=document.createElement("div");o.className="paperlens-journal-trend-header";const s=document.createElement("div");s.className="paperlens-journal-title-wrap";const l=document.createElement("div");l.className="paperlens-journal-trend-title",l.textContent=n?.journalName??a.journalName,s.appendChild(l);const c=document.createElement("div");c.className="paperlens-journal-preview-subtitle",c.textContent=[n?.issn?.length?`ISSN ${n.issn.filter(d=>d&&d!=="N/A").slice(0,2).join(", ")}`:"",n?.country].filter(Boolean).join(" \xB7 "),c.textContent&&s.appendChild(c);const u=document.createElement("div");if(u.className="paperlens-journal-trend-range",u.textContent=r&&i?`${r.year}-${i.year} IF`:"\u671F\u520A\u8BE6\u60C5",o.append(s,u),t.appendChild(o),n){t.appendChild(_g(n));const d=Dg(n);d&&t.appendChild(d);const p=Fg(n);p&&t.appendChild(p);const m=kg(n);m&&t.appendChild(m)}if(e.length>=2){const d=document.createElement("div");d.className="paperlens-journal-chart-block";const p=document.createElement("canvas");p.className="paperlens-journal-trend-canvas",d.appendChild(p),t.appendChild(d)}return t}function _g(a){const e=document.createElement("div");e.className="paperlens-journal-preview-tags",Number.isFinite(a.impactFactor)&&Ea(e,`IF ${Xi(a.impactFactor,1)}`,"if"),a.jcrQuartile&&String(a.jcrQuartile)!=="N/A"&&Ea(e,`JCR ${a.jcrQuartile}`,lc(a.jcrQuartile));const t=Mr(a.casQuartile);return t&&Ea(e,`\u4E2D\u79D1\u9662 ${t.label}`,"cas"),a.sjrQuartile&&Ea(e,`SJR ${a.sjrQuartile}`,lc(a.sjrQuartile)),e}function Dg(a){const e=[];if(a.openAccess!==void 0&&e.push(["OA",a.openAccess?"\u5F00\u653E\u83B7\u53D6":"\u975E\u5F00\u653E\u83B7\u53D6"]),a.openAccessDiamond&&e.push(["Diamond OA","\u662F"]),Number.isFinite(a.sjr)&&e.push(["SJR",Xi(a.sjr,3)]),Number.isFinite(a.sjrHIndex)&&e.push(["H-index",String(Math.round(a.sjrHIndex??0))]),Number.isFinite(a.citationsPerDoc)&&e.push(["Cite/Doc",Xi(a.citationsPerDoc,1)]),Number.isFinite(a.totalDocs2025)&&e.push(["2025 \u53D1\u6587",String(Math.round(a.totalDocs2025??0))]),e.length===0)return null;const t=document.createElement("div");t.className="paperlens-journal-fact-grid";for(const[n,r]of e.slice(0,6)){const i=document.createElement("div");i.className="paperlens-journal-fact";const o=document.createElement("span");o.className="paperlens-journal-fact-label",o.textContent=n;const s=document.createElement("span");s.className="paperlens-journal-fact-value",s.textContent=r,i.append(o,s),t.appendChild(i)}return t}function Fg(a){const e=[...a.scimagoCategories??[],...a.category??[]].filter((r,i,o)=>r&&o.indexOf(r)===i);if(e.length===0)return null;const t=document.createElement("div");t.className="paperlens-journal-category-row";const n=document.createElement("span");n.className="paperlens-journal-category-label",n.textContent="\u5B66\u79D1",t.appendChild(n);for(const r of e.slice(0,3)){const i=document.createElement("span");i.className="paperlens-journal-category-chip",i.textContent=r,t.appendChild(i)}return t}function kg(a){const e=[];if(a.casWarning){const n=a.casWarningYears?.length?`\uFF08${a.casWarningYears.join(", ")}\uFF09`:"";e.push(`\u4E2D\u79D1\u9662\u9884\u8B66${n}`)}if(a.wosStatus==="delisted"?e.push(`WoS \u5DF2\u79FB\u9664${a.wosStatusDate?`\uFF08${a.wosStatusDate}\uFF09`:""}`):a.wosStatus==="on_hold"&&e.push(`WoS \u6682\u505C\u6536\u5F55${a.wosStatusDate?`\uFF08${a.wosStatusDate}\uFF09`:""}`),e.length===0)return null;const t=document.createElement("div");return t.className="paperlens-journal-warning-row",t.textContent=e.join(" \xB7 "),t}function Ea(a,e,t){const n=document.createElement("span");n.className=`paperlens-journal-preview-tag paperlens-journal-preview-tag--${t}`,n.textContent=e,a.appendChild(n)}function lc(a){const e=a?.toLowerCase();return e&&/^q[1-4]$/.test(e)?e:"neutral"}function Xi(a,e){return Number.isFinite(a)?Number(a).toFixed(e):"N/A"}function Lg(a,e){const n=e.getBoundingClientRect(),r=a.getBoundingClientRect(),i=n.bottom+10,o=n.top-r.height-10,l=i+r.height<=window.innerHeight-10?i:Math.max(10,o),c=n.left+n.width/2-r.width/2,u=Math.min(Math.max(10,c),Math.max(10,window.innerWidth-r.width-10));a.style.top=`${l}px`,a.style.left=`${u}px`}function cc(){_a(),Ta=setTimeout(uc,180)}function _a(){Ta&&(clearTimeout(Ta),Ta=null)}function uc(){_a(),Ki?.remove(),Ki=null}function Ng(){if(document.getElementById(oc))return;const a=document.createElement("style");a.id=oc,a.textContent=`
    .paperlens-journal-trend-popover {
      position: fixed;
      z-index: 2147483647;
      width: min(430px, calc(100vw - 20px));
      padding: 12px;
      box-sizing: border-box;
      border: 1px solid #d8dee8;
      border-radius: 8px;
      background: #fff;
      box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: #1f2937;
    }
    .paperlens-journal-preview {
      display: flex;
      flex-direction: column;
      gap: 9px;
      min-width: 0;
    }
    .paperlens-journal-trend-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
    }
    .paperlens-journal-title-wrap {
      min-width: 0;
    }
    .paperlens-journal-trend-title {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 13px;
      font-weight: 700;
    }
    .paperlens-journal-preview-subtitle {
      margin-top: 2px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 11px;
      line-height: 1.35;
      color: #64748b;
    }
    .paperlens-journal-trend-range {
      flex: 0 0 auto;
      font-size: 11px;
      color: #64748b;
    }
    .paperlens-journal-preview-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
    }
    .paperlens-journal-preview-tag {
      display: inline-flex;
      align-items: center;
      min-height: 20px;
      padding: 2px 7px;
      border: 1px solid #d8dee8;
      border-radius: 4px;
      background: #f8fafc;
      color: #334155;
      font-size: 11px;
      font-weight: 700;
      line-height: 1.2;
      white-space: nowrap;
    }
    .paperlens-journal-preview-tag--if {
      border-color: #fdba74;
      background: #ffedd5;
      color: #7c2d12;
    }
    .paperlens-journal-preview-tag--cas {
      border-color: #c4b5fd;
      background: #ede9fe;
      color: #5b21b6;
    }
    .paperlens-journal-preview-tag--q1 {
      border-color: #b91c1c;
      background: #b91c1c;
      color: #fff;
    }
    .paperlens-journal-preview-tag--q2 {
      border-color: #15803d;
      background: #15803d;
      color: #fff;
    }
    .paperlens-journal-preview-tag--q3 {
      border-color: #b45309;
      background: #b45309;
      color: #fff;
    }
    .paperlens-journal-preview-tag--q4 {
      border-color: #475569;
      background: #475569;
      color: #fff;
    }
    .paperlens-journal-fact-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
    }
    .paperlens-journal-fact {
      min-width: 0;
      padding: 6px 7px;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      background: #f8fafc;
    }
    .paperlens-journal-fact-label,
    .paperlens-journal-fact-value {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .paperlens-journal-fact-label {
      color: #64748b;
      font-size: 10px;
      font-weight: 600;
    }
    .paperlens-journal-fact-value {
      margin-top: 2px;
      color: #1f2937;
      font-size: 12px;
      font-weight: 700;
    }
    .paperlens-journal-category-row {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 5px;
    }
    .paperlens-journal-category-label {
      color: #64748b;
      font-size: 11px;
      font-weight: 700;
    }
    .paperlens-journal-category-chip {
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding: 2px 6px;
      border-radius: 999px;
      background: #eff6ff;
      color: #1d4ed8;
      font-size: 10px;
      font-weight: 600;
    }
    .paperlens-journal-warning-row {
      padding: 6px 8px;
      border: 1px solid #fecaca;
      border-radius: 6px;
      background: #fff1f2;
      color: #991b1b;
      font-size: 11px;
      font-weight: 700;
      line-height: 1.4;
    }
    .paperlens-journal-chart-block {
      padding-top: 3px;
      border-top: 1px solid #edf2f7;
    }
    .paperlens-journal-trend-canvas {
      display: block;
    }
  `,document.head.appendChild(a)}const Rg=qe+`
`+dg,eo="data-paperlens-enhanced",Pg="paperlens-metric-host",Ig="paperlens-shimmer-host";function Mg(a){const e=Array.from(a.trim()).length||10;return Math.min(Math.max(e+2,14),56)}function dc(a){const e=document.createElement("div");e.className=a;const t=e.attachShadow({mode:"open"}),n=document.createElement("style");return n.textContent=Rg,t.appendChild(n),{host:e,shadow:t}}function pc(a=!1){const{host:e,shadow:t}=dc(Ig);a||(e.style.visibility="hidden");const n=document.createElement("div");n.className="pl-metric-shimmer";const r=document.createElement("span");r.className="pl-shimmer-bar pl-shimmer-bar--if";const i=document.createElement("span");i.className="pl-shimmer-bar pl-shimmer-bar--q";const o=document.createElement("span");return o.className="pl-shimmer-bar pl-shimmer-bar--q",n.append(r,i,o),t.appendChild(n),e}function to(a,e={}){const{host:t,shadow:n}=dc(Pg);e.layout&&e.layout!=="default"&&(t.dataset.plLayout=e.layout),(a.casWarning||a.wosStatus)&&tc(n),Number.isFinite(a.impactFactor)&&(t.dataset.plIf=String(a.impactFactor));const r=String(a.jcrQuartile??""),i=r&&r!=="N/A"?r:void 0;i&&(t.dataset.plJcr=i);const o=i??a.sjrQuartile??"Q4",s=Number.isFinite(a.impactFactor),l=Number.isFinite(a.sjr),c=a.openAccess===!0,u=document.createElement("div");u.className=`pl-metric-bar pl-metric-bar--${o.toLowerCase()}`,u.title=a.journalName;const d=e.paper?.journal||a.journalName,p=document.createElement("span");if(p.className="pl-metric-cell pl-metric-journal",p.style.setProperty("--pl-metric-journal-max",`${Mg(d)}ch`),p.textContent=d,p.title=`${d} \xB7 \u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF`,u.appendChild(p),no(p,a),a.casWarning||a.wosStatus){const h=document.createElement("span");h.className="pl-metric-cell pl-metric-warnings",h.appendChild(ec(a)),u.appendChild(h)}if(s){const h=document.createElement("span");h.className="pl-metric-cell pl-metric-if",h.textContent=`IF ${a.impactFactor.toFixed(1)}`,h.title="\u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF",u.appendChild(h),no(h,a)}else if(l){const h=document.createElement("span");h.className="pl-metric-cell pl-metric-if",h.textContent=`SJR ${a.sjr?.toFixed(2)}`,h.title="SCImago Journal Rank",u.appendChild(h),no(h,a)}if(c){t.dataset.plOpenAccess="true";const h=document.createElement("span");h.className="pl-metric-cell pl-metric-oa",h.textContent=a.openAccessDiamond?"Diamond OA":"OA",h.title=a.openAccessDiamond?"Diamond Open Access \u671F\u520A":"Open Access \u671F\u520A",u.appendChild(h)}if(i){const h=`pl-metric-${i.toLowerCase()}`,y=document.createElement("span");y.className=`pl-metric-cell pl-metric-jcr ${h}`,y.textContent=i,y.setAttribute("data-pl-jcr-quartile",""),u.appendChild(y)}else if(a.sjrQuartile){const h=`pl-metric-${a.sjrQuartile.toLowerCase()}`,y=document.createElement("span");y.className=`pl-metric-cell pl-metric-jcr ${h}`,y.textContent=`SJR ${a.sjrQuartile}`,y.title="SCImago \u5206\u533A",u.appendChild(y)}const m=Mr(a.casQuartile);if(m){t.dataset.plCas=m.value;const h=document.createElement("span");h.className=`pl-metric-cell pl-metric-cas-${m.value}`,h.textContent=m.label,h.title="\u4E2D\u79D1\u9662\u5206\u533A",h.setAttribute("data-pl-cas-quartile",""),u.appendChild(h)}if(e.paper?.publicationDate){const h=document.createElement("span");h.className="pl-metric-cell pl-metric-date",h.textContent=e.paper.publicationDate,h.title="\u53D1\u8868\u65E5\u671F",u.appendChild(h)}if(e.paper?.articleType){const h=document.createElement("span");h.className="pl-metric-cell pl-metric-type",h.textContent=e.paper.articleType,u.appendChild(h)}return n.appendChild(u),t}function Da(a){return a.hasAttribute(eo)}function zn(a){a.setAttribute(eo,"")}function hc(a){a.removeAttribute(eo)}const fc=new Map;function no(a,e){(e.normalizedName||e.journalName)&&Hn(a,{journalName:e.journalName,journal:e,getTrendData:()=>Bg(e),delayMs:280})}function Bg(a){const t=(a.normalizedName||a.journalName).toLowerCase(),n=fc.get(t);if(n)return n;const r=$.runtime.sendMessage({type:"GET_JOURNAL_TREND_DATA",payload:{normalizedName:a.normalizedName,journalName:a.journalName}}).then(i=>i?.success&&Array.isArray(i.data?.trendData)?i.data.trendData:[]).catch(()=>[]);return fc.set(t,r),r}let mc=null,bc=null,gc=null,yc=null,Fa=null;function jg(){const a=globalThis;return(a.browser?.runtime??a.chrome?.runtime)?.getURL?.("data")??"data"}async function qg(){return Fa||(Fa=(async()=>{try{const a=jg(),[e,t,n,r]=await Promise.allSettled([fetch(`${a}/pku-core-journals.json`).then(i=>i.json()),fetch(`${a}/cscd-journals.json`).then(i=>i.json()),fetch(`${a}/cssci-journals.json`).then(i=>i.json()),fetch(`${a}/cas-warning-all.json`).then(i=>i.json())]);e.status==="fulfilled"&&e.value?.journals&&(mc=new Set(e.value.journals.map(i=>Br(i?.name)).filter(Boolean))),t.status==="fulfilled"&&t.value?.journals&&(bc=new Map(t.value.journals.flatMap(i=>{const o=Br(i?.name);return o&&i?.library_type?[[o,i.library_type]]:[]}))),n.status==="fulfilled"&&n.value?.journals&&(gc=new Map(n.value.journals.flatMap(i=>{const o=Br(i?.name);return o?[[o,i.is_core?"\u6838\u5FC3":"\u6269\u5C55"]]:[]}))),r.status==="fulfilled"&&r.value?.journals&&(yc=new Set(r.value.journals.map(i=>Br(i?.name)).filter(Boolean)))}catch(a){console.warn("[ChineseMetrics] Failed to load data:",a)}})(),Fa)}function Br(a){return(a??"").toLowerCase().replace(/^期刊[:：]/,"").replace(/[《》〈〉“”"'‘’【】\[\]{}]/g,"").replace(/[\s·•.。．、，,;；:：|｜/\\（）()\u00A0\u3000-]/g,"")}async function $g(a){await qg();const e=Br(a);return e?{pkuCore:mc?.has(e)??!1,cscd:bc?.get(e)??void 0,cssci:gc?.get(e)??void 0,casWarning:yc?.has(e)??!1}:{pkuCore:!1,casWarning:!1}}const Jn={pku:{bg:"#e8f4fd",color:"#1976d2",label:"\u5317\u5927\u6838\u5FC3"},cscdCore:{bg:"#e8f5e9",color:"#2e7d32",label:"CSCD\u6838\u5FC3"},cscdExt:{bg:"#f1f8e9",color:"#558b2f",label:"CSCD\u6269\u5C55"},cssciCore:{bg:"#fce4ec",color:"#c62828",label:"CSSCI\u6838\u5FC3"},cssciExt:{bg:"#f3e5f5",color:"#6a1b9a",label:"CSSCI\u6269\u5C55"},warning:{bg:"#fff3e0",color:"#e65100",label:"\u26A0\uFE0F\u9884\u8B66"}};function Og(a){const e=[];if(a.pkuCore){const t=Jn.pku;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:500;">${t.label}</span>`)}if(a.cscd==="\u6838\u5FC3\u5E93"){const t=Jn.cscdCore;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:500;">${t.label}</span>`)}else if(a.cscd==="\u6269\u5C55\u5E93"){const t=Jn.cscdExt;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:500;">${t.label}</span>`)}if(a.cssci==="\u6838\u5FC3"){const t=Jn.cssciCore;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:500;">${t.label}</span>`)}else if(a.cssci==="\u6269\u5C55"){const t=Jn.cssciExt;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:500;">${t.label}</span>`)}if(a.casWarning){const t=Jn.warning;e.push(`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${t.bg};color:${t.color};margin-right:4px;font-weight:600;">${t.label}</span>`)}return e.join("")}let Vn=null,Wn=null,ka=null;function Ug(){const a=globalThis;return(a.browser?.runtime??a.chrome?.runtime)?.getURL?.("data")??"data"}async function Hg(){return ka||(ka=(async()=>{try{const a=Ug(),t=await(await fetch(`${a}/ccf-journals.json`)).json();Vn=new Map,Wn=new Map;for(const n of t.journals??[]){const r={ccfClass:n.ccf_class,type:"journal",domain:n.domain,abbreviation:n.abbreviation,fullName:n.full_name},i=jr(n.abbreviation??n.full_name??"");i&&Vn.set(i,r),n.full_name&&Vn.set(jr(n.full_name),r)}for(const n of t.conferences??[]){const r={ccfClass:n.ccf_class,type:"conference",domain:n.domain,abbreviation:n.abbreviation,fullName:n.full_name},i=jr(n.abbreviation??n.full_name??"");i&&Wn.set(i,r),n.full_name&&Wn.set(jr(n.full_name),r)}}catch(a){console.warn("[CCFBadge] Failed to load data:",a)}})(),ka)}function jr(a){return a.toLowerCase().replace(/[\s.\-']/g,"")}async function zg(a,e){if(await Hg(),!Vn||!Wn)return null;const t=jr(a);return t?e==="conference"?Wn.get(t)??null:e==="journal"?Vn.get(t)??null:Vn.get(t)??Wn.get(t)??null:null}const Jg={A:{bg:"#ffebee",color:"#c62828",label:"CCF-A"},B:{bg:"#fff3e0",color:"#e65100",label:"CCF-B"},C:{bg:"#e3f2fd",color:"#1565c0",label:"CCF-C"}};function Vg(a){if(!a.ccfClass)return"";const e=Jg[a.ccfClass];if(!e)return"";const t=a.type==="conference"?"\u{1F4C5}":"\u{1F4F0}";return`<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:11px;background:${e.bg};color:${e.color};margin-right:4px;font-weight:600;">${t} ${e.label}</span>`}const{entries:xc,setPrototypeOf:Ac,isFrozen:Wg,getPrototypeOf:Gg,getOwnPropertyDescriptor:Yg}=Object;let{freeze:Le,seal:Ke,create:Gn}=Object,{apply:ro,construct:ao}=typeof Reflect<"u"&&Reflect;Le||(Le=function(e){return e}),Ke||(Ke=function(e){return e}),ro||(ro=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)}),ao||(ao=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)});const qr=fe(Array.prototype.forEach),Zg=fe(Array.prototype.lastIndexOf),Cc=fe(Array.prototype.pop),$r=fe(Array.prototype.push),Qg=fe(Array.prototype.splice),Ne=Array.isArray,Or=fe(String.prototype.toLowerCase),io=fe(String.prototype.toString),vc=fe(String.prototype.match),Yn=fe(String.prototype.replace),wc=fe(String.prototype.indexOf),Kg=fe(String.prototype.trim),Xg=fe(Number.prototype.toString),ey=fe(Boolean.prototype.toString),Sc=typeof BigInt>"u"?null:fe(BigInt.prototype.toString),Tc=typeof Symbol>"u"?null:fe(Symbol.prototype.toString),se=fe(Object.prototype.hasOwnProperty),Ur=fe(Object.prototype.toString),ve=fe(RegExp.prototype.test),La=ty(TypeError);function fe(a){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return ro(a,e,n)}}function ty(a){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ao(a,t)}}function O(a,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Or;if(Ac&&Ac(a,null),!Ne(e))return a;let n=e.length;for(;n--;){let r=e[n];if(typeof r=="string"){const i=t(r);i!==r&&(Wg(e)||(e[n]=i),r=i)}a[r]=!0}return a}function ny(a){for(let e=0;e<a.length;e++)se(a,e)||(a[e]=null);return a}function Me(a){const e=Gn(null);for(const[t,n]of xc(a))se(a,t)&&(Ne(n)?e[t]=ny(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Me(n):e[t]=n);return e}function ry(a){switch(typeof a){case"string":return a;case"number":return Xg(a);case"boolean":return ey(a);case"bigint":return Sc?Sc(a):"0";case"symbol":return Tc?Tc(a):"Symbol()";case"undefined":return Ur(a);case"function":case"object":{if(a===null)return Ur(a);const e=a,t=Zn(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:Ur(n)}return Ur(a)}default:return Ur(a)}}function Zn(a,e){for(;a!==null;){const n=Yg(a,e);if(n){if(n.get)return fe(n.get);if(typeof n.value=="function")return fe(n.value)}a=Gg(a)}function t(){return null}return t}function ay(a){try{return ve(a,""),!0}catch{return!1}}const Ec=Le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),oo=Le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),so=Le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),iy=Le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),lo=Le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),oy=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_c=Le(["#text"]),Dc=Le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),co=Le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fc=Le(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Na=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),sy=Ke(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ly=Ke(/<%[\w\W]*|[\w\W]*%>/gm),cy=Ke(/\$\{[\w\W]*/gm),uy=Ke(/^data-[\-\w.\u00B7-\uFFFF]+$/),dy=Ke(/^aria-[\-\w]+$/),kc=Ke(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),py=Ke(/^(?:\w+script|data):/i),hy=Ke(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Lc=Ke(/^html$/i),fy=Ke(/^[a-z][.\w]*(-[.\w]+)+$/i);var Nc=Object.freeze({__proto__:null,ARIA_ATTR:dy,ATTR_WHITESPACE:hy,CUSTOM_ELEMENT:fy,DATA_ATTR:uy,DOCTYPE_NAME:Lc,ERB_EXPR:ly,IS_ALLOWED_URI:kc,IS_SCRIPT_OR_DATA:py,MUSTACHE_EXPR:sy,TMPLIT_EXPR:cy});const Hr={element:1,text:3,progressingInstruction:7,comment:8,document:9},my=function(){return typeof window>"u"?null:window},by=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Rc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Pc(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:my();const e=P=>Pc(P);if(e.version="3.4.2",e.removed=[],!a||!a.document||a.document.nodeType!==Hr.document||!a.Element)return e.isSupported=!1,e;let{document:t}=a;const n=t,r=n.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:s,Element:l,NodeFilter:c,NamedNodeMap:u=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:m}=a,h=l.prototype,y=Zn(h,"cloneNode"),x=Zn(h,"remove"),T=Zn(h,"nextSibling"),F=Zn(h,"childNodes"),w=Zn(h,"parentNode");if(typeof o=="function"){const P=t.createElement("template");P.content&&P.content.ownerDocument&&(t=P.content.ownerDocument)}let b,v="";const{implementation:D,createNodeIterator:B,createDocumentFragment:U,getElementsByTagName:L}=t,{importNode:R}=n;let E=Rc();e.isSupported=typeof xc=="function"&&typeof w=="function"&&D&&D.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:I,ERB_EXPR:M,TMPLIT_EXPR:j,DATA_ATTR:z,ARIA_ATTR:ce,IS_SCRIPT_OR_DATA:ue,ATTR_WHITESPACE:Je,CUSTOM_ELEMENT:Rt}=Nc;let{IS_ALLOWED_URI:yt}=Nc,J=null;const mn=O({},[...Ec,...oo,...so,...lo,..._c]);let G=null;const bn=O({},[...Dc,...co,...Fc,...Na]);let ne=Object.seal(Gn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Pt=null,ye=null;const at=Object.seal(Gn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let De=!0,Xt=!0,pr=!1,hr=!0,Fe=!1,gn=!0,ft=!1,yn=!1,It=!1,xt=!1,xn=!1,An=!1,Cn=!0,At=!1;const Ve="user-content-";let vn=!0,We=!1,Se={},Te=null;const wn=O({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let fr=null;const mr=O({},["audio","video","img","source","image","track"]);let Sn=null;const br=O({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ct="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",re="http://www.w3.org/1999/xhtml";let de=re,en=!1,tn=null;const $s=O({},[Ct,vt,re],io);let sa=O({},["mi","mo","mn","ms","mtext"]),nn=O({},["annotation-xml"]);const Os=O({},["title","style","font","a","script"]);let Mt=null;const gr=["application/xhtml+xml","text/html"],hi="text/html";let X=null,it=null;const Tn=t.createElement("form"),En=function(f){return f instanceof RegExp||f instanceof Function},Bt=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(it&&it===f)return;(!f||typeof f!="object")&&(f={}),f=Me(f),Mt=gr.indexOf(f.PARSER_MEDIA_TYPE)===-1?hi:f.PARSER_MEDIA_TYPE,X=Mt==="application/xhtml+xml"?io:Or,J=se(f,"ALLOWED_TAGS")&&Ne(f.ALLOWED_TAGS)?O({},f.ALLOWED_TAGS,X):mn,G=se(f,"ALLOWED_ATTR")&&Ne(f.ALLOWED_ATTR)?O({},f.ALLOWED_ATTR,X):bn,tn=se(f,"ALLOWED_NAMESPACES")&&Ne(f.ALLOWED_NAMESPACES)?O({},f.ALLOWED_NAMESPACES,io):$s,Sn=se(f,"ADD_URI_SAFE_ATTR")&&Ne(f.ADD_URI_SAFE_ATTR)?O(Me(br),f.ADD_URI_SAFE_ATTR,X):br,fr=se(f,"ADD_DATA_URI_TAGS")&&Ne(f.ADD_DATA_URI_TAGS)?O(Me(mr),f.ADD_DATA_URI_TAGS,X):mr,Te=se(f,"FORBID_CONTENTS")&&Ne(f.FORBID_CONTENTS)?O({},f.FORBID_CONTENTS,X):wn,Pt=se(f,"FORBID_TAGS")&&Ne(f.FORBID_TAGS)?O({},f.FORBID_TAGS,X):Me({}),ye=se(f,"FORBID_ATTR")&&Ne(f.FORBID_ATTR)?O({},f.FORBID_ATTR,X):Me({}),Se=se(f,"USE_PROFILES")?f.USE_PROFILES&&typeof f.USE_PROFILES=="object"?Me(f.USE_PROFILES):f.USE_PROFILES:!1,De=f.ALLOW_ARIA_ATTR!==!1,Xt=f.ALLOW_DATA_ATTR!==!1,pr=f.ALLOW_UNKNOWN_PROTOCOLS||!1,hr=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Fe=f.SAFE_FOR_TEMPLATES||!1,gn=f.SAFE_FOR_XML!==!1,ft=f.WHOLE_DOCUMENT||!1,xt=f.RETURN_DOM||!1,xn=f.RETURN_DOM_FRAGMENT||!1,An=f.RETURN_TRUSTED_TYPE||!1,It=f.FORCE_BODY||!1,Cn=f.SANITIZE_DOM!==!1,At=f.SANITIZE_NAMED_PROPS||!1,vn=f.KEEP_CONTENT!==!1,We=f.IN_PLACE||!1,yt=ay(f.ALLOWED_URI_REGEXP)?f.ALLOWED_URI_REGEXP:kc,de=typeof f.NAMESPACE=="string"?f.NAMESPACE:re,sa=se(f,"MATHML_TEXT_INTEGRATION_POINTS")&&f.MATHML_TEXT_INTEGRATION_POINTS&&typeof f.MATHML_TEXT_INTEGRATION_POINTS=="object"?Me(f.MATHML_TEXT_INTEGRATION_POINTS):O({},["mi","mo","mn","ms","mtext"]),nn=se(f,"HTML_INTEGRATION_POINTS")&&f.HTML_INTEGRATION_POINTS&&typeof f.HTML_INTEGRATION_POINTS=="object"?Me(f.HTML_INTEGRATION_POINTS):O({},["annotation-xml"]);const C=se(f,"CUSTOM_ELEMENT_HANDLING")&&f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING=="object"?Me(f.CUSTOM_ELEMENT_HANDLING):Gn(null);if(ne=Gn(null),se(C,"tagNameCheck")&&En(C.tagNameCheck)&&(ne.tagNameCheck=C.tagNameCheck),se(C,"attributeNameCheck")&&En(C.attributeNameCheck)&&(ne.attributeNameCheck=C.attributeNameCheck),se(C,"allowCustomizedBuiltInElements")&&typeof C.allowCustomizedBuiltInElements=="boolean"&&(ne.allowCustomizedBuiltInElements=C.allowCustomizedBuiltInElements),Fe&&(Xt=!1),xn&&(xt=!0),Se&&(J=O({},_c),G=Gn(null),Se.html===!0&&(O(J,Ec),O(G,Dc)),Se.svg===!0&&(O(J,oo),O(G,co),O(G,Na)),Se.svgFilters===!0&&(O(J,so),O(G,co),O(G,Na)),Se.mathMl===!0&&(O(J,lo),O(G,Fc),O(G,Na))),at.tagCheck=null,at.attributeCheck=null,se(f,"ADD_TAGS")&&(typeof f.ADD_TAGS=="function"?at.tagCheck=f.ADD_TAGS:Ne(f.ADD_TAGS)&&(J===mn&&(J=Me(J)),O(J,f.ADD_TAGS,X))),se(f,"ADD_ATTR")&&(typeof f.ADD_ATTR=="function"?at.attributeCheck=f.ADD_ATTR:Ne(f.ADD_ATTR)&&(G===bn&&(G=Me(G)),O(G,f.ADD_ATTR,X))),se(f,"ADD_URI_SAFE_ATTR")&&Ne(f.ADD_URI_SAFE_ATTR)&&O(Sn,f.ADD_URI_SAFE_ATTR,X),se(f,"FORBID_CONTENTS")&&Ne(f.FORBID_CONTENTS)&&(Te===wn&&(Te=Me(Te)),O(Te,f.FORBID_CONTENTS,X)),se(f,"ADD_FORBID_CONTENTS")&&Ne(f.ADD_FORBID_CONTENTS)&&(Te===wn&&(Te=Me(Te)),O(Te,f.ADD_FORBID_CONTENTS,X)),vn&&(J["#text"]=!0),ft&&O(J,["html","head","body"]),J.table&&(O(J,["tbody"]),delete Pt.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw La('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw La('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=f.TRUSTED_TYPES_POLICY,v=b.createHTML("")}else b===void 0&&(b=by(m,r)),b!==null&&typeof v=="string"&&(v=b.createHTML(""));Le&&Le(f),it=f},rn=O({},[...oo,...so,...iy]),_n=O({},[...lo,...oy]),jt=function(f){let C=w(f);(!C||!C.tagName)&&(C={namespaceURI:de,tagName:"template"});const N=Or(f.tagName),q=Or(C.tagName);return tn[f.namespaceURI]?f.namespaceURI===vt?C.namespaceURI===re?N==="svg":C.namespaceURI===Ct?N==="svg"&&(q==="annotation-xml"||sa[q]):!!rn[N]:f.namespaceURI===Ct?C.namespaceURI===re?N==="math":C.namespaceURI===vt?N==="math"&&nn[q]:!!_n[N]:f.namespaceURI===re?C.namespaceURI===vt&&!nn[q]||C.namespaceURI===Ct&&!sa[q]?!1:!_n[N]&&(Os[N]||!rn[N]):!!(Mt==="application/xhtml+xml"&&tn[f.namespaceURI]):!1},pe=function(f){$r(e.removed,{element:f});try{w(f).removeChild(f)}catch{x(f)}},qt=function(f,C){try{$r(e.removed,{attribute:C.getAttributeNode(f),from:C})}catch{$r(e.removed,{attribute:null,from:C})}if(C.removeAttribute(f),f==="is")if(xt||xn)try{pe(C)}catch{}else try{C.setAttribute(f,"")}catch{}},Dn=function(f){let C=null,N=null;if(It)f="<remove></remove>"+f;else{const ae=vc(f,/^[\r\n\t ]+/);N=ae&&ae[0]}Mt==="application/xhtml+xml"&&de===re&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const q=b?b.createHTML(f):f;if(de===re)try{C=new p().parseFromString(q,Mt)}catch{}if(!C||!C.documentElement){C=D.createDocument(de,"template",null);try{C.documentElement.innerHTML=en?v:q}catch{}}const ee=C.body||C.documentElement;return f&&N&&ee.insertBefore(t.createTextNode(N),ee.childNodes[0]||null),de===re?L.call(C,ft?"html":"body")[0]:ft?C.documentElement:ee},yr=function(f){return B.call(f.ownerDocument||f,f,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fn=function(f){return f instanceof d&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof u)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},kn=function(f){return typeof s=="function"&&f instanceof s};function ot(P,f,C){qr(P,N=>{N.call(e,f,C,it)})}const wt=function(f){let C=null;if(ot(E.beforeSanitizeElements,f,null),Fn(f))return pe(f),!0;const N=X(f.nodeName);if(ot(E.uponSanitizeElement,f,{tagName:N,allowedTags:J}),gn&&f.hasChildNodes()&&!kn(f.firstElementChild)&&ve(/<[/\w!]/g,f.innerHTML)&&ve(/<[/\w!]/g,f.textContent)||gn&&f.namespaceURI===re&&N==="style"&&kn(f.firstElementChild)||f.nodeType===Hr.progressingInstruction||gn&&f.nodeType===Hr.comment&&ve(/<[/\w]/g,f.data))return pe(f),!0;if(Pt[N]||!(at.tagCheck instanceof Function&&at.tagCheck(N))&&!J[N]){if(!Pt[N]&&xr(N)&&(ne.tagNameCheck instanceof RegExp&&ve(ne.tagNameCheck,N)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(N)))return!1;if(vn&&!Te[N]){const q=w(f)||f.parentNode,ee=F(f)||f.childNodes;if(ee&&q){const ae=ee.length;for(let Ee=ae-1;Ee>=0;--Ee){const ke=y(ee[Ee],!0);q.insertBefore(ke,T(f))}}}return pe(f),!0}return f instanceof l&&!jt(f)||(N==="noscript"||N==="noembed"||N==="noframes")&&ve(/<\/no(script|embed|frames)/i,f.innerHTML)?(pe(f),!0):(Fe&&f.nodeType===Hr.text&&(C=f.textContent,qr([I,M,j],q=>{C=Yn(C,q," ")}),f.textContent!==C&&($r(e.removed,{element:f.cloneNode()}),f.textContent=C)),ot(E.afterSanitizeElements,f,null),!1)},St=function(f,C,N){if(ye[C]||Cn&&(C==="id"||C==="name")&&(N in t||N in Tn))return!1;const q=G[C]||at.attributeCheck instanceof Function&&at.attributeCheck(C,f);if(!(Xt&&!ye[C]&&ve(z,C))){if(!(De&&ve(ce,C))){if(!q||ye[C]){if(!(xr(f)&&(ne.tagNameCheck instanceof RegExp&&ve(ne.tagNameCheck,f)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(f))&&(ne.attributeNameCheck instanceof RegExp&&ve(ne.attributeNameCheck,C)||ne.attributeNameCheck instanceof Function&&ne.attributeNameCheck(C,f))||C==="is"&&ne.allowCustomizedBuiltInElements&&(ne.tagNameCheck instanceof RegExp&&ve(ne.tagNameCheck,N)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(N))))return!1}else if(!Sn[C]){if(!ve(yt,Yn(N,Je,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&f!=="script"&&wc(N,"data:")===0&&fr[f])){if(!(pr&&!ve(ue,Yn(N,Je,"")))){if(N)return!1}}}}}}return!0},fi=O({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),xr=function(f){return!fi[Or(f)]&&ve(Rt,f)},xe=function(f){ot(E.beforeSanitizeAttributes,f,null);const{attributes:C}=f;if(!C||Fn(f))return;const N={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let q=C.length;for(;q--;){const ee=C[q],{name:ae,namespaceURI:Ee,value:ke}=ee,Pe=X(ae),Ln=ke;let oe=ae==="value"?Ln:Kg(Ln);if(N.attrName=Pe,N.attrValue=oe,N.keepAttr=!0,N.forceKeepAttr=void 0,ot(E.uponSanitizeAttribute,f,N),oe=N.attrValue,At&&(Pe==="id"||Pe==="name")&&wc(oe,Ve)!==0&&(qt(ae,f),oe=Ve+oe),gn&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,oe)){qt(ae,f);continue}if(Pe==="attributename"&&vc(oe,"href")){qt(ae,f);continue}if(N.forceKeepAttr)continue;if(!N.keepAttr){qt(ae,f);continue}if(!hr&&ve(/\/>/i,oe)){qt(ae,f);continue}Fe&&qr([I,M,j],S=>{oe=Yn(oe,S," ")});const A=X(f.nodeName);if(!St(A,Pe,oe)){qt(ae,f);continue}if(b&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ee)switch(m.getAttributeType(A,Pe)){case"TrustedHTML":{oe=b.createHTML(oe);break}case"TrustedScriptURL":{oe=b.createScriptURL(oe);break}}if(oe!==Ln)try{Ee?f.setAttributeNS(Ee,ae,oe):f.setAttribute(ae,oe),Fn(f)?pe(f):Cc(e.removed)}catch{qt(ae,f)}}ot(E.afterSanitizeAttributes,f,null)},Ar=function(f){let C=null;const N=yr(f);for(ot(E.beforeSanitizeShadowDOM,f,null);C=N.nextNode();)ot(E.uponSanitizeShadowNode,C,null),wt(C),xe(C),C.content instanceof i&&Ar(C.content);ot(E.afterSanitizeShadowDOM,f,null)};return e.sanitize=function(P){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,N=null,q=null,ee=null;if(en=!P,en&&(P="<!-->"),typeof P!="string"&&!kn(P)&&(P=ry(P),typeof P!="string"))throw La("dirty is not a string, aborting");if(!e.isSupported)return P;if(yn||Bt(f),e.removed=[],typeof P=="string"&&(We=!1),We){const ke=P.nodeName;if(typeof ke=="string"){const Pe=X(ke);if(!J[Pe]||Pt[Pe])throw La("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof s)C=Dn("<!---->"),N=C.ownerDocument.importNode(P,!0),N.nodeType===Hr.element&&N.nodeName==="BODY"||N.nodeName==="HTML"?C=N:C.appendChild(N);else{if(!xt&&!Fe&&!ft&&P.indexOf("<")===-1)return b&&An?b.createHTML(P):P;if(C=Dn(P),!C)return xt?null:An?v:""}C&&It&&pe(C.firstChild);const ae=yr(We?P:C);for(;q=ae.nextNode();)wt(q),xe(q),q.content instanceof i&&Ar(q.content);if(We)return P;if(xt){if(Fe){C.normalize();let ke=C.innerHTML;qr([I,M,j],Pe=>{ke=Yn(ke,Pe," ")}),C.innerHTML=ke}if(xn)for(ee=U.call(C.ownerDocument);C.firstChild;)ee.appendChild(C.firstChild);else ee=C;return(G.shadowroot||G.shadowrootmode)&&(ee=R.call(n,ee,!0)),ee}let Ee=ft?C.outerHTML:C.innerHTML;return ft&&J["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&ve(Lc,C.ownerDocument.doctype.name)&&(Ee="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
`+Ee),Fe&&qr([I,M,j],ke=>{Ee=Yn(Ee,ke," ")}),b&&An?b.createHTML(Ee):Ee},e.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bt(P),yn=!0},e.clearConfig=function(){it=null,yn=!1},e.isValidAttribute=function(P,f,C){it||Bt({});const N=X(P),q=X(f);return St(N,q,C)},e.addHook=function(P,f){typeof f=="function"&&$r(E[P],f)},e.removeHook=function(P,f){if(f!==void 0){const C=Zg(E[P],f);return C===-1?void 0:Qg(E[P],C,1)[0]}return Cc(E[P])},e.removeHooks=function(P){E[P]=[]},e.removeAllHooks=function(){E=Rc()},e}var gy=Pc();const yy=`/**
 * Extra Download Button Styles \u2014 injected into each button's Shadow DOM
 *
 * Design Token \u4F9D\u8D56\uFF1A
 *   --pl-color-* / --pl-font-* / --pl-space-* / --pl-radius-*
 *   \u7531 tokens.css \u5728\u540C\u4E00 Shadow DOM \u5185\u901A\u8FC7 :host \u5B9A\u4E49
 */

:host {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  padding: 0;
  margin: 0;
  vertical-align: middle;
}

/* \u2500\u2500 \u6309\u94AE\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-extra-dl-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  font-family: var(--pl-font-sans);
  font-size: 13px;
  line-height: 1;
}

/* \u2500\u2500 \u53EF\u70B9\u51FB\u7684\u4E0B\u8F7D\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-extra-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  font-size: 13px;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  background-color: #eff6ff;
  color: #1d4ed8;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background-color var(--pl-transition-fast),
              border-color var(--pl-transition-fast),
              box-shadow var(--pl-transition-fast),
              color var(--pl-transition-fast),
              transform var(--pl-transition-fast);
}

.pl-extra-dl-btn:hover {
  border-color: #93c5fd;
  background-color: #dbeafe;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.pl-extra-dl-btn:active {
  transform: scale(0.96);
}

.pl-extra-dl-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* \u2500\u2500 \u7F6E\u7070\u72B6\u6001\uFF08\u65E0 DOI\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-extra-dl-btn--disabled {
  border-color: #e5e7eb;
  background-color: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
  pointer-events: auto;
  position: relative;
}

.pl-extra-dl-btn--disabled:hover {
  border-color: #e5e7eb;
  background-color: #f1f5f9;
  box-shadow: none;
}

/* \u2500\u2500 \u65E0 DOI \u7684 Tooltip \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-extra-dl-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-gray-800);
  color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-normal);
  white-space: nowrap;
  z-index: var(--pl-z-tooltip);
  box-shadow: var(--pl-shadow-md);
  pointer-events: none;
}

.pl-extra-dl-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--pl-color-gray-800);
}

.pl-extra-dl-btn--disabled:hover .pl-extra-dl-tooltip {
  display: block;
}
`,xy=`/**
 * PaperLens Toast Notification Styles
 *
 * Plain DOM \u2014 NOT inside Shadow DOM.
 * Appended to document.body for maximum z-index stacking.
 * Uses --pl-* tokens via inline fallbacks for dark mode compatibility.
 */

/* \u2500\u2500 Container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toast-container {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483647;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

/* \u2500\u2500 Individual Toast \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-width: min(240px, 100%);
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  color: #fff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  user-select: none;
  word-break: break-word;
  opacity: 0;
  transform: translateY(-14px) scale(0.98);
  animation: pl-toast-in 300ms ease forwards;
}

.pl-toast--closing {
  animation: pl-toast-out 250ms ease forwards;
}

/* \u2500\u2500 Type Variants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toast--success {
  background: rgba(16, 185, 129, 0.92);
}
.pl-toast--error {
  background: rgba(239, 68, 68, 0.92);
}
.pl-toast--info {
  background: rgba(59, 130, 246, 0.92);
}

/* \u2500\u2500 Icon \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toast-icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

/* \u2500\u2500 Message \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toast-message {
  flex: 1;
}

/* \u2500\u2500 Animations (GPU-accelerated) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@keyframes pl-toast-in {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pl-toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

/* \u2500\u2500 Dark Mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@media (prefers-color-scheme: dark) {
  .pl-toast {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  .pl-toast--success {
    background: rgba(52, 211, 153, 0.88);
    color: #064e3b;
  }
  .pl-toast--error {
    background: rgba(248, 113, 113, 0.88);
    color: #7f1d1d;
  }
  .pl-toast--info {
    background: rgba(96, 165, 250, 0.88);
    color: #1e3a5f;
  }
}
`,Ay={success:"\u2713",error:"\u2715",info:"\u2139"};let uo=!1;function Cy(){if(uo||typeof document>"u")return;if(document.getElementById("paperlens-toast-styles")){uo=!0;return}const e=document.createElement("style");e.id="paperlens-toast-styles",e.textContent=xy,document.head.appendChild(e),uo=!0}class Qn{static instance;container=null;constructor(){}static getInstance(){return Qn.instance||(Qn.instance=new Qn),Qn.instance}ensureContainer(){if(this.container&&this.container.parentNode)return this.container;Cy();const e=document.createElement("div");return e.className="pl-toast-container",document.body.appendChild(e),this.container=e,e}show(e){const t=this.ensureContainer(),n=e.duration??3e3,r=document.createElement("div");r.className=`pl-toast pl-toast--${e.type}`;const i=document.createElement("span");i.className="pl-toast-icon",i.textContent=Ay[e.type];const o=document.createElement("span");o.className="pl-toast-message",o.textContent=e.message,r.append(i,o),r.addEventListener("click",()=>{this.dismiss(r)}),t.appendChild(r);const s=setTimeout(()=>{this.dismiss(r)},n);r.dataset.timer=String(s)}dismiss(e){e.dataset.dismissed||(e.dataset.dismissed="true",e.dataset.timer&&clearTimeout(Number(e.dataset.timer)),e.classList.add("pl-toast--closing"),e.addEventListener("animationend",()=>{e.remove(),this.container&&this.container.childNodes.length===0&&(this.container.remove(),this.container=null)},{once:!0}))}success(e,t){this.show({type:"success",message:e,duration:t})}error(e,t){this.show({type:"error",message:e,duration:t})}info(e,t){this.show({type:"info",message:e,duration:t})}}const k=Qn.getInstance(),vy=7e3;function dt(a,e=vy){return new Promise((t,n)=>{let r=!1;const i=window.setTimeout(()=>{r||(r=!0,n(new Error("runtime message timed out")))},e);$.runtime.sendMessage(a).then(o=>{r||(r=!0,window.clearTimeout(i),t(o))}).catch(o=>{r||(r=!0,window.clearTimeout(i),n(o))})})}const Ic=qe+`
`+yy,po="paperlens-extra-download-host",wy="data-pl-doi",Mc="data-pl-oa",zr='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>';function Bc(a,e,t,n,r={}){if(t&&(r.openAccessPdfUrl||r.pmcid))return null;const i=document.createElement("div");i.className=po,i.setAttribute("data-paperlens-fulltext","extra-download"),a&&i.setAttribute(wy,a),i.setAttribute(Mc,t?"true":"false");const o=i.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=Ic,o.appendChild(s);const l=document.createElement("div");l.className="pl-extra-dl-bar";const c=t||r.journalOpenAccess===!0;if(e||!!(c&&a))if(a){const d=document.createElement("a");d.className="pl-extra-dl-btn",d.href=c?Dy(a):Ey(e??"",a),d.target="_blank",d.rel="noopener noreferrer",d.title=c?"\u901A\u8FC7 DOI \u6253\u5F00\u5F00\u653E\u83B7\u53D6\u5168\u6587":"\u901A\u8FC7\u81EA\u5B9A\u4E49\u6E90\u4E0B\u8F7D\u5168\u6587",ho(d,{doi:a,title:n,fallbackDomain:e,pmid:r.pmid,nativeFullTextUrl:r.nativeFullTextUrl,openAccessPdfUrl:r.openAccessPdfUrl,pmcid:r.pmcid,journalOpenAccess:r.journalOpenAccess},c?"\u5F00\u653E\u83B7\u53D6\u9875\u9762":"\u5907\u7528\u5168\u6587\u4E0B\u8F7D");const p=document.createElement("span");p.className="pl-extra-dl-icon",p.innerHTML=zr;const m=document.createElement("span");m.textContent="\u5168\u6587\u4E0B\u8F7D",d.append(p,m),l.appendChild(d)}else if(n&&e){const d=document.createElement("a");d.className="pl-extra-dl-btn",d.href=_y(e,n),d.target="_blank",d.rel="noopener noreferrer",d.title="\u901A\u8FC7\u8BBA\u6587\u6807\u9898\u641C\u7D22\u4E0B\u8F7D\u5168\u6587",ho(d,{title:n,fallbackDomain:e,pmid:r.pmid,nativeFullTextUrl:r.nativeFullTextUrl,openAccessPdfUrl:r.openAccessPdfUrl,pmcid:r.pmcid,journalOpenAccess:r.journalOpenAccess},"\u5907\u7528\u5168\u6587\u641C\u7D22");const p=document.createElement("span");p.className="pl-extra-dl-icon",p.innerHTML=zr;const m=document.createElement("span");m.textContent="\u5168\u6587\u4E0B\u8F7D",d.append(p,m),l.appendChild(d)}else{const d=document.createElement("button");d.className="pl-extra-dl-btn pl-extra-dl-btn--disabled",d.type="button",d.disabled=!0,d.title="\u8BE5\u8BBA\u6587\u65E0 DOI\uFF0C\u65E0\u6CD5\u8DF3\u8F6C";const p=document.createElement("span");p.className="pl-extra-dl-icon",p.innerHTML=zr;const m=document.createElement("span");m.textContent="\u5168\u6587\u4E0B\u8F7D",d.append(p,m),l.appendChild(d)}else{const d=document.createElement("button");d.className="pl-extra-dl-btn pl-extra-dl-btn--disabled",d.type="button",d.title="\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u914D\u7F6E\u4E0B\u8F7D\u6E90",d.addEventListener("click",()=>{k.info("\u8BF7\u5728\u767B\u5F55\u540E\u7684\u8BBE\u7F6E\u4E2D\u914D\u7F6E\u4E0B\u8F7D\u6E90")});const p=document.createElement("span");p.className="pl-extra-dl-icon",p.innerHTML=zr;const m=document.createElement("span");m.textContent="\u5168\u6587\u4E0B\u8F7D";const h=document.createElement("span");h.className="pl-extra-dl-tooltip",h.textContent="\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u914D\u7F6E\u4E0B\u8F7D\u6E90",d.append(p,m,h),l.appendChild(d)}return o.appendChild(l),i}function Sy(a,e="\u5168\u6587\u83B7\u53D6",t){const n=Ty(a);if(!n)return null;const r=document.createElement("div");r.className=po,r.setAttribute("data-paperlens-fulltext","native");const i=r.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=Ic,i.appendChild(o);const s=document.createElement("div");s.className="pl-extra-dl-bar";const l=document.createElement("a");l.className="pl-extra-dl-btn",l.href=n,l.target="_blank",l.rel="noopener noreferrer",l.title="\u4F18\u5148\u6253\u5F00\u539F\u7AD9\u6216\u5F00\u653E\u83B7\u53D6\u5168\u6587";const c=!!(t?.doi||t?.openAccessPdfUrl||t?.pmcid||t?.journalOpenAccess);t&&c?ho(l,{pmid:t.pmid,doi:t.doi,title:t.title,fallbackDomain:t.fallbackDomain,nativeFullTextUrl:t.nativeFullTextUrl??n,openAccessPdfUrl:t.openAccessPdfUrl,pmcid:t.pmcid,journalOpenAccess:t.journalOpenAccess}):l.addEventListener("click",p=>{p.stopPropagation()});const u=document.createElement("span");u.className="pl-extra-dl-icon",u.innerHTML=zr;const d=document.createElement("span");return d.textContent=e,l.append(u,d),s.appendChild(l),i.appendChild(s),r}function Ty(a){try{const e=new URL(a,location.href);return e.protocol==="http:"||e.protocol==="https:"?e.href:null}catch{return null}}function Ey(a,e){const t=jc(a),n=e.replace(/^\/+/,"");return`${t}/${n}`}function _y(a,e){return`${jc(a)}/search?q=${encodeURIComponent(e)}`}function Dy(a){return`https://doi.org/${a.replace(/^\/+/,"")}`}function ho(a,e,t="\u5907\u7528\u5168\u6587\u4E0B\u8F7D"){a.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),ky(a.href,e,t)})}function Fy(a){return a?.success===!1&&a.error==="No full text target found"}async function ky(a,e,t="\u5907\u7528\u5168\u6587\u4E0B\u8F7D"){const n=window.open("","_blank");try{k.info("\u6B63\u5728\u6838\u5BF9\u5F00\u653E\u83B7\u53D6\u5168\u6587...");const r=await dt({type:"RESOLVE_FULLTEXT_DOWNLOAD",payload:e},12e3);if(r?.success===!1&&!Fy(r)){n?.close(),k.error(r.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u5168\u6587\u4E0B\u8F7D");return}const i=r?.success&&r.data?.url?r.data.url:a,o=r?.success&&r.data?.isOpenAccess?r.data.label:t;Ly(n,i),k.success(`\u5DF2\u6253\u5F00${o}`)}catch(r){n?.close(),k.error(r instanceof Error&&r.message==="runtime message timed out"?"\u5728\u7EBF\u6743\u9650\u6821\u9A8C\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5":"\u5728\u7EBF\u6743\u9650\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}}function Ly(a,e){if(a&&!a.closed){a.opener=null,a.location.href=e;return}window.open(e,"_blank","noopener,noreferrer")}function jc(a){const e=a.trim().replace(/\/+$/,"");return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function Ny(a,e){document.querySelectorAll(`.${po}`).forEach(n=>{if(n.getAttribute("data-paperlens-fulltext")==="native"){n.style.display="";return}const r=n.getAttribute(Mc)==="true";n.style.display=a&&(r||e)?"":"none"})}const Jr="paperlens_library";async function Vr(){try{const a=await $.storage.local.get(Jr);return a[Jr]&&Array.isArray(a[Jr])?a[Jr]:[]}catch(a){return console.error("[Library] Failed to read library:",a),[]}}async function qc(a){try{await $.storage.local.set({[Jr]:a})}catch(e){throw console.error("[Library] Failed to write library:",e),e}}function fo(a){return a.pmid||a.sourceId||a.doi||""}function Xe(a){const e=a?.trim()??"";return/^10\.\d{4,9}\//i.test(e)?e.toLowerCase():e}function Ry(a,e){return!!(e.pmid&&a.pmid===e.pmid||e.doi&&a.doi&&Xe(a.doi)===Xe(e.doi)||e.sourceId&&a.sourceId===e.sourceId||!e.pmid&&!e.doi&&!e.sourceId&&e.title&&a.title===e.title)}function Py(a,e){const t={...a};for(const[n,r]of Object.entries(e))r===void 0||r===""||Array.isArray(r)&&r.length===0||(t[n]=r);return t.savedAt=a.savedAt,t}function mo(a,e){try{const t=$.runtime;if(typeof t.sendMessage!="function")return;t.sendMessage({type:a,payload:{paper:e}}).then(n=>{n?.success===!1&&console.error(`[Library] ${a} failed:`,n.error)}).catch(n=>{console.error(`[Library] ${a} message failed:`,n)})}catch(t){console.error(`[Library] ${a} dispatch failed:`,t)}}async function Iy(a){const e=fo(a);if(!e){console.warn("[Library] Cannot add paper without a valid identifier (pmid/doi)");return}const t=await Vr(),n=t.find(r=>Ry(r,a));if(n){console.log(`[Library] Paper ${e} already in library, skipping`),mo("SYNC_LIBRARY_PAPER",Py(n,a));return}t.push(a),await qc(t),console.log(`[Library] Added paper ${e} to library (${t.length} total)`),mo("SYNC_LIBRARY_PAPER",a)}async function My(a){const e=new Set(a.map(Xe).filter(Boolean));if(e.size===0){console.warn("[Library] Cannot remove papers with empty ID set");return}const t=await Vr(),n=t.filter(i=>{const o=Xe(fo(i));return e.has(o)||i.pmid&&e.has(Xe(i.pmid))||i.doi&&e.has(Xe(i.doi))||i.sourceId&&e.has(Xe(i.sourceId))});if(n.length===0){console.log(`[Library] Papers ${Array.from(e).join(", ")} not found in library`);return}const r=t.filter(i=>!n.includes(i));await qc(r),console.log(`[Library] Removed ${n.length} papers from library (${r.length} remaining)`);for(const i of n)mo("REMOVE_LIBRARY_PAPER",i)}async function Ra(a){if(!a)return!1;const e=await Vr(),t=Xe(a);return e.some(n=>Xe(fo(n))===t||Xe(n.pmid)===t||Xe(n.doi)===t||Xe(n.sourceId)===t)}const $c="paperlens_auth_tokens";async function Oc(){const a=await By();return a?!!a.refresh_token:!1}async function By(){try{const e=(await $.storage.local.get($c))[$c];return!e?.access_token||!e?.refresh_token?null:e}catch(a){return console.error("[TokenManager] Failed to load tokens:",a),null}}const jy=15e3;function qy(a){return{...a,authors:a.authors?[...a.authors]:void 0,keywords:a.keywords?[...a.keywords]:void 0,meshTerms:a.meshTerms?[...a.meshTerms]:void 0,publicationTypes:a.publicationTypes?[...a.publicationTypes]:void 0,affiliations:a.affiliations?[...a.affiliations]:void 0}}function $y(a){return!a.pmid||!a.issn||!a.publisher||a.citationCount==null}async function Oy(a){const e=qy(a);if(!$y(e))return e;try{const t=await dt({type:"ENRICH_LIBRARY_PAPER",payload:{paper:e}},jy);if(t?.success&&t.data)return t.data;t?.error&&console.warn("[PaperLens] Library metadata enrichment failed:",t.error)}catch(t){console.warn("[PaperLens] Library metadata enrichment request failed:",t)}return e}const Uy=qe+`
`+`/**
 * Save Button Styles \u2014 injected into each save button's Shadow DOM
 *
 * \u8BBE\u8BA1\u89C4\u8303\uFF1A
 * - \u672A\u6536\u85CF\uFF1A\u6587\u5B57\u6536\u85CF\uFF0Chover \u63D0\u793A\u300C\u6536\u85CF\u6B64\u8BBA\u6587\u300D
 * - \u5DF2\u6536\u85CF\uFF1A\u6587\u5B57\u5DF2\u6536\u85CF\uFF0Chover \u63D0\u793A\u300C\u53D6\u6D88\u6536\u85CF\u300D
 * - \u70B9\u51FB\u5207\u6362\u72B6\u6001\uFF0C\u5373\u65F6\u66F4\u65B0 UI
 *
 * Design Token \u4F9D\u8D56\uFF1A
 *   --pl-color-* / --pl-font-* / --pl-space-* / --pl-radius-*
 *   \u7531 tokens.css \u5728\u540C\u4E00 Shadow DOM \u5185\u901A\u8FC7 :host \u5B9A\u4E49
 */

:host {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
}

/* \u2500\u2500 \u6309\u94AE\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-save-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  font-family: var(--pl-font-sans);
  font-size: 13px;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--pl-transition-fast),
              border-color var(--pl-transition-fast),
              box-shadow var(--pl-transition-fast),
              color var(--pl-transition-fast),
              transform var(--pl-transition-fast);
  outline: none;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* \u2500\u2500 \u672A\u6536\u85CF\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-save-btn--unsaved {
  color: #334155;
}

.pl-save-btn--unsaved:hover {
  color: #1d4ed8;
  border-color: #93c5fd;
  background-color: #eff6ff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.pl-save-btn--unsaved:active {
  transform: scale(0.92);
}

/* \u2500\u2500 \u5DF2\u6536\u85CF\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-save-btn--saved {
  color: #9a3412;
  border-color: #fdba74;
  background-color: #fff7ed;
}

.pl-save-btn--saved:hover {
  color: #b91c1c;
  border-color: #fecaca;
  background-color: #fff1f2;
}

.pl-save-btn--saved:active {
  transform: scale(0.92);
}

/* \u6536\u85CF\u52A8\u753B \u2014 \u653E\u5927\u540E\u56DE\u5F39 */
@keyframes pl-save-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.pl-save-label--animate {
  animation: pl-save-bounce 0.35s ease-out;
}

/* \u2500\u2500 \u63D0\u793A\u6587\u5B57 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-save-label {
  font-size: 13px;
  line-height: 1;
}

/* \u2500\u2500 Tooltip \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-save-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-gray-800);
  color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-normal);
  white-space: nowrap;
  z-index: var(--pl-z-tooltip);
  box-shadow: var(--pl-shadow-md);
  pointer-events: none;
}

.pl-save-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--pl-color-gray-800);
}

.pl-save-btn:hover .pl-save-tooltip {
  display: block;
}
`,Uc="paperlens-save-host";function Hy(){const a=document.createElement("div");a.className=Uc,a.dataset.pmid="";const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=Uy,e.appendChild(t),{host:a,shadow:e}}function bo(a,e=!1){const{host:t,shadow:n}=Hy();zc(t,Jy(a));const r=document.createElement("button");r.type="button",r.className=e?"pl-save-btn pl-save-btn--saved":"pl-save-btn pl-save-btn--unsaved";const i=document.createElement("span");i.className="pl-save-label",i.textContent=yo(e);const o=document.createElement("span");return o.className="pl-save-tooltip",o.textContent=e?"\u53D6\u6D88\u6536\u85CF":"\u6536\u85CF\u6B64\u8BBA\u6587",r.append(i,o),n.appendChild(r),r.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),zy(t,r,i,a)}),t}async function zy(a,e,t,n){const r=a.dataset.pmid||Hc(n);if(e.classList.contains("pl-save-btn--saved")){const o=Array.from(go(a));await My(o),Gr(a,!1),Jc(a,!1),k.success("\u5DF2\u4ECE\u6587\u732E\u5E93\u79FB\u9664"),a.dispatchEvent(new CustomEvent("paperlens:unsaved",{bubbles:!0,detail:{pmid:r,ids:o}}))}else{if(!await Oc()){k.info("\u8BF7\u5148\u767B\u5F55\u540E\u518D\u6536\u85CF\u8BBA\u6587",4e3);return}try{const s=Wy(n),l=await Oy(s),c=Vy(l,n.alternateIds);zc(a,c);const u=(await Promise.all(c.map(d=>Ra(d)))).some(Boolean);await Iy(l),Gr(a,!0),Jc(a,!0),t.classList.add("pl-save-label--animate"),t.addEventListener("animationend",()=>{t.classList.remove("pl-save-label--animate")},{once:!0}),u?k.info("\u8BE5\u8BBA\u6587\u5DF2\u5728\u6587\u732E\u5E93\u4E2D"):k.success("\u5DF2\u4FDD\u5B58\u5230\u6587\u732E\u5E93"),a.dispatchEvent(new CustomEvent("paperlens:saved",{bubbles:!0,detail:{pmid:c[0]??r,ids:c}}))}catch{k.error("\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}}function Hc(a){return a.pmid||a.sourceId||a.doi||""}function Jy(a){return Array.from(new Set([Hc(a),a.pmid,a.sourceId,a.doi,Wr(a.doi),...a.alternateIds??[],...(a.alternateIds??[]).map(Wr)].filter(Boolean)))}function Vy(a,e=[]){return Array.from(new Set([a.pmid,a.sourceId,a.doi,Wr(a.doi),...e,...e.map(Wr)].filter(Boolean)))}function go(a){const e=[a.dataset.pmid,...a.dataset.paperlensIds?.split("	")??[]].filter(t=>!!t);return new Set(e.flatMap(t=>[t,Wr(t)]).filter(Boolean))}function Wr(a){const e=a?.trim()??"";return/^10\.\d{4,9}\//i.test(e)?e.toLowerCase():e}function zc(a,e){a.dataset.pmid=e[0]??"",a.dataset.paperlensIds=e.join("	")}function Wy(a){return{sourceId:a.sourceId,source:a.source,pmid:a.pmid,doi:a.doi,title:a.title,journal:a.journal,impactFactor:a.impactFactor,jcrQuartile:a.jcrQuartile,casQuartile:a.casQuartile,year:a.year,citationCount:a.citationCount,url:a.url,language:a.language,authors:a.authors?[...a.authors]:void 0,abstract:a.abstract,keywords:a.keywords?[...a.keywords]:void 0,meshTerms:a.meshTerms?[...a.meshTerms]:void 0,publicationTypes:a.publicationTypes?[...a.publicationTypes]:void 0,volume:a.volume,issue:a.issue,pages:a.pages,publisher:a.publisher,issn:a.issn,pmcid:a.pmcid,pdfUrl:a.pdfUrl,oaUrl:a.oaUrl,sourceUrl:a.sourceUrl||a.url,affiliations:a.affiliations?[...a.affiliations]:void 0,savedAt:Date.now()}}function yo(a){return a?"\u5DF2\u6536\u85CF":"\u6536\u85CF"}function Jc(a,e){const t=go(a);t.size!==0&&a.ownerDocument.querySelectorAll(`.${Uc}`).forEach(n=>{if(n===a)return;const r=go(n);Array.from(t).some(i=>r.has(i))&&Gr(n,e)})}function Gr(a,e){const t=a.shadowRoot;if(!t)return;const n=t.querySelector(".pl-save-btn"),r=t.querySelector(".pl-save-label"),i=t.querySelector(".pl-save-tooltip");!n||!r||!i||(e?(n.className="pl-save-btn pl-save-btn--saved",r.textContent=yo(!0),i.textContent="\u53D6\u6D88\u6536\u85CF"):(n.className="pl-save-btn pl-save-btn--unsaved",r.textContent=yo(!1),i.textContent="\u6536\u85CF\u6B64\u8BBA\u6587"))}function xo(a,e,t){const n=new Blob([a],{type:t}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}const Ao={ris:"application/x-research-info-systems",bibtex:"application/x-bibtex",medline:"text/plain",csv:"text/csv;charset=utf-8"},Vc={ris:".ris",bibtex:".bib",medline:".txt",csv:".csv"},Co=Object.freeze(Object.defineProperty({__proto__:null,EXPORT_EXTENSIONS:Vc,EXPORT_MIME_TYPES:Ao,downloadFile:xo},Symbol.toStringTag,{value:"Module"})),Gy="pubmed.query_optimizer",Yy="PubMed \u68C0\u7D22\u8BCD\u4F18\u5316",Zy="pubmed.advanced_filter",Qy="PubMed \u9AD8\u7EA7\u7B5B\u9009",Ky="pubmed.full_result_analysis",Xy="PubMed \u5168\u91CF\u7ED3\u679C\u5206\u6790",ex="export.zotero",tx="Zotero \u5BFC\u51FA",nx={ris:"export.ris",bibtex:"export.bibtex",medline:"export.nbib",csv:"export.csv"},rx={ris:"RIS \u5BFC\u51FA",bibtex:"BibTeX \u5BFC\u51FA",medline:"MEDLINE/NBIB \u5BFC\u51FA",csv:"CSV \u5BFC\u51FA"};async function et(a,e){try{const t=await $.runtime.sendMessage({type:"CHECK_ENTITLEMENT",payload:{featureKey:a,featureLabel:e}});return t?.success===!0&&t.data?.allowed===!0?{allowed:!0}:{allowed:!1,error:t?.error||`\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528${e}`}}catch{return{allowed:!1,error:"\u8BF7\u5148\u767B\u5F55\u8D26\u6237\uFF0C\u6216\u7A0D\u540E\u91CD\u8BD5"}}}function Wc(){return et(Gy,Yy)}function ax(){return et(Zy,Qy)}function ix(){return et(Ky,Xy)}function ox(a){return nx[a]}function sx(a){return rx[a]}function Et(a){return et(ox(a),sx(a))}function Kn(){return et(ex,tx)}const lx=qe+`
`+`/**
 * Export Button Styles \u2014 injected into each export button's Shadow DOM
 *
 * \u8BBE\u8BA1\u89C4\u8303\uFF1A
 * - \u5C0F\u5DE7\u7D27\u51D1\u7684\u5BFC\u51FA\u6309\u94AE\uFF0C\u4E0E metric-bar \u98CE\u683C\u4E00\u81F4
 * - \u4E0B\u62C9\u83DC\u5355\u4F7F\u7528 Shadow DOM \u9694\u79BB
 * - \u4F7F\u7528 --pl-* design tokens
 */

:host {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  position: relative;
  user-select: none;
}

/* \u2500\u2500 \u6309\u94AE\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  background-color: #ffffff;
  font-family: var(--pl-font-sans);
  font-size: 13px;
  font-weight: var(--pl-weight-semibold);
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  height: 28px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all var(--pl-transition-fast);
}

.pl-export-btn:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
  background-color: #eff6ff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.pl-export-btn:active {
  transform: scale(0.95);
}

.pl-export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* \u2500\u2500 \u6279\u91CF\u5BFC\u51FA\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-btn--batch {
  padding: 4px 10px;
  height: 28px;
}

.pl-export-label {
  font-size: 13px;
  line-height: 1;
}

/* \u2500\u2500 Tooltip \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-gray-800);
  color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-normal);
  white-space: nowrap;
  z-index: var(--pl-z-tooltip);
  box-shadow: var(--pl-shadow-md);
  pointer-events: none;
}

.pl-export-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--pl-color-gray-800);
}

.pl-export-btn:hover .pl-export-tooltip {
  display: block;
}

/* \u2500\u2500 \u4E0B\u62C9\u83DC\u5355 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 160px;
  background-color: var(--pl-color-white);
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-md);
  box-shadow: var(--pl-shadow-lg);
  z-index: var(--pl-z-dropdown);
  padding: var(--pl-space-xs) 0;
  overflow: hidden;
}

/* \u2500\u2500 \u4E0B\u62C9\u83DC\u5355\u9009\u9879 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  border: none;
  background: none;
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  cursor: pointer;
  transition: background-color var(--pl-transition-fast);
  text-align: left;
}

.pl-export-option:hover {
  background-color: var(--pl-color-primary-light);
}

.pl-export-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pl-export-option:disabled:hover {
  background: none;
}

.pl-export-option-name {
  font-weight: var(--pl-weight-semibold);
  color: var(--pl-color-gray-800);
}

.pl-export-option-desc {
  font-weight: var(--pl-weight-normal);
  color: var(--pl-color-gray-400);
  margin-left: 8px;
}
`,cx="paperlens-export-host",ux=[{value:"ris",label:"RIS",desc:"EndNote / Zotero"},{value:"bibtex",label:"BibTeX",desc:"LaTeX"},{value:"medline",label:"MEDLINE",desc:"\u5B66\u672F\u6570\u636E\u5E93"},{value:"csv",label:"CSV",desc:"Excel"}];function Gc(){const a=document.createElement("div");a.className=cx;const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=lx,e.appendChild(t),{host:a,shadow:e}}function dx(a){return a==="ris"||a==="bibtex"||a==="medline"||a==="csv"}async function Yc(a){const e=await Et(a);return e.allowed?!0:(k.error(e.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u8BE5\u5BFC\u51FA\u683C\u5F0F"),!1)}async function Zc(a){const e=Array.from(a.querySelectorAll(".pl-export-option[data-export-format]"));await Promise.all(e.map(async t=>{const n=t.dataset.exportFormat;if(!dx(n))return;const r=await Et(n),i=t.querySelector(".pl-export-option-desc"),o=t.dataset.defaultDesc||i?.textContent||"";if(r.allowed){t.disabled=!1,t.title="",t.classList.remove("pl-export-option--locked"),t.removeAttribute("aria-disabled"),i&&(i.textContent=o);return}t.disabled=!0,t.title=r.error||"\u8BE5\u5BFC\u51FA\u683C\u5F0F\u6682\u4E0D\u53EF\u7528",t.classList.add("pl-export-option--locked"),t.setAttribute("aria-disabled","true"),i&&(i.textContent="Pro")}))}function Qc(a,e){const t=document.createElement("button");t.type="button",t.className="pl-export-option",t.dataset.exportFormat=a.value,t.dataset.defaultDesc=a.desc;const n=document.createElement("span");n.className="pl-export-option-name",n.textContent=a.label;const r=document.createElement("span");return r.className="pl-export-option-desc",r.textContent=a.desc,t.append(n,r),t.addEventListener("click",async()=>{await e()}),t}function px(a){const{host:e,shadow:t}=Gc(),n=document.createElement("button");n.type="button",n.className="pl-export-btn",n.setAttribute("aria-label","\u5BFC\u51FA\u6587\u732E");const r=document.createElement("span");r.className="pl-export-label",r.textContent="\u5BFC\u51FA",n.appendChild(r);const i=hx(a);return i.classList.add("pl-export-dropdown"),i.style.display="none",t.append(n,i),n.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation();const s=i.style.display!=="none";Kc(),s||(i.style.display="block",Zc(i))}),document.addEventListener("click",o=>{e.contains(o.target)||(i.style.display="none")}),e}function hx(a){const e=document.createElement("div");for(const t of ux){const n=Qc(t,async()=>{e.style.display="none",await fx([a],t.value)});e.appendChild(n)}return e}function Kc(){document.querySelectorAll(Rn).forEach(a=>{const e=a.shadowRoot;if(e){const t=e.querySelector(".pl-export-dropdown");t instanceof HTMLElement&&(t.style.display="none")}})}async function fx(a,e){if(!await Yc(e))return;const t={type:"EXPORT_PUBMED_RECORDS",payload:{pmids:a,format:e}};let n;try{k.info("\u6B63\u5728\u5BFC\u51FA..."),n=await $.runtime.sendMessage(t)}catch{k.error("\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");return}if(!n?.success||!n.data){k.error(n?.error?`\u5BFC\u51FA\u5931\u8D25\uFF1A${n.error}`:"\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");return}const{downloadFile:r,EXPORT_MIME_TYPES:i,EXPORT_EXTENSIONS:o}=await Promise.resolve().then(()=>Co),s=o[e]??".txt",l=i[e]??"text/plain",c=a.length===1?`PMID${a[0]}${s}`:`pubmed_export_${new Date().toISOString().slice(0,10)}${s}`;r(n.data,c,l),k.success(`\u5DF2\u5BFC\u51FA ${a.length} \u7BC7\u6587\u732E`)}const mx=[{value:"ris",label:"RIS",desc:"EndNote / Zotero"},{value:"bibtex",label:"BibTeX",desc:"LaTeX"},{value:"csv",label:"CSV",desc:"Excel"}];function bx(a){const e=[],t=a.citationType??"article",n=t==="inproceedings"?"CONF":t==="incollection"?"CHAP":t==="book"?"BOOK":t==="misc"?"GEN":"JOUR";if(e.push(`TY  - ${n}`),e.push(`TI  - ${a.title}`),a.authors)for(const r of a.authors)e.push(`AU  - ${r}`);if(a.journal&&e.push(`JO  - ${a.journal}`),a.journal&&e.push(`T2  - ${a.journal}`),a.publicationDate&&e.push(`DA  - ${a.publicationDate}`),a.year&&e.push(`PY  - ${a.year}`),a.volume&&e.push(`VL  - ${a.volume}`),a.issue&&e.push(`IS  - ${a.issue}`),a.pages){const{startPage:r,endPage:i}=gx(a.pages);e.push(`SP  - ${r}`),i&&e.push(`EP  - ${i}`)}return a.doi&&e.push(`DO  - ${a.doi}`),a.issn&&e.push(`SN  - ${a.issn}`),a.url&&e.push(`UR  - ${a.url}`),a.abstract&&e.push(`AB  - ${a.abstract}`),e.push("ER  -"),e.join(`
`)}function gx(a){const e=a.trim();if(!e)return{startPage:a};const n=e.replace(/[–—]/g,"-").split(/\s*-\s*/).map(r=>r.trim()).filter(Boolean);return n.length>=2?{startPage:n[0],endPage:n[n.length-1]}:{startPage:e}}function yx(a){const e=a.citationType??"article",n=(a.authors?.[0]?.split(" ").pop()??"unknown").toLowerCase().replace(/[^a-z]/g,"")+(a.year??""),r=[];if(r.push(`  title = {${Jt(a.title)}}`),a.authors?.length&&r.push(`  author = {${a.authors.map(Jt).join(" and ")}}`),a.journal){const i=e==="inproceedings"||e==="incollection"?"booktitle":e==="misc"?"howpublished":"journal";r.push(`  ${i} = {${Jt(a.journal)}}`)}return a.volume&&r.push(`  volume = {${Jt(a.volume)}}`),a.issue&&r.push(`  number = {${Jt(a.issue)}}`),a.pages&&r.push(`  pages = {${Jt(a.pages.replace(/-/g,"--"))}}`),a.year&&r.push(`  year = {${a.year}}`),a.doi&&r.push(`  doi = {${a.doi}}`),a.issn&&r.push(`  issn = {${Jt(a.issn)}}`),a.url&&r.push(`  url = {${a.url}}`),a.abstract&&r.push(`  abstract = {${Jt(a.abstract)}}`),`@${e}{${n},
${r.join(`,
`)}
}`}function Jt(a){return a.replace(/\\/g,"\\\\").replace(/\{/g,"\\{").replace(/\}/g,"\\}")}function xx(a){return`"Title","Authors","Journal","PublicationDate","Year","Volume","Issue","Pages","DOI","ISSN","URL"
`+[a.title,(a.authors??[]).join("; "),a.journal??"",a.publicationDate??"",a.year?.toString()??"",a.volume??"",a.issue??"",a.pages??"",a.doi??"",a.issn??"",a.url??""].map(t=>`"${t.replace(/"/g,'""')}"`).join(",")}function Ax(a,e){if(e==="ris")return a.nativeExportUrls?.ris;if(e==="bibtex")return a.nativeExportUrls?.bibtex}function Xc(a,e){const t=Vc[e]??".txt";return`${a.title.slice(0,40).replace(/[^a-zA-Z0-9]/g,"_")}${t}`}async function Cx(a,e){if(!await Yc(e))return;const t=Ax(a,e);if(t){try{const i=await fetch(t);if(i.ok){const o=await i.text(),s=Ao[e]??"text/plain";xo(o,Xc(a,e),s),k.success("\u5DF2\u5BFC\u51FA\u6587\u732E");return}}catch{}window.open(t,"_blank","noopener,noreferrer"),k.success("\u5DF2\u6253\u5F00\u539F\u7AD9\u5BFC\u51FA");return}let n;switch(e){case"ris":n=bx(a);break;case"bibtex":n=yx(a);break;case"csv":n=xx(a);break}const r=Ao[e]??"text/plain";xo(n,Xc(a,e),r),k.success("\u5DF2\u5BFC\u51FA\u6587\u732E")}function vx(a){const{host:e,shadow:t}=Gc(),n=document.createElement("button");n.type="button",n.className="pl-export-btn",n.setAttribute("aria-label","\u5BFC\u51FA\u6587\u732E");const r=document.createElement("span");r.className="pl-export-label",r.textContent="\u5BFC\u51FA",n.appendChild(r);const i=document.createElement("div");i.className="pl-export-dropdown",i.style.display="none";for(const o of mx){const s=Qc(o,()=>{i.style.display="none",Cx(a,o.value)});i.appendChild(s)}return t.append(n,i),n.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation();const s=i.style.display!=="none";Kc(),s||(i.style.display="block",Zc(i))}),document.addEventListener("click",o=>{e.contains(o.target)||(i.style.display="none")}),e}function vo(a){const e={itemType:wx(a),title:a.title,creators:Tx(a),abstractNote:a.abstract||void 0,date:Ex(a),DOI:a.doi||void 0,url:a.url||(a.pmid?`https://pubmed.ncbi.nlm.nih.gov/${a.pmid}/`:void 0),extra:_x(a),publicationTitle:a.journal||void 0,volume:a.volume||void 0,issue:a.issue||void 0,pages:a.pages||void 0,ISSN:a.issn||void 0,tags:(a.tags||[]).map(t=>({tag:t})),attachments:[],notes:[],seeAlso:[],complete:!0,libraryCatalog:Sx(a),accessDate:new Date().toISOString().slice(0,10)};return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function wx(a){switch(a.citationType){case"inproceedings":return"conferencePaper";case"incollection":return"bookSection";case"book":return"book";case"misc":return"webpage";default:return"journalArticle"}}function Sx(a){if(a.pmid)return"PubMed";if(a.source)switch(a.source){case"sciencedirect":return"ScienceDirect";case"springerlink":return"SpringerLink";case"wiley":return"Wiley Online Library";case"sage-journals":return"Sage Journals";case"nature":return"Nature";case"science-org":return"Science.org";default:return a.source}}function Tx(a){return a.s2Authors&&a.s2Authors.length>0?a.s2Authors.map(e=>{if(e.firstName&&e.lastName)return{creatorType:"author",firstName:e.firstName,lastName:e.lastName};const t=(e.name||"").trim();return t?eu(t):null}).filter(e=>e!==null):a.authors&&a.authors.length>0?a.authors.map(e=>eu(e)).filter(Boolean):[]}function eu(a){const e=a.trim();if(!e)return{creatorType:"author",name:e};if(e.includes(",")){const i=e.split(",").map(o=>o.trim());if(i.length>=2&&i[0]&&i[1])return{creatorType:"author",lastName:i[0],firstName:i[1]}}const t=e.split(/\s+/);if(t.length===1)return{creatorType:"author",name:e};const n=t[t.length-1];return{creatorType:"author",firstName:t.slice(0,-1).join(" "),lastName:n}}function Ex(a){if(a.publicationDate)return a.publicationDate;if(a.year)return String(a.year)}function _x(a){const e=[];return a.pmid&&e.push(`PMID: ${a.pmid}`),a.pmcid&&e.push(`PMCID: ${a.pmcid}`),e.length>0?e.join(`
`):void 0}const Dx=`:host {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.zotero-modal-frame {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.zotero-modal-backdrop {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.42);
  cursor: default;
}

.zotero-modal {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 420px;
  max-width: min(420px, calc(100vw - 40px));
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.zotero-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.zotero-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.zotero-modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
}

.zotero-modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.zotero-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.zotero-modal-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.zotero-collection-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.zotero-collection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: background 0.15s;
}

.zotero-collection-item:hover {
  background: #f3f4f6;
}

.zotero-collection-item--selected {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.zotero-collection-item--selected:hover {
  background: #dbeafe;
}

.zotero-collection-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.zotero-collection-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zotero-collection-check {
  color: #3b82f6;
  font-size: 14px;
  flex-shrink: 0;
  display: none;
}

.zotero-collection-item--selected .zotero-collection-check {
  display: inline;
}

.zotero-collection-item[data-zotero-level="0"] {
  font-weight: 650;
}

.zotero-collection-item[data-zotero-level="1"],
.zotero-collection-item[data-zotero-level="2"],
.zotero-collection-item[data-zotero-level="3"],
.zotero-collection-item[data-zotero-level="4"],
.zotero-collection-item[data-zotero-level="5"],
.zotero-collection-item[data-zotero-level="6"],
.zotero-collection-item[data-zotero-level="7"],
.zotero-collection-item[data-zotero-level="8"] {
  position: relative;
}

.zotero-collection-item[data-zotero-level="1"]::before,
.zotero-collection-item[data-zotero-level="2"]::before,
.zotero-collection-item[data-zotero-level="3"]::before,
.zotero-collection-item[data-zotero-level="4"]::before,
.zotero-collection-item[data-zotero-level="5"]::before,
.zotero-collection-item[data-zotero-level="6"]::before,
.zotero-collection-item[data-zotero-level="7"]::before,
.zotero-collection-item[data-zotero-level="8"]::before {
  content: '';
  width: 8px;
  height: 1px;
  background: #cbd5e1;
  border-radius: 999px;
  flex: 0 0 8px;
  margin-left: -4px;
}

.zotero-collection-empty {
  text-align: center;
  padding: 24px;
  color: #9ca3af;
  font-size: 13px;
}

.zotero-modal-loading {
  text-align: center;
  padding: 24px;
  color: #6b7280;
  font-size: 13px;
}

.zotero-modal-loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: zotero-spin 0.6s linear infinite;
  margin-bottom: 8px;
}

@keyframes zotero-spin {
  to { transform: rotate(360deg); }
}

.zotero-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
}

.zotero-remember-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
}

.zotero-remember-check input {
  cursor: pointer;
  accent-color: #3b82f6;
}

.zotero-modal-actions {
  display: flex;
  gap: 8px;
}

.zotero-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.zotero-btn--cancel {
  background: #f3f4f6;
  color: #374151;
}

.zotero-btn--cancel:hover {
  background: #e5e7eb;
}

.zotero-btn--confirm {
  background: #3b82f6;
  color: #ffffff;
}

.zotero-btn--confirm:hover {
  background: #2563eb;
}

.zotero-btn--confirm:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}
`;function wo(a){let e=!1;const t=document.createElement("div");t.className="zotero-modal-overlay-wrapper";const n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=Dx,n.appendChild(r);const i=document.createElement("div");i.className="zotero-modal-frame";const o=document.createElement("button");o.className="zotero-modal-backdrop",o.type="button",o.setAttribute("aria-label","\u5173\u95ED Zotero \u4FDD\u5B58\u4F4D\u7F6E\u9009\u62E9");const s=document.createElement("div");s.className="zotero-modal";const l=document.createElement("div");l.className="zotero-modal-header";const c=document.createElement("h3");c.className="zotero-modal-title",c.textContent="\u4FDD\u5B58\u5230 Zotero";const u=document.createElement("button");u.className="zotero-modal-close",u.textContent="\u2715",u.type="button",l.append(c,u);const d=document.createElement("div");d.className="zotero-modal-body";const p=document.createElement("div");p.className="zotero-modal-label",p.textContent="\u9009\u62E9 Zotero \u4FDD\u5B58\u4F4D\u7F6E:";const m=document.createElement("div");m.innerHTML=`
    <div class="zotero-modal-loading">
      <div class="zotero-modal-loading-spinner"></div>
      <div>\u6B63\u5728\u8BFB\u53D6 Zotero \u4FDD\u5B58\u4F4D\u7F6E...</div>
    </div>
  `,d.append(p,m);const h=document.createElement("div");h.className="zotero-modal-footer";const y=document.createElement("label");y.className="zotero-remember-check";const x=document.createElement("input");x.type="checkbox",x.checked=!0;const T=document.createElement("span");T.textContent="\u8BB0\u4F4F\u672C\u6B21\u9009\u62E9",y.append(x,T);const F=document.createElement("div");F.className="zotero-modal-actions";const w=document.createElement("button");w.className="zotero-btn zotero-btn--cancel",w.type="button",w.textContent="\u53D6\u6D88";const b=document.createElement("button");b.className="zotero-btn zotero-btn--confirm",b.type="button",b.textContent="\u786E\u8BA4\u4FDD\u5B58",b.disabled=!1,F.append(w,b),h.append(y,F),s.append(l,d,h),i.append(o,s),n.appendChild(i);let v=a.defaultCollectionKey||"",D=a.defaultCollectionName||(a.defaultCollectionKey?"\u672A\u77E5\u6587\u4EF6\u5939":"\u6211\u7684\u8D44\u6599\u5E93");function B(E,I,M,j,z){const ce=document.createElement("li");ce.className="zotero-collection-item";const ue=Math.max(0,Math.min(M,8));ce.dataset.zoteroLevel=String(ue),ce.style.paddingLeft=`${12+ue*20}px`,j&&ce.classList.add("zotero-collection-item--selected");const Je=document.createElement("span");Je.className="zotero-collection-icon",Je.textContent=E.startsWith("L")?"\u{1F4DA}":"\u{1F4C1}";const Rt=document.createElement("span");Rt.className="zotero-collection-name",Rt.textContent=I;const yt=document.createElement("span");return yt.className="zotero-collection-check",yt.textContent="\u2713",ce.append(Je,Rt,yt),ce.addEventListener("click",J=>{J.stopPropagation(),m.querySelectorAll(".zotero-collection-item--selected").forEach(G=>G.classList.remove("zotero-collection-item--selected")),ce.classList.add("zotero-collection-item--selected"),z()}),ce}function U(E){m.innerHTML="";const I=document.createElement("ul");I.className="zotero-collection-list";const M=B("","Zotero \u5F53\u524D\u5E93/\u5F53\u524D\u6587\u4EF6\u5939",0,!0,()=>{v="",D="Zotero \u5F53\u524D\u5E93",b.disabled=!1});if(I.appendChild(M),E){const j=document.createElement("li");j.className="zotero-collection-empty",j.textContent=`\u65E0\u6CD5\u8BFB\u53D6 Zotero \u4FDD\u5B58\u4F4D\u7F6E\uFF0C\u53EF\u76F4\u63A5\u4FDD\u5B58\u5230\u5F53\u524D\u5E93\u3002${E}`,I.appendChild(j)}v="",D="Zotero \u5F53\u524D\u5E93",b.disabled=!1,x.checked=!1,x.disabled=!0,m.appendChild(I)}function L(E){m.innerHTML="";const I=document.createElement("ul");I.className="zotero-collection-list";const M=E[0],j=!!(v&&E.some(z=>z.id===v));if((!v||!j)&&M&&(v=M.id,D=M.name),E.length===0){U("Zotero \u672A\u8FD4\u56DE\u53EF\u4FDD\u5B58\u4F4D\u7F6E\u3002");return}for(const z of E)I.appendChild(B(z.id,z.name,z.level||0,z.id===v,()=>{v=z.id,D=z.name,b.disabled=!1}));m.appendChild(I)}function R(){e||(e=!0,t.remove())}return u.addEventListener("click",()=>{a.onCancel?.(),R()}),w.addEventListener("click",()=>{a.onCancel?.(),R()}),b.addEventListener("click",()=>{a.onConfirm(v,D,x.checked),R()}),o.addEventListener("click",()=>{a.onCancel?.(),R()}),(async()=>{try{const E=await dt({type:"ZOTERO_FETCH_COLLECTIONS"});if(!E?.success){const I=E?.error||"\u8BF7\u786E\u8BA4 Zotero \u5DF2\u5F00\u542F\u672C\u5730\u8FDE\u63A5\u3002";U(I.includes("FEATURE_NOT_ENTITLED")?"\u5F53\u524D\u8D26\u53F7\u6682\u672A\u5F00\u901A Zotero \u5BFC\u51FA\u6743\u9650\u3002":I);return}L(E.data||[])}catch(E){U(E instanceof Error&&E.message==="runtime message timed out"?"\u8BFB\u53D6\u4FDD\u5B58\u4F4D\u7F6E\u8D85\u65F6\uFF0C\u53EF\u76F4\u63A5\u4FDD\u5B58\u5230 Zotero \u5F53\u524D\u5E93\u3002":"\u8BF7\u786E\u8BA4 Zotero \u5DF2\u5F00\u542F\u672C\u5730\u8FDE\u63A5\u3002")}})(),document.body.appendChild(t),R}const Fx=`.pl-zotero-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.15s;
}

.pl-zotero-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.pl-zotero-btn:active {
  background: #f1f5f9;
  transform: scale(0.96);
}

.pl-zotero-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pl-zotero-btn--saving {
  opacity: 0.7;
  pointer-events: none;
}

.pl-zotero-btn-icon {
  font-size: 13px;
  line-height: 1;
}

.pl-zotero-btn-label {
  line-height: 1;
}
`,kx="paperlens-zotero-host",So="paperlens_zotero_last_collection",To="paperlens_zotero_last_collection_name";function Lx(a){return new Promise(e=>setTimeout(e,a))}async function tu(){try{const a=await $.storage.local.get([So,To]);return{key:a[So]||"",name:a[To]||""}}catch{return{key:"",name:""}}}async function nu(a,e){try{await $.storage.local.set({[So]:a,[To]:e})}catch{}}function Nx(a,e,t){a.disabled=!0,a.title=t,a.setAttribute("aria-disabled","true"),e.textContent="Zotero Pro"}async function ru(a,e){const t=await Kn();if(t.allowed){a.disabled=!1,a.title="",a.removeAttribute("aria-disabled"),e.textContent="Zotero";return}Nx(a,e,t.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA")}async function au(){const a=await Kn();return a.allowed?!0:(k.error(a.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA"),!1)}function iu(a){const e=document.createElement("div");e.className=kx;const t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=Fx,t.appendChild(n);const r=document.createElement("button");r.type="button",r.className="pl-zotero-btn",r.setAttribute("aria-label","\u4FDD\u5B58\u5230 Zotero");const i=document.createElement("span");i.className="pl-zotero-btn-icon",i.textContent="\u{1F4DA}";const o=document.createElement("span");return o.className="pl-zotero-btn-label",o.textContent="Zotero",r.append(i,o),t.appendChild(r),ru(r,o),r.addEventListener("click",async s=>{if(s.preventDefault(),s.stopPropagation(),!await au()){await ru(r,o);return}r.classList.add("pl-zotero-btn--saving"),o.textContent="\u68C0\u6D4B\u4E2D...",k.info("\u6B63\u5728\u8FDE\u63A5 Zotero...");try{const l=await dt({type:"ZOTERO_PING"});(!l?.success||!l?.data)&&k.info(`\u672A\u68C0\u6D4B\u5230 Zotero\uFF0C\u5C06\u76F4\u63A5\u5C1D\u8BD5\u4FDD\u5B58${l?.error?`\uFF1A${l.error}`:""}`);const c=await tu();o.textContent="Zotero",r.classList.remove("pl-zotero-btn--saving"),wo({defaultCollectionKey:c.key,defaultCollectionName:c.name,onConfirm:async(u,d,p)=>{let m=a.paper;if(a.beforeSave){k.info("\u6B63\u5728\u8865\u5168\u5143\u6570\u636E...");try{m=await a.beforeSave({...a.paper,authors:a.paper.authors?[...a.paper.authors]:void 0,s2Authors:a.paper.s2Authors?a.paper.s2Authors.map(x=>({...x})):void 0,tags:a.paper.tags?[...a.paper.tags]:void 0})}catch(x){console.warn("[PaperLens] Zotero beforeSave failed, falling back to page metadata:",x),k.info("\u5143\u6570\u636E\u8865\u5168\u5931\u8D25\uFF0C\u7EE7\u7EED\u4F7F\u7528\u9875\u9762\u6570\u636E\u4FDD\u5B58"),m=a.paper}}const h=vo(m),y=u?[u]:void 0;k.info("\u6B63\u5728\u4FDD\u5B58\u5230 Zotero...");try{const x=await dt({type:"ZOTERO_SAVE_ITEMS",payload:{items:[h],collections:y}});x?.success?(x.warning?k.info(x.warning):k.success(`\u5DF2\u4FDD\u5B58\u5230 Zotero${d?` \u2192 ${d}`:""}`),p&&u&&await nu(u,d)):k.error(`\u4FDD\u5B58\u5931\u8D25\uFF1A${x?.error||x?.message||"\u672A\u77E5\u9519\u8BEF"}`)}catch(x){k.error(x instanceof Error&&x.message==="runtime message timed out"?"\u4FDD\u5B58\u5230 Zotero \u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5":"\u4FDD\u5B58\u5230 Zotero \u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 Zotero \u8FDE\u63A5")}}})}catch(l){k.error(l instanceof Error&&l.message==="runtime message timed out"?"Zotero \u68C0\u6D4B\u8D85\u65F6\uFF0C\u8BF7\u5237\u65B0\u6269\u5C55\u540E\u91CD\u8BD5":"\u65E0\u6CD5\u8FDE\u63A5 Zotero\uFF0C\u8BF7\u68C0\u67E5 Zotero \u662F\u5426\u8FD0\u884C"),o.textContent="Zotero",r.classList.remove("pl-zotero-btn--saving")}}),e}async function Rx(a){if(!await au())return;k.info("\u6B63\u5728\u8FDE\u63A5 Zotero...");let e;try{e=await dt({type:"ZOTERO_PING"})}catch(n){e={success:!1,error:n instanceof Error&&n.message==="runtime message timed out"?"Zotero \u68C0\u6D4B\u8D85\u65F6":"Zotero \u68C0\u6D4B\u5931\u8D25"}}(!e?.success||!e?.data)&&k.info(`\u672A\u68C0\u6D4B\u5230 Zotero\uFF0C\u5C06\u76F4\u63A5\u5C1D\u8BD5\u4FDD\u5B58${e?.error?`\uFF1A${e.error}`:""}`);const t=await tu();wo({defaultCollectionKey:t.key,defaultCollectionName:t.name,onConfirm:async(n,r,i)=>{const o=a.map(vo),s=n?[n]:void 0;let l=0,c=0;k.info(`\u6B63\u5728\u4FDD\u5B58 ${o.length} \u7BC7\u5230 Zotero...`);for(let u=0;u<o.length;u++){try{(await dt({type:"ZOTERO_SAVE_ITEMS",payload:{items:[o[u]],collections:s}}))?.success?l++:c++}catch{c++}u<o.length-1&&await Lx(300)}c===0?k.success(`${l} \u7BC7\u5DF2\u4FDD\u5B58\u5230 Zotero${r?` \u2192 ${r}`:""}`):k.info(`\u5DF2\u4FDD\u5B58 ${l}/${l+c} \u7BC7\uFF0C${c} \u7BC7\u5931\u8D25`),i&&n&&await nu(n,r)}})}const Px=`/* AI Translate component styles */

:host,
.pl-translate-wrapper {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-top: 0;
  max-width: 100%;
  line-height: 1;
  vertical-align: middle;
}

:host(.pl-translate-wrapper--article-page),
.pl-translate-wrapper--article-page {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
  max-width: 100%;
  line-height: 1;
  vertical-align: middle;
}

/* \u2500\u2500 Button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 28px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.15s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  appearance: none;
}

.pl-translate-wrapper--article-page .pl-translate-btn {
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  padding: 0 11px;
}

.pl-translate-btn:hover:not(:disabled) {
  color: #2563eb;
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.pl-translate-wrapper--article-page .pl-translate-btn:hover:not(:disabled) {
  color: #1d4ed8;
  background: #dbeafe;
}

.pl-translate-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.pl-translate-btn--deep:hover:not(:disabled) {
  color: #6d28d9;
  border-color: #c4b5fd;
  background: #f5f3ff;
}

.pl-translate-wrapper--article-page .pl-translate-btn--deep:hover:not(:disabled) {
  color: #6d28d9;
  background: #ede9fe;
}

/* \u2500\u2500 Drawer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: min(420px, 92vw);
  height: 100vh;
  border-left: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: -4px 0 18px rgba(15, 23, 42, 0.12);
  color: #1f2937;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transform: translateX(100%);
  animation: pl-translate-drawer-in 220ms ease-out forwards;
}

.pl-translate-drawer--closing {
  animation: pl-translate-drawer-out 180ms ease-in forwards;
}

@keyframes pl-translate-drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes pl-translate-drawer-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

.pl-translate-drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pl-translate-drawer-title-wrap {
  flex: 1;
  min-width: 0;
}

.pl-translate-drawer-title {
  margin: 0;
  color: #111827;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

.pl-translate-drawer-meta {
  margin-top: 3px;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.3;
}

.pl-translate-drawer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pl-translate-drawer-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.pl-translate-drawer-pdf:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.pl-translate-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #ffffff;
  color: #4b5563;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.pl-translate-drawer-close:hover {
  border-color: #d1d5db;
  background: #f9fafb;
  color: #111827;
}

.pl-translate-drawer-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.pl-translate-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.pl-translate-source-title {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.pl-translate-paper-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: -2px 0 14px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.pl-translate-paper-meta-item {
  min-width: 0;
  font-size: 12px;
  line-height: 1.45;
}

.pl-translate-paper-meta-label {
  display: inline-block;
  margin-right: 6px;
  color: #6b7280;
  font-weight: 650;
}

.pl-translate-paper-meta-value {
  color: #374151;
  overflow-wrap: anywhere;
  text-decoration: none;
}

a.pl-translate-paper-meta-value:hover {
  color: #005ea8;
  text-decoration: underline;
}

.pl-translate-drawer-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: #4b5563;
  font-size: 13px;
}

.pl-translate-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  border-radius: 999px;
  animation: pl-translate-spin 700ms linear infinite;
}

@keyframes pl-translate-spin {
  to { transform: rotate(360deg); }
}

.pl-translate-drawer .pl-translate-result {
  margin-top: 0;
}

.pl-translate-drawer-error {
  padding: 10px 12px;
  border-radius: 4px;
  background: #fef2f2;
}

/* \u2500\u2500 Result Panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-result {
  margin-top: 8px;
  padding: 0;
  background: transparent;
  font-size: 13px;
  line-height: 1.6;
  animation: pl-translate-fade-in 0.3s ease;
}

@keyframes pl-translate-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pl-translate-section {
  margin-bottom: 14px;
}

.pl-translate-section-label {
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.pl-translate-title-zh {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  line-height: 1.55;
}

.pl-translate-abstract-zh {
  font-size: 13px;
  color: #374151;
  line-height: 1.75;
  white-space: pre-wrap;
}

.pl-translate-abstract-original {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.75;
  white-space: pre-wrap;
}

/* \u2500\u2500 Keywords \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-keywords {
  margin: 2px 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pl-translate-keywords-label {
  margin-right: 2px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
}

.pl-translate-keyword-tag {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* \u2500\u2500 Interpretation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-interpretation {
  margin-top: 4px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}

.pl-translate-interp-header {
  padding: 9px 11px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
  font-weight: 650;
}

.pl-translate-framework-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid #f3f4f6;
}

.pl-translate-framework-item:last-child {
  border-bottom: 0;
}

.pl-translate-framework-label {
  color: #4b5563;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.55;
}

.pl-translate-framework-text {
  color: #374151;
  font-size: 13px;
  line-height: 1.65;
}

/* \u2500\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

.pl-translate-error {
  margin-top: 6px;
  font-size: 12px;
  color: #dc2626;
  animation: pl-translate-fade-in 0.3s ease;
}

/* \u2500\u2500 Dark Mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

@media (prefers-color-scheme: dark) {
  .pl-translate-btn:hover:not(:disabled) {
    color: #60a5fa;
    background: rgba(37, 99, 235, 0.15);
  }

  .pl-translate-btn--deep:hover:not(:disabled) {
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.15);
  }

  .pl-translate-title-zh {
    color: #93c5fd;
  }

  .pl-translate-abstract-zh {
    color: #d1d5db;
  }

  .pl-translate-abstract-original {
    color: #d1d5db;
  }

  .pl-translate-keyword-tag {
    background: rgba(96, 165, 250, 0.2);
    color: #93c5fd;
  }

  .pl-translate-interpretation {
    border-color: #374151;
    background: rgba(255, 255, 255, 0.03);
  }

  .pl-translate-interp-header {
    border-bottom-color: #374151;
    background: rgba(255, 255, 255, 0.04);
    color: #d1d5db;
  }

  .pl-translate-framework-item {
    border-bottom-color: #374151;
  }

  .pl-translate-framework-label {
    color: #9ca3af;
  }

  .pl-translate-framework-text {
    color: #d1d5db;
  }

  .pl-translate-paper-meta {
    border-color: #374151;
    background: rgba(255, 255, 255, 0.03);
  }

  .pl-translate-paper-meta-value { color: #d1d5db; }


  .pl-translate-error {
    color: #f87171;
  }
}

/* PubMed explicit dark mode */
body.dark-mode .pl-translate-btn:hover:not(:disabled) {
  color: #60a5fa;
  background: rgba(37, 99, 235, 0.15);
}

body.dark-mode .pl-translate-title-zh { color: #93c5fd; }
body.dark-mode .pl-translate-abstract-zh { color: #d1d5db; }
body.dark-mode .pl-translate-abstract-original { color: #d1d5db; }
body.dark-mode .pl-translate-keyword-tag {
  background: rgba(96, 165, 250, 0.2);
  color: #93c5fd;
}
body.dark-mode .pl-translate-interpretation {
  border-color: #374151;
  background: rgba(255, 255, 255, 0.03);
}
body.dark-mode .pl-translate-interp-header {
  border-bottom-color: #374151;
  background: rgba(255, 255, 255, 0.04);
  color: #d1d5db;
}
body.dark-mode .pl-translate-framework-item { border-bottom-color: #374151; }
body.dark-mode .pl-translate-framework-label { color: #9ca3af; }
body.dark-mode .pl-translate-framework-text { color: #d1d5db; }
body.dark-mode .pl-translate-error { color: #f87171; }
`,Yr="deep",Ix="AI \u89E3\u8BFB",Mx="\u67E5\u770B\u7FFB\u8BD1\u3001\u5173\u952E\u8BCD\u548C\u7ED3\u6784\u5316\u89E3\u8BFB",ou="\u89E3\u8BFB\u4E2D\u2026",Bx="\u6B63\u5728\u751F\u6210\u89E3\u8BFB\u2026";let $e=null,Eo=0,_o=0;function Do(a,e,t,n={}){const{wrapper:r,button:i}=su();return i.addEventListener("click",()=>{$x(i,r,a,e,t,Yr,n)}),r}function jx(a){const{wrapper:e,button:t}=su();return t.addEventListener("click",()=>{Ox(t,e,a)}),e}async function qx(a){const e=Fo(),t=lu(a),n=cu(a);Oe({pmid:a.pmid,paperTitle:a.title,paperMeta:t,status:"loading"});try{const r=await $.runtime.sendMessage({type:"ARTICLE_AI_REQUEST",payload:a});if(Xn(e))return;if(!r?.success){const o=r?.error==="NOT_AUTHENTICATED"?"\u8BF7\u5148\u767B\u5F55 PaperLens \u8D26\u6237":r?.error||"\u89E3\u8BFB\u5931\u8D25";Oe({pmid:a.pmid,paperId:n,paperTitle:a.title,paperMeta:t,mode:Yr,status:"error",error:o});return}const i=r.data;Oe({pmid:a.pmid,paperId:n,paperTitle:a.title,paperMeta:t,mode:Yr,status:"success",data:i,cached:i.cached})}catch{if(Xn(e))return;Oe({pmid:a.pmid,paperTitle:a.title,paperMeta:t,status:"error",error:"\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5"})}}function su(){const a=document.createElement("div");a.className="pl-translate-wrapper";const e=a.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Px;const n=document.createElement("button");return n.type="button",n.className="pl-translate-btn pl-translate-btn--deep",n.textContent=Ix,n.title=Mx,e.append(t,n),{wrapper:a,button:n}}async function $x(a,e,t,n,r,i,o){if(a.disabled)return;const s=Fo();a.disabled=!0;const l=a.textContent;a.textContent=ou,Oe({pmid:t,paperTitle:n,paperMeta:o,status:"loading"});const c=e.querySelector(".pl-translate-result");c&&c.remove();const u=e.querySelector(".pl-translate-error");u&&u.remove();try{const d=await zx(t,r,o),p=await $.runtime.sendMessage({type:"TRANSLATE_REQUEST",payload:{pmid:t,title:n,abstract:d,mode:i}});if(Xn(s)){_t(a,l);return}if(!p?.success){const h=p?.error==="NOT_AUTHENTICATED"?"\u8BF7\u5148\u767B\u5F55 PaperLens \u8D26\u6237":p?.error||"\u89E3\u8BFB\u5931\u8D25";Oe({pmid:t,paperTitle:n,paperMeta:o,mode:i,status:"error",error:h}),_t(a,l);return}const m=p.data;Oe({pmid:t,paperTitle:n,paperMeta:o,mode:i,status:"success",data:m,cached:m.cached}),a.textContent=m.cached?"\u2705 \u5DF2\u89E3\u8BFB\uFF08\u7F13\u5B58\uFF09":"\u2705 \u89E3\u8BFB\u5B8C\u6210",setTimeout(()=>{a.textContent=l,a.disabled=!1},3e3)}catch{if(Xn(s)){_t(a,l);return}Oe({pmid:t,paperTitle:n,paperMeta:o,status:"error",error:"\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5"}),_t(a,l)}}async function Ox(a,e,t){if(a.disabled)return;const n=Fo();a.disabled=!0;const r=a.textContent;a.textContent=ou;const i=lu(t),o=cu(t);if(!Ux(t)){Oe({pmid:t.pmid,paperTitle:t.title,paperMeta:i,status:"error",error:"\u672A\u53EF\u9760\u8BFB\u53D6\u5230\u6458\u8981\u3002\u8BF7\u5212\u9009\u6458\u8981\u6B63\u6587\u540E\uFF0C\u70B9\u51FB\u6D6E\u52A8\u5DE5\u5177\u680F\u91CC\u7684\u201C\u6458\u8981\u89E3\u8BFB\u201D\u3002"}),_t(a,r);return}Oe({pmid:t.pmid,paperTitle:t.title,paperMeta:i,status:"loading"}),e.querySelector(".pl-translate-result")?.remove(),e.querySelector(".pl-translate-error")?.remove();try{const s=await $.runtime.sendMessage({type:"ARTICLE_AI_REQUEST",payload:t});if(Xn(n)){_t(a,r);return}if(!s?.success){const c=s?.error==="NOT_AUTHENTICATED"?"\u8BF7\u5148\u767B\u5F55 PaperLens \u8D26\u6237":s?.error||"\u89E3\u8BFB\u5931\u8D25";Oe({pmid:t.pmid,paperId:o,paperTitle:t.title,paperMeta:i,mode:Yr,status:"error",error:c}),_t(a,r);return}const l=s.data;Oe({pmid:t.pmid,paperId:o,paperTitle:t.title,paperMeta:i,mode:Yr,status:"success",data:l,cached:l.cached}),a.textContent=l.cached?"\u2705 \u5DF2\u89E3\u8BFB\uFF08\u7F13\u5B58\uFF09":"\u2705 \u89E3\u8BFB\u5B8C\u6210",setTimeout(()=>{a.textContent=r,a.disabled=!1},3e3)}catch{if(Xn(n)){_t(a,r);return}Oe({pmid:t.pmid,paperTitle:t.title,paperMeta:i,status:"error",error:"\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5"}),_t(a,r)}}function lu(a){return{journal:a.journal,authors:a.authors,doi:a.doi,publicationDate:a.publication_date,source:a.source,sourceUrl:a.source_url}}function cu(a){return a.paper_id??a.pmid??a.doi??a.source_url}function Ux(a){const e=a.abstract?.trim();if(!e||e.length<50)return!1;const t=a.title?.trim();return t?uu(e)!==uu(t):!0}function uu(a){return a.normalize("NFKC").toLowerCase().replace(/[^a-z0-9\u3400-\u9fff]+/g,"")}function Fo(){return _o=Eo,++Eo}function Hx(){_o=Eo}function Xn(a){return a<=_o}function _t(a,e){a.textContent=e,a.disabled=!1}async function zx(a,e,t){const n=e.trim();return t.hasFullAbstract&&n?n:Jx(a,n)}async function Jx(a,e){try{const t=await $.runtime.sendMessage({type:"GET_PAPER_SUMMARY",payload:{pmid:a}}),n=t?.data;if(t?.success&&typeof n?.abstract=="string"&&n.abstract.trim())return n.abstract.trim()}catch{}return e}function Oe(a){const e=Vx();e.classList.remove("pl-translate-drawer--closing"),Gx(e,a)}function Vx(){return $e?.isConnected&&$e.ownerDocument===document||($e=document.createElement("aside"),$e.className="pl-translate-drawer",$e.setAttribute("role","dialog"),$e.setAttribute("aria-modal","false"),document.body.appendChild($e)),$e}function Wx(){if(Hx(),!$e)return;const a=$e;a.classList.add("pl-translate-drawer--closing"),a.addEventListener("animationend",()=>{a.remove(),$e===a&&($e=null)},{once:!0})}function Gx(a,e){a.textContent="";const t=document.createElement("div");t.className="pl-translate-drawer-header";const n=document.createElement("div");n.className="pl-translate-drawer-title-wrap";const r=document.createElement("h2");r.className="pl-translate-drawer-title",r.textContent="AI \u89E3\u8BFB";const i=document.createElement("div");i.className="pl-translate-drawer-meta",i.textContent=e.pmid?`PMID: ${e.pmid}`:e.paperMeta?.journal||e.paperMeta?.source||"\u5F53\u524D\u6587\u7AE0",n.append(r,i);const o=document.createElement("div");if(o.className="pl-translate-drawer-actions",e.status==="success"&&e.data){const u=document.createElement("button");u.type="button",u.className="pl-translate-drawer-pdf",u.textContent="\u5BFC\u51FA PDF",u.addEventListener("click",()=>Xx(e)),o.appendChild(u)}const s=document.createElement("button");s.type="button",s.className="pl-translate-drawer-close",s.setAttribute("aria-label","\u5173\u95ED"),s.innerHTML=Kx(),s.addEventListener("click",Wx),o.appendChild(s),t.append(n,o),a.appendChild(t);const l=document.createElement("div");l.className="pl-translate-drawer-body";const c=document.createElement("div");if(c.className="pl-translate-source-title",c.textContent=e.paperTitle,l.appendChild(c),l.appendChild(Qx(e.pmid,e.paperMeta)),e.status==="loading"){const u=document.createElement("div");u.className="pl-translate-drawer-loading";const d=document.createElement("span");d.className="pl-translate-spinner";const p=document.createElement("span");p.textContent=Bx,u.append(d,p),l.appendChild(u)}else if(e.status==="error"){const u=document.createElement("div");u.className="pl-translate-error pl-translate-drawer-error",u.textContent=`\u26A0\uFE0F ${e.error||"\u8BF7\u6C42\u5931\u8D25"}`,l.appendChild(u)}else e.data&&l.appendChild(Yx(e.data));a.appendChild(l)}function Yx(a){const e=document.createElement("div");if(e.className="pl-translate-result",Pa(e,a.title_zh,"pl-translate-title-zh","\u6807\u9898\u7FFB\u8BD1"),Pa(e,a.original_summary,"pl-translate-abstract-original","\u539F\u6587\u6458\u8981"),Pa(e,a.abstract_zh??a.summary_zh,"pl-translate-abstract-zh","\u4E2D\u6587\u6458\u8981"),du(a.summary_zh,a.abstract_zh)&&Pa(e,a.summary_zh,"pl-translate-summary-zh","\u4E2D\u6587\u6982\u8981"),a.keywords?.length){const t=document.createElement("div");t.className="pl-translate-keywords";const n=document.createElement("span");n.className="pl-translate-keywords-label",n.textContent="\u5173\u952E\u8BCD",t.appendChild(n);for(const r of a.keywords){const i=document.createElement("span");i.className="pl-translate-keyword-tag",i.textContent=r,t.appendChild(i)}e.appendChild(t)}if(a.interpretation){const t=a.interpretation,n=document.createElement("div");n.className="pl-translate-interpretation";const r=document.createElement("div");r.className="pl-translate-interp-header",r.textContent="\u89E3\u8BFB\u6846\u67B6",n.appendChild(r);const i=[{label:"\u4E00\u53E5\u8BDD\u7ED3\u8BBA",value:t.one_sentence_summary},{label:"\u7814\u7A76\u95EE\u9898",value:t.research_question??t.background},{label:"\u7814\u7A76\u65B9\u6CD5",value:t.methods},{label:"\u5173\u952E\u53D1\u73B0",value:t.key_findings??t.core_findings},{label:"\u5C40\u9650",value:t.limitations},{label:"\u4EF7\u503C\u610F\u4E49",value:t.significance??t.clinical_significance}];for(const o of i)o.value&&n.appendChild(Zx(o.label,o.value));e.appendChild(n)}return e}function Pa(a,e,t,n){if(!e)return;const r=document.createElement("section");if(r.className="pl-translate-section",n){const o=document.createElement("div");o.className="pl-translate-section-label",o.textContent=n,r.appendChild(o)}const i=document.createElement("div");i.className=t,i.textContent=e,r.appendChild(i),a.appendChild(r)}function du(a,e){return a?e?pu(a)!==pu(e):!0:!1}function pu(a){return a.normalize("NFKC").replace(/\s+/g,"").trim()}function Zx(a,e){const t=document.createElement("div");t.className="pl-translate-framework-item";const n=document.createElement("div");n.className="pl-translate-framework-label",n.textContent=a;const r=document.createElement("div");return r.className="pl-translate-framework-text",r.textContent=e,t.append(n,r),t}function Qx(a,e){const t=document.createElement("div");t.className="pl-translate-paper-meta";const n=[{label:"\u671F\u520A",value:e?.journal},{label:"\u4F5C\u8005",value:hu(e?.authors)},{label:"PMID",value:a,href:a?`https://pubmed.ncbi.nlm.nih.gov/${a}/`:void 0},{label:"DOI",value:e?.doi,href:e?.doi?`https://doi.org/${e.doi}`:void 0},{label:"\u53D1\u8868\u65E5\u671F",value:e?.publicationDate},{label:"\u6587\u7AE0\u7C7B\u578B",value:e?.articleType},{label:"\u6765\u6E90",value:e?.source}];for(const r of n){if(!r.value)continue;const i=document.createElement("div");i.className="pl-translate-paper-meta-item";const o=document.createElement("span");o.className="pl-translate-paper-meta-label",o.textContent=r.label;const s=r.href?document.createElement("a"):document.createElement("span");s.className="pl-translate-paper-meta-value",s.textContent=r.value,s instanceof HTMLAnchorElement&&r.href&&(s.href=r.href,s.target="_blank",s.rel="noopener noreferrer"),i.append(o,s),t.appendChild(i)}return t}function hu(a){return a?.length?a.length<=4?a.join(", "):`${a.slice(0,4).join(", ")} \u7B49 ${a.length} \u4F4D\u4F5C\u8005`:""}function Kx(){return`
    <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      <path d="M6.75 6.75l10.5 10.5M17.25 6.75l-10.5 10.5" />
    </svg>
  `}function Xx(a){if(!a.data)return;const e=window.open("","_blank");e&&(e.opener=null,e.document.open(),e.document.write(eA(a)),e.document.close(),e.focus(),e.setTimeout(()=>{e.print()},250))}function eA(a){const e=a.data;if(!e)return"";const t=e.interpretation,n=[["\u671F\u520A",a.paperMeta?.journal],["\u4F5C\u8005",hu(a.paperMeta?.authors)],["PMID",a.pmid],["DOI",a.paperMeta?.doi],["\u53D1\u8868\u65E5\u671F",a.paperMeta?.publicationDate],["\u6587\u7AE0\u7C7B\u578B",a.paperMeta?.articleType],["\u6765\u6E90",a.paperMeta?.source]].filter(i=>!!i[1]),r=t?[["\u4E00\u53E5\u8BDD\u7ED3\u8BBA",t.one_sentence_summary],["\u7814\u7A76\u95EE\u9898",t.research_question??t.background],["\u7814\u7A76\u65B9\u6CD5",t.methods],["\u5173\u952E\u53D1\u73B0",t.key_findings??t.core_findings],["\u5C40\u9650",t.limitations],["\u4EF7\u503C\u610F\u4E49",t.significance??t.clinical_significance]].filter(i=>!!i[1]):[];return`<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>${Ue("AI \u89E3\u8BFB")} - ${Ue(a.paperTitle)}</title>
  <style>
    body { margin: 28px; color: #111827; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.65; }
    h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.35; }
    h2 { margin: 22px 0 10px; font-size: 16px; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
    .source-title { margin: 0 0 12px; color: #374151; font-size: 14px; font-weight: 600; }
    .meta { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; margin: 12px 0 18px; font-size: 12px; color: #374151; }
    .meta b { color: #6b7280; }
    .abstract { white-space: pre-wrap; }
    .interp { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; }
    .interp b { color: #374151; }
    ol { padding-left: 22px; }
    li { margin-bottom: 10px; }
    a { color: #005ea8; text-decoration: none; }
    @page { margin: 18mm; }
  </style>
</head>
<body>
  <h1>${Ue("AI \u89E3\u8BFB")}</h1>
  <div class="source-title">${Ue(a.paperTitle)}</div>
  ${n.length?`<div class="meta">${n.map(([i,o])=>`<b>${Ue(i)}</b><span>${Ue(o)}</span>`).join("")}</div>`:""}
  <h2>\u6807\u9898\u7FFB\u8BD1</h2>
  <p>${Ue(e.title_zh||"")}</p>
  ${e.original_summary?`<h2>\u539F\u6587\u6458\u8981</h2><p class="abstract">${Ue(e.original_summary)}</p>`:""}
  <h2>\u4E2D\u6587\u6458\u8981</h2>
  <p class="abstract">${Ue(e.abstract_zh||e.summary_zh||"")}</p>
  ${du(e.summary_zh,e.abstract_zh)?`<h2>\u4E2D\u6587\u6982\u8981</h2><p class="abstract">${Ue(e.summary_zh)}</p>`:""}
  ${e.keywords?.length?`<h2>\u5173\u952E\u8BCD</h2><p>${e.keywords.map(Ue).join("\uFF0C")}</p>`:""}
  ${r.length?`<h2>\u89E3\u8BFB\u6846\u67B6</h2><div class="interp">${r.map(([i,o])=>`<b>${Ue(i)}</b><span>${Ue(o)}</span>`).join("")}</div>`:""}
</body>
</html>`}function Ue(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const tA=7,nA="1.0.0",Vt=`https://${["sci","hub.ru"].join("-")}/`,er={appVersion:nA,schemaVersion:tA,showImpactFactor:!0,showCitations:!0,showOpenAccess:!0,showReferences:!1,showExtraDownload:!0,pubmedApiKey:"",extraDownloadUrl:Vt,quartileSource:"both",showScimagoSJR:!0},ko="paperlens_settings",Lo=["show","Sci","hub"].join(""),No=["sci","hub","Domain"].join("");function rA(a,e){return a}function aA(a){const e={...a};let t=!1;return Lo in e&&("showExtraDownload"in e||(e.showExtraDownload=e[Lo]),delete e[Lo],t=!0),No in e&&("extraDownloadUrl"in e||(e.extraDownloadUrl=e[No]),delete e[No],t=!0),t&&$.storage.sync.set({[ko]:e}),e}async function pt(){try{let e=(await $.storage.sync.get(ko))[ko];return e?(e=aA(e),rA({...er,...e},e)):{...er}}catch(a){return console.error("[Settings] Failed to get settings:",a),{...er}}}const Ro=gy;function iA(a){return typeof Ro.sanitize=="function"?Ro.sanitize(a):Ro(window).sanitize(a)}function Po(a,e){switch(a.position){case"after":a.element.after(e);break;case"before":a.element.before(e);break;case"prepend":a.element.prepend(e);break;case"append":a.element.appendChild(e);break;default:a.element.after(e)}}async function oA(a){try{const e=await dt({type:"ENRICH_ZOTERO_PAPER",payload:{paper:a}},1e4);if(e?.success&&e.data)return e.data;e?.error&&console.warn("[PaperLens] Zotero CrossRef enrich failed:",e.error)}catch(e){console.warn("[PaperLens] Zotero CrossRef enrich request failed:",e)}return a}const Ia="data-paperlens-article-id",Io="data-paperlens-article-signature",fu=[Ot,".paperlens-extra-tags",Us,mi,Pn,".paperlens-action-row",Nn,Rn].join(","),sA={pubmed:"sites.pubmed","google-scholar":"sites.google_scholar","baidu-scholar":"sites.baidu_scholar","semantic-scholar":"sites.semantic_scholar",cnki:"sites.cnki",wanfang:"sites.wanfang",wos:"sites.webofscience","ieee-xplore":"sites.ieee_acm","acm-dl":"sites.acm_dl",jstor:"sites.jstor",mdpi:"sites.mdpi","science-org":"sites.science_org","publisher-network":"sites.publisher_sites",nature:"sites.publisher_sites",springerlink:"sites.publisher_sites",sciencedirect:"sites.publisher_sites",wiley:"sites.publisher_sites",lww:"sites.publisher_sites",lancet:"sites.publisher_sites",bmj:"sites.publisher_sites",nejm:"sites.publisher_sites","jama-network":"sites.publisher_sites","sage-journals":"sites.publisher_sites","taylor-francis":"sites.publisher_sites","oxford-academic":"sites.publisher_sites","cambridge-core":"sites.publisher_sites","cell-com":"sites.publisher_sites",plos:"sites.publisher_sites",openreview:"sites.preprints",dblp:"sites.preprints"};async function Ma(a){if(typeof $?.runtime?.sendMessage!="function")return{pluginAllowed:!0,siteAllowed:!0,metricsBasic:!0,warningTags:!0,fulltextOpenAccess:!0};const e=sA[a.id],[t,n,r,i,o]=await Promise.all([et("plugin.chrome","Chrome \u6269\u5C55"),e?et(e,a.name):Promise.resolve({allowed:!0}),et("metrics.basic","\u57FA\u7840\u671F\u520A\u6307\u6807"),et("metrics.warning_tags","\u9884\u8B66\u4E0E\u4E2D\u6587\u6807\u7B7E"),et("fulltext.open_access","\u5F00\u653E\u83B7\u53D6\u5168\u6587")]);return{pluginAllowed:t.allowed,siteAllowed:n.allowed,metricsBasic:r.allowed,warningTags:i.allowed,fulltextOpenAccess:o.allowed}}function Ba(a,e){return e.pluginAllowed&&e.siteAllowed?!0:(console.warn(`[PaperLens] Enhancement disabled by server entitlement for ${a.id}`),!1)}function lA(a,e){const t=e.getRootNode();return t.nodeType===11&&"host"in t?t:a}function bt(a,e){return!!a.querySelector(e)}function mu(a){a.querySelectorAll(fu).forEach(e=>e.remove())}function bu(a){if(a.pmid)return a.pmid;if(a.sourceId)return a.sourceId;if(a.doi)return a.doi;const e=`${a.source??"article"}|${a.url??""}|${a.title}`;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`${a.source??"article"}:${Math.abs(t).toString(36)}`}function cA(a,e){return Array.from(new Set([e,a.pmid,a.sourceId,a.doi].filter(Boolean)))}function gu(a){const e=a?.trim()??"";return/^10\.\d{4,9}\//i.test(e)?e.toLowerCase():e}function yu(a){const e=new Set;for(const t of a)for(const n of[t.pmid,t.sourceId,t.doi]){const r=n?.trim();if(!r)continue;e.add(r);const i=gu(r);i&&e.add(i)}return e}function xu(a){let e=0;for(let t=0;t<a.length;t++)e=(e<<5)-e+a.charCodeAt(t)|0;return Math.abs(e).toString(36)}function Au(a,e){return xu([e,a.title,a.journalName,a.doi,a.year,a.url,a.abstractSnippet,a.articleTypes?.join("|"),a.authors?.join("|")].filter(Boolean).join("||"))}function Cu(a,e,t){return a.id==="baidu-scholar"&&e.hostElement?vu(e.hostElement,t):Au(e,t)}function tr(a){return(a??"").replace(/\s+/g," ").trim()}function Mo(a){const e=a?.trim();if(!e)return"";try{return new URL(e,location.href).href}catch{return e}}const uA=/\b10\.\d{4,9}\/[-._;()/:<>+\[\]A-Z0-9]+/i;function vu(a,e){const t=a.querySelector('.sc_title a, h3 a, .result-title a, a[data-click*="title"]'),n=Array.from(a.querySelectorAll(".sc_author, .sc_source, .sc_time, .sc_type, .result-meta, [data-paperlens-meta]")).map(o=>tr(o.textContent??"")).filter(Boolean).join("|"),i=tr(a.textContent??"").match(uA)?.[0]??"";return xu([e,tr(t?.textContent??""),Mo(t?.getAttribute("href")??t?.href??""),n,tr(i)].join("||"))}function dA(a,e,t){const n=a.hostElement;if(!n?.isConnected)return!1;const r=n.getAttribute(Ia);if(r&&r!==e)return!1;const i=n.querySelector('.sc_title a, h3 a, .result-title a, a[data-click*="title"]'),o=tr(i?.textContent??"");if(o&&o!==tr(a.title))return!1;const s=Mo(i?.getAttribute("href")??i?.href??""),l=Mo(a.url);return s&&l&&s!==l?!1:vu(n,e)===t}function pA(a,e,t,n){const r=a.getAttribute(Io),i=!!e.querySelector(fu);r!==n&&(r||i)&&mu(e),a.getAttribute(Ia)!==t&&a.setAttribute(Ia,t),r!==n&&a.setAttribute(Io,n)}function hA(a,e,t,n){if(!e.hostElement?.isConnected)return!1;if(a.id==="baidu-scholar")return dA(e,t,n);let r;if(a.isSearchPage())r=a.parseSearchResults().find(o=>o.hostElement===e.hostElement);else if(a.isArticlePage()){if(r=a.parseArticlePage(),r?.hostElement!==e.hostElement)return!1}else return!0;if(!r)return!1;const i=bu(r);return i===t&&Cu(a,r,i)===n}function Wt(a,e,t,n,r){return hA(a,e,n,r)?!1:(mu(t),e.hostElement?.removeAttribute(Ia),e.hostElement?.removeAttribute(Io),!0)}function fA(a){const e=a.match(/[A-Za-z]/g)?.length??0,t=a.match(/[\u3400-\u9fff]/g)?.length??0;return e>=12&&e>t}function mA(a,e){return e.showExtraDownload===!1||!(e.extraDownloadUrl??Vt)?!1:a.source==="cnki"||a.source==="wanfang"||a.source==="baidu-scholar"?a.doi?!0:a.source==="baidu-scholar"?!1:fA(a.title)&&wu(a):!0}function wu(a){if(!a.articleTypes||a.articleTypes.length===0)return!0;const e=a.articleTypes.join(" ").toLowerCase();return!/(conference|proceedings|proceeding paper|meeting abstract|preprint|book review|book|chapter|thesis|dissertation|patent|newspaper|会议|学位|硕士|博士|专利|报纸|图书|章节|预印本)/i.test(e)}async function bA(a){const e=[a.journalName,...a.journalCandidates??[]].map(n=>n?.trim()).filter(n=>!!n),t=new Set;for(const n of e){const r=n.toLowerCase();if(t.has(r))continue;t.add(r);const i=await Ir(n,a.issn);if(i)return{match:i,journalName:i.journal.journalName}}if(a.issn){const n=await Ir("",a.issn);if(n)return{match:n,journalName:n.journal.journalName}}return{match:null,journalName:a.journalName}}async function gA(a,e){const t=Su(a),n=[e,a.journalName,...a.journalCandidates??[]].map(i=>i?.trim()).filter(i=>!!i),r=new Set;for(const i of n){const o=i.toLowerCase();if(r.has(o))continue;r.add(o);const s=await zg(i,t);if(s)return s}return null}function Su(a){if(a.citationType==="inproceedings")return"conference";if(a.citationType==="article")return"journal";const e=a.articleTypes?.join(" ").toLowerCase()??"";if(/conference|proceedings|会议/.test(e))return"conference";if(/journal|期刊/.test(e))return"journal"}function yA(a,e){return e?!0:Su(a)==="conference"}function xA(a){return a.isArticlePage()||a.id==="springerlink"||a.id==="nature"||a.id==="wanfang"||a.id==="cell-com"||a.id==="jstor"||a.id==="lancet"||a.id==="bmj"}function AA(a,e){return!a.isArticlePage()||e.position!=="after"?!1:a.id==="publisher-network"?!0:/^(a|span|strong|em|b|i|small|sup|sub)$/i.test(e.element.tagName)}function CA(a,e){if(e.id==="publisher-network"){a.style.cssText=["display:block","flex:0 0 100%","grid-column:1 / -1","align-self:stretch","justify-self:stretch","box-sizing:border-box","width:100%","min-width:0","max-width:100%",'font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif',"margin:6px 0 0","clear:both"].join(";")+";";return}a.style.cssText="display:block;width:max-content;max-width:100%;margin:6px 0 0;"}function vA(a){const e=Number.isFinite(a.impactFactor)&&!!a.jcrQuartile&&a.jcrQuartile!=="N/A",t=Number.isFinite(a.sjr)&&!!a.sjrQuartile;return e||t}function wA(a,e){const t=a.sourceId??"";return t.startsWith("pnas:")?"PNAS":t.startsWith("acs:")?e:t.startsWith("csh-perspectives:")?"Cold Spring Harbor Perspectives":t.startsWith("genes-dev:")?"Genes & Development":a.journalName||e}function SA(a,e,t){return a.id==="publisher-network"?wA(e,t):a.id==="science-org"&&a.isArticlePage()?t||e.journalName:e.journalName||t}function TA(a){return a.id==="publisher-network"&&a.isArticlePage()?["display:flex","flex:0 0 100%","grid-column:1 / -1","align-items:center","justify-content:flex-start","flex-wrap:wrap","gap:8px","box-sizing:border-box","width:100%","min-width:0","max-width:100%",'font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif',"margin:6px 0 0","clear:both"].join(";")+";":xA(a)?"display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:8px 0 0;":"display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:8px;"}const EA=/^(?:在线阅读|查看全文|下载全文|下载|全文快报|引用|收藏|评审材料|导出)$/,_A=/(?:被引(?:量)?|下载(?:量)?|浏览(?:量)?|阅读(?:量)?|引证)[:：]?\d+/,Tu=[".reference",".org",".abstract",".record-title",".title-row",".meta-row",".abstract-row",".keyword-row",".wf-search-card__meta",".wf-search-card__abstract"].join(", ");function Bo(a){return(a??"").replace(/\s+/g,"").trim()}function DA(a){return Bo(a).replace(/^(?:AI)?(?:free)?/i,"").replace(/(?:AI)?(?:free)?$/i,"")}function Eu(a){return a.matches(Tu)}function _u(a){const e=DA(a.textContent??"");return!e||e.length>20?!1:EA.test(e)}function jo(a){if(!a)return!1;const e=Bo(a.textContent??"");return!!e&&_A.test(e)}function FA(a){const e=Bo(a.textContent??"");return e?/^[|/·•\-—丨]+$/.test(e):!0}function Du(a){return Eu(a)||!!a.querySelector(Tu)}function ja(a,e){const t=Array.from(a.children);return t.length===0?!1:t.every(n=>e.some(r=>n===r||n.contains(r))||jo(n)||FA(n))}function Fu(a,e){let t=a;for(;t.parentElement&&t.parentElement!==e;){const n=t.parentElement;if(Eu(n))return n;if(Du(n))break;if(ja(n,[t])){t=n;continue}if(_u(n)&&n.children.length<=3){t=n;continue}if(n.matches(".wf-list-button, .btn-read, .btn-download, .lnk-view, .lnk-download, .list-button-quote, a, button")){t=n;continue}break}return t}function qo(a){if(a.length===0)return null;if(a.length===1)return a[0]?.parentElement??null;const t=(n=>{const r=[];let i=n;for(;i;)r.push(i),i=i.parentElement;return r})(a[0]);for(const n of t)if(a.every(r=>n.contains(r)))return n;return null}function kA(a){const e=a.hostElement,t=e.querySelector(".wf-search-card__actions, .action-row, .item-btnpanel, .btnpanel");if(t)return t;const n=Array.from(e.querySelectorAll(".wf-list-button, .btn-read, .btn-download, .lnk-view, .lnk-download, .list-button-quote, a, button, span, div")).filter(s=>_u(s));if(n.length===0)return null;const r=n[0]?.parentElement;if(r&&n.every(s=>s.parentElement===r))return ja(r,n)?jo(r.nextElementSibling)&&r.parentElement&&r.parentElement!==e&&ja(r.parentElement,n)?r.parentElement:r:Fu(n.at(-1)??r,e);const i=qo(n);if(i&&i!==e&&!Du(i))return jo(i.nextElementSibling)&&i.parentElement&&i.parentElement!==e&&ja(i.parentElement,n)?i.parentElement:i;const o=n.at(-1);return o?Fu(o,e):null}function LA(a,e){return a.id==="wanfang"&&a.isSearchPage()?kA(e):a.id==="jstor"&&a.isSearchPage()?PA(e):a.id==="cell-com"&&a.isSearchPage()?qA(e):null}const NA=/^(?:read online|download|save(?: to workspace)?|cite|this content is not available for download)$/i;function RA(a){return(a??"").replace(/\s+/g," ").trim()}function ku(a){const e=RA(a.textContent??"");return!e||e.length>48?!1:NA.test(e)}function PA(a){const e=a.hostElement,t=e.querySelector('.actions, .result-actions, .search-result__actions, .item-actions, [data-testid*="actions"], [class*="actions"]');if(t&&Array.from(t.querySelectorAll("button, a, span, div, li")).some(o=>ku(o)))return t;const n=Array.from(e.querySelectorAll("button, a, span, div, li")).filter(o=>ku(o));if(n.length===0)return null;const r=n[0]?.parentElement;if(r&&n.every(o=>o.parentElement===r)&&r!==e)return r;const i=qo(n);return i&&i!==e?i:null}const IA=/^(?:download(?:\s+pdf)?|export\s+citation|request\s+permissions|get\s+access)$/i,MA=/^[|/·•\-—]+$/,Lu=[".abstract",".issue-item__abstract",".summary",".meta",".publication_meta",".issue-item__title",".art_title"].join(", ");function $o(a){return(a??"").replace(/\s+/g," ").trim()}function Oo(a){const e=$o(a.textContent??"");return!e||e.length>40?!1:IA.test(e)}function BA(a){const e=$o(a.textContent??"");return!e||MA.test(e)}function jA(a){const e=$o(a.textContent??"");return!!e&&(/^doi\b/i.test(e)||/doi\.org\//i.test(e))}function Nu(a){return Array.from(a.querySelectorAll("a, button, span, div")).filter(e=>Oo(e)).length}function Zr(a){return a.matches(Lu)||!!a.querySelector(Lu)}function Ru(a){if(Zr(a))return!1;const e=Array.from(a.children);return e.length===0?!1:e.every(t=>Oo(t)||BA(t)||jA(t)||Nu(t)>0)}function Pu(a,e){let t=a;for(;t.parentElement&&t.parentElement!==e;){const n=t.parentElement;if(Zr(n))break;if(n.children.length===1||Ru(n)){t=n;continue}break}return t}function qA(a){const e=a.hostElement,t=Array.from(e.querySelectorAll("a, button, span, div")).filter(l=>Oo(l));if(t.length===0)return null;const n=Array.from(new Set(t.map(l=>Pu(l,e)).filter(l=>l!==e))),r=e.querySelector(".article-tools, .issue-item__buttons, .toolbar, .action-bar, .search-result__actions, .issue-item__detail, .issue-item__detail-actions, .article-links");if(r&&!Zr(r))return n.filter(c=>!r.contains(c)).at(-1)??r;if(r){const l=Array.from(r.querySelectorAll("div, span, ul, ol")).find(c=>Ru(c)&&Nu(c)>0);if(l)return l}const i=t[0]?.parentElement;if(i&&t.every(l=>l.parentElement===i)&&!Zr(i))return i;if(n.length>0)return n.at(-1)??null;const o=qo(t);if(o&&o!==e&&!Zr(o))return o;const s=t.at(-1);return s?Pu(s,e):null}async function qa(a,e,t,n,r){if(!e.hostElement)return"skipped";const i=bu(e),o=Cu(a,e,i),s=a.getMetricBarAnchor(e.hostElement),l=lA(e.hostElement,s.element);pA(e.hostElement,l,i,o);let c=null;const u=n.metricsBasic&&wu(e),d=e.journalName||e.journalCandidates?.[0]||"",p=u?bA(e):Promise.resolve({match:null,journalName:e.journalName}),m=cA(e,i),h=LA(a,e),y=!!h;let x=l.querySelector(".paperlens-action-row");const T=()=>x||(x=document.createElement("div"),x.className="paperlens-action-row",x.style.cssText=TA(a),h?h.after(x):c?c.after(x):Po(s,x),x),F=await p;if(Wt(a,e,l,i,o))return"stale";const w=F.journalName||e.journalName,b=F.match?.journal,v=n.fulltextOpenAccess?e.nativeFullTextUrl:void 0,D=n.fulltextOpenAccess&&mA(e,t),B={pmid:e.pmid,doi:e.doi,title:e.title,fallbackDomain:t.extraDownloadUrl??Vt,nativeFullTextUrl:v,journalOpenAccess:!!b?.openAccess},U=bt(l,'[data-paperlens-fulltext="native"]')||bt(l,'[data-paperlens-fulltext="extra-download"]'),L=!U&&v?Sy(v,"\u5168\u6587\u83B7\u53D6",B):!U&&D?Bc(e.doi,t.extraDownloadUrl??Vt,!!b?.openAccess,e.title,B):null;if(L&&(L.style.cssText="display:inline-flex;align-items:center;",T().appendChild(L)),Wt(a,e,l,i,o))return"stale";if(e.title&&!bt(l,mi)){const j=iu({paper:{pmid:e.pmid??"",title:e.title,authors:e.authors,abstract:e.abstractSnippet,publicationDate:e.publicationDate,year:e.year,doi:e.doi,journal:d,volume:e.volume,issue:e.issue,pages:e.pages,issn:e.issn,url:e.url,citationType:e.citationType,source:e.source},beforeSave:e.doi?void 0:oA});j.style.cssText="display:inline-flex;align-items:center;",T().appendChild(j)}if(Wt(a,e,l,i,o))return"stale";if(e.title&&(!bt(l,Nn)||!bt(l,Rn))){if(!bt(l,Nn)){const j=r?m.some(ue=>r.has(ue)||r.has(gu(ue))):(await Promise.all(m.map(ue=>Ra(ue)))).some(Boolean);if(Wt(a,e,l,i,o)||Wt(a,e,l,i,o))return"stale";const z=b,ce=bo({sourceId:e.sourceId??(e.pmid||e.doi?void 0:i),alternateIds:m,source:e.source,pmid:e.pmid,doi:e.doi,title:e.title,journal:d,impactFactor:z?.impactFactor,jcrQuartile:z?.jcrQuartile,casQuartile:z?.casQuartile?String(z.casQuartile).replace("\u533A",""):void 0,year:e.year,url:e.url,language:["\u4E2D\u56FD\u77E5\u7F51","\u4E07\u65B9\u6570\u636E","\u767E\u5EA6\u5B66\u672F","cnki","wanfang","baidu-scholar"].includes(e.source??"")?"zh":void 0,authors:e.authors,abstract:e.abstractSnippet,publicationTypes:e.articleTypes,volume:e.volume,issue:e.issue,pages:e.pages,issn:e.issn,pdfUrl:e.nativeFullTextUrl,oaUrl:e.nativeFullTextUrl,sourceUrl:e.url},j);ce.style.cssText="display:inline-flex;align-items:center;",T().appendChild(ce)}if(!bt(l,Rn)){const j=vx({title:e.title,journal:d,publicationDate:e.publicationDate,year:e.year,doi:e.doi,url:e.url,authors:e.authors,abstract:e.abstractSnippet,volume:e.volume,issue:e.issue,pages:e.pages,issn:e.issn,citationType:e.citationType,nativeExportUrls:e.nativeExportUrls});j.style.cssText="display:inline-flex;align-items:center;",T().appendChild(j)}}if(e.title&&!bt(l,Pn)){const j=jx({paper_id:i,pmid:e.pmid,doi:e.doi,title:e.title,abstract:e.abstractSnippet,journal:d,authors:e.authors,year:e.year,publication_date:e.publicationDate,source:e.source,source_url:e.url??location.href});j.style.cssText="display:inline-flex;align-items:center;",T().appendChild(j)}if(Wt(a,e,l,i,o))return"stale";if(u&&(w||e.issn)&&!bt(l,Ot)){const j=F.match;if(j&&vA(j.journal)){const z=to(j.journal,{layout:a.id==="baidu-scholar"?"compact":"default",paper:{journal:SA(a,e,j.journal.journalName)}});AA(a,s)&&CA(z,a),x&&!y?x.before(z):Po(s,z),c=z}}const R=n.warningTags&&u&&w?Og(await $g(w)):"";if(Wt(a,e,l,i,o))return"stale";const E=n.warningTags&&yA(e,u)?await gA(e,w):null;if(Wt(a,e,l,i,o))return"stale";const I=E?Vg(E):"",M=R+I;if(M&&!bt(l,".paperlens-extra-tags")){const j=document.createElement("span");j.className="paperlens-extra-tags",j.innerHTML=iA(M),j.style.cssText="display:inline-flex;align-items:center;gap:2px;margin-left:4px;",c?c.after(j):x&&!y?x.before(j):Po(s,j),c=j}return"enhanced"}async function Uo(a){let e=a.parseSearchResults();if(e.length===0)return console.log(`[PaperLens] No articles found by ${a.id} adapter`),0;console.log(`[PaperLens] Enhancing ${e.length} articles on ${a.name}`);const t=await Ma(a);if(!Ba(a,t))return 0;await Un().catch(()=>{});let n;try{n=await pt()}catch(s){console.warn("[PaperLens] getSettings failed, using defaults:",s),n={extraDownloadUrl:Vt}}let r;try{r=yu(await Vr())}catch(s){console.warn("[PaperLens] Failed to preload library ids for multi-site enhancement:",s)}let i=0,o=!1;for(let s=0;s<5;s++){o=!1;for(const l of e)try{const c=await qa(a,l,n,t,r);c==="enhanced"&&i++,c==="stale"&&(o=!0)}catch(c){console.warn(`[PaperLens] Failed to enhance article "${l.title?.slice(0,40)}":`,c)}if(!o)break;if(e=a.parseSearchResults(),a.id==="baidu-scholar"&&e.length>0)for(let l=0;l<2&&e.length>0;l++)await Promise.resolve(),e=a.parseSearchResults();if(e.length===0)break}return console.log(`[PaperLens] Enhanced ${i}/${e.length} articles`),i}async function Z(a){const e=a.parseArticlePage();if(!e)return console.log(`[PaperLens] No detail article found by ${a.id} adapter`),0;const t=await Ma(a);if(!Ba(a,t))return 0;await Un().catch(i=>console.warn("[PaperLens] loadJournals failed:",i));let n;try{n=await pt()}catch{n={extraDownloadUrl:Vt}}let r;try{r=yu(await Vr())}catch(i){console.warn("[PaperLens] Failed to preload library ids for detail-page enhancement:",i)}return await qa(a,e,n,t,r),console.log(`[PaperLens] Enhanced article page on ${a.name}`),1}async function $A(a){const e=a,t=e.parseCitationLibrary();if(t.length===0)return console.log("[PaperLens] No articles found in citation library"),0;console.log(`[PaperLens] Enhancing ${t.length} citation library articles`);const n=await Ma(a);if(!Ba(a,n))return 0;await Un().catch(l=>console.warn("[PaperLens] loadJournals failed:",l));let r;try{r=await pt()}catch{r={extraDownloadUrl:Vt}}const i=l=>e.getCitationLibraryAnchor(l);let o=0;for(const l of t)if(l.hostElement&&!l.hostElement.hasAttribute("data-pl-enhanced"))try{const c=a.getMetricBarAnchor.bind(a);a.getMetricBarAnchor=i,await qa(a,l,r,n),a.getMetricBarAnchor=c,l.hostElement.setAttribute("data-pl-enhanced","true"),o++}catch(c){console.warn(`[PaperLens] Failed to enhance library article "${l.title?.slice(0,40)}"`,c)}const s=document.getElementById("gsc_a_b");if(s){let l=null;const c=new MutationObserver(()=>{l&&clearTimeout(l),l=setTimeout(async()=>{const u=e.parseCitationLibrary(),d=await Ma(a);if(!Ba(a,d))return;const p=a.getMetricBarAnchor.bind(a);a.getMetricBarAnchor=i;for(const m of u)if(m.hostElement&&!m.hostElement.hasAttribute("data-pl-enhanced"))try{await qa(a,m,r,d),m.hostElement.setAttribute("data-pl-enhanced","true")}catch(h){console.warn("[PaperLens] dynamic enhance failed:",h)}a.getMetricBarAnchor=p},300)});c.observe(s,{childList:!0,subtree:!0}),document.addEventListener("visibilitychange",()=>{document.hidden?c.disconnect():c.observe(s,{childList:!0,subtree:!0})})}return console.log(`[PaperLens] Enhanced ${o}/${t.length} library articles`),o}const OA=`/**
 * PaperLens Shadow DOM \u5185\u90E8\u6837\u5F0F
 *
 * \u6B64\u6587\u4EF6\u4E2D\u7684\u6240\u6709\u6837\u5F0F\u4EC5\u4F5C\u7528\u4E8E Shadow DOM \u5185\u90E8\u3002
 * Shadow DOM \u7684\u6837\u5F0F\u9694\u79BB\u673A\u5236\u786E\u4FDD\uFF1A
 *   1. PubMed \u9875\u9762\u7684 CSS \u9009\u62E9\u5668\u65E0\u6CD5\u5339\u914D Shadow DOM \u5185\u90E8\u5143\u7D20
 *   2. Shadow DOM \u5185\u90E8\u7684\u6837\u5F0F\u4E0D\u4F1A\u6CC4\u6F0F\u5230 PubMed \u9875\u9762
 *   3. \u5373\u4F7F PubMed \u4F7F\u7528\u4E86\u4E0E\u6211\u4EEC\u76F8\u540C\u7684 class \u540D\uFF0C\u4E5F\u4E0D\u4F1A\u51B2\u7A81
 *
 * \u6280\u672F\u539F\u7406\uFF1A
 *   - Shadow DOM \u4E3A\u5185\u90E8\u5143\u7D20\u521B\u5EFA\u4E86\u4E00\u4E2A\u72EC\u7ACB\u7684 CSS \u4F5C\u7528\u57DF
 *   - \u5916\u90E8\u6837\u5F0F\u8868\u4E2D :root / body \u7B49\u9009\u62E9\u5668\u65E0\u6CD5\u7A7F\u900F Shadow boundary
 *   - \u5185\u90E8\u5B9A\u4E49\u7684\u6837\u5F0F\u4E5F\u4E0D\u4F1A\u5F71\u54CD document \u4E2D\u7684\u5143\u7D20
 *   - \u552F\u4E00\u4F8B\u5916\uFF1ACSS Custom Properties (inherit) \u53EF\u4ECE\u5916\u90E8\u7EE7\u627F\uFF0C
 *     \u4F46\u6211\u4EEC\u5728 :host \u4E0A\u663E\u5F0F\u5B9A\u4E49\u4E86\u6240\u6709 --pl-* \u53D8\u91CF\uFF0C\u8986\u76D6\u4E86\u7EE7\u627F
 */

/* \u2500\u2500 Design Tokens \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
/* tokens.css \u7531 content script \u5728 JS \u4E2D\u62FC\u63A5\uFF0C\u4E0D\u901A\u8FC7 @import */

/* \u2500\u2500 \u5BB9\u5668\u5E03\u5C40\uFF08\u5BBF\u4E3B\u5143\u7D20\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
:host {
  all: initial;
  display: block;
  color: inherit;
  font: inherit;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2147483647; /* 32-bit signed max \u2014 \u786E\u4FDD\u5728\u6700\u9876\u5C42 */
  pointer-events: none;
  font-family: var(--pl-font-sans);
  color: var(--pl-color-text);
  line-height: 1.5;
}

/* \u2500\u2500 \u5185\u90E8\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-container {
  box-sizing: border-box;
  pointer-events: auto;
  margin: var(--pl-space-sm);
}

/* \u2500\u2500 \u6D4B\u8BD5 Badge \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  background-color: var(--pl-color-primary);
  color: var(--pl-color-white);
  padding: var(--pl-space-xs) var(--pl-space-md);
  border-radius: var(--pl-radius-full);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-sm);
  font-weight: var(--pl-weight-medium);
  line-height: 1.4;
  box-shadow: var(--pl-shadow-md);
  cursor: default;
  user-select: none;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--pl-transition-normal);
}

.pl-badge:hover {
  background-color: var(--pl-color-primary-hover);
  box-shadow: var(--pl-shadow-lg);
}

.pl-badge--faded {
  opacity: 0.6;
}

/* \u2500\u2500 Utility Classes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */

/* \u6392\u7248 */
.pl-text-xs   { font-size: var(--pl-font-xs); }
.pl-text-sm   { font-size: var(--pl-font-sm); }
.pl-text-base { font-size: var(--pl-font-base); }
.pl-text-lg   { font-size: var(--pl-font-lg); }
.pl-text-xl   { font-size: var(--pl-font-xl); }

.pl-font-normal   { font-weight: var(--pl-weight-normal); }
.pl-font-medium   { font-weight: var(--pl-weight-medium); }
.pl-font-semibold { font-weight: var(--pl-weight-semibold); }
.pl-font-bold     { font-weight: var(--pl-weight-bold); }

/* \u5E03\u5C40 */
.pl-flex          { display: flex; }
.pl-flex-center   { display: flex; align-items: center; justify-content: center; }
.pl-flex-col      { display: flex; flex-direction: column; }
.pl-items-center  { display: flex; align-items: center; }
.pl-gap-xs        { gap: var(--pl-space-xs); }
.pl-gap-sm        { gap: var(--pl-space-sm); }
.pl-gap-md        { gap: var(--pl-space-md); }

/* \u95F4\u8DDD */
.pl-m-0   { margin: 0; }
.pl-p-0   { padding: 0; }
.pl-p-xs  { padding: var(--pl-space-xs); }
.pl-p-sm  { padding: var(--pl-space-sm); }
.pl-p-md  { padding: var(--pl-space-md); }
.pl-p-lg  { padding: var(--pl-space-lg); }

/* \u76D2\u6A21\u578B\u91CD\u7F6E\uFF08\u6240\u6709\u5185\u90E8\u5143\u7D20\uFF09 */
.pl-badge *,
.pl-container * {
  box-sizing: border-box;
}

/* \u989C\u8272\u5DE5\u5177 */
.pl-text-primary  { color: var(--pl-color-primary); }
.pl-text-white    { color: var(--pl-color-white); }
.pl-text-gray-500 { color: var(--pl-color-gray-500); }
.pl-bg-primary    { background-color: var(--pl-color-primary); }
.pl-bg-white      { background-color: var(--pl-color-white); }

/* \u5706\u89D2 */
.pl-rounded-sm   { border-radius: var(--pl-radius-sm); }
.pl-rounded-md   { border-radius: var(--pl-radius-md); }
.pl-rounded-lg   { border-radius: var(--pl-radius-lg); }
.pl-rounded-full { border-radius: var(--pl-radius-full); }

/* \u9634\u5F71 */
.pl-shadow-sm { box-shadow: var(--pl-shadow-sm); }
.pl-shadow-md { box-shadow: var(--pl-shadow-md); }
.pl-shadow-lg { box-shadow: var(--pl-shadow-lg); }
`,UA=`/**
 * Citation Badge Styles \u2014 injected into each citation badge's Shadow DOM
 *
 * Design Token \u4F9D\u8D56\uFF1A
 *   --pl-color-* / --pl-font-* / --pl-space-* / --pl-radius-*
 *   \u7531 tokens.css \u5728\u540C\u4E00 Shadow DOM \u5185\u901A\u8FC7 :host \u5B9A\u4E49
 */

:host {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  padding: 0;
  margin: 0;
  vertical-align: middle;
}

/* \u2500\u2500 \u6307\u6807\u884C\u5BB9\u5668\uFF08\u4E0E metric-bar \u540C\u884C\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-citation-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  line-height: 1;
}

/* \u2500\u2500 \u5F15\u7528\u6570 Badge \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-citation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--pl-radius-sm);
  font-size: 12px;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  border: 0;
  background-color: var(--pl-color-gray-100);
  color: var(--pl-color-gray-700);
  font-family: var(--pl-font-sans);
  cursor: default;
  position: relative;
}

.pl-citation-badge:hover {
  background-color: var(--pl-color-gray-200);
}

.pl-citation-badge--clickable {
  cursor: pointer;
}

.pl-citation-badge--clickable:hover {
  color: var(--pl-color-primary);
}

.pl-citation-icon {
  font-size: 12px;
  opacity: 0.82;
}

/* \u2500\u2500 OA Badge \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-oa-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--pl-radius-sm);
  font-size: 12px;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  background-color: var(--pl-color-success-light);
  color: var(--pl-color-success);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--pl-transition-fast);
}

.pl-oa-badge:hover {
  background-color: var(--pl-color-success-light);
}

.pl-oa-badge:active {
  background-color: var(--pl-color-success);
  color: var(--pl-color-bg);
}

.pl-oa-icon {
  font-size: 10px;
  letter-spacing: 0;
}

/* \u2500\u2500 OA Badge: \u72B6\u6001 2 \u2014 OA \u4F46\u65E0 PDF \u94FE\u63A5\uFF08\u7070\u8272\u4E0D\u53EF\u70B9\u51FB\uFF09 \u2500\u2500 */
.pl-oa-badge--no-pdf {
  background-color: var(--pl-color-gray-100);
  color: var(--pl-color-gray-500);
  cursor: default;
  pointer-events: auto; /* allow hover for tooltip */
}

.pl-oa-badge--no-pdf:hover {
  background-color: var(--pl-color-gray-200);
}
`;class tt{static currentDrawer=null;static register(e){tt.currentDrawer&&tt.currentDrawer.close(),tt.currentDrawer=e}static unregister(e){tt.currentDrawer===e&&(tt.currentDrawer=null)}static getCurrent(){return tt.currentDrawer}}const HA=`/**
 * Citation Drawer Styles \u2014 injected into Shadow DOM
 *
 * \u53F3\u4FA7\u6ED1\u51FA\u62BD\u5C49\u9762\u677F\uFF0C\u663E\u793A\u5F15\u7528\u6587\u732E\u5217\u8868\u3002
 * \u4F7F\u7528 --pl-* design tokens
 */

:host {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

/* \u2500\u2500 \u89E6\u53D1\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-panel-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs);
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-gray-100);
  color: var(--pl-color-gray-700);
  font-family: var(--pl-font-sans);
  font-size: 12px;
  font-weight: var(--pl-weight-medium);
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--pl-transition-fast);
  white-space: nowrap;
}

.pl-panel-trigger:hover {
  background-color: var(--pl-color-gray-200);
}

.pl-panel-trigger:active {
  background-color: var(--pl-color-gray-300);
}

.pl-trigger-icon {
  font-size: 12px;
  transition: transform var(--pl-transition-fast);
}

.pl-trigger-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--pl-color-gray-300);
  border-top-color: var(--pl-color-gray-600);
  border-radius: 50%;
  animation: pl-spin 0.6s linear infinite;
}

@keyframes pl-spin {
  to { transform: rotate(360deg); }
}

/* \u2500\u2500 \u62BD\u5C49\u5BBF\u4E3B\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
:host(.pl-drawer) {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: min(420px, 92vw);
  height: 100vh;
  z-index: 999999;
  background: var(--pl-color-bg, #ffffff);
  border-left: 1px solid var(--pl-color-gray-200, #e5e7eb);
  box-shadow: -4px 0 16px var(--pl-color-shadow, rgba(0, 0, 0, 0.08));
  display: flex;
  flex-direction: column;
  font-family: var(--pl-font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  will-change: transform;
  transform: translateX(100%);
  animation: pl-drawer-slide-in 300ms ease-out forwards;
}

:host(.pl-drawer--closing) {
  animation: pl-drawer-slide-out 250ms ease-in forwards;
}

@keyframes pl-drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes pl-drawer-slide-out {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

/* \u2500\u2500 \u6807\u9898\u680F\uFF08\u56FA\u5B9A\u9876\u90E8\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-header {
  display: flex;
  align-items: flex-start;
  gap: var(--pl-space-sm, 8px);
  padding: var(--pl-space-lg, 16px);
  border-bottom: 1px solid var(--pl-color-gray-200, #e5e7eb);
  flex-shrink: 0;
}

.pl-drawer-title {
  flex: 1;
  font-size: var(--pl-font-sm, 12px);
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-900, #111827);
  line-height: 1.4;
  margin: 0;
  padding-right: var(--pl-space-xs, 4px);
}

.pl-drawer-count {
  display: inline-block;
  font-size: 10px;
  font-weight: var(--pl-weight-medium, 500);
  color: var(--pl-color-gray-500, #6b7280);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.pl-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: 999px;
  background: var(--pl-color-white, #ffffff);
  color: var(--pl-color-gray-600, #4b5563);
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: all var(--pl-transition-fast, 150ms ease);
}

.pl-drawer-close:hover {
  border-color: var(--pl-color-gray-300, #d1d5db);
  background-color: var(--pl-color-gray-50, #f9fafb);
  color: var(--pl-color-gray-900, #111827);
}

.pl-drawer-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* \u2500\u2500 \u5206\u9875\u5DE5\u5177\u6761 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pl-space-sm, 8px);
  padding: 10px var(--pl-space-lg, 16px);
  border-bottom: 1px solid var(--pl-color-gray-100, #f3f4f6);
  background: var(--pl-color-gray-50, #f9fafb);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pl-drawer-range {
  min-width: 92px;
  font-size: 11px;
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-700, #374151);
  white-space: nowrap;
}

.pl-drawer-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.pl-drawer-selection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--pl-color-gray-600, #4b5563);
  white-space: nowrap;
}

.pl-drawer-select-page {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.pl-drawer-select-page input,
.pl-ref-select {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--pl-color-primary, #2563eb);
  cursor: pointer;
}

.pl-drawer-select-page input:disabled {
  cursor: not-allowed;
}

.pl-drawer-selected-count {
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-700, #374151);
}

.pl-drawer-page-size {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--pl-color-gray-500, #6b7280);
  white-space: nowrap;
}

.pl-drawer-page-size select {
  height: 24px;
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: var(--pl-radius-sm, 4px);
  background: var(--pl-color-bg, #ffffff);
  color: var(--pl-color-gray-700, #374151);
  font-size: 11px;
}

.pl-drawer-tool-btn {
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: var(--pl-radius-sm, 4px);
  background: var(--pl-color-bg, #ffffff);
  color: var(--pl-color-gray-700, #374151);
  font-size: 11px;
  font-weight: var(--pl-weight-medium, 500);
  cursor: pointer;
  white-space: nowrap;
}

.pl-drawer-tool-btn:hover:not(:disabled) {
  background: var(--pl-color-gray-100, #f3f4f6);
}

.pl-drawer-tool-btn:disabled,
.pl-drawer-page-size select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* \u2500\u2500 \u5BFC\u51FA\u4E0B\u62C9\u83DC\u5355 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-export-wrap {
  position: relative;
  display: inline-block;
}

.pl-drawer-export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--pl-color-bg, #ffffff);
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: var(--pl-radius-sm, 4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000000;
  min-width: 180px;
  overflow: hidden;
}

.pl-drawer-export-group {
  padding: 7px 10px 3px;
  font-size: 10px;
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-500, #6b7280);
  background: var(--pl-color-gray-50, #f9fafb);
}

.pl-drawer-export-divider {
  height: 1px;
  background: var(--pl-color-gray-100, #f3f4f6);
}

.pl-drawer-export-option {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--pl-font-sans);
  transition: background-color 0.12s ease;
}

.pl-drawer-export-option:hover {
  background-color: var(--pl-color-gray-50, #f9fafb);
}

.pl-drawer-export-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pl-drawer-export-option:disabled:hover {
  background: transparent;
}

.pl-drawer-export-name {
  font-size: 11px;
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-800, #1f2937);
}

.pl-drawer-export-desc {
  font-size: 9px;
  color: var(--pl-color-gray-500, #6b7280);
}

/* \u2500\u2500 \u5F15\u7528\u5217\u8868\uFF08\u53EF\u6EDA\u52A8\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pl-drawer-list::-webkit-scrollbar {
  width: 4px;
}

.pl-drawer-list::-webkit-scrollbar-track {
  background: transparent;
}

.pl-drawer-list::-webkit-scrollbar-thumb {
  background: var(--pl-color-gray-300, #d1d5db);
  border-radius: 2px;
}

/* \u2500\u2500 \u5355\u6761\u5F15\u7528\u6587\u732E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--pl-space-sm, 8px) var(--pl-space-lg, 16px);
  border-bottom: 1px solid var(--pl-color-gray-100, #f3f4f6);
  transition: background-color var(--pl-transition-fast, 150ms ease);
}

.pl-drawer-item:hover {
  background-color: var(--pl-color-gray-50, #f9fafb);
}

.pl-drawer-item:last-child {
  border-bottom: none;
}

.pl-drawer-item-head {
  display: grid;
  grid-template-columns: 14px 28px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.pl-ref-select {
  align-self: start;
  margin-top: 3px;
}

.pl-ref-index {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 2px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--pl-color-gray-400, #9ca3af);
}

.pl-ref-title {
  min-width: 0;
  font-size: var(--pl-font-xs, 11px);
  font-weight: var(--pl-weight-medium, 500);
  color: var(--pl-color-primary, #2563eb);
  text-decoration: none;
  line-height: 1.5;
  cursor: pointer;
}

.pl-ref-title:hover {
  text-decoration: underline;
}

.pl-ref-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs, 4px);
  padding-left: 58px;
  font-size: 10px;
  color: var(--pl-color-gray-500, #6b7280);
  line-height: 1.3;
  flex-wrap: wrap;
}

.pl-ref-journal {
  font-style: italic;
}

.pl-ref-citations {
  color: var(--pl-color-gray-600, #4b5563);
  font-weight: var(--pl-weight-medium, 500);
}

/* \u2500\u2500 \u52A0\u8F7D\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--pl-space-xl, 24px);
}

.pl-drawer-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--pl-color-gray-200, #e5e7eb);
  border-top-color: var(--pl-color-primary, #2563eb);
  border-radius: 50%;
  animation: pl-spin 0.6s linear infinite;
}

/* \u2500\u2500 \u9519\u8BEF\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-error {
  padding: var(--pl-space-lg, 16px);
  font-size: var(--pl-font-xs, 11px);
  color: var(--pl-color-error, #ef4444);
  text-align: center;
}

.pl-drawer-empty {
  padding: var(--pl-space-xl, 24px) var(--pl-space-lg, 16px);
  font-size: var(--pl-font-xs, 11px);
  color: var(--pl-color-gray-500, #6b7280);
  text-align: center;
}

/* \u2500\u2500 \u5E95\u90E8\u63D0\u793A \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-drawer-footer {
  padding: var(--pl-space-sm, 8px) var(--pl-space-lg, 16px);
  font-size: 10px;
  color: var(--pl-color-gray-400, #9ca3af);
  font-style: italic;
  text-align: center;
  border-top: 1px solid var(--pl-color-gray-100, #f3f4f6);
  flex-shrink: 0;
}
`;function Ho(a){return a.replace(/([&%$#_{}])/g,"\\$1")}const zA=qe+`
`+HA,JA=80,VA=50,WA=[20,50,100],GA=[{format:"ris",label:"RIS",desc:"EndNote / Zotero"},{format:"bibtex",label:"BibTeX",desc:"LaTeX"},{format:"medline",label:"MEDLINE",desc:"\u5B66\u672F\u6570\u636E\u5E93"},{format:"csv",label:"CSV",desc:"Excel"}];function YA(a,e){return a?a.length>e?a.slice(0,e)+"\u2026":a:"Untitled"}function Gt(a){return a.toLocaleString("en-US")}function Iu(a){return a?`https://pubmed.ncbi.nlm.nih.gov/${a}/`:null}function Mu(a){return a?`https://doi.org/${a}`:null}function ZA(a){return a?`https://www.semanticscholar.org/paper/${encodeURIComponent(a)}`:null}function QA(a){const e=Iu(a.externalIds?.PubMed);if(e)return{url:e,source:"PubMed"};const t=Mu(a.externalIds?.DOI);if(t)return{url:t,source:"DOI"};const n=ZA(a.paperId);return n?{url:n,source:"Semantic Scholar"}:null}function KA(a,e,t){if(Array.isArray(a))return{papers:a,offset:e,limit:t};if(!a||typeof a!="object")return null;const n=a;if(Array.isArray(n.papers)&&typeof n.total=="number"){const i=n.papers.map(t0),o=n.papers.length,s=e+i.length<o?e+i.length:void 0;return{papers:i,total:o,offset:e,limit:t,next:s}}const r=a;return Array.isArray(r.papers)?{papers:r.papers,total:typeof r.total=="number"?r.total:void 0,offset:typeof r.offset=="number"?r.offset:e,limit:typeof r.limit=="number"?r.limit:t,next:typeof r.next=="number"?r.next:void 0}:null}function XA(a){const e=a==null?"":String(a);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function e0(a){return a.replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"").slice(0,80)||"paper"}function t0(a){return{paperId:a.s2PaperId??a.pmid??a.doi??"",title:a.title,citationCount:a.citationCount??0,influentialCitationCount:0,isOpenAccess:a.isOpenAccess??!1,openAccessPdf:a.openAccessPdf?{url:a.openAccessPdf}:void 0,year:a.year,venue:a.venue,externalIds:{PubMed:a.pmid,DOI:a.doi},authors:a.authors?a.authors.split(",").map(e=>({name:e.trim()})):void 0}}function $a(a){return a.paperId?`s2:${a.paperId}`:a.externalIds?.PubMed?`pmid:${a.externalIds.PubMed}`:a.externalIds?.DOI?`doi:${a.externalIds.DOI}`:`paper:${a.title??"untitled"}:${a.year??""}`}class ht{constructor(e){this.opts=e,this.total=e.count>0?e.count:void 0}opts;static instance=null;drawer=null;shadow=null;isOpen=!1;escHandler=null;currentOffset=0;pageSize=VA;total;nextOffset;currentPapers=[];selectedPapers=new Map;requestSeq=0;static open(e){ht.instance?.isOpen&&ht.instance.close(),ht.instance=new ht(e),ht.instance.doOpen()}static closeCurrent(){ht.instance?.isOpen&&ht.instance.close()}doOpen(){tt.register(this),this.drawer=document.createElement("div"),this.drawer.className="pl-drawer",document.body.appendChild(this.drawer),this.shadow=this.drawer.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=zA,this.shadow.appendChild(e),this.renderHeader(),this.renderToolbar(),this.renderLoading(),this.escHandler=t=>{t.key==="Escape"&&this.close()},document.addEventListener("keydown",this.escHandler),this.isOpen=!0,this.loadPapers(0)}close(){if(!this.isOpen)return;tt.unregister(this),this.escHandler&&(document.removeEventListener("keydown",this.escHandler),this.escHandler=null),this.drawer&&this.drawer.classList.add("pl-drawer--closing");const e=this.drawer;setTimeout(()=>{e?.remove()},250),this.isOpen=!1,this.drawer=null,this.shadow=null,ht.instance===this&&(ht.instance=null)}renderHeader(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-drawer-header";const t=document.createElement("h3");t.className="pl-drawer-title",t.textContent=this.opts.mode==="citations"?"\u88AB\u5F15\u8BE6\u60C5":this.opts.paperTitle??"\u5F15\u7528\u6587\u732E";const n=document.createElement("span");n.className="pl-drawer-count",n.textContent=this.opts.mode==="citations"?`${Gt(this.opts.count)} \u6B21\u88AB\u5F15`:`${Gt(this.opts.count)} \u7BC7\u5F15\u7528\u6587\u732E`;const r=document.createElement("button");r.className="pl-drawer-close",r.type="button",r.setAttribute("aria-label","\u5173\u95ED"),r.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6.75 6.75l10.5 10.5M17.25 6.75l-10.5 10.5"/></svg>',r.addEventListener("click",()=>this.close()),e.append(t,n,r),this.shadow.appendChild(e)}renderToolbar(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-drawer-toolbar",e.setAttribute("data-role","toolbar");const t=document.createElement("span");t.className="pl-drawer-range",t.setAttribute("data-role","range"),t.textContent="\u52A0\u8F7D\u4E2D...";const n=document.createElement("div");n.className="pl-drawer-selection";const r=document.createElement("label");r.className="pl-drawer-select-page";const i=document.createElement("input");i.type="checkbox",i.setAttribute("data-role","select-page"),i.addEventListener("change",()=>{this.setCurrentPageSelected(i.checked)});const o=document.createElement("span");o.textContent="\u672C\u9875\u5168\u9009",r.append(i,o);const s=document.createElement("span");s.className="pl-drawer-selected-count",s.setAttribute("data-role","selected-count"),s.textContent="\u5DF2\u9009 0",n.append(r,s);const l=document.createElement("div");l.className="pl-drawer-controls";const c=document.createElement("label");c.className="pl-drawer-page-size",c.textContent="\u6BCF\u9875";const u=document.createElement("select");u.setAttribute("data-role","page-size");for(const v of WA){const D=document.createElement("option");D.value=String(v),D.textContent=String(v),D.selected=v===this.pageSize,u.appendChild(D)}u.addEventListener("change",()=>{this.pageSize=Number(u.value),this.loadPapers(0)}),c.appendChild(u);const d=document.createElement("button");d.className="pl-drawer-tool-btn",d.type="button",d.textContent="\u4E0A\u4E00\u9875",d.setAttribute("data-role","prev"),d.addEventListener("click",()=>{this.loadPapers(Math.max(0,this.currentOffset-this.pageSize))});const p=document.createElement("button");p.className="pl-drawer-tool-btn",p.type="button",p.textContent="\u4E0B\u4E00\u9875",p.setAttribute("data-role","next"),p.addEventListener("click",()=>{typeof this.nextOffset=="number"&&this.loadPapers(this.nextOffset)});const m=document.createElement("div");m.className="pl-drawer-export-wrap",m.setAttribute("data-role","export");const h=document.createElement("button");h.className="pl-drawer-tool-btn",h.type="button",h.textContent="\u5BFC\u51FA \u25BE";const y=document.createElement("div");y.className="pl-drawer-export-dropdown",y.style.display="none";const x=(v,D)=>{const B=document.createElement("div");B.className="pl-drawer-export-group",B.textContent=v,y.appendChild(B);for(const U of GA){const L=document.createElement("button");L.type="button",L.className="pl-drawer-export-option",L.dataset.exportScope=D,L.dataset.exportFormat=U.format,L.dataset.defaultDesc=U.desc;const R=document.createElement("span");R.className="pl-drawer-export-name",R.textContent=U.label;const E=document.createElement("span");E.className="pl-drawer-export-desc",E.textContent=U.desc,L.append(R,E),L.addEventListener("click",()=>{y.style.display="none",this.exportPapers(U.format,D)}),y.appendChild(L)}};x("\u9009\u4E2D\u6587\u732E","selected");const T=document.createElement("div");T.className="pl-drawer-export-divider",y.appendChild(T),x("\u5F53\u524D\u9875\u5168\u90E8","page");const F=document.createElement("button");F.type="button",F.className="pl-drawer-export-option pl-drawer-clear-selection",F.setAttribute("data-role","clear-selection");const w=document.createElement("span");w.className="pl-drawer-export-name",w.textContent="\u6E05\u7A7A\u9009\u62E9";const b=document.createElement("span");b.className="pl-drawer-export-desc",b.textContent="\u4FDD\u7559\u5F53\u524D\u9875",F.append(w,b),F.addEventListener("click",()=>{y.style.display="none",this.clearSelection()}),y.appendChild(F);for(const v of y.querySelectorAll(".pl-drawer-export-option"))v.addEventListener("click",D=>D.stopPropagation());h.addEventListener("click",v=>{v.stopPropagation();const D=y.style.display!=="none";y.style.display=D?"none":"block",D||this.refreshExportAccess(y)}),document.addEventListener("click",v=>{m.contains(v.target)||(y.style.display="none")}),m.append(h,y),l.append(c,d,p,m),e.append(t,n,l),this.shadow.appendChild(e),this.updateToolbar(!0)}renderLoading(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-drawer-loading",e.setAttribute("data-role","loading");const t=document.createElement("span");t.className="pl-drawer-spinner",e.appendChild(t),this.shadow.appendChild(e)}clearDynamicContent(){this.shadow&&this.shadow.querySelectorAll('[data-role="loading"], [data-role="list"], [data-role="empty"], [data-role="error"], [data-role="footer"]').forEach(e=>e.remove())}updateToolbar(e=!1){if(!this.shadow)return;const t=this.shadow.querySelector('[data-role="range"]'),n=this.shadow.querySelector('[data-role="prev"]'),r=this.shadow.querySelector('[data-role="next"]'),i=this.shadow.querySelector('[data-role="export"] button'),o=this.shadow.querySelector('[data-role="page-size"]'),s=this.shadow.querySelector('[data-role="select-page"]'),l=this.shadow.querySelector('[data-role="selected-count"]'),c=this.shadow.querySelectorAll('[data-export-scope="selected"]'),u=this.shadow.querySelectorAll('[data-export-scope="page"]'),d=this.shadow.querySelector('[data-role="clear-selection"]');if(t)if(e)t.textContent="\u52A0\u8F7D\u4E2D...";else if(this.currentPapers.length===0)t.textContent=typeof this.total=="number"?`0 / ${Gt(this.total)}`:"0";else{const p=this.currentOffset+1,m=this.currentOffset+this.currentPapers.length,h=typeof this.total=="number"?` / ${Gt(this.total)}`:"";t.textContent=`${Gt(p)}-${Gt(m)}${h}`}if(n&&(n.disabled=e||this.currentOffset<=0),r&&(r.disabled=e||typeof this.nextOffset!="number"),i&&(i.disabled=e||this.currentPapers.length===0&&this.selectedPapers.size===0),o&&(o.disabled=e),l&&(l.textContent=`\u5DF2\u9009 ${Gt(this.selectedPapers.size)}`),s){const p=this.getCurrentPageSelectedCount();s.disabled=e||this.currentPapers.length===0,s.checked=this.currentPapers.length>0&&p===this.currentPapers.length,s.indeterminate=p>0&&p<this.currentPapers.length}c.forEach(p=>{p.disabled=e||this.selectedPapers.size===0}),u.forEach(p=>{p.disabled=e||this.currentPapers.length===0}),d&&(d.disabled=e||this.selectedPapers.size===0)}getCurrentPageSelectedCount(){return this.currentPapers.reduce((e,t)=>e+(this.selectedPapers.has($a(t))?1:0),0)}setCurrentPageSelected(e){for(const t of this.currentPapers){const n=$a(t);e?this.selectedPapers.set(n,t):this.selectedPapers.delete(n)}this.syncCurrentPageCheckboxes(),this.updateToolbar(!1)}setPaperSelected(e,t){const n=$a(e);t?this.selectedPapers.set(n,e):this.selectedPapers.delete(n),this.updateToolbar(!1)}clearSelection(){this.selectedPapers.clear(),this.syncCurrentPageCheckboxes(),this.updateToolbar(!1)}syncCurrentPageCheckboxes(){this.shadow&&this.shadow.querySelectorAll('[data-role="paper-select"]').forEach(e=>{const t=e.dataset.paperKey;e.checked=!!(t&&this.selectedPapers.has(t))})}async loadPapers(e=this.currentOffset){if(!this.shadow)return;const t=++this.requestSeq,n=Math.max(0,Math.floor(e||0));this.currentOffset=n,this.currentPapers=[],this.nextOffset=void 0,this.clearDynamicContent(),this.updateToolbar(!0),this.renderLoading();try{const r=await this.opts.sendToBackground(this.opts.mode==="citations"?"GET_CITATIONS":"GET_REFERENCES",{paperId:this.opts.paperId,pmid:this.opts.pmid??"",offset:String(n),limit:String(this.pageSize)});if(!this.isOpen||t!==this.requestSeq)return;if(this.clearDynamicContent(),r.success){const i=KA(r.data,n,this.pageSize);if(i){this.renderPapers(i);return}this.renderError("Unexpected paper list response")}else this.renderError(r.error??"Failed to load papers")}catch{if(!this.isOpen||t!==this.requestSeq)return;this.clearDynamicContent(),this.renderError("Network error")}}renderPapers(e){if(!this.shadow)return;if(this.currentOffset=e.offset,this.nextOffset=e.next,typeof e.total=="number"&&(this.total=e.total),e.papers.length===0){this.currentPapers=[],this.updateToolbar(!1),this.renderEmpty((this.total??0)>0);return}const t=[...e.papers];this.currentPapers=t,this.updateToolbar(!1);const n=document.createElement("ul");n.className="pl-drawer-list",n.setAttribute("data-role","list");for(let r=0;r<t.length;r++){const i=t[r],o=document.createElement("li");o.className="pl-drawer-item";const s=QA(i),l=s?document.createElement("a"):document.createElement("span");l.className="pl-ref-title",l.textContent=YA(i.title??"",JA),s&&l instanceof HTMLAnchorElement&&(l.href=s.url,l.target="_blank",l.rel="noopener noreferrer",l.title=`\u6253\u5F00 ${s.source}`);const c=document.createElement("div");c.className="pl-drawer-item-head";const u=$a(i),d=document.createElement("input");d.className="pl-ref-select",d.type="checkbox",d.checked=this.selectedPapers.has(u),d.dataset.paperKey=u,d.setAttribute("data-role","paper-select"),d.setAttribute("aria-label",`\u9009\u62E9\u6587\u732E ${e.offset+r+1}`),d.addEventListener("change",()=>{this.setPaperSelected(i,d.checked)});const p=document.createElement("span");p.className="pl-ref-index",p.textContent=String(e.offset+r+1),c.append(d,p,l);const m=document.createElement("span");m.className="pl-ref-meta";const h=[],y=i.journal?.name||i.venue||"";y&&h.push(y),i.year&&h.push(String(i.year));const x=h.length>0?h.join(", "):"";if(x){const T=document.createElement("span");T.className="pl-ref-journal",T.textContent=x,m.appendChild(T)}if(typeof i.citationCount=="number"){const T=document.createElement("span");T.className="pl-ref-citations",T.textContent=`\u88AB\u5F15 ${Gt(i.citationCount)}`,m.appendChild(T)}o.appendChild(c),o.appendChild(m),n.appendChild(o)}this.shadow.appendChild(n),this.renderFooter()}renderEmpty(e=!1){if(!this.shadow)return;const t=document.createElement("div");t.className="pl-drawer-empty",t.setAttribute("data-role","empty"),e?t.textContent=this.opts.mode==="citations"?"Semantic Scholar \u6709\u88AB\u5F15\u8BA1\u6570\uFF0C\u4F46\u6682\u672A\u8FD4\u56DE\u53EF\u5C55\u793A\u7684\u88AB\u5F15\u6587\u732E\u5217\u8868":"Semantic Scholar \u6709\u5F15\u7528\u8BA1\u6570\uFF0C\u4F46\u6682\u672A\u8FD4\u56DE\u53EF\u5C55\u793A\u7684\u5F15\u7528\u6587\u732E\u5217\u8868":t.textContent=this.opts.mode==="citations"?"\u6682\u65E0\u88AB\u5F15\u8BB0\u5F55":"\u6682\u65E0\u5F15\u7528\u6587\u732E",this.shadow.appendChild(t)}renderFooter(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-drawer-footer",e.setAttribute("data-role","footer"),e.textContent="\u53EF\u52FE\u9009\u6587\u732E\u540E\u5BFC\u51FA\uFF1B\u7FFB\u9875\u9009\u62E9\u4F1A\u4FDD\u7559\u5230\u62BD\u5C49\u5173\u95ED\u3002",this.shadow.appendChild(e)}renderError(e){if(!this.shadow)return;this.currentPapers=[],this.nextOffset=void 0,this.updateToolbar(!1);const t=document.createElement("div");t.className="pl-drawer-error",t.setAttribute("data-role","error"),t.textContent=`\u26A0 ${e}`,this.shadow.appendChild(t)}async exportPapers(e="csv",t="page"){const n=await Et(e);if(!n.allowed){k.error(n.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u8BE5\u5BFC\u51FA\u683C\u5F0F");return}const r=t==="selected"?Array.from(this.selectedPapers.values()):this.currentPapers;if(r.length===0)return;const i=t==="selected"?0:this.currentOffset,o=this.buildExport(r,i,e),s={ris:"application/x-research-info-systems",bibtex:"application/x-bibtex",medline:"text/plain",csv:"text/csv;charset=utf-8"},l={ris:".ris",bibtex:".bib",medline:".txt",csv:".csv"},c=e==="csv"?`\uFEFF${o}`:o,u=new Blob([c],{type:s[e]||"text/plain"}),d=URL.createObjectURL(u),p=document.createElement("a"),m=this.opts.mode==="citations"?"citations":"references",h=t==="selected"?`selected-${r.length}`:`${this.currentOffset+1}-${this.currentOffset+r.length}`;p.href=d,p.download=`paperlens-${m}-${e0(this.opts.paperId)}-${h}${l[e]||".txt"}`,p.style.display="none",document.body.appendChild(p),p.click(),p.remove(),window.setTimeout(()=>URL.revokeObjectURL(d),1e3)}async refreshExportAccess(e){const t=Array.from(e.querySelectorAll(".pl-drawer-export-option[data-export-format]"));await Promise.all(t.map(async n=>{const r=n.dataset.exportFormat;if(!r)return;const i=await Et(r),o=n.querySelector(".pl-drawer-export-desc"),s=n.dataset.defaultDesc||o?.textContent||"";if(i.allowed){n.disabled=!1,n.title="",n.removeAttribute("aria-disabled"),o&&(o.textContent=s);return}n.disabled=!0,n.title=i.error||"\u8BE5\u5BFC\u51FA\u683C\u5F0F\u6682\u4E0D\u53EF\u7528",n.setAttribute("aria-disabled","true"),o&&(o.textContent="Pro")}))}buildExport(e,t,n){switch(n){case"ris":return this.buildRis(e);case"bibtex":return this.buildBibtex(e);case"medline":return this.buildMedline(e);default:return this.buildCsv(e,t)}}buildRis(e){const t=[];for(const n of e){const r=[];if(r.push("TY  - JOUR"),r.push(`TI  - ${n.title??""}`),n.authors)for(const i of n.authors)r.push(`AU  - ${i.name}`);r.push(`JO  - ${n.journal?.name||n.venue||""}`),n.year&&r.push(`YR  - ${n.year}`),n.journal?.volume&&r.push(`VL  - ${n.journal.volume}`),n.journal?.pages&&r.push(`SP  - ${n.journal.pages}`),n.externalIds?.DOI&&r.push(`DO  - ${n.externalIds.DOI}`),n.abstract&&r.push(`AB  - ${n.abstract}`),r.push("ER  - "),t.push(r.join(`
`))}return t.join(`
`)}buildBibtex(e){const t=[];for(const n of e){const r=[],i=n.externalIds?.PubMed?`PMID${n.externalIds.PubMed}`:n.paperId??"unknown";r.push(`@article{${i},`),r.push(`  title = {${Ho(n.title??"")}},`),n.authors&&n.authors.length>0&&r.push(`  author = {${n.authors.map(o=>Ho(o.name)).join(" and ")}},`),r.push(`  journal = {${Ho(n.journal?.name||n.venue||"")}},`),n.year&&r.push(`  year = {${n.year}},`),n.journal?.volume&&r.push(`  volume = {${n.journal.volume}},`),n.journal?.pages&&r.push(`  pages = {${n.journal.pages.replace("-","--")}},`),n.externalIds?.DOI&&r.push(`  doi = {${n.externalIds.DOI}},`),r.push("}"),t.push(r.join(`
`))}return t.join(`

`)}buildMedline(e){const t=[];for(const n of e){const r=[];if(r.push(`PMID- ${n.externalIds?.PubMed??n.paperId??""}`),r.push(`TI  - ${n.title??""}`),n.authors)for(const o of n.authors)r.push(`AU  - ${o.name}`);r.push(`JT  - ${n.journal?.name||n.venue||""}`);const i=[];n.year&&i.push(String(n.year)),n.journal?.volume&&i.push(n.journal.volume),i.length>0&&r.push(`DP  - ${i.join(";")}`),n.externalIds?.DOI&&r.push(`AID - ${n.externalIds.DOI} [doi]`),n.abstract&&r.push(`AB  - ${n.abstract}`),r.push(""),t.push(r.join(`
`))}return t.join(`
`)}buildCsv(e,t){const n=[["No","Title","Year","Journal","Citation Count","PMID","DOI","Semantic Scholar ID","PubMed URL","DOI URL"]];return e.forEach((r,i)=>{const o=r.externalIds?.PubMed,s=r.externalIds?.DOI;n.push([String(t+i+1),r.title??"",r.year?String(r.year):"",r.journal?.name||r.venue||"",typeof r.citationCount=="number"?String(r.citationCount):"",o??"",s??"",r.paperId??"",Iu(o)??"",Mu(s)??""])}),n.map(r=>r.map(XA).join(",")).join(`
`)}}function n0(a){ht.open({mode:"citations",paperId:a.paperId,pmid:a.pmid,count:a.citationCount,paperTitle:a.paperTitle,sendToBackground:a.sendToBackground})}const r0=qe+`
`+UA,a0="paperlens-citation-host";function i0(a){return a.toLocaleString("en-US")}function o0(){const a=document.createElement("div");a.className=a0;const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=r0,e.appendChild(t),{host:a,shadow:e}}function Bu(a,e={}){const{host:t,shadow:n}=o0();t.dataset.plCitations=String(a.citationCount);const r=document.createElement("div");r.className="pl-citation-bar";const o=!!(e.paperId&&e.sendToBackground)?document.createElement("button"):document.createElement("span");o.className="pl-citation-badge",o instanceof HTMLButtonElement&&(o.type="button",o.classList.add("pl-citation-badge--clickable"),o.title="\u67E5\u770B\u88AB\u5F15\u8BE6\u60C5",o.setAttribute("aria-label","\u67E5\u770B\u88AB\u5F15\u8BE6\u60C5"),o.addEventListener("click",()=>{n0({paperId:e.paperId,pmid:e.pmid,citationCount:a.citationCount,paperTitle:e.paperTitle,sendToBackground:e.sendToBackground})}));const s=document.createElement("span");s.className="pl-citation-icon",s.textContent="\u88AB\u5F15";const l=document.createElement("span");if(l.className="pl-citation-count",l.textContent=i0(a.citationCount),o.append(s,l),r.appendChild(o),a.isOpenAccess)if(a.openAccessPdf?.url){const c=document.createElement("a");c.className="pl-oa-badge",c.setAttribute("data-pl-oa-badge",""),c.href=a.openAccessPdf.url,c.target="_blank",c.rel="noopener noreferrer",c.title="Open Access \u2014 \u70B9\u51FB\u4E0B\u8F7D PDF";const u=document.createElement("span");u.className="pl-oa-icon",u.textContent="PDF";const d=document.createElement("span");d.textContent="OA",c.append(u,d),r.appendChild(c),t.setAttribute("data-pl-oa-badge","")}else{const c=document.createElement("span");c.className="pl-oa-badge pl-oa-badge--no-pdf",c.setAttribute("data-pl-oa-badge",""),c.title="\u5F00\u653E\u83B7\u53D6\uFF0C\u4F46\u672A\u627E\u5230\u76F4\u63A5 PDF \u94FE\u63A5";const u=document.createElement("span");u.className="pl-oa-icon",u.textContent="OA",c.appendChild(u),r.appendChild(c),t.setAttribute("data-pl-oa-badge","")}return n.appendChild(r),t}function ju(a){return a!=null&&typeof a.citationCount=="number"}const s0=qe+`
`+`/**
 * Paper Preview Drawer Styles \u2014 injected into Shadow DOM
 *
 * \u53F3\u4FA7\u6ED1\u51FA\u9884\u89C8\u9762\u677F\uFF0C\u663E\u793A\u8BBA\u6587\u8BE6\u60C5\uFF08\u6458\u8981\u3001\u4F5C\u8005\u3001\u5173\u952E\u8BCD\u3001MeSH Terms \u7B49\uFF09\u3002
 * \u5BBD\u5EA6 420px\uFF0C\u4F7F\u7528 --pl-* design tokens\u3002
 */

/* \u2500\u2500 \u62BD\u5C49\u5BBF\u4E3B\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
:host(.pl-preview-drawer) {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  z-index: 999999;
  background: #ffffff;
  border-left: 1px solid var(--pl-color-gray-200, #e5e7eb);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  font-family: var(--pl-font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  will-change: transform;
  transform: translateX(100%);
  animation: pl-preview-slide-in 300ms ease-out forwards;
}

:host(.pl-preview-drawer--closing) {
  animation: pl-preview-slide-out 250ms ease-in forwards;
}

@keyframes pl-preview-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes pl-preview-slide-out {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

/* \u2500\u2500 \u6807\u9898\u680F \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-header {
  display: flex;
  align-items: flex-start;
  padding: var(--pl-space-lg, 16px);
  border-bottom: 1px solid var(--pl-color-gray-200, #e5e7eb);
  flex-shrink: 0;
  gap: var(--pl-space-sm, 8px);
}

.pl-preview-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: 999px;
  background: var(--pl-color-white, #ffffff);
  color: var(--pl-color-gray-600, #4b5563);
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: all var(--pl-transition-fast, 150ms ease);
}

.pl-preview-close:hover {
  border-color: var(--pl-color-gray-300, #d1d5db);
  background-color: var(--pl-color-gray-50, #f9fafb);
  color: var(--pl-color-gray-900, #111827);
}

.pl-preview-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* \u2500\u2500 \u5185\u5BB9\u533A\uFF08\u53EF\u6EDA\u52A8\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--pl-space-lg, 16px);
}

.pl-preview-content::-webkit-scrollbar {
  width: 4px;
}

.pl-preview-content::-webkit-scrollbar-track {
  background: transparent;
}

.pl-preview-content::-webkit-scrollbar-thumb {
  background: var(--pl-color-gray-300, #d1d5db);
  border-radius: 2px;
}

/* \u2500\u2500 \u6807\u9898\u533A \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-title {
  font-size: var(--pl-font-lg, 16px);
  font-weight: var(--pl-weight-bold, 700);
  color: var(--pl-color-gray-900, #111827);
  line-height: 1.4;
  margin: 0 0 var(--pl-space-sm, 8px);
}

.pl-preview-authors {
  font-size: var(--pl-font-sm, 12px);
  color: var(--pl-color-gray-600, #4b5563);
  line-height: 1.4;
  margin: 0 0 var(--pl-space-xs, 4px);
}

.pl-preview-journal {
  font-size: var(--pl-font-sm, 12px);
  color: var(--pl-color-gray-500, #6b7280);
  font-style: italic;
  line-height: 1.4;
  margin: 0 0 var(--pl-space-md, 12px);
}

.pl-preview-notice {
  padding: var(--pl-space-sm, 8px) var(--pl-space-md, 12px);
  margin: 0 0 var(--pl-space-md, 12px);
  border: 1px solid var(--pl-color-warning-light, #fef3c7);
  border-radius: var(--pl-radius-md, 6px);
  background: var(--pl-color-warning-light, #fef3c7);
  color: var(--pl-color-gray-700, #374151);
  font-size: var(--pl-font-xs, 11px);
  line-height: 1.5;
}

/* \u2500\u2500 \u6807\u8BC6\u884C\uFF08DOI / PMID / PMCID\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-ids {
  display: flex;
  flex-direction: column;
  gap: var(--pl-space-xs, 4px);
  margin-bottom: var(--pl-space-lg, 16px);
}

.pl-preview-id-row {
  display: flex;
  align-items: center;
  gap: var(--pl-space-xs, 4px);
  font-size: var(--pl-font-xs, 11px);
  color: var(--pl-color-gray-700, #374151);
}

.pl-preview-id-label {
  font-weight: var(--pl-weight-semibold, 600);
  min-width: 44px;
}

.pl-preview-id-value {
  font-family: var(--pl-font-mono, monospace);
  word-break: break-all;
}

.pl-preview-id-value a {
  color: var(--pl-color-primary, #2563eb);
  text-decoration: none;
}

.pl-preview-id-value a:hover {
  text-decoration: underline;
}

.pl-preview-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--pl-radius-sm, 4px);
  background: transparent;
  color: var(--pl-color-gray-400, #9ca3af);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--pl-transition-fast, 150ms ease),
              color var(--pl-transition-fast, 150ms ease);
}

.pl-preview-copy-btn:hover {
  background-color: var(--pl-color-gray-100, #f3f4f6);
  color: var(--pl-color-gray-700, #374151);
}

.pl-preview-copy-btn--copied {
  color: var(--pl-color-success, #10b981);
}

/* \u2500\u2500 \u5206\u533A\u6807\u9898 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-section {
  margin-bottom: var(--pl-space-lg, 16px);
}

.pl-preview-section-title {
  font-size: var(--pl-font-xs, 11px);
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-gray-500, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--pl-color-gray-200, #e5e7eb);
  padding-bottom: var(--pl-space-xs, 4px);
  margin: 0 0 var(--pl-space-sm, 8px);
}

/* \u2500\u2500 \u6458\u8981\u533A \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-abstract {
  font-size: var(--pl-font-sm, 12px);
  color: var(--pl-color-gray-800, #1f2937);
  line-height: 1.6;
  white-space: pre-line;
}

.pl-preview-abstract-label {
  font-weight: var(--pl-weight-semibold, 600);
  color: var(--pl-color-primary, #2563eb);
  margin-top: var(--pl-space-sm, 8px);
  margin-bottom: var(--pl-space-xs, 4px);
  font-size: var(--pl-font-sm, 12px);
}

.pl-preview-abstract-text {
  margin: 0;
  line-height: 1.6;
}

/* \u2500\u2500 \u6807\u7B7E\u5217\u8868\uFF08Keywords / MeSH Terms\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pl-space-xs, 4px);
}

.pl-preview-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--pl-radius-full, 9999px);
  background-color: var(--pl-color-gray-100, #f3f4f6);
  color: var(--pl-color-gray-700, #374151);
  font-size: 10px;
  font-weight: var(--pl-weight-medium, 500);
  line-height: 1.5;
}

/* \u2500\u2500 \u5E95\u90E8\u64CD\u4F5C\u680F \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-actions {
  display: flex;
  align-items: center;
  gap: var(--pl-space-sm, 8px);
  padding: var(--pl-space-md, 12px) var(--pl-space-lg, 16px);
  border-top: 1px solid var(--pl-color-gray-200, #e5e7eb);
  flex-shrink: 0;
}

.pl-preview-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--pl-space-xs, 4px);
  padding: 6px 12px;
  border: 1px solid var(--pl-color-gray-200, #e5e7eb);
  border-radius: var(--pl-radius-md, 8px);
  background: var(--pl-color-white, #ffffff);
  color: var(--pl-color-gray-700, #374151);
  font-family: var(--pl-font-sans, sans-serif);
  font-size: var(--pl-font-xs, 11px);
  font-weight: var(--pl-weight-medium, 500);
  cursor: pointer;
  transition: background-color var(--pl-transition-fast, 150ms ease),
              border-color var(--pl-transition-fast, 150ms ease);
  white-space: nowrap;
}

.pl-preview-action-btn:hover {
  background-color: var(--pl-color-gray-50, #f9fafb);
  border-color: var(--pl-color-gray-300, #d1d5db);
}

.pl-preview-action-btn--primary {
  background-color: var(--pl-color-primary, #2563eb);
  color: #ffffff;
  border-color: var(--pl-color-primary, #2563eb);
}

.pl-preview-action-btn--primary:hover {
  background-color: var(--pl-color-primary-hover, #1d4ed8);
}

/* \u2500\u2500 Skeleton \u52A0\u8F7D\u52A8\u753B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-skeleton {
  padding: var(--pl-space-lg, 16px);
}

.pl-preview-skeleton-line {
  height: 12px;
  border-radius: var(--pl-radius-sm, 4px);
  background: linear-gradient(90deg, var(--pl-color-gray-100, #f3f4f6) 25%, var(--pl-color-gray-200, #e5e7eb) 50%, var(--pl-color-gray-100, #f3f4f6) 75%);
  background-size: 200% 100%;
  animation: pl-preview-skeleton-shimmer 1.5s infinite;
  margin-bottom: var(--pl-space-sm, 8px);
}

.pl-preview-skeleton-line--title {
  height: 18px;
  width: 85%;
}

.pl-preview-skeleton-line--subtitle {
  width: 60%;
}

.pl-preview-skeleton-line--id {
  width: 45%;
}

.pl-preview-skeleton-line--text {
  width: 100%;
}

.pl-preview-skeleton-line--short {
  width: 70%;
}

@keyframes pl-preview-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* \u2500\u2500 \u9519\u8BEF\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-preview-error {
  padding: var(--pl-space-xl, 24px) var(--pl-space-lg, 16px);
  font-size: var(--pl-font-sm, 12px);
  color: var(--pl-color-error, #ef4444);
  text-align: center;
}
`;function l0(a,e){navigator.clipboard.writeText(a).then(()=>{k.success("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");const t=e.textContent??"";e.textContent="\u2713",e.classList.add("pl-preview-copy-btn--copied"),setTimeout(()=>{e.textContent=t,e.classList.remove("pl-preview-copy-btn--copied")},1500)}).catch(()=>{k.error("\u590D\u5236\u5931\u8D25")})}class Dt{constructor(e,t,n,r){this.paperTitle=t,this.pmid=e,this.fallbackAbstract=n,this.sendToBackground=r}paperTitle;static instance=null;overlay=null;drawer=null;shadow=null;isOpen=!1;escHandler=null;pmid;fallbackAbstract;sendToBackground;static async open(e,t,n,r){const i=tt.getCurrent();i&&i.close(),Dt.instance=new Dt(e,t,n,r),Dt.instance.doOpen()}static closeCurrent(){Dt.instance?.isOpen&&Dt.instance.close()}doOpen(){tt.register(this),this.drawer=document.createElement("div"),this.drawer.className="pl-preview-drawer",document.body.appendChild(this.drawer),this.shadow=this.drawer.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=s0,this.shadow.appendChild(e),this.renderHeader(),this.renderSkeleton(),this.escHandler=t=>{t.key==="Escape"&&this.close()},document.addEventListener("keydown",this.escHandler),this.isOpen=!0,this.loadDetail()}close(){if(!this.isOpen)return;tt.unregister(this),this.escHandler&&(document.removeEventListener("keydown",this.escHandler),this.escHandler=null),this.overlay&&this.overlay.classList.add("pl-preview-overlay--closing"),this.drawer&&this.drawer.classList.add("pl-preview-drawer--closing");const e=this.overlay,t=this.drawer;setTimeout(()=>{e?.remove(),t?.remove()},250),this.isOpen=!1,this.overlay=null,this.drawer=null,this.shadow=null,Dt.instance===this&&(Dt.instance=null)}renderHeader(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-preview-header";const t=document.createElement("div");t.style.flex="1";const n=document.createElement("button");n.className="pl-preview-close",n.type="button",n.setAttribute("aria-label","\u5173\u95ED"),n.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6.75 6.75l10.5 10.5M17.25 6.75l-10.5 10.5"/></svg>',n.addEventListener("click",()=>this.close()),e.append(t,n),this.shadow.appendChild(e)}renderSkeleton(){if(!this.shadow)return;const e=document.createElement("div");e.className="pl-preview-skeleton",e.setAttribute("data-role","loading"),e.innerHTML=`
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--title"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--subtitle"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--subtitle"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--id"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--id"></div>
      <div style="margin-top: 16px;"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--text"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--text"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--text"></div>
      <div class="pl-preview-skeleton-line pl-preview-skeleton-line--short"></div>
    `,this.shadow.appendChild(e)}async loadDetail(){if(this.shadow)try{const e=await this.sendToBackground("GET_PAPER_SUMMARY",{pmid:this.pmid});if(!this.isOpen)return;this.shadow.querySelector('[data-role="loading"]')?.remove(),e.success&&e.data?this.renderDetail(e.data):this.fallbackAbstract?this.renderFallbackDetail(e.error??"PubMed detail temporarily unavailable"):this.renderError(e.error??"Failed to load paper detail")}catch{if(!this.isOpen)return;this.shadow.querySelector('[data-role="loading"]')?.remove(),this.fallbackAbstract?this.renderFallbackDetail("Network error"):this.renderError("Network error")}}renderDetail(e){if(!this.shadow)return;const t=document.createElement("div");t.className="pl-preview-content";const n=document.createElement("h2");if(n.className="pl-preview-title",n.textContent=e.title||this.paperTitle,t.appendChild(n),e.authors?.length){const o=document.createElement("p");o.className="pl-preview-authors",o.textContent=e.authors.join(", "),t.appendChild(o)}const r=[];if(e.journal&&r.push(e.journal),e.year&&r.push(String(e.year)),e.volume&&r.push(`Vol ${e.volume}`),e.issue&&r.push(`Issue ${e.issue}`),e.pages&&r.push(e.pages),r.length>0){const o=document.createElement("p");o.className="pl-preview-journal",o.textContent=r.join("; "),t.appendChild(o)}const i=document.createElement("div");if(i.className="pl-preview-ids",e.doi&&i.appendChild(this.createIdRow("DOI",e.doi,`https://doi.org/${e.doi}`)),i.appendChild(this.createIdRow("PMID",e.pmid,`https://pubmed.ncbi.nlm.nih.gov/${e.pmid}/`)),e.pmcid&&i.appendChild(this.createIdRow("PMCID",e.pmcid)),t.appendChild(i),e.abstract||e.abstractSections?.length){const o=document.createElement("div");o.className="pl-preview-section";const s=document.createElement("div");s.className="pl-preview-section-title",s.textContent="Abstract",o.appendChild(s);const l=document.createElement("div");if(l.className="pl-preview-abstract",e.abstractSections?.length)for(const c of e.abstractSections){const u=document.createElement("div");u.className="pl-preview-abstract-label",u.textContent=c.label;const d=document.createElement("p");d.className="pl-preview-abstract-text",d.textContent=c.text,l.append(u,d)}else if(e.abstract){const c=document.createElement("p");c.className="pl-preview-abstract-text",c.textContent=e.abstract,l.appendChild(c)}o.appendChild(l),t.appendChild(o)}e.keywords?.length&&t.appendChild(this.createTagSection("Keywords",e.keywords)),e.meshTerms?.length&&t.appendChild(this.createTagSection("MeSH Terms",e.meshTerms)),this.shadow.appendChild(t),this.renderActions(e)}renderFallbackDetail(e){if(!this.shadow)return;const t=document.createElement("div");t.className="pl-preview-content";const n=document.createElement("h2");n.className="pl-preview-title",n.textContent=this.paperTitle,t.appendChild(n);const r=document.createElement("div");r.className="pl-preview-notice",r.textContent=`\u5B8C\u6574\u6458\u8981\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\uFF0C\u4EE5\u4E0B\u663E\u793A PubMed \u641C\u7D22\u7ED3\u679C\u4E2D\u7684\u6458\u8981\u7247\u6BB5\u3002${e}`,t.appendChild(r);const i=document.createElement("div");i.className="pl-preview-section";const o=document.createElement("div");o.className="pl-preview-section-title",o.textContent="Abstract Snippet",i.appendChild(o);const s=document.createElement("div");s.className="pl-preview-abstract";const l=document.createElement("p");l.className="pl-preview-abstract-text",l.textContent=this.fallbackAbstract??"",s.appendChild(l),i.appendChild(s),t.appendChild(i),this.shadow.appendChild(t)}createIdRow(e,t,n){const r=document.createElement("div");r.className="pl-preview-id-row";const i=document.createElement("span");i.className="pl-preview-id-label",i.textContent=`${e}:`;const o=document.createElement("span");if(o.className="pl-preview-id-value",n){const l=document.createElement("a");l.href=n,l.target="_blank",l.rel="noopener noreferrer",l.textContent=t,o.appendChild(l)}else o.textContent=t;const s=document.createElement("button");return s.className="pl-preview-copy-btn",s.type="button",s.textContent="\u{1F4CB}",s.title="Copy",s.addEventListener("click",()=>l0(t,s)),r.append(i,o,s),r}createTagSection(e,t){const n=document.createElement("div");n.className="pl-preview-section";const r=document.createElement("div");r.className="pl-preview-section-title",r.textContent=e,n.appendChild(r);const i=document.createElement("div");i.className="pl-preview-tags";for(const o of t){const s=document.createElement("span");s.className="pl-preview-tag",s.textContent=o,i.appendChild(s)}return n.appendChild(i),n}renderActions(e){if(!this.shadow)return;const t=document.createElement("div");t.className="pl-preview-actions";const n=document.createElement("button");n.className="pl-preview-action-btn",n.type="button",n.innerHTML="\u2B50 Save",n.addEventListener("click",()=>{this.sendToBackground("SAVE_PAPER",{pmid:e.pmid}).catch(o=>{console.warn("[PaperLens] Save paper failed:",o)}),n.innerHTML="\u2705 Saved",n.disabled=!0});const r=document.createElement("button");r.className="pl-preview-action-btn",r.type="button",r.innerHTML="\u{1F4E5} Export \u25BE",r.addEventListener("click",async()=>{const o=await Et("ris");if(!o.allowed){k.error(o.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528 RIS \u5BFC\u51FA");return}this.sendToBackground("EXPORT_PUBMED_RECORDS",{pmids:e.pmid,format:"ris"}).then(s=>{if(s.success&&typeof s.data=="string"){const l=new Blob([s.data],{type:"application/x-research-info-systems"}),c=URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=`${e.pmid}.ris`,u.click(),URL.revokeObjectURL(c)}}).catch(s=>{console.warn("[PaperLens] Export failed:",s)})});const i=document.createElement("a");i.className="pl-preview-action-btn pl-preview-action-btn--primary",i.href=`https://pubmed.ncbi.nlm.nih.gov/${e.pmid}/`,i.target="_blank",i.rel="noopener noreferrer",i.textContent="\u{1F517} PubMed",t.append(n,r,i),this.shadow.appendChild(t)}renderError(e){if(!this.shadow)return;const t=document.createElement("div");t.className="pl-preview-error",t.textContent=`\u26A0 ${e}`,this.shadow.appendChild(t)}}async function c0(a){await Dt.open(a.pmid,a.paperTitle,a.fallbackAbstract,a.sendToBackground)}const u0=qe+`
`+`/**
 * Abstract Button Styles \u2014 compact inline action for PubMed result rows.
 */

:host {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.pl-abstract-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  font-family: var(--pl-font-sans);
  font-size: 13px;
  font-weight: var(--pl-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition:
    border-color var(--pl-transition-fast),
    background-color var(--pl-transition-fast),
    box-shadow var(--pl-transition-fast),
    color var(--pl-transition-fast);
}

.pl-abstract-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.pl-abstract-icon {
  font-size: 12px;
  line-height: 1;
}
`,d0="paperlens-abstract-host";function p0(){const a=document.createElement("div");a.className=d0,a.dataset.pmid="";const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=u0,e.appendChild(t),{host:a,shadow:e}}function h0(a){const{host:e,shadow:t}=p0();e.dataset.pmid=a.pmid;const n=document.createElement("button");n.type="button",n.className="pl-abstract-btn",n.setAttribute("aria-label","\u67E5\u770B\u6458\u8981");const r=document.createElement("span");r.className="pl-abstract-icon",r.textContent="\u25A3";const i=document.createElement("span");return i.textContent="Abstract",n.append(r,i),t.appendChild(n),n.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),c0({pmid:a.pmid,paperTitle:a.paperTitle,fallbackAbstract:a.fallbackAbstract,sendToBackground:a.sendToBackground})}),e}class He{static instance;selectedPmids=new Map;listeners=new Set;constructor(){}static getInstance(){return He.instance||(He.instance=new He),He.instance}toggle(e,t){this.selectedPmids.has(e)?this.selectedPmids.delete(e):this.selectedPmids.set(e,t),this.notify()}selectAll(e){if(e.length!==0){for(const t of e)t.PMID&&this.selectedPmids.set(t.PMID,t);this.notify()}}deselectAll(){this.selectedPmids.size!==0&&(this.selectedPmids.clear(),this.notify())}isSelected(e){return this.selectedPmids.has(e)}getSelected(){return new Map(this.selectedPmids)}getCount(){return this.selectedPmids.size}getSelectedPmids(){return Array.from(this.selectedPmids.keys())}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const f0=qe+`
`+`/**
 * Checkbox Styles \u2014 injected into each checkbox's Shadow DOM
 *
 * \u81EA\u5B9A\u4E49\u590D\u9009\u6846\u6837\u5F0F\uFF1A
 * - 16x16px \u5706\u89D2\u65B9\u5F62
 * - \u672A\u9009\u4E2D\uFF1A\u7070\u8272\u8FB9\u6846\uFF0C\u767D\u8272\u80CC\u666F
 * - \u9009\u4E2D\uFF1A--pl-color-primary \u586B\u5145\uFF0C\u767D\u8272 \u2713
 * - hover \u5FAE\u53CD\u9988
 */

:host {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
}

/* \u2500\u2500 \u590D\u9009\u6846\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: all var(--pl-transition-fast);
  position: relative;
  outline: none;
}

.pl-checkbox:hover {
  border-color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
}

.pl-checkbox:focus-visible {
  box-shadow: 0 0 0 2px var(--pl-color-primary-light);
}

/* \u2500\u2500 \u9009\u4E2D\u72B6\u6001 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-checkbox[data-pl-checked="true"] {
  background-color: var(--pl-color-primary);
  border-color: var(--pl-color-primary);
}

.pl-checkbox[data-pl-checked="true"]:hover {
  background-color: var(--pl-color-primary-hover);
  border-color: var(--pl-color-primary-hover);
}

/* \u2500\u2500 \u2713 \u56FE\u6807 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-checkbox-icon {
  font-size: 11px;
  font-weight: var(--pl-weight-bold);
  line-height: 1;
  color: transparent;
  transition: color var(--pl-transition-fast);
  pointer-events: none;
}

.pl-checkbox[data-pl-checked="true"] .pl-checkbox-icon {
  color: var(--pl-color-white);
}
`,qu="paperlens-checkbox-host",zo="data-pl-checked";function m0(a,e){const t=document.createElement("div");t.className=qu,t.dataset.pmid=a;const n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=f0,n.appendChild(r);const i=document.createElement("button");i.type="button",i.className="pl-checkbox",i.setAttribute("role","checkbox"),i.setAttribute("aria-checked","false"),i.setAttribute("aria-label","\u9009\u62E9\u6B64\u8BBA\u6587"),i.setAttribute(zo,"false");const o=document.createElement("span");return o.className="pl-checkbox-icon",o.textContent="\u2713",i.appendChild(o),n.appendChild(i),i.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation();const l=He.getInstance();l.toggle(a,e);const c=l.isSelected(a);i.setAttribute("aria-checked",String(c)),i.setAttribute(zo,String(c))}),t}function Jo(a,e){const t=a.shadowRoot;if(!t)return;const n=t.querySelector(".pl-checkbox");n&&(n.setAttribute("aria-checked",String(e)),n.setAttribute(zo,String(e)))}function Vo(){return qu}const me=new Map,b0=300,g0=8e3;function $u(a){const e=String(a??"").trim().replace("\u533A","");if(e==="1"||e==="2"||e==="3"||e==="4")return Number(e)}function y0(a){const e=a.match(/[A-Za-z]/g)?.length??0,t=a.match(/[\u3400-\u9fff]/g)?.length??0;return e>=12&&e>t}function Ou(a){return a.extraDownloadUrl?.trim()||Vt}function x0(a,e){return e.showExtraDownload===!1||!Ou(e)?!1:!!a.DOI||y0(a.title)}async function Uu(){const a=await et("metrics.basic","\u57FA\u7840\u671F\u520A\u6307\u6807");return a.allowed||console.warn("[PaperLens] PubMed metrics disabled by entitlement:",a.error),a.allowed}const Hu="paperlens-action-row",Ft={abstract:10,citationCount:20,download:35,save:40,export:55,zotero:56,translate:60};function Oa(a,e){const t=a.article.querySelector(Ht);if(t){t.after(e);return}a.citation.before(e)}function A0(a){return a.querySelector(yi)??a.querySelector(ba)??a.querySelector(Qs)}function nr(a){const e=a.querySelector(`.${Hu}`);if(e instanceof HTMLElement)return e;const t=A0(a);if(!t)return null;const n=document.createElement("div");return n.className=Hu,n.style.display="flex",n.style.flexWrap="wrap",n.style.alignItems="center",n.style.gap="8px",n.style.marginTop="8px",n.style.maxWidth="100%",t.after(n),n}function kt(a,e,t){e.style.order=String(t),a.appendChild(e)}function C0(a,e,t){const n=document.createElement("button");return n.type="button",n.disabled=!0,n.className=t,n.textContent=a,n.title=e,n.style.display="inline-flex",n.style.alignItems="center",n.style.minHeight="28px",n.style.padding="0 11px",n.style.border="1px solid #e5e7eb",n.style.borderRadius="7px",n.style.background="#f8fafc",n.style.color="#94a3b8",n.style.font='650 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',n.style.whiteSpace="nowrap",n.style.cursor="not-allowed",n}function v0(a){a.querySelectorAll(".paperlens-citation-placeholder").forEach(e=>e.remove())}function zu(a,e){!a.querySelector(Ut)&&!a.querySelector(".paperlens-citation-placeholder")&&kt(e,C0("\u88AB\u5F15 \u2014","\u6682\u65E0\u88AB\u5F15\u6570\u636E","paperlens-citation-placeholder"),Ft.citationCount)}function Wo(a){return Array.from(a.entries()).map(([e,t])=>({pmid:e,doi:t.paper.DOI}))}function w0(a){const e=new Set(a.map(n=>n.pmid)),t=document.querySelectorAll(`${lt} ${_e}`);for(const n of t){if(!Da(n))continue;const i=n.querySelector(Ht)?.getAttribute(sn);if(!i||!e.has(i))continue;const o=nr(n);o&&zu(n,o)}}function Go(){const a=document.querySelectorAll(`${lt} ${_e}`);for(const e of a){if(e.dataset.plTitleIntercepted)continue;const t=e.querySelector(Ht);if(!t)continue;const n=t.getAttribute(sn);n&&(e.dataset.plTitleIntercepted="true",t.addEventListener("click",r=>{const i=r;if(i.button===0&&!i.shiftKey&&!i.ctrlKey&&!i.metaKey&&!i.altKey){i.preventDefault(),i.stopPropagation();const o=t.getAttribute("href")??`https://pubmed.ncbi.nlm.nih.gov/${n}/`;window.open(o,"_blank","noopener")}}))}}function S0(){const a=document.querySelectorAll(`${lt} ${_e}`);let e=0;for(const t of a)if(!Da(t))try{const n=ya(t);if(!n.PMID||!n.journal){zn(t);continue}const r=t.querySelector(ba);if(!r){zn(t);continue}me.set(n.PMID,{journal:n.journal,article:t,citation:r,shimmerHost:null,paper:n}),zn(t),e++}catch{}return console.log(`[PaperLens] Collected ${e} pending entries`),e}function T0(){for(const a of me.values())if(!a.shimmerHost){const e=pc(!0);Oa(a,e),a.shimmerHost=e}}function E0(){return me.size}async function _0(){if(me.size===0)return 0;if(!await Uu()){for(const i of me.values())i.shimmerHost?.remove();return Yo(me),Zo(me),Qo(me),(await pt().catch(()=>er)).showCitations&&Ko(Wo(me)),me.clear(),0}const e=[];for(const[r,i]of me)e.push({id:r,journal:i.journal});const t=await wa(e);let n=0;for(const[r,i]of me){const o=t.get(r);if(o){i.paper.impactFactor=o.journal.impactFactor,i.paper.jcrQuartile=o.journal.jcrQuartile,i.paper.journalOpenAccess=o.journal.openAccess===!0;const s=$u(o.journal.casQuartile);s&&(i.paper.casQuartile=s);const l=to(o.journal,{paper:i.paper});i.shimmerHost?i.shimmerHost.replaceWith(l):Oa(i,l),n++}else i.shimmerHost?.remove()}return me.size>0&&(Yo(me),Zo(me),Qo(me)),n>0&&Ko(Wo(me)),D0(),me.clear(),n>0&&Go(),console.log(`[PaperLens] Rendered ${n} metric bars`),n}function Ju(){return async(a,e)=>{try{const t=await $.runtime.sendMessage({type:a,payload:e});return t||{success:!1,error:"No response from background"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Message send failed"}}}}function Yo(a){const e=Ju();for(const[t,n]of a){if(n.article.querySelector(fh))continue;const r=nr(n.article);r&&kt(r,h0({pmid:t,paperTitle:n.paper.title,fallbackAbstract:n.paper.abstractSnippet,sendToBackground:e}),Ft.abstract)}}function Vu(a){Yo(a)}function Zo(a){const e=Array.from(a.entries());(async()=>{try{const t=e.map(([o])=>o);if(t.length===0)return;const n=await Promise.all(t.map(async o=>({pmid:o,saved:await Ra(o)}))),r=new Map(n.map(({pmid:o,saved:s})=>[o,s])),i=await pt().catch(()=>({...er}));for(const[o,s]of e){if(!s.article.querySelector(`.${Vo().split(" ").join(".")}`)){const c=m0(o,s.paper),u=s.article.querySelector("div.docsum-wrap");u?u.insertBefore(c,u.firstChild):s.article.insertBefore(c,s.article.firstChild),He.getInstance().isSelected(o)&&Jo(c,!0)}const l=nr(s.article);if(l&&!s.article.querySelector(Us)&&x0(s.paper,i)){const c=Bc(s.paper.DOI,Ou(i),!!(s.paper.isOpenAccess||s.paper.journalOpenAccess),s.paper.title,{pmid:o,openAccessPdfUrl:s.paper.openAccessPdf,journalOpenAccess:s.paper.journalOpenAccess});c&&kt(l,c,Ft.download)}if(!s.article.querySelector(Nn)){const c=s.paper,u={source:"PubMed",pmid:o,doi:c.DOI,title:c.title,journal:c.journal,impactFactor:c.impactFactor,jcrQuartile:c.jcrQuartile,casQuartile:c.casQuartile?String(c.casQuartile):void 0,year:c.year,citationCount:c.citationCount,url:`https://pubmed.ncbi.nlm.nih.gov/${encodeURIComponent(o)}/`,authors:c.authors,abstract:c.abstractSnippet,publicationTypes:c.articleType?[c.articleType]:void 0,oaUrl:c.openAccessPdf,sourceUrl:`https://pubmed.ncbi.nlm.nih.gov/${encodeURIComponent(o)}/`},d=r.get(o)??!1,p=bo(u,d);l?kt(l,p,Ft.save):s.citation.after(p)}if(!s.article.querySelector(Rn)){const c=px(o);l?kt(l,c,Ft.export):s.citation.after(c)}if(!s.article.querySelector(mi)){const c=s.paper,u={paper:{pmid:o,title:c.title,authors:c.authors,doi:c.DOI,journal:c.journal,year:c.year,publicationDate:c.publicationDate,abstract:c.abstractSnippet}},d=iu(u);l?kt(l,d,Ft.zotero):s.citation.after(d)}}console.log(`[PaperLens] Save buttons injected for ${t.length} papers`)}catch(t){console.warn("[PaperLens] Failed to inject save buttons:",t)}})()}function Wu(a){Zo(a)}function Qo(a){for(const[e,t]of a){if(t.article.querySelector(Pn))continue;const n=nr(t.article);if(!n)continue;const r=Do(e,t.paper.title,t.paper.abstractSnippet||"",{journal:t.paper.journal,authors:t.paper.authors,doi:t.paper.DOI,publicationDate:t.paper.publicationDate,articleType:t.paper.articleType});kt(n,r,Ft.translate)}}function D0(){const a=document.querySelectorAll("article.full-docsum");for(const e of a){if(e.querySelector(Pn))continue;const t=ya(e),n=t.PMID;if(!n)continue;const r=nr(e);if(!r)continue;const i=t.title,o=t.abstractSnippet||"";if(!i)continue;const s=Do(n,i,o,{journal:t.journal,authors:t.authors,doi:t.DOI,publicationDate:t.publicationDate,articleType:t.articleType});kt(r,s,Ft.translate)}}function Gu(a){Qo(a)}function Ko(a){(async()=>{try{w0(a);const e=await F0(a,g0)??{},t=new Map(a.map(i=>[i.pmid,i.doi])),n=new Set(a.map(i=>i.pmid)),r=document.querySelectorAll(`${lt} ${_e}`);for(const i of r){if(!Da(i))continue;const s=i.querySelector(Ht)?.getAttribute(sn);if(!s||!n.has(s))continue;const l=nr(i);if(!l)continue;const c=t.get(s),u=e[s]??(c?e[c]:void 0);if(!ju(u)){zu(i,l);continue}v0(i);const d=Ju();if(!i.querySelector(Ut)){const p=Bu(u,{paperId:u.paperId,pmid:u.externalIds?.PubMed,paperTitle:u.title??void 0,sendToBackground:d});kt(l,p,Ft.citationCount)}}console.log(`[PaperLens] Citation badges rendered for ${Object.keys(e).length} papers`),document.dispatchEvent(new CustomEvent("paperlens:data-updated"))}catch(e){console.warn("[PaperLens] S2 citation query failed (graceful degradation):",e)}})()}async function F0(a,e){const t=Array.from(new Set(a.map(l=>l.pmid).filter(Boolean))),n=Array.from(new Set(a.map(l=>l.doi).filter(l=>!!l))),r={type:"GET_BATCH_PAPER_DATA",payload:{pmids:t,...n.length?{dois:n}:{}}},i=$.runtime.sendMessage(r),o=new Promise(l=>setTimeout(()=>l(null),e)),s=await Promise.race([i,o]);return!s||!s.success||!s.data?null:s.data}function Yu(a){Ko(a)}function k0(){for(const a of me.values())a.shimmerHost?.remove(),hc(a.article);me.clear(),console.warn("[PaperLens] Cleaned up all pending entries after error")}async function Zu(a){const e=new Map;for(const r of a)if(!Da(r))try{const i=ya(r);if(!i.PMID||!i.journal){zn(r);continue}const o=r.querySelector(ba);if(!o){zn(r);continue}e.set(i.PMID,{journal:i.journal,article:r,citation:o,shimmerHost:null,paper:i}),zn(r)}catch{}if(e.size===0)return 0;if(!await Uu())return Vu(e),Wu(e),Gu(e),(await pt().catch(()=>er)).showCitations&&Yu(Wo(e)),Go(),0;const t=setTimeout(()=>{for(const r of e.values())if(!r.shimmerHost){const i=pc(!0);Oa(r,i),r.shimmerHost=i}},b0),n=[];for(const[r,i]of e)n.push({id:r,journal:i.journal});try{const r=await wa(n);let i=0;for(const[o,s]of e){const l=r.get(o);if(l){s.paper.impactFactor=l.journal.impactFactor,s.paper.jcrQuartile=l.journal.jcrQuartile,s.paper.journalOpenAccess=l.journal.openAccess===!0;const c=$u(l.journal.casQuartile);c&&(s.paper.casQuartile=c);const u=to(l.journal,{paper:s.paper});s.shimmerHost?s.shimmerHost.replaceWith(u):Oa(s,u),i++}else s.shimmerHost?.remove()}if(i>0){console.log(`[PaperLens] Enhanced ${i} new articles`),Vu(e),Wu(e),Gu(e);const o=[];for(const s of e.keys())if(r.has(s)){const l=e.get(s);o.push({pmid:s,doi:l?.paper.DOI})}o.length>0&&Yu(o),Go()}return i}catch(r){for(const i of e.values())i.shimmerHost?.remove(),hc(i.article);throw console.warn("[PaperLens] Failed to enhance new articles, cleaned up:",r),r}finally{clearTimeout(t)}}const L0={sortField:"default",oaOnly:!1,jcrQuartiles:[],casQuartiles:[],ifMin:void 0,ifMax:void 0,journalQuery:void 0};function N0(){return{...L0}}let rr=null;function R0(a){rr||(rr=a.map(e=>({element:e,position:{parent:e.parentElement,nextSibling:e.nextElementSibling}})))}function P0(a){const e=a.querySelector(Ot);if(!e)return;const t=e.dataset.plIf;if(t!==void 0){const i=parseFloat(t);if(!isNaN(i))return i}if(!e.shadowRoot)return;const n=e.shadowRoot.querySelector(".pl-metric-if");if(!n?.textContent)return;const r=n.textContent.match(/IF:\s*([\d.]+)/);return r?parseFloat(r[1]):void 0}function I0(a){const e=a.querySelector(Ot);if(e?.shadowRoot)for(const t of["q1","q2","q3","q4"]){const n=e.shadowRoot.querySelector(`.pl-metric-${t}`);if(n?.textContent)return n.textContent.trim().toUpperCase()}}function M0(a){const e=a.querySelector(Ot);if(e?.shadowRoot)for(const t of["1","2","3","4"]){const n=e.shadowRoot.querySelector(`.pl-metric-cas-${t}`);if(n?.textContent)return n.textContent.trim().replace("\u533A","")}}function B0(a){const e=a.querySelector(Ut),t=e?.dataset.plCitations;if(t!==void 0){const i=parseInt(t.replace(/,/g,""),10);if(!isNaN(i))return i}if(!e?.shadowRoot)return;const n=e.shadowRoot.querySelector(".pl-citation-count");if(!n?.textContent)return;const r=n.textContent.match(/([\d,]+)/);return r?parseInt(r[1].replace(/,/g,""),10):void 0}function j0(a){const e=a.querySelector(Ut);return e?.shadowRoot?e.shadowRoot.querySelector(".pl-oa-badge")!==null:!1}function q0(a){const t=a.querySelector(xh)?.dataset.plArticleType?.trim();if(t)return t;const n=a.querySelector(ma)?.textContent?.trim();return ga(n??null)??void 0}function $0(a){return a.querySelector(Ht)?.getAttribute(sn)??""}function O0(a){const e=a.querySelector(Tr);if(!e?.textContent)return;const t=e.textContent.match(/\b(\d{4})\b/);if(t?.[1]){const n=parseInt(t[1],10);if(n>=1800&&n<=2100)return n}}function U0(){const a=document.querySelectorAll(`${lt} ${_e}`),e=[];for(const t of a){const n=$0(t);if(!n)continue;let r;const i=t.querySelector("span.docsum-journal-citation.full-journal-citation");i?.textContent&&(r=i.textContent.split(".")[0]?.trim()||void 0),e.push({element:t,pmid:n,year:O0(t),impactFactor:P0(t),citationCount:B0(t),isOpenAccess:j0(t),jcrQuartile:I0(t),casQuartile:M0(t),journal:r,articleType:q0(t)})}return e}function H0(a,e,t){const n=[...a],r=t==="desc"?-1:1;return n.sort((i,o)=>{let s,l;switch(e){case"impactFactor":s=i.impactFactor,l=o.impactFactor;break;case"citationCount":s=i.citationCount,l=o.citationCount;break;case"year":s=i.year,l=o.year;break;default:return 0}return s===void 0&&l===void 0?0:s===void 0?1:l===void 0?-1:(s-l)*r}),n}function z0(a,e){return e?a.filter(t=>t.isOpenAccess===!0):a}function J0(a,e){return e.length===0?a:a.filter(t=>t.jcrQuartile!==void 0&&e.includes(t.jcrQuartile))}function V0(a,e){return e.length===0?a:a.filter(t=>t.casQuartile!==void 0&&e.includes(t.casQuartile))}function W0(a,e,t){return e===void 0&&t===void 0?a:a.filter(n=>!(n.year===void 0||e!==void 0&&n.year<e||t!==void 0&&n.year>t))}function Qu(a){return a.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]/g,"")}const G0=new Set(["a","an","and","de","for","in","of","the"]);function Ku(a){return a.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function Y0(a,e){return a===e?!0:a.length<3||e.length<3?!1:e.startsWith(a)||a.startsWith(e)}function Xu(a,e){if(!e||!e.trim())return!0;if(!a)return!1;const t=e.trim(),n=t.toLowerCase(),r=Qu(t),i=a.toLowerCase(),o=Qu(a);if(!r||i.includes(n)||o.includes(r))return!0;const s=Ku(n),l=Ku(i);if(s.length===0||l.length===0)return!1;const c=l.map(p=>p[0]).join("");if(r.length>=2&&c.startsWith(r))return!0;const u=s.filter(p=>!G0.has(p));return(u.length>0?u:s).every(p=>l.some(m=>Y0(p,m)))}function Z0(a,e){return!e||!e.trim()?a:a.filter(t=>Xu(t.journal,e))}function Q0(a,e,t){return e===void 0&&t===void 0?a:a.filter(n=>!(n.impactFactor===void 0||e!==void 0&&n.impactFactor<e||t!==void 0&&n.impactFactor>t))}function K0(a){const e=document.querySelector(fa);if(!e)return{total:0,visible:0};const t=e.querySelector(lt)??e,n=Array.from(document.querySelectorAll(`${lt} ${_e}`));if(n.length===0)return{total:0,visible:0};R0(n);let r=U0();const i=r.length;if(r=z0(r,a.oaOnly),r=J0(r,a.jcrQuartiles),r=V0(r,a.casQuartiles),r=W0(r,a.yearMin,a.yearMax),r=Q0(r,a.ifMin,a.ifMax),r=Z0(r,a.journalQuery),a.sortField!=="default"){const c=a.sortField==="year-asc"?"asc":"desc",u=a.sortField==="year-asc"||a.sortField==="year-desc"?"year":a.sortField;r=H0(r,u,c)}const o=r.length,s=new Set(r.map(c=>c.element)),l=r.map(c=>c.element);for(const c of l)t.appendChild(c);for(const c of n)s.has(c)?c.style.display="":c.style.display="none";return{total:i,visible:o}}function ed(){if(rr){for(let a=rr.length-1;a>=0;a--){const{element:e,position:t}=rr[a],{parent:n,nextSibling:r}=t;e.style.display="",r&&r.parentElement?n.insertBefore(e,r):n.appendChild(e)}rr=null}}function td(a){return a.sortField==="default"&&!a.oaOnly&&a.jcrQuartiles.length===0&&a.casQuartiles.length===0&&a.yearMin===void 0&&a.yearMax===void 0&&a.ifMin===void 0&&a.ifMax===void 0&&a.journalQuery===void 0}const we="paperlens-global-results-root",nd="paperlens-global-results-style",X0=200,rd=2e3,ad=80,eC=6e4,tC="pubmed.full_result_analysis",id="PubMed \u5168\u91CF\u7ED3\u679C\u5206\u6790";let ge=null,Xo=0,Ua=null;function nC(){return ge!==null}function rC(a){const e=a.publicationTypes?.length?a.publicationTypes:a.articleType?[a.articleType]:void 0;return{pmid:a.pmid,year:a.year,jcrQuartile:a.jcrQuartile,casQuartile:a.casQuartile,articleTypes:e}}function aC(){return ge?Ha(ge):null}function Ha(a){const e=Yt(a);return{scope:"global",sourceTotal:a.sourceTotal,analyzed:ar(a),visible:e.length,done:a.done,loading:a.loading,records:e.map(rC)}}async function iC(a,e={}){const t=fd();if(!t)return{scope:"global",sourceTotal:0,analyzed:0,visible:0,done:!0,loading:!1,records:[]};const n={requestId:0,term:t,pubmedSort:md(),state:a,sourceTotal:0,nextStart:0,records:[],loading:!0,done:!1},r=()=>{e.onUpdate?.(Ha(n))},i=()=>{if(e.signal?.aborted)throw new DOMException("Analysis aborted","AbortError")};r();try{for(;!n.done;){i();const o=await ld(n);i(),n.sourceTotal=o.count,n.nextStart=o.retstart+o.pmids.length,n.done=o.pmids.length===0||n.nextStart>=o.count;const s=await cd(o.papers,n.state);i(),n.records.push(...s),n.loading=!n.done,r(),n.done||await hd(ad)}}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return n.loading=!1,r(),Ha(n);throw o}return n.loading=!1,r(),Ha(n)}function es(){Xo++,ts(),ge=null,document.getElementById(we)?.remove(),ns(!1)}function oC(){Xo++,ts();const a=ge!==null;ge=null,document.getElementById(we)?.remove(),ns(!1),a&&console.log("[PaperLens] Global filter cancelled by user")}async function sC(a){const e=fd(),t=++Xo;return e?(ge={requestId:t,term:e,pubmedSort:md(),state:a,sourceTotal:0,nextStart:0,records:[],loading:!1,done:!1},AC(),ns(!0),Ja(ge,[]),lC(t),await od(t)):(es(),{sourceTotal:0,analyzed:0,visible:0,done:!0,loading:!1})}async function od(a,e){if(!await za(a))return dn();const t=ge?ar(ge):0;let n=await sd(a);for(;xC(a,n,t);){if(await hd(ad),!await za(a))return dn();n=await sd(a)}return n}async function sd(a=ge?.requestId??0){const e=ge;if(!e||e.requestId!==a||!await za(a))return dn();if(e.loading)return Qr(e,Yt(e).length);if(e.done){const t=Yt(e);return Ja(e,t),Qr(e,t.length)}e.loading=!0,rs(e,Yt(e).length),Ja(e,Yt(e));try{const t=await ld(e);if(ge?.requestId!==a)return dn();e.sourceTotal=t.count,e.nextStart=t.retstart+t.pmids.length,e.done=t.pmids.length===0||e.nextStart>=t.count;const n=await cd(t.papers,e.state);if(ge?.requestId!==a)return dn();e.records.push(...n);const r=Yt(e);e.loading=!1,Ja(e,r),rs(e,r.length);const i=gC();return i.length>0&&Zu(i),Qr(e,r.length)}catch(t){return ge?.requestId!==a?dn():(e.loading=!1,e.done=!0,dC(t),rs(e,Yt(e).length),Qr(e,Yt(e).length))}}function lC(a){ts(),Ua=window.setInterval(()=>{za(a)},eC)}function ts(){Ua!==null&&(window.clearInterval(Ua),Ua=null)}async function za(a=ge?.requestId??0){const e=ge;if(!e||e.requestId!==a)return!1;try{const t=await $.runtime.sendMessage({type:"CHECK_ENTITLEMENT",payload:{featureKey:tC,featureLabel:id}});if(t?.success===!0&&t.data?.allowed===!0)return!0}catch{}if(ge?.requestId===a){es();const t=`${id}\u5F53\u524D\u4E0D\u53EF\u7528\uFF0C\u8BF7\u5237\u65B0\u8D26\u6237\u6743\u9650\u540E\u91CD\u8BD5`;document.dispatchEvent(new CustomEvent("paperlens:global-filter-denied",{detail:{message:t}}))}return!1}async function ld(a){const e={term:a.term,retstart:a.nextStart,retmax:X0,sort:a.pubmedSort},t=await $.runtime.sendMessage({type:"SEARCH_PUBMED_RESULTS",payload:e});if(!t?.success||!t.data)throw new Error(t?.error??"PubMed global search failed");return t.data}async function cd(a,e){const t=await wa(a.map(r=>({id:r.pmid,journal:r.journal}))),n=e.sortField==="citationCount"?await cC(a):new Map;return a.map(r=>{const i=t.get(r.pmid),o=n.get(r.pmid),s=!!r.pmcid||!!o?.isOpenAccess;return{...r,impactFactor:i?.journal.impactFactor,citationCount:o?.citationCount,isOpenAccess:s,jcrQuartile:i?.journal.jcrQuartile,casQuartile:i?gg(i.journal.casQuartile):void 0,journalMatch:i}})}async function cC(a){const e=a.map(n=>n.pmid).filter(Boolean),t=a.map(n=>n.doi).filter(n=>!!n);if(e.length===0&&t.length===0)return new Map;try{const n=await $.runtime.sendMessage({type:"GET_BATCH_PAPER_DATA",payload:{pmids:e,dois:t}});if(!n?.success||!n.data)return new Map;const r=new Map;for(const i of a){const o=n.data[i.pmid],s=i.doi?n.data[i.doi]:void 0,l=o??s;l&&r.set(i.pmid,{citationCount:l.citationCount,isOpenAccess:l.isOpenAccess})}return r}catch{return new Map}}function Yt(a){let e=[...a.records];const{state:t}=a;return t.oaOnly&&(e=e.filter(n=>n.isOpenAccess===!0)),t.jcrQuartiles.length>0&&(e=e.filter(n=>n.jcrQuartile!==void 0&&t.jcrQuartiles.includes(n.jcrQuartile))),t.casQuartiles.length>0&&(e=e.filter(n=>n.casQuartile!==void 0&&t.casQuartiles.includes(n.casQuartile))),(t.yearMin!==void 0||t.yearMax!==void 0)&&(e=e.filter(n=>!(n.year===void 0||t.yearMin!==void 0&&n.year<t.yearMin||t.yearMax!==void 0&&n.year>t.yearMax))),(t.ifMin!==void 0||t.ifMax!==void 0)&&(e=e.filter(n=>!(n.impactFactor===void 0||t.ifMin!==void 0&&n.impactFactor<t.ifMin||t.ifMax!==void 0&&n.impactFactor>t.ifMax))),t.journalQuery!==void 0&&(e=e.filter(n=>Xu(n.journal,t.journalQuery))),uC(e,t)}function uC(a,e){if(e.sortField==="default")return a;const t=e.sortField==="year-asc"?"asc":"desc",n=e.sortField==="year-asc"||e.sortField==="year-desc"?"year":e.sortField,r=t==="desc"?-1:1;return[...a].sort((i,o)=>{const s=ud(i,n),l=ud(o,n);return s===void 0&&l===void 0?0:s===void 0?1:l===void 0?-1:(s-l)*r})}function ud(a,e){if(e==="impactFactor")return a.impactFactor;if(e==="citationCount")return a.citationCount;if(e==="year")return a.year}function Ja(a,e){const t=dd();if(!t)return;t.innerHTML="";const n=document.createElement("div");n.className="paperlens-global-status";const r=document.createElement("div");r.className="paperlens-global-status-text",r.textContent=yC(a,e.length);const i=document.createElement("div");i.className="paperlens-global-status-actions";const o=document.createElement("button");o.type="button",o.className="paperlens-global-load-more",o.textContent=a.done?"\u5DF2\u5B8C\u6210":a.loading?"\u5206\u6790\u4E2D...":"\u7EE7\u7EED\u5206\u6790\u66F4\u591A",o.disabled=a.done||a.loading,o.addEventListener("click",()=>{od(a.requestId)}),i.appendChild(o),n.append(r,i),t.appendChild(n);const s=document.createElement("div");s.className="search-results-chunks paperlens-global-chunks";const l=document.createElement("div");l.className="search-results-chunk results-chunk paperlens-global-chunk",l.dataset.pageNumber="1",l.dataset.resultsAmount=String(a.sourceTotal),l.dataset.chunkIds=e.map(c=>c.pmid).join(","),e.length===0?l.appendChild(pC(a)):e.forEach((c,u)=>{l.appendChild(hC(c,u+1))}),s.appendChild(l),t.appendChild(s)}function dC(a){const e=dd();if(!e)return;e.innerHTML="";const t=document.createElement("div");t.className="paperlens-global-status paperlens-global-status--error",t.textContent=a instanceof Error?`\u5168\u91CF\u7B5B\u9009\u5931\u8D25\uFF1A${a.message}`:"\u5168\u91CF\u7B5B\u9009\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",e.appendChild(t)}function pC(a){const e=document.createElement("div");return e.className="paperlens-global-empty",a.loading?e.innerHTML=`
      <div class="pl-empty-icon">\u{1F50D}</div>
      <div class="pl-empty-title">\u6B63\u5728\u5206\u6790 PubMed \u5168\u91CF\u7ED3\u679C...</div>
      <div class="pl-empty-desc">\u9996\u6B21\u5206\u6790\u53EF\u80FD\u9700\u8981\u51E0\u79D2\uFF0C\u8BF7\u7A0D\u5019</div>
    `:a.done?e.innerHTML=`
      <div class="pl-empty-icon">\u{1F4ED}</div>
      <div class="pl-empty-title">\u6CA1\u6709\u627E\u5230\u7B26\u5408\u6761\u4EF6\u7684\u6587\u732E</div>
      <div class="pl-empty-desc">\u5DF2\u5206\u6790\u5168\u90E8 ${a.sourceTotal.toLocaleString()} \u6761\u7ED3\u679C\uFF0C\u5747\u4E0D\u7B26\u5408\u5F53\u524D\u7B5B\u9009\u6761\u4EF6\u3002\u5EFA\u8BAE\u653E\u5BBD\u7B5B\u9009\u6761\u4EF6\u540E\u91CD\u8BD5\u3002</div>
    `:e.innerHTML=`
      <div class="pl-empty-icon">\u{1F50D}</div>
      <div class="pl-empty-title">\u5F53\u524D\u6279\u6B21\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u6587\u732E</div>
      <div class="pl-empty-desc">\u5DF2\u5206\u6790\u524D ${ar(a).toLocaleString()} \u6761\u3002\u6BCF\u8F6E\u6700\u591A\u81EA\u52A8\u5206\u6790 ${rd.toLocaleString()} \u6761\uFF0C\u53EF\u4EE5\u70B9\u51FB\u4E0A\u65B9\u300C\u7EE7\u7EED\u5206\u6790\u66F4\u591A\u300D\u52A0\u8F7D\u4E0B\u4E00\u8F6E\u3002</div>
    `,e}function hC(a,e){const t=document.createElement("article");t.className="full-docsum paperlens-global-docsum",t.dataset.relPos=String(e);const n=document.createElement("div");n.className=`item-selector-wrap selectors-and-actions${e===1?" first-selector":""}`;const r=document.createElement("label");r.className="search-result-position";const i=document.createElement("span");i.className="position-number",i.textContent=String(e),r.appendChild(i),n.appendChild(r);const o=document.createElement("div");o.className="docsum-wrap";const s=document.createElement("div");s.className="docsum-content";const l=document.createElement("a");l.className="docsum-title",l.href=`/${a.pmid}/`,l.dataset.articleId=a.pmid,l.textContent=a.title||`PMID ${a.pmid}`;const c=document.createElement("div");c.className="docsum-citation full-citation";const u=document.createElement("span");u.className="docsum-authors full-authors",u.textContent=mC(a.authors);const d=document.createElement("span");d.className="docsum-authors short-authors",d.textContent=bC(a.authors);const p=document.createElement("span");p.className="docsum-journal-citation full-journal-citation",p.textContent=fC(a);const m=document.createElement("span");m.className="docsum-journal-citation short-journal-citation",m.textContent=`${a.journal||"PubMed"}${a.year?`. ${a.year}.`:"."}`;const h=document.createElement("span");h.className="citation-part",h.append("PMID: ");const y=document.createElement("span");if(y.className="docsum-pmid",y.textContent=a.pmid,h.appendChild(y),c.append(u,d,p,m,h),a.pmcid){const x=document.createElement("span");x.className="free-resources spaced-citation-item citation-part",x.textContent="Free PMC article.",c.appendChild(x)}if(a.articleType){const x=document.createElement("span");x.className="publication-type spaced-citation-item citation-part",x.textContent=`${a.articleType}.`,c.appendChild(x)}if(s.append(l,c),a.abstractSnippet){const x=document.createElement("div");x.className="docsum-snippet",x.textContent=a.abstractSnippet,s.appendChild(x)}return o.appendChild(s),t.append(n,o),t}function fC(a){const e=[`${a.journal||"PubMed"}.`];return a.year&&e.push(`${a.year}.`),a.doi&&e.push(`doi: ${a.doi}.`),e.join(" ")}function mC(a){return a.length===0?"":`${a.join(", ")}.`}function bC(a){return a.length===0?"":a.length===1?`${a[0]}.`:`${a[0]}, et al.`}function dd(){const a=document.getElementById(we);if(a instanceof HTMLElement)return a;const e=document.querySelector(Zs),n=pd()??e?.firstElementChild??e;if(!e||!n)return null;const r=document.createElement("div");return r.id=we,r.className="paperlens-global-results",n.before(r),r}function gC(){const a=document.getElementById(we);return a?Array.from(a.querySelectorAll(_e)):[]}function ns(a){const e=pd();e instanceof HTMLElement&&(e.style.display=a?"none":"")}function pd(){return Array.from(document.querySelectorAll(fa)).find(a=>!a.closest(`#${we}`))??null}function yC(a,e){const t=a.sourceTotal>0?a.sourceTotal:0,r=`\u5DF2\u5206\u6790 ${ar(a).toLocaleString()} / ${t.toLocaleString()}\uFF0C\u663E\u793A ${e.toLocaleString()}`;return a.loading?t>0?`\u5168\u91CF\u7B5B\u9009\u4E2D\uFF1A${r}`:"\u6B63\u5728\u8BFB\u53D6 PubMed \u5168\u91CF\u7ED3\u679C...":a.done?`\u5168\u91CF\u7B5B\u9009\u5B8C\u6210\uFF1A${r}`:`\u5168\u91CF\u7B5B\u9009\uFF1A${r}\uFF0C\u672C\u8F6E\u5DF2\u6682\u505C\uFF0C\u53EF\u7EE7\u7EED\u5206\u6790\u66F4\u591A`}function rs(a,e){document.dispatchEvent(new CustomEvent("paperlens:global-filter-updated",{detail:Qr(a,e)}))}function Qr(a,e){return{sourceTotal:a.sourceTotal,analyzed:ar(a),visible:e,done:a.done,loading:a.loading}}function ar(a){return a.sourceTotal<=0?a.records.length:Math.min(Math.max(a.records.length,a.nextStart),a.sourceTotal)}function xC(a,e,t){const n=ge;return!n||n.requestId!==a||n.loading||n.done||e.done?!1:ar(n)-t<rd}function hd(a){return new Promise(e=>window.setTimeout(e,a))}function dn(){return{sourceTotal:0,analyzed:0,visible:0,done:!0,loading:!1}}function fd(){try{return new URL(window.location.href).searchParams.get("term")?.trim()??""}catch{return""}}function md(){try{return new URL(window.location.href).searchParams.get("sort")?.trim()||void 0}catch{return}}function AC(){if(document.getElementById(nd))return;const a=document.createElement("style");a.id=nd,a.textContent=`
    #${we}.paperlens-global-results {
      width: 100%;
      margin: 0 0 10px;
    }

    #${we} .paperlens-global-status {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin: 8px 0 10px;
      padding: 8px 10px;
      border: 1px solid #d8dee8;
      border-radius: 4px;
      background: #f8fafc;
      color: #4b5563;
      font-size: 14px;
      line-height: 1.4;
    }

    #${we} .paperlens-global-status--error {
      border-color: #fecaca;
      background: #fef2f2;
      color: #991b1b;
    }

    #${we} .paperlens-global-status-actions {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }

    #${we} .paperlens-global-load-more {
      min-height: 28px;
      padding: 4px 10px;
      border: 1px solid #b8c7dc;
      border-radius: 4px;
      background: #ffffff;
      color: #1f2937;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
    }

    #${we} .paperlens-global-load-more:disabled {
      cursor: default;
      opacity: 0.6;
    }

    #${we} .paperlens-global-empty {
      padding: 40px 20px;
      text-align: center;
      color: #6b7280;
    }

    #${we} .pl-empty-icon {
      font-size: 36px;
      margin-bottom: 12px;
      line-height: 1;
    }

    #${we} .pl-empty-title {
      font-size: 15px;
      font-weight: 600;
      color: #374151;
      margin-bottom: 6px;
    }

    #${we} .pl-empty-desc {
      font-size: 13px;
      color: #9ca3af;
      line-height: 1.5;
      max-width: 400px;
      margin: 0 auto;
    }

    #${we} .paperlens-global-docsum {
      border-bottom: 1px solid #e5e7eb;
    }
  `,document.head.appendChild(a)}const bd=new Set(["chen","wang","zhang","li","liu","huang","zhao","wu","xu","sun","ma","zhu","hu","guo","he","lin","gao","luo","zheng","liang","song","xie","tang","han","feng","deng","cao","peng","zeng"]),CC=new Set(["of","for","in","with","without","and","or","study","review","trial","analysis","cancer","medicine","genome","screening","therapy","detection","biomarker","risk","surgical","clinical","patient","treatment","diagnosis","prognosis","survival","meta-analysis","systematic","management","control","disease","effect","effects","result","results","new","england","journal","open","network","research","cell","nature","science","blood","bone","liver","heart","lung","brain","immune","public","international"]),vC=/[0-9\/:=\[\]{}<>@#$%^&*\\]/,wC=/^[A-Za-z\s,\-\'.]+$/,SC=new Set(["new","england","journal","open","network","research","cell","nature","science","blood","bone","liver","heart","lung","brain","immune","public","international","scientific","reports","medical","clinical","surgical","international","national","global","world","university","college","school","institute","center","hospital","control","disease","effect","effects","result","results","outcome","outcomes"]),TC=/\b(jr|sr|ii|iii|iv)\b/i;function Va(a){return a.trim().replace(/\s+,/g,",").replace(/,\s*$/g,"").replace(/\s+/g," ")}function Wa(a,e){const t=a.trim();if(!t)return null;const n=t.split(/\s+/);if(n.length<2||n.length>4||!wC.test(t)||vC.test(t)||n.length===2&&n.every(h=>h.replace(/[.,]/g,"").length===1&&/^[A-Za-z]$/.test(h.replace(/[.,]/g,"")))||n.map(h=>h.toLowerCase().replace(/[,'.]/g,"")).every(h=>SC.has(h)))return null;const s=n.map(h=>h.toLowerCase().replace(/[,'.]/g,""));for(const h of s)if(CC.has(h))return null;let l=0,c=null;const u=t.match(/^([A-Z][A-Za-z'\-.]+)\s+([A-Z]{1,4}|[A-Z](?:\.[A-Z]){0,3}\.?)$/);u&&(l+=.95,c="surname-initial");const d=t.match(/^([A-Za-z][A-Za-z'\-.]*(?:\s+(?:[A-Za-z][A-Za-z'\-.]*|jr|sr|ii|iii|iv))?),\s+([A-Za-z][A-Za-z'\-.]*(?:\s+[A-Za-z])?)$/i);if(!u&&d&&(l+=.92,c="inverted"),!c){const h=n.length;if(h===2||h===3)if(n.every(x=>/^[A-Za-z]/.test(x.replace(/[,'.]/g,""))))l+=.73,c="natural";else return null;else return null}const p=s[0],m=s[s.length-1];return(bd.has(p)||bd.has(m))&&(l+=n.length===2?.18:.08),e.hasJournalSibling&&(l+=.1),e.hitsConceptRule&&(l-=.2),l>=.9?{confidence:l,terms:gd(t,c),note:`"${t}" \u2192 detected as author name`}:l>=.8&&e.hasJournalSibling?{confidence:l,terms:gd(t,c),note:`"${t}" \u2192 detected as author name (medium confidence, supported by journal context)`}:null}function gd(a,e){const t=[],n=a.trim();switch(e){case"surname-initial":{t.push(n),n.endsWith(".")?t.push(n.slice(0,-1)):t.push(`${n}.`);break}case"inverted":{t.push(n);const r=n.split(/,\s*/);if(r.length===2){const i=Va(r[0]),o=Va(r[1]);if(t.push(`${i} ${o}`),o.length>=1){const s=o[0].toUpperCase();t.push(`${i} ${s}`),t.push(`${i} ${s}.`)}}break}case"natural":{t.push(n);const r=n.split(/\s+/);if(r.length===2){const[i,o]=r;t.push(`${o} ${i}`);const s=i[0].toUpperCase();t.push(`${o} ${s}`),t.push(`${o} ${s}.`)}else if(r.length===3)if(TC.test(r[1])){const i=Va(r[2]),o=Va(`${r[0]} ${r[1]}`);t.push(`${o}, ${i}`),t.push(`${o} ${i}`),t.push(`${o} ${i[0].toUpperCase()}`),t.push(`${o} ${i[0].toUpperCase()}.`)}else{const i=r.slice(0,2).join(" "),o=r[2];t.push(`${o} ${i}`),t.push(`${o} ${i[0].toUpperCase()}`),t.push(`${o} ${i[0].toUpperCase()}.`)}break}default:t.push(n)}return EC(t)}function EC(a){return Array.from(new Set(a.filter(Boolean)))}const yd=new Map(Object.entries({nature:{canonical:"Nature",aliases:["Nat"]},science:{canonical:"Science",aliases:["Sci"]},cell:{canonical:"Cell",aliases:[]},"the lancet":{canonical:"The Lancet",aliases:["Lancet","Lanc"]},lancet:{canonical:"The Lancet",aliases:["Lanc"]},"new england journal of medicine":{canonical:"New England Journal of Medicine",aliases:["N Engl J Med","NEJM","N Engl J"]},nejm:{canonical:"New England Journal of Medicine",aliases:["N Engl J Med","New England Journal of Medicine"]},jama:{canonical:"JAMA",aliases:["JAMA","J Am Med Assoc","Journal of the American Medical Association"]},"journal of the american medical association":{canonical:"JAMA",aliases:["JAMA","J Am Med Assoc"]},bmj:{canonical:"BMJ",aliases:["BMJ","Br Med J","British Medical Journal"]},"british medical journal":{canonical:"BMJ",aliases:["BMJ","Br Med J"]},"nature medicine":{canonical:"Nature Medicine",aliases:["Nat Med"]},"nature genetics":{canonical:"Nature Genetics",aliases:["Nat Genet"]},"nature biotechnology":{canonical:"Nature Biotechnology",aliases:["Nat Biotechnol"]},"nature cell biology":{canonical:"Nature Cell Biology",aliases:["Nat Cell Biol"]},"nature immunology":{canonical:"Nature Immunology",aliases:["Nat Immunol"]},"nature neuroscience":{canonical:"Nature Neuroscience",aliases:["Nat Neurosci"]},"nature methods":{canonical:"Nature Methods",aliases:["Nat Methods"]},"nature reviews cancer":{canonical:"Nature Reviews Cancer",aliases:["Nat Rev Cancer"]},"nature reviews immunology":{canonical:"Nature Reviews Immunology",aliases:["Nat Rev Immunol"]},"nature reviews genetics":{canonical:"Nature Reviews Genetics",aliases:["Nat Rev Genet"]},"nature reviews molecular cell biology":{canonical:"Nature Reviews Molecular Cell Biology",aliases:["Nat Rev Mol Cell Biol"]},"nature reviews drug discovery":{canonical:"Nature Reviews Drug Discovery",aliases:["Nat Rev Drug Discov"]},"nature reviews clinical oncology":{canonical:"Nature Reviews Clinical Oncology",aliases:["Nat Rev Clin Oncol"]},"nature communications":{canonical:"Nature Communications",aliases:["Nat Commun"]},"nature structural and molecular biology":{canonical:"Nature Structural & Molecular Biology",aliases:["Nat Struct Mol Biol"]},"cancer discovery":{canonical:"Cancer Discovery",aliases:["Cancer Discov"]},"cancer cell":{canonical:"Cancer Cell",aliases:["Cancer Cell"]},"cancer research":{canonical:"Cancer Research",aliases:["Cancer Res"]},"journal of clinical oncology":{canonical:"Journal of Clinical Oncology",aliases:["J Clin Oncol","JCO"]},jco:{canonical:"Journal of Clinical Oncology",aliases:["J Clin Oncol","Journal of Clinical Oncology"]},"clinical cancer research":{canonical:"Clinical Cancer Research",aliases:["Clin Cancer Res"]},"the new england journal of medicine":{canonical:"New England Journal of Medicine",aliases:["N Engl J Med","NEJM"]},"genome medicine":{canonical:"Genome Medicine",aliases:["Genome Med"]},"genome biology":{canonical:"Genome Biology",aliases:["Genome Biol"]},"genome research":{canonical:"Genome Research",aliases:["Genome Res"]},"nature genomics":{canonical:"Nature Genomics",aliases:["Nat Genomics"]},"cell research":{canonical:"Cell Research",aliases:["Cell Res"]},"cell metabolism":{canonical:"Cell Metabolism",aliases:["Cell Metab"]},"cell stem cell":{canonical:"Cell Stem Cell",aliases:["Cell Stem Cell"]},"molecular cell":{canonical:"Molecular Cell",aliases:["Mol Cell"]},"developmental cell":{canonical:"Developmental Cell",aliases:["Dev Cell"]},immunity:{canonical:"Immunity",aliases:[]},neuron:{canonical:"Neuron",aliases:[]},"the embo journal":{canonical:"The EMBO Journal",aliases:["EMBO J"]},"embo journal":{canonical:"The EMBO Journal",aliases:["EMBO J"]},"embo reports":{canonical:"EMBO Reports",aliases:["EMBO Rep"]},"proceedings of the national academy of sciences":{canonical:"Proceedings of the National Academy of Sciences",aliases:["Proc Natl Acad Sci U S A","PNAS"]},pnas:{canonical:"Proceedings of the National Academy of Sciences",aliases:["Proc Natl Acad Sci U S A","Proceedings of the National Academy of Sciences"]},"science translational medicine":{canonical:"Science Translational Medicine",aliases:["Sci Transl Med"]},"science immunology":{canonical:"Science Immunology",aliases:["Sci Immunol"]},"science advances":{canonical:"Science Advances",aliases:["Sci Adv"]},"the journal of experimental medicine":{canonical:"The Journal of Experimental Medicine",aliases:["J Exp Med"]},"journal of experimental medicine":{canonical:"The Journal of Experimental Medicine",aliases:["J Exp Med"]},"the journal of clinical investigation":{canonical:"The Journal of Clinical Investigation",aliases:["J Clin Invest","JCI"]},"journal of clinical investigation":{canonical:"The Journal of Clinical Investigation",aliases:["J Clin Invest","JCI"]},jci:{canonical:"The Journal of Clinical Investigation",aliases:["J Clin Invest","The Journal of Clinical Investigation"]},"journal of the national cancer institute":{canonical:"Journal of the National Cancer Institute",aliases:["J Natl Cancer Inst","JNCI"]},jnci:{canonical:"Journal of the National Cancer Institute",aliases:["J Natl Cancer Inst","Journal of the National Cancer Institute"]},"annals of oncology":{canonical:"Annals of Oncology",aliases:["Ann Oncol"]},"the lancet oncology":{canonical:"The Lancet Oncology",aliases:["Lancet Oncol"]},"lancet oncology":{canonical:"The Lancet Oncology",aliases:["Lancet Oncol"]},"the lancet neurology":{canonical:"The Lancet Neurology",aliases:["Lancet Neurol"]},"the lancet infectious diseases":{canonical:"The Lancet Infectious Diseases",aliases:["Lancet Infect Dis"]},"the lancet respiratory medicine":{canonical:"The Lancet Respiratory Medicine",aliases:["Lancet Respir Med"]},"the lancet gastroenterology and hepatology":{canonical:"The Lancet Gastroenterology & Hepatology",aliases:["Lancet Gastroenterol Hepatol"]},"the lancet diabetes and endocrinology":{canonical:"The Lancet Diabetes & Endocrinology",aliases:["Lancet Diabetes Endocrinol"]},"the lancet psychiatry":{canonical:"The Lancet Psychiatry",aliases:["Lancet Psychiatry"]},"the lancet haematology":{canonical:"The Lancet Haematology",aliases:["Lancet Haematol"]},"the lancet global health":{canonical:"The Lancet Global Health",aliases:["Lancet Glob Health"]},"the lancet digital health":{canonical:"The Lancet Digital Health",aliases:["Lancet Digit Health"]},gastroenterology:{canonical:"Gastroenterology",aliases:["Gastroenterology"]},gut:{canonical:"Gut",aliases:["Gut"]},"the american journal of gastroenterology":{canonical:"The American Journal of Gastroenterology",aliases:["Am J Gastroenterol"]},"american journal of gastroenterology":{canonical:"The American Journal of Gastroenterology",aliases:["Am J Gastroenterol"]},"gut microbes":{canonical:"Gut Microbes",aliases:["Gut Microbes"]},microbiome:{canonical:"Microbiome",aliases:["Microbiome"]},"gastrointestinal endoscopy":{canonical:"Gastrointestinal Endoscopy",aliases:["Gastrointest Endosc"]},endoscopy:{canonical:"Endoscopy",aliases:["Endoscopy"]},"the american journal of human genetics":{canonical:"The American Journal of Human Genetics",aliases:["Am J Hum Genet","AJHG"]},"american journal of human genetics":{canonical:"The American Journal of Human Genetics",aliases:["Am J Hum Genet","AJHG"]},ajhg:{canonical:"The American Journal of Human Genetics",aliases:["Am J Hum Genet","The American Journal of Human Genetics"]},"american journal of pathology":{canonical:"The American Journal of Pathology",aliases:["Am J Pathol"]},"the journal of biological chemistry":{canonical:"The Journal of Biological Chemistry",aliases:["J Biol Chem","JBC"]},"journal of biological chemistry":{canonical:"The Journal of Biological Chemistry",aliases:["J Biol Chem","JBC"]},jbc:{canonical:"The Journal of Biological Chemistry",aliases:["J Biol Chem","The Journal of Biological Chemistry"]},"nature chemical biology":{canonical:"Nature Chemical Biology",aliases:["Nat Chem Biol"]},"nature chemistry":{canonical:"Nature Chemistry",aliases:["Nat Chem"]},"nature physics":{canonical:"Nature Physics",aliases:["Nat Phys"]},"nature materials":{canonical:"Nature Materials",aliases:["Nat Mater"]},"nature nanotechnology":{canonical:"Nature Nanotechnology",aliases:["Nat Nanotechnol"]},"nature photonics":{canonical:"Nature Photonics",aliases:["Nat Photonics"]},"nature ecology and evolution":{canonical:"Nature Ecology & Evolution",aliases:["Nat Ecol Evol"]},"nature climate change":{canonical:"Nature Climate Change",aliases:["Nat Clim Chang"]},"nature energy":{canonical:"Nature Energy",aliases:["Nat Energy"]},"nature food":{canonical:"Nature Food",aliases:["Nat Food"]},"nature aging":{canonical:"Nature Aging",aliases:["Nat Aging"]},"nature cancer":{canonical:"Nature Cancer",aliases:["Nat Cancer"]},"nature metabolism":{canonical:"Nature Metabolism",aliases:["Nat Metab"]},"nature microbiology":{canonical:"Nature Microbiology",aliases:["Nat Microbiol"]},"nature plants":{canonical:"Nature Plants",aliases:["Nat Plants"]},blood:{canonical:"Blood",aliases:["Blood"]},"the journal of immunology":{canonical:"The Journal of Immunology",aliases:["J Immunol"]},"journal of immunology":{canonical:"The Journal of Immunology",aliases:["J Immunol"]},immunology:{canonical:"Immunology",aliases:["Immunology"]},"frontiers in immunology":{canonical:"Frontiers in Immunology",aliases:["Front Immunol"]},"frontiers in oncology":{canonical:"Frontiers in Oncology",aliases:["Front Oncol"]},"frontiers in genetics":{canonical:"Frontiers in Genetics",aliases:["Front Genet"]},"frontiers in cell and developmental biology":{canonical:"Frontiers in Cell and Developmental Biology",aliases:["Front Cell Dev Biol"]},"frontiers in microbiology":{canonical:"Frontiers in Microbiology",aliases:["Front Microbiol"]},"frontiers in pharmacology":{canonical:"Frontiers in Pharmacology",aliases:["Front Pharmacol"]},"frontiers in neuroscience":{canonical:"Frontiers in Neuroscience",aliases:["Front Neurosci"]},"frontiers in medicine":{canonical:"Frontiers in Medicine",aliases:["Front Med"]},"frontiers in public health":{canonical:"Frontiers in Public Health",aliases:["Front Public Health"]},"frontiers in endocrinology":{canonical:"Frontiers in Endocrinology",aliases:["Front Endocrinol"]},"frontiers in nutrition":{canonical:"Frontiers in Nutrition",aliases:["Front Nutr"]},oncogene:{canonical:"Oncogene",aliases:["Oncogene"]},oncogenesis:{canonical:"Oncogenesis",aliases:["Oncogenesis"]},oncotarget:{canonical:"Oncotarget",aliases:["Oncotarget"]},cancers:{canonical:"Cancers",aliases:["Cancers (Basel)"]},"journal of pathology":{canonical:"The Journal of Pathology",aliases:["J Pathol"]},"the journal of pathology":{canonical:"The Journal of Pathology",aliases:["J Pathol"]},"modern pathology":{canonical:"Modern Pathology",aliases:["Mod Pathol"]},"laboratory investigation":{canonical:"Laboratory Investigation",aliases:["Lab Invest"]},"american journal of surgical pathology":{canonical:"The American Journal of Surgical Pathology",aliases:["Am J Surg Pathol"]},"the american journal of surgical pathology":{canonical:"The American Journal of Surgical Pathology",aliases:["Am J Surg Pathol"]},histopathology:{canonical:"Histopathology",aliases:["Histopathology"]},"virchows archiv":{canonical:"Virchows Archiv",aliases:["Virchows Arch"]},"human pathology":{canonical:"Human Pathology",aliases:["Hum Pathol"]},"nature medicine new york":{canonical:"Nature Medicine",aliases:["Nat Med"]},"plos medicine":{canonical:"PLOS Medicine",aliases:["PLoS Med"]},"plos biology":{canonical:"PLOS Biology",aliases:["PLoS Biol"]},"plos genetics":{canonical:"PLOS Genetics",aliases:["PLoS Genet"]},"plos computational biology":{canonical:"PLOS Computational Biology",aliases:["PLoS Comput Biol"]},"plos pathogens":{canonical:"PLOS Pathogens",aliases:["PLoS Pathog"]},"plos neglected tropical diseases":{canonical:"PLOS Neglected Tropical Diseases",aliases:["PLoS Negl Trop Dis"]},"plos one":{canonical:"PLOS ONE",aliases:["PLoS One","PLoS ONE"]},elife:{canonical:"eLife",aliases:["eLife"]},"bmj open":{canonical:"BMJ Open",aliases:["BMJ Open"]},"bmj medicine":{canonical:"BMJ Medicine",aliases:["BMJ Med"]},"bmj global health":{canonical:"BMJ Global Health",aliases:["BMJ Glob Health"]},"annals of internal medicine":{canonical:"Annals of Internal Medicine",aliases:["Ann Intern Med"]},"archives of internal medicine":{canonical:"Archives of Internal Medicine",aliases:["Arch Intern Med","JAMA Intern Med"]},"jama internal medicine":{canonical:"JAMA Internal Medicine",aliases:["JAMA Intern Med"]},"jama oncology":{canonical:"JAMA Oncology",aliases:["JAMA Oncol"]},"jama neurology":{canonical:"JAMA Neurology",aliases:["JAMA Neurol"]},"jama cardiology":{canonical:"JAMA Cardiology",aliases:["JAMA Cardiol"]},"jama surgery":{canonical:"JAMA Surgery",aliases:["JAMA Surg"]},"jama pediatrics":{canonical:"JAMA Pediatrics",aliases:["JAMA Pediatr"]},"jama ophthalmology":{canonical:"JAMA Ophthalmology",aliases:["JAMA Ophthalmol"]},circulation:{canonical:"Circulation",aliases:["Circulation"]},"journal of the american college of cardiology":{canonical:"Journal of the American College of Cardiology",aliases:["J Am Coll Cardiol","JACC"]},jacc:{canonical:"Journal of the American College of Cardiology",aliases:["J Am Coll Cardiol","Journal of the American College of Cardiology"]},"european heart journal":{canonical:"European Heart Journal",aliases:["Eur Heart J"]},"circulation research":{canonical:"Circulation Research",aliases:["Circ Res"]},"nature cardiovascular research":{canonical:"Nature Cardiovascular Research",aliases:["Nat Cardiovasc Res"]},"european respiratory journal":{canonical:"European Respiratory Journal",aliases:["Eur Respir J"]},"american journal of respiratory and critical care medicine":{canonical:"American Journal of Respiratory and Critical Care Medicine",aliases:["Am J Respir Crit Care Med"]},chest:{canonical:"Chest",aliases:["Chest"]},thorax:{canonical:"Thorax",aliases:["Thorax"]},diabetes:{canonical:"Diabetes",aliases:["Diabetes"]},diabetologia:{canonical:"Diabetologia",aliases:["Diabetologia"]},"the lancet planetary health":{canonical:"The Lancet Planetary Health",aliases:["Lancet Planet Health"]},stroke:{canonical:"Stroke",aliases:["Stroke"]},neurology:{canonical:"Neurology",aliases:["Neurology"]},brain:{canonical:"Brain",aliases:["Brain"]},"annals of neurology":{canonical:"Annals of Neurology",aliases:["Ann Neurol"]},"acta neuropathologica":{canonical:"Acta Neuropathologica",aliases:["Acta Neuropathol"]},"kidney international":{canonical:"Kidney International",aliases:["Kidney Int"]},"journal of the american society of nephrology":{canonical:"Journal of the American Society of Nephrology",aliases:["J Am Soc Nephrol","JASN"]},jasn:{canonical:"Journal of the American Society of Nephrology",aliases:["J Am Soc Nephrol","Journal of the American Society of Nephrology"]},hepatology:{canonical:"Hepatology",aliases:["Hepatology"]},"journal of hepatology":{canonical:"Journal of Hepatology",aliases:["J Hepatol"]},"american journal of transplantation":{canonical:"American Journal of Transplantation",aliases:["Am J Transplant","AJT"]},ajt:{canonical:"American Journal of Transplantation",aliases:["Am J Transplant"]},transplantation:{canonical:"Transplantation",aliases:["Transplantation"]},"arthritis and rheumatology":{canonical:"Arthritis & Rheumatology",aliases:["Arthritis Rheumatol","Arthritis Rheum"]},"annals of the rheumatic diseases":{canonical:"Annals of the Rheumatic Diseases",aliases:["Ann Rheum Dis"]},"journal of allergy and clinical immunology":{canonical:"Journal of Allergy and Clinical Immunology",aliases:["J Allergy Clin Immunol","JACI"]},jaci:{canonical:"Journal of Allergy and Clinical Immunology",aliases:["J Allergy Clin Immunol"]},"clinical infectious diseases":{canonical:"Clinical Infectious Diseases",aliases:["Clin Infect Dis"]},"the journal of infectious diseases":{canonical:"The Journal of Infectious Diseases",aliases:["J Infect Dis"]},"journal of virology":{canonical:"Journal of Virology",aliases:["J Virol"]},"infection and immunity":{canonical:"Infection and Immunity",aliases:["Infect Immun"]},microbiology:{canonical:"Microbiology",aliases:["Microbiology"]},mbio:{canonical:"mBio",aliases:["mBio"]},"cell host and microbe":{canonical:"Cell Host & Microbe",aliases:["Cell Host Microbe"]},"trends in microbiology":{canonical:"Trends in Microbiology",aliases:["Trends Microbiol"]},"molecular microbiology":{canonical:"Molecular Microbiology",aliases:["Mol Microbiol"]},"cell reports":{canonical:"Cell Reports",aliases:["Cell Rep"]},"cell reports medicine":{canonical:"Cell Reports Medicine",aliases:["Cell Rep Med"]},iscience:{canonical:"iScience",aliases:["iScience"]},"signal transduction and targeted therapy":{canonical:"Signal Transduction and Targeted Therapy",aliases:["Signal Transduct Target Ther"]},"cell discovery":{canonical:"Cell Discovery",aliases:["Cell Discov"]},"protein and cell":{canonical:"Protein & Cell",aliases:["Protein Cell"]},"national science review":{canonical:"National Science Review",aliases:["Natl Sci Rev","NSR"]},"science bulletin":{canonical:"Science Bulletin",aliases:["Sci Bull"]},"medical journal of australia":{canonical:"Medical Journal of Australia",aliases:["Med J Aust"]},"canadian medical association journal":{canonical:"Canadian Medical Association Journal",aliases:["CMAJ","Can Med Assoc J"]},cmaj:{canonical:"Canadian Medical Association Journal",aliases:["Can Med Assoc J","Canadian Medical Association Journal"]},"deutsches arzteblatt international":{canonical:"Deutsches Arzteblatt International",aliases:["Dtsch Arztebl Int"]},"bmc medicine":{canonical:"BMC Medicine",aliases:["BMC Med"]},"systematic reviews":{canonical:"Systematic Reviews",aliases:["Syst Rev"]},trials:{canonical:"Trials",aliases:["Trials"]},peerj:{canonical:"PeerJ",aliases:["PeerJ"]},"scientific reports":{canonical:"Scientific Reports",aliases:["Sci Rep"]},heliyon:{canonical:"Heliyon",aliases:["Heliyon"]},"communications biology":{canonical:"Communications Biology",aliases:["Commun Biol"]},"communications medicine":{canonical:"Communications Medicine",aliases:["Commun Med"]},"cell systems":{canonical:"Cell Systems",aliases:["Cell Syst"]},"molecular systems biology":{canonical:"Molecular Systems Biology",aliases:["Mol Syst Biol"]},"nature methods new york":{canonical:"Nature Methods",aliases:["Nat Methods"]},bioinformatics:{canonical:"Bioinformatics",aliases:["Bioinformatics"]},"briefings in bioinformatics":{canonical:"Briefings in Bioinformatics",aliases:["Brief Bioinform"]},"nucleic acids research":{canonical:"Nucleic Acids Research",aliases:["Nucleic Acids Res","NAR"]},nar:{canonical:"Nucleic Acids Research",aliases:["Nucleic Acids Res"]},"biochimica et biophysica acta":{canonical:"Biochimica et Biophysica Acta",aliases:["Biochim Biophys Acta","BBA"]},"journal of molecular biology":{canonical:"Journal of Molecular Biology",aliases:["J Mol Biol"]},"trends in biochemical sciences":{canonical:"Trends in Biochemical Sciences",aliases:["Trends Biochem Sci"]},"trends in cell biology":{canonical:"Trends in Cell Biology",aliases:["Trends Cell Biol"]},"trends in genetics":{canonical:"Trends in Genetics",aliases:["Trends Genet"]},"trends in molecular medicine":{canonical:"Trends in Molecular Medicine",aliases:["Trends Mol Med"]},"trends in pharmacological sciences":{canonical:"Trends in Pharmacological Sciences",aliases:["Trends Pharmacol Sci"]},"trends in cancer":{canonical:"Trends in Cancer",aliases:["Trends Cancer"]},"pharmacological reviews":{canonical:"Pharmacological Reviews",aliases:["Pharmacol Rev"]},"annual review of immunology":{canonical:"Annual Review of Immunology",aliases:["Annu Rev Immunol"]},"annual review of biochemistry":{canonical:"Annual Review of Biochemistry",aliases:["Annu Rev Biochem"]},"annual review of cell and developmental biology":{canonical:"Annual Review of Cell and Developmental Biology",aliases:["Annu Rev Cell Dev Biol"]},"annual review of genetics":{canonical:"Annual Review of Genetics",aliases:["Annu Rev Genet"]},"annual review of medicine":{canonical:"Annual Review of Medicine",aliases:["Annu Rev Med"]},"annual review of pathology":{canonical:"Annual Review of Pathology",aliases:["Annu Rev Pathol"]},"annual review of neuroscience":{canonical:"Annual Review of Neuroscience",aliases:["Annu Rev Neurosci"]},"annual review of pharmacology and toxicology":{canonical:"Annual Review of Pharmacology and Toxicology",aliases:["Annu Rev Pharmacol Toxicol"]},"current biology":{canonical:"Current Biology",aliases:["Curr Biol"]},genetics:{canonical:"Genetics",aliases:["Genetics"]},genomics:{canonical:"Genomics",aliases:["Genomics"]},"human molecular genetics":{canonical:"Human Molecular Genetics",aliases:["Hum Mol Genet"]},"human genetics":{canonical:"Human Genetics",aliases:["Hum Genet"]},"genetic epidemiology":{canonical:"Genetic Epidemiology",aliases:["Genet Epidemiol"]},"statistical genetics":{canonical:"Statistical Genetics",aliases:[]},bioethics:{canonical:"Bioethics",aliases:["Bioethics"]},"jama network open":{canonical:"JAMA Network Open",aliases:["JAMA Netw Open"]},"annals of surgery":{canonical:"Annals of Surgery",aliases:["Ann Surg"]},"clinical gastroenterology and hepatology":{canonical:"Clinical Gastroenterology and Hepatology",aliases:["Clin Gastroenterol Hepatol"]},"the lancet public health":{canonical:"The Lancet Public Health",aliases:["Lancet Public Health"]}}));function Ga(a){const e=a.trim().toLowerCase();if(!e||e.length<2)return null;const t=yd.get(e);if(t)return{entry:t,confidence:.98};for(const[,n]of yd){if(n.canonical.toLowerCase()===e)return{entry:n,confidence:.98};if(n.aliases.some(r=>r.toLowerCase()===e))return{entry:n,confidence:.95}}return null}function as(a){return _C([a.canonical,...a.aliases]).filter(Boolean)}function _C(a){return Array.from(new Set(a.filter(Boolean)))}function is(a){return/^10\.\d{4,}\/[^\s]+$/.test(a.trim())}function os(a){const t=a.trim().match(/^(?:PMID:\s*)?(\d{6,8})$/i);return t?{isValid:!0,pmid:t[1]}:{isValid:!1,pmid:null}}const ss=new Set(["head and neck cancer","quality of life","signs and symptoms","research and development"]),xd=new Set(["a","an","and","are","as","at","be","by","for","from","in","into","is","of","on","or","that","the","their","this","to","use","using","via","with","without"]),DC=new Set(["study","studies","analysis","method","methods","approach","approaches","factors","factor","effect","effects","result","results","data","review","reviews","report","reports","case","cases","cells","cell","tissue","tissues","sample","samples","patients","patient","group","groups","model","models","role","impact","association","relationship","correlation","evidence","finding","findings","outcome","outcomes","level","levels","type","types","form","forms","base","based","use","using","used","new","novel"]),FC=new Set(["cell","cancer","diabetes"]),Ad=[{key:"colorectal-cancer",label:"colorectal cancer",patterns:[/\bcrc\b/i,/\bcolorectal cancer\b/i,/\bcolorectal neoplasms?\b/i,/\bcolon cancer\b/i,/\brectal cancer\b/i],titleAbstractTerms:["colorectal cancer","CRC","colorectal neoplasms","colon cancer","rectal cancer"],meshTerms:["Colorectal Neoplasms"],note:"Expanded a common colorectal cancer synonym / abbreviation bucket.",domains:["colorectal"]},{key:"gastric-cancer",label:"gastric cancer",patterns:[/\bgastric cancer\b/i,/\bstomach cancer\b/i,/\bgastric neoplasms?\b/i,/\bstomach neoplasms?\b/i,/\bgastric carcinoma\b/i],titleAbstractTerms:["gastric cancer","stomach cancer","gastric neoplasms","stomach neoplasms","gastric carcinoma"],meshTerms:["Stomach Neoplasms"],note:"Expanded gastric / stomach cancer wording into one organ-consistent bucket.",domains:["gastric"]},{key:"pancreatic-cancer",label:"pancreatic cancer",patterns:[/\bpancreatic cancer\b/i,/\bpancreatic neoplasms?\b/i,/\bpancreatic carcinoma\b/i,/\bpancreas cancer\b/i],titleAbstractTerms:["pancreatic cancer","pancreatic neoplasms","pancreatic carcinoma","pancreas cancer"],meshTerms:["Pancreatic Neoplasms"],note:"Expanded pancreatic cancer wording without crossing into other GI organs.",domains:["pancreatic"]},{key:"hepatocellular-carcinoma",label:"hepatocellular carcinoma",patterns:[/\bhcc\b/i,/\bhepatocellular carcinoma\b/i,/\bliver cancer\b/i,/\bhepatic cancer\b/i],titleAbstractTerms:["hepatocellular carcinoma","HCC","liver cancer","hepatic cancer"],meshTerms:["Carcinoma, Hepatocellular"],note:"Expanded HCC / liver cancer wording into a liver-specific bucket.",domains:["liver"]},{key:"breast-cancer",label:"breast cancer",patterns:[/\bbreast cancer\b/i,/\bbreast neoplasms?\b/i,/\bmammary carcinoma\b/i],titleAbstractTerms:["breast cancer","breast neoplasms","mammary carcinoma"],meshTerms:["Breast Neoplasms"],note:"Expanded breast cancer wording into a breast-specific bucket.",domains:["breast"]},{key:"lung-cancer",label:"lung cancer",patterns:[/\blung cancer\b/i,/\blung neoplasms?\b/i,/\bnsclc\b/i,/\bnon-small cell lung cancer\b/i,/\bsmall cell lung cancer\b/i],titleAbstractTerms:["lung cancer","lung neoplasms","NSCLC","non-small cell lung cancer","small cell lung cancer"],meshTerms:["Lung Neoplasms"],note:"Expanded lung cancer wording into a thoracic-oncology bucket.",domains:["lung"]},{key:"melanoma",label:"melanoma",patterns:[/\bmelanoma\b/i,/\bcutaneous melanoma\b/i],titleAbstractTerms:["melanoma","cutaneous melanoma"],meshTerms:["Melanoma"],note:"Expanded melanoma wording while keeping skin-oncology scope isolated.",domains:["melanoma"]},{key:"prostate-cancer",label:"prostate cancer",patterns:[/\bprostate cancer\b/i,/\bprostatic neoplasms?\b/i,/\bprostate neoplasms?\b/i,/\bprostate carcinoma\b/i],titleAbstractTerms:["prostate cancer","prostatic neoplasms","prostate neoplasms","prostate carcinoma"],meshTerms:["Prostatic Neoplasms"],note:"Expanded prostate cancer wording into a prostate-specific oncology bucket."},{key:"generic-cancer",label:"cancer",patterns:[/\bcancer\b/i,/\bcancers\b/i,/\bneoplasm(?:s)?\b/i,/\btumo(?:r|ur)(?:s)?\b/i,/\boncology\b/i],titleAbstractTerms:["cancer","cancers","neoplasm","neoplasms","tumor","tumors","tumour","tumours","oncology"],meshTerms:["Neoplasms"],note:"Preserved a generic cancer / oncology anchor so broad disease framing is not lost during method-oriented expansion."},{key:"ibd",label:"inflammatory bowel disease",patterns:[/\bibd\b/i,/\binflammatory bowel disease\b/i,/\bulcerative colitis\b/i,/\bcrohn'?s disease\b/i],titleAbstractTerms:["inflammatory bowel disease","IBD","ulcerative colitis","Crohn's disease"],meshTerms:["Inflammatory Bowel Diseases","Colitis, Ulcerative","Crohn Disease"],note:"Expanded IBD wording into a bowel-inflammatory disease bucket.",domains:["ibd"]},{key:"diabetes",label:"diabetes",patterns:[/\bdiabetes\b/i,/\bdiabetes mellitus\b/i,/\btype 1 diabetes\b/i,/\btype 2 diabetes\b/i,/\bt1d\b/i,/\bt2d\b/i],titleAbstractTerms:["diabetes","diabetes mellitus","type 1 diabetes","type 2 diabetes","T1D","T2D"],meshTerms:["Diabetes Mellitus","Diabetes Mellitus, Type 1","Diabetes Mellitus, Type 2"],note:"Expanded diabetes wording into a disease-specific metabolic bucket."},{key:"screening",label:"screening",patterns:[/\bscreen(?:ing)?\b/i,/\bmass screening\b/i],titleAbstractTerms:["screening","mass screening"],meshTerms:["Mass Screening","Early Detection of Cancer"],note:"Keeps generic screening intent separate from organ-specific screening modalities."},{key:"surveillance",label:"surveillance",patterns:[/\bsurveillance\b/i,/\bmonitoring\b/i,/\bfollow-up\b/i],titleAbstractTerms:["surveillance","monitoring","follow-up"],meshTerms:[],note:"Keeps surveillance / monitoring intent as its own retrieval bucket."},{key:"colorectal-screening-modality",label:"colorectal screening modality",patterns:[/\bcolonoscopy\b/i,/\bfit\b/i,/\bfecal immunochemical test\b/i,/\bstool-based test\b/i,/\bstool dna\b/i,/\bfecal dna\b/i],titleAbstractTerms:["colonoscopy","FIT","fecal immunochemical test","stool-based test","stool DNA","fecal DNA"],meshTerms:["Colonoscopy"],note:"Groups colorectal-specific screening modalities so they are never injected by a generic screening intent alone.",domains:["colorectal"]},{key:"early-onset",label:"early-onset",patterns:[/\bearly[- ]onset\b/i,/\byoung[- ]onset\b/i,/\bunder 50\b/i,/\bbefore age 50\b/i,/\byounger adults?\b/i],titleAbstractTerms:["early-onset","young-onset","under 50","before age 50","younger adults"],meshTerms:["Age of Onset"],note:"Expanded age-at-onset wording into one explainable bucket."},{key:"liquid-biopsy",label:"liquid biopsy",patterns:[/\bliquid biopsy\b/i,/\bctdna\b/i,/\bcfdna\b/i,/\bcirculating tumor dna\b/i,/\bcell[- ]free dna\b/i],titleAbstractTerms:["liquid biopsy","ctDNA","cfDNA","circulating tumor DNA","cell-free DNA"],meshTerms:["Liquid Biopsy","DNA, Circulating","Cell-Free Nucleic Acids"],note:"Expanded liquid-biopsy shorthand into common circulating DNA variants."},{key:"organoid-model",label:"organoid model",patterns:[/\borganoid(s)?\b/i,/\bpatient[- ]derived organoid(s)?\b/i,/\bpdo(s)?\b/i],titleAbstractTerms:["organoid","organoids","patient-derived organoid","patient derived organoid","PDO"],meshTerms:["Organoids"],note:"Preserved organoid / patient-derived organoid wording as a model-system bucket."},{key:"early-detection",label:"early detection",patterns:[/\bearly detection\b/i,/\bearly diagnosis\b/i,/\bearly diagnostic\b/i],titleAbstractTerms:["early detection","early diagnosis"],meshTerms:["Early Detection of Cancer"],note:"Preserved the early-detection intent as a dedicated concept bucket."},{key:"microbiome",label:"microbiome",patterns:[/\bmicrobiome\b/i,/\bmicrobiota\b/i,/\bgut microbiome\b/i,/\bgut microbiota\b/i],titleAbstractTerms:["microbiome","microbiota","gut microbiome","gut microbiota"],meshTerms:["Microbiota","Gastrointestinal Microbiome"],note:"Grouped microbiome / microbiota variants together."},{key:"immunotherapy",label:"immunotherapy",patterns:[/\bimmunotherapy\b/i,/\bcheckpoint inhibitors?\b/i,/\bpd-1\b/i,/\bpd-l1\b/i,/\bctla-4\b/i,/\bpembrolizumab\b/i,/\bnivolumab\b/i,/\bipilimumab\b/i],titleAbstractTerms:["immunotherapy","checkpoint inhibitor","PD-1","PD-L1","CTLA-4","pembrolizumab","nivolumab","ipilimumab"],meshTerms:["Immunotherapy","Immune Checkpoint Inhibitors"],note:"Expanded common immunotherapy synonyms and checkpoint abbreviations."},{key:"her2-status",label:"HER2 status",patterns:[/\bher2[- ]positive\b/i,/\bher2[- ]negative\b/i,/\berbb2[- ]positive\b/i,/\berbb2[- ]negative\b/i],titleAbstractTerms:["HER2 positive","HER2 negative","HER2-positive","HER2-negative","ERBB2 positive","ERBB2 negative"],meshTerms:["Receptor, ErbB-2"],note:"Preserved HER2 status wording and linked it to the canonical ErbB-2 receptor concept."},{key:"targeted-therapy",label:"targeted therapy",patterns:[/\btargeted therapy\b/i,/\bmolecular targeted therapy\b/i,/\btargeted treatment\b/i],titleAbstractTerms:["targeted therapy","molecular targeted therapy","targeted treatment"],meshTerms:["Molecular Targeted Therapy"],note:"Expanded targeted therapy wording into the curated molecular targeted therapy bucket."},{key:"guideline",label:"guideline",patterns:[/\bguideline(s)?\b/i,/\brecommendation(s)?\b/i,/\bconsensus\b/i,/\bpolicy\b/i],titleAbstractTerms:["guideline","recommendation","consensus","policy"],meshTerms:["Practice Guidelines as Topic"],note:"Grouped guideline, recommendation, and policy language."},{key:"prevention",label:"prevention",patterns:[/\bprevention\b/i,/\bpreventive\b/i,/\brisk reduction\b/i],titleAbstractTerms:["prevention","preventive","risk reduction"],meshTerms:["Primary Prevention","Risk Reduction Behavior"],note:"Kept prevention-oriented language in its own bucket."},{key:"epidemiology",label:"epidemiology",patterns:[/\bepidemiology\b/i,/\bincidence\b/i,/\bmortality\b/i,/\bprevalence\b/i,/\btrend(s)?\b/i],titleAbstractTerms:["epidemiology","incidence","mortality","prevalence","trends"],meshTerms:["Epidemiology","Incidence","Mortality","Prevalence"],note:"Grouped epidemiology / trend-monitoring wording together."},{key:"survival",label:"survival",patterns:[/\bsurvival\b/i,/\boutcome(s)?\b/i,/\bprognos(is|tic)\b/i,/\brecurrence\b/i,/\brelapse\b/i],titleAbstractTerms:["survival","outcomes","prognosis","prognostic","recurrence","relapse"],meshTerms:["Survival Analysis","Treatment Outcome","Prognosis","Neoplasm Recurrence, Local"],note:"Grouped survival, prognosis, and recurrence wording together."},{key:"microsatellite-instability",label:"microsatellite instability",patterns:[/\bmicrosatellite instability\b/i,/\bMSI[- ]?H\b/i,/\bMSI\b/i,/\bmismatch repair\b/i,/\bdMMR\b/i,/\bpMMR\b/i],titleAbstractTerms:["microsatellite instability","MSI","MSI-H","mismatch repair","dMMR","pMMR"],meshTerms:["Microsatellite Instability"],note:"Preserved MSI / mismatch-repair wording as a molecular subtype bucket."},{key:"polygenic-risk-score",label:"polygenic risk score",patterns:[/\bpolygenic risk score(s)?\b/i,/\bpolygenic score(s)?\b/i,/\bgenetic risk score(s)?\b/i,/\bgenomic risk score(s)?\b/i,/\bgenome-wide polygenic score(s)?\b/i,/\bPRS\b/i],titleAbstractTerms:["polygenic risk score","polygenic score","genetic risk score","genomic risk score","genome-wide polygenic score","PRS"],meshTerms:[],note:"Preserved polygenic-risk-score phrasing as its own genetics anchor bucket instead of collapsing it into a generic risk-model synonym pool."},{key:"risk-stratification",label:"risk stratification",patterns:[/\brisk stratification\b/i,/\brisk-stratified\b/i,/\brisk stratified\b/i,/\brisk assessment\b/i],titleAbstractTerms:["risk stratification","risk-stratified","risk stratified","risk assessment"],meshTerms:["Risk Assessment"],note:"Preserved risk-stratification wording as an explicit must-match intent bucket rather than letting it dissolve into a generic model term."},{key:"prediction-model",label:"prediction model",patterns:[/\bprediction model(s)?\b/i,/\bpredictive model(s)?\b/i,/\brisk prediction\b/i,/\brisk model(s)?\b/i,/\brisk score(s)?\b/i,/\bprognostic model(s)?\b/i,/\bnomogram(s)?\b/i,/\bclinical prediction rule(s)?\b/i,/\bmachine learning model(s)?\b/i,/\bexternal validation\b/i,/\binternal validation\b/i,/\bmodel validation\b/i],titleAbstractTerms:["prediction model","predictive model","risk prediction","risk model","risk score","prognostic model","nomogram","clinical prediction rule","prediction tool","predictive performance","discrimination","calibration","external validation"],meshTerms:["Models, Statistical","Risk Assessment","Nomograms"],note:"Expanded prediction-model wording into common biomedical model-development and validation synonyms."},{key:"response-prediction",label:"response prediction",patterns:[/\bresponse prediction\b/i,/\bresponse predictor(s)?\b/i,/\btreatment response prediction\b/i,/\bresponse model(s)?\b/i],titleAbstractTerms:["response prediction","response predictor","treatment response prediction","response model"],meshTerms:[],note:"Preserved treatment-response prediction as a distinct execution bucket."},{key:"minimal-residual-disease",label:"minimal residual disease",patterns:[/\bminimal residual disease\b/i,/\bmeasurable residual disease\b/i,/\bMRD\b/i],titleAbstractTerms:["minimal residual disease","measurable residual disease","MRD"],meshTerms:[],note:"Preserved MRD wording as a dedicated disease-monitoring bucket."},{key:"biomarker",label:"biomarker",patterns:[/\bbiomarker(s)?\b/i,/\bsignature(s)?\b/i,/\bmethylation\b/i,/\bfragmentomics\b/i],titleAbstractTerms:["biomarker","signature","methylation","fragmentomics","cell-free DNA","ctDNA","blood-based"],meshTerms:["Biomarkers, Tumor","DNA Methylation","MicroRNAs"],note:"Expanded generic biomarker / signal terminology without injecting organ-specific assay modalities."},{key:"diagnosis",label:"diagnosis",patterns:[/\bdiagnos(is|tic)\b/i,/\bdiagnostic accuracy\b/i,/\bsensitivity\b/i,/\bspecificity\b/i,/\broc\b/i,/\bauc\b/i],titleAbstractTerms:["diagnosis","diagnostic","diagnostic accuracy","sensitivity","specificity","ROC","AUC"],meshTerms:["Diagnosis","Sensitivity and Specificity","ROC Curve"],note:"Expanded diagnostic-performance wording into common PubMed retrieval expressions."},{key:"artificial-intelligence",label:"artificial intelligence",patterns:[/\bai\b/i,/\bartificial intelligence\b/i,/\bmachine learning\b/i,/\bdeep learning\b/i,/\bneural network(s)?\b/i,/\bradiomics\b/i],titleAbstractTerms:["artificial intelligence","AI","machine learning","deep learning","neural network","radiomics"],meshTerms:["Artificial Intelligence","Machine Learning"],note:"Expanded AI / machine-learning wording into common biomedical informatics retrieval expressions."},{key:"digital-pathology",label:"digital pathology",patterns:[/\bdigital pathology\b/i,/\bcomputational pathology\b/i,/\bwhole[- ]slide imaging\b/i,/\bwhole slide\b/i,/\bWSI\b/i],titleAbstractTerms:["digital pathology","computational pathology","whole-slide imaging","whole slide imaging","WSI"],meshTerms:[],note:"Preserved digital pathology and whole-slide imaging wording as its own retrieval bucket."},{key:"high-risk-population",label:"high-risk population",patterns:[/\bhigh[- ]risk population(s)?\b/i,/\bhigh[- ]risk patient(s)?\b/i,/\belevated[- ]risk population(s)?\b/i,/\bhigh-risk group(s)?\b/i],titleAbstractTerms:["high-risk population","high-risk patients","elevated-risk population","high-risk group"],meshTerms:[],note:"Treats high-risk populations as an independent population bucket instead of a soft modifier."},{key:"asian-patients",label:"Asian patients",patterns:[/\basian patient(s)?\b/i,/\basian population(s)?\b/i,/\basian cohort(s)?\b/i],titleAbstractTerms:["Asian patients","Asian population","Asian cohort"],meshTerms:[],note:"Treats Asian populations as an independent population bucket."},{key:"primary-care",label:"primary care",patterns:[/\bprimary care\b/i,/\bcommunity setting\b/i,/\bambulatory care\b/i],titleAbstractTerms:["primary care","community setting","ambulatory care"],meshTerms:["Primary Health Care"],note:"Treats care setting language as its own setting bucket."},{key:"imaging",label:"imaging",patterns:[/\bimaging\b/i,/\bradiolog(y|ic)\b/i,/\bmri\b/i,/\bmagnetic resonance\b/i,/\bct\b/i,/\bcomputed tomography\b/i,/\bultrasound\b/i,/\bmammograph(y|ic)\b/i],titleAbstractTerms:["imaging","radiology","MRI","magnetic resonance imaging","CT","computed tomography","ultrasound","mammography"],meshTerms:["Diagnostic Imaging"],note:"Expanded explicit imaging wording into standard PubMed imaging expressions without adding new disease anchors."},{key:"randomized-trial",label:"randomized controlled trial",patterns:[/\brandomized controlled trial\b/i,/\brandomised controlled trial\b/i,/\brandomized trial\b/i,/\bclinical trial\b/i,/\bdouble-blind\b/i,/\bplacebo-controlled\b/i],titleAbstractTerms:["randomized controlled trial","randomised controlled trial","randomized trial","clinical trial","double-blind","placebo-controlled"],meshTerms:["Randomized Controlled Trials as Topic","Clinical Trials as Topic"],note:"Expanded randomized / interventional trial wording into a broader clinical-trial bucket."}],Cd=new Set(["colorectal-cancer","gastric-cancer","pancreatic-cancer","hepatocellular-carcinoma","breast-cancer","lung-cancer","melanoma","prostate-cancer"]),kC=new Set(["control","disease","effect","effects","result","results","outcome","outcomes","study","review","trial","analysis","medicine","genome","nature","science","screening","therapy","detection","risk","patient","treatment","journal"]);function Re(a){return a.replace(/\s+/g," ").trim()}function ls(a){return a.toLowerCase().split(/[^a-z0-9-]+/).map(e=>e.trim()).filter(e=>e.length>=2)}function be(a){return Array.from(new Set(a.filter(Boolean)))}function Ya(a,e=!1){const t=new Set,n=Re(a);return t.add(n),e||(n.includes("-")&&t.add(n.replace(/-/g," ")),n.includes("/")&&!e&&n.split("/").map(r=>r.trim()).filter(r=>r.length>=2).forEach(r=>t.add(r)),/^[A-Z]{2,8}$/.test(n)&&t.add(n.toUpperCase())),Array.from(t)}function vd(a,e){return Cd.has(a)||a==="generic-cancer"||a==="ibd"||a==="diabetes"?"disease":["screening","early-detection","surveillance","diagnosis","risk-stratification","response-prediction"].includes(a)?"intent":["colorectal-screening-modality","liquid-biopsy","imaging","artificial-intelligence","digital-pathology","organoid-model"].includes(a)?"modality":["biomarker","microbiome","her2-status","microsatellite-instability"].includes(a)?"biomarker":["high-risk-population","asian-patients","early-onset"].includes(a)?"population":["primary-care"].includes(a)?"setting":["survival","prediction-model","polygenic-risk-score","minimal-residual-disease"].includes(a)?"outcome":["immunotherapy","targeted-therapy"].includes(a)?"modality":/\bpatients?\b|\bpopulation\b|\bcohort\b/i.test(e)?"population":/\bcare\b|\bsetting\b/i.test(e)?"setting":"literal"}const LC=[{domain:"colorectal",patterns:[/\bcrc\b/i,/\bcolorectal\b/i,/\bcolon\b/i,/\brectal\b/i]},{domain:"gastric",patterns:[/\bgastric\b/i,/\bstomach\b/i]},{domain:"pancreatic",patterns:[/\bpancrea(?:tic|s)\b/i]},{domain:"liver",patterns:[/\bhcc\b/i,/\bhepatocellular\b/i,/\bliver cancer\b/i,/\bhepatic\b/i]},{domain:"breast",patterns:[/\bbreast cancer\b/i,/\bbreast neoplasm\b/i,/\bmammograph\w*\b/i]},{domain:"lung",patterns:[/\blung cancer\b/i,/\bnsclc\b/i,/\bsmall cell lung\b/i]},{domain:"melanoma",patterns:[/\bmelanoma\b/i]},{domain:"ibd",patterns:[/\bibd\b/i,/\binflammatory bowel disease\b/i,/\bulcerative colitis\b/i,/\bcrohn'?s\b/i]}];function NC(a){const e=new Set;return a.forEach(t=>{const n=Re(t??"");n&&(LC.forEach(r=>{r.patterns.some(i=>i.test(n))&&e.add(r.domain)}),Ad.forEach(r=>{!r.domains||r.domains.length===0||r.patterns.some(i=>i.test(n))&&r.domains.forEach(i=>e.add(i))}))}),e}function RC(a,e){return!a.domains||a.domains.length===0||e.size===0?!0:a.domains.some(t=>e.has(t))}function PC(a,e){let t=Number.MAX_SAFE_INTEGER;for(const n of a.patterns){const r=e.match(n);r?.index!==void 0&&(t=Math.min(t,r.index))}return t===Number.MAX_SAFE_INTEGER?0:t}function IC(a){return a.replace(/\b([a-z])/g,e=>e.toUpperCase())}function wd(a){return[/\bcancer\b/i,/\bneoplasm\b/i,/\bcolon\b/i,/\brectal\b/i,/\bcolorectal\b/i,/\btumor\b/i,/\btumour\b/i,/\boncology\b/i,/\bmalignan\b/i].some(t=>t.test(a))}function MC(a,e){if(!e.some(i=>i.key==="colorectal-cancer"))return!1;const n=a.trim();return/^crc$/i.test(n)?!wd(n):!1}function Sd(a){const e=new Map,t=a.filter(n=>n.kind!=="author"&&n.kind!=="journal"&&!n.isDoi&&!n.isPmid&&!n.isLiteralBoolean);return t.forEach(n=>{if(n.matchedRules.length===0){const o=`literal:${n.cleaned.toLowerCase()}`,s=e.get(o),l=Ya(n.cleaned),c=n.cleaned.includes(" ")&&!ss.has(n.cleaned.toLowerCase())?ls(n.cleaned).filter(p=>p.length>=3&&!l.includes(p)&&!DC.has(p)&&!xd.has(p)):[],u=be([...l,...c]),d={key:o,label:IC(n.cleaned.toLowerCase()),anchor:n.cleaned,normalizedAnchor:n.cleaned.toLowerCase(),source:n.source==="builder"?"user_explicit":"auto_discovered",category:vd(o,n.cleaned),mustMatch:!0,confidence:.7,literalTerms:l,synonymTerms:[],abbreviationTerms:l.filter(p=>/^[A-Z0-9-]{2,10}$/.test(p)),titleAbstractTerms:u,meshTerms:[],sourceTerms:[n.cleaned],clause:"",note:"Kept the literal phrase because no curated synonym rule matched it.",usedInRecommendedQuery:!1};!s||n.priority<s.priority?e.set(o,{concept:d,priority:n.priority,order:n.order}):(s.concept.sourceTerms=be([...s.concept.sourceTerms,n.cleaned]),s.concept.titleAbstractTerms=be([...s.concept.titleAbstractTerms,...d.titleAbstractTerms]),s.concept.literalTerms=be([...s.concept.literalTerms,...l]),s.order=Math.min(s.order,n.order));return}const r=MC(n.cleaned,n.matchedRules),i=wd(t.map(o=>o.cleaned).join(" "));n.matchedRules.forEach(o=>{const s=e.get(o.key),l=new Set(["cancer","cancers","neoplasm","neoplasms","tumor","tumors","tumour","tumours","oncology"]),c=o.key==="generic-cancer"&&ls(n.cleaned).some(D=>!l.has(D)),u=n.cleaned.length>o.label.length*2&&!c?o.label:n.cleaned,d=Re(u),p=Ya(d),m=be([...o.titleAbstractTerms.filter(D=>/^[A-Z0-9-]{2,10}$/.test(D)),...p.filter(D=>/^[A-Z0-9-]{2,10}$/.test(D))]),h=be(o.titleAbstractTerms.filter(D=>!p.includes(D)&&!m.includes(D))),y=n.order*1e3+PC(o,n.cleaned),x=be([...p,...o.titleAbstractTerms]),T=o.key==="colorectal-cancer",F=T&&r&&!i,w=F?.6:.95;let b=o.note;T&&(F?b=`CRC interpreted as colorectal cancer, but confidence lowered due to lack of cancer context (could also mean Clinical Research Center, Cyclic Redundancy Check, etc.). ${o.note}`:b=`CRC expanded to colorectal cancer. ${o.note}`);const v={key:o.key,label:o.label,anchor:d,normalizedAnchor:d.toLowerCase(),source:n.source==="builder"?"user_explicit":"auto_discovered",category:vd(o.key,d),mustMatch:!0,confidence:w,literalTerms:p,synonymTerms:h,abbreviationTerms:m,titleAbstractTerms:x,meshTerms:o.meshTerms,sourceTerms:[d],clause:"",note:`${b} Preserved the user's original anchor phrase alongside broader synonym expansion.`,usedInRecommendedQuery:!1};!s||n.priority<s.priority?e.set(o.key,{concept:v,priority:n.priority,order:y}):(s.concept.sourceTerms=be([...s.concept.sourceTerms,d]),s.concept.titleAbstractTerms=be([...s.concept.titleAbstractTerms,...x]),s.concept.literalTerms=be([...s.concept.literalTerms,...p]),s.concept.synonymTerms=be([...s.concept.synonymTerms,...h]),s.concept.abbreviationTerms=be([...s.concept.abbreviationTerms,...m]),s.order=Math.min(s.order,y))})}),Array.from(e.values()).sort((n,r)=>n.priority!==r.priority?n.priority-r.priority:n.order-r.order).map(n=>n.concept)}const BC=[{value:"Adaptive Clinical Trial",labelZh:"\u9002\u5E94\u6027\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Address",labelZh:"\u5730\u5740/\u81F4\u8F9E"},{value:"Autobiography",labelZh:"\u81EA\u4F20",discontinued:!0},{value:"Bibliography",labelZh:"\u4E66\u76EE",discontinued:!0},{value:"Biography",labelZh:"\u4F20\u8BB0"},{value:"Case Reports",labelZh:"\u75C5\u4F8B\u62A5\u544A"},{value:"Clinical Conference",labelZh:"\u4E34\u5E8A\u4F1A\u8BAE",discontinued:!0},{value:"Clinical Study",labelZh:"\u4E34\u5E8A\u7814\u7A76"},{value:"Clinical Trial",labelZh:"\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Clinical Trial, Phase I",labelZh:"I\u671F\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Clinical Trial, Phase II",labelZh:"II\u671F\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Clinical Trial, Phase III",labelZh:"III\u671F\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Clinical Trial, Phase IV",labelZh:"IV\u671F\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Clinical Trial Protocol",labelZh:"\u4E34\u5E8A\u8BD5\u9A8C\u65B9\u6848"},{value:"Clinical Trial, Veterinary",labelZh:"\u517D\u533B\u5B66\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Collected Work",labelZh:"\u6587\u96C6"},{value:"Comment",labelZh:"\u8BC4\u8BBA"},{value:"Comparative Study",labelZh:"\u6BD4\u8F83\u7814\u7A76"},{value:"Conference Proceedings",labelZh:"\u4F1A\u8BAE\u8BBA\u6587\u96C6"},{value:"Consensus Statement",labelZh:"\u5171\u8BC6\u58F0\u660E"},{value:"Consensus Development Conference, NIH",labelZh:"NIH\u5171\u8BC6\u53D1\u5C55\u4F1A\u8BAE",discontinued:!0},{value:"Controlled Clinical Trial",labelZh:"\u5BF9\u7167\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Corrected and Republished Article",labelZh:"\u66F4\u6B63\u540E\u91CD\u53D1\u6587\u7AE0"},{value:"Dataset",labelZh:"\u6570\u636E\u96C6"},{value:"Dictionary",labelZh:"\u8BCD\u5178",discontinued:!0},{value:"Directory",labelZh:"\u540D\u5F55",discontinued:!0},{value:"Duplicate Publication",labelZh:"\u91CD\u590D\u53D1\u8868"},{value:"Editorial",labelZh:"\u793E\u8BBA"},{value:"Electronic Supplementary Materials",labelZh:"\u7535\u5B50\u8865\u5145\u6750\u6599"},{value:"English Abstract",labelZh:"\u82F1\u6587\u6458\u8981"},{value:"Equivalence Trial",labelZh:"\u7B49\u6548\u6027\u8BD5\u9A8C"},{value:"Evaluation Study",labelZh:"\u8BC4\u4F30\u7814\u7A76"},{value:"Evidence Synthesis",labelZh:"\u8BC1\u636E\u7EFC\u5408"},{value:"Expression of Concern",labelZh:"\u5173\u6CE8\u58F0\u660E"},{value:"Festschrift",labelZh:"\u7EAA\u5FF5\u6587\u96C6"},{value:"Government Publication",labelZh:"\u653F\u5E9C\u51FA\u7248\u7269",discontinued:!0},{value:"Guideline",labelZh:"\u6307\u5357"},{value:"Historical Article",labelZh:"\u5386\u53F2\u6587\u7AE0"},{value:"Interactive Tutorial",labelZh:"\u4E92\u52A8\u6559\u7A0B",discontinued:!0},{value:"Interview",labelZh:"\u8BBF\u8C08"},{value:"Introductory Journal Article",labelZh:"\u671F\u520A\u5BFC\u8BFB"},{value:"Journal Article",labelZh:"\u671F\u520A\u6587\u7AE0"},{value:"Lecture",labelZh:"\u8BB2\u5EA7"},{value:"Legal Case",labelZh:"\u6CD5\u5F8B\u6848\u4F8B",discontinued:!0},{value:"Legislation",labelZh:"\u7ACB\u6CD5",discontinued:!0},{value:"Letter",labelZh:"\u901A\u8BAF"},{value:"Meta-Analysis",labelZh:"\u835F\u8403\u5206\u6790"},{value:"Multicenter Study",labelZh:"\u591A\u4E2D\u5FC3\u7814\u7A76"},{value:"Network Meta-Analysis",labelZh:"\u7F51\u7EDC\u835F\u8403\u5206\u6790"},{value:"News",labelZh:"\u65B0\u95FB"},{value:"Newspaper Article",labelZh:"\u62A5\u7EB8\u6587\u7AE0",discontinued:!0},{value:"Observational Study",labelZh:"\u89C2\u5BDF\u6027\u7814\u7A76"},{value:"Observational Study, Veterinary",labelZh:"\u517D\u533B\u5B66\u89C2\u5BDF\u6027\u7814\u7A76"},{value:"Overall",labelZh:"\u603B\u4F53",discontinued:!0},{value:"Patient Education Handout",labelZh:"\u60A3\u8005\u6559\u80B2\u624B\u518C"},{value:"Periodical Index",labelZh:"\u671F\u520A\u7D22\u5F15",discontinued:!0},{value:"Personal Narrative",labelZh:"\u4E2A\u4EBA\u53D9\u8FF0"},{value:"Portrait",labelZh:"\u4EBA\u7269\u8096\u50CF",discontinued:!0},{value:"Practice Guideline",labelZh:"\u5B9E\u8DF5\u6307\u5357"},{value:"Pragmatic Clinical Trial",labelZh:"\u5B9E\u7528\u6027\u4E34\u5E8A\u8BD5\u9A8C"},{value:"Preprint",labelZh:"\u9884\u5370\u672C"},{value:"Published Erratum",labelZh:"\u5DF2\u53D1\u8868\u52D8\u8BEF"},{value:"Randomized Controlled Trial",labelZh:"\u968F\u673A\u5BF9\u7167\u8BD5\u9A8C"},{value:"Randomized Controlled Trial, Veterinary",labelZh:"\u517D\u533B\u5B66\u968F\u673A\u5BF9\u7167\u8BD5\u9A8C"},{value:"Research Support, American Recovery and Reinvestment Act",labelZh:"\u7F8E\u56FD\u590D\u82CF\u4E0E\u518D\u6295\u8D44\u6CD5\u6848\u8D44\u52A9\u7814\u7A76"},{value:"Research Support, N.I.H., Extramural",labelZh:"NIH\u6821\u5916\u8D44\u52A9\u7814\u7A76"},{value:"Research Support, N.I.H., Intramural",labelZh:"NIH\u6821\u5185\u8D44\u52A9\u7814\u7A76"},{value:"Research Support, Non-U.S. Gov't",labelZh:"\u975E\u7F8E\u56FD\u653F\u5E9C\u8D44\u52A9\u7814\u7A76"},{value:"Research Support, U.S. Gov't, Non-P.H.S.",labelZh:"\u7F8E\u56FD\u653F\u5E9C\u975E\u516C\u5171\u536B\u751F\u670D\u52A1\u8D44\u52A9\u7814\u7A76"},{value:"Research Support, U.S. Gov't, P.H.S.",labelZh:"\u7F8E\u56FD\u653F\u5E9C\u516C\u5171\u536B\u751F\u670D\u52A1\u8D44\u52A9\u7814\u7A76"},{value:"Retracted Publication",labelZh:"\u64A4\u7A3F\u6587\u7AE0"},{value:"Retraction Notice",labelZh:"\u64A4\u7A3F\u901A\u77E5"},{value:"Review",labelZh:"\u7EFC\u8FF0"},{value:"Scientific Integrity Review",labelZh:"\u79D1\u5B66\u8BDA\u4FE1\u5BA1\u67E5",discontinued:!0},{value:"Scoping Review",labelZh:"\u8303\u56F4\u7EFC\u8FF0"},{value:"Seminal Article",labelZh:"\u5F00\u521B\u6027\u6587\u7AE0",discontinued:!0},{value:"Systematic Review",labelZh:"\u7CFB\u7EDF\u7EFC\u8FF0"},{value:"Technical Report",labelZh:"\u6280\u672F\u62A5\u544A",discontinued:!0},{value:"Twin Study",labelZh:"\u53CC\u80DE\u80CE\u7814\u7A76"},{value:"Validation Study",labelZh:"\u9A8C\u8BC1\u7814\u7A76"},{value:"Video-Audio Media",labelZh:"\u97F3\u89C6\u9891\u5A92\u4F53"},{value:"Webcast",labelZh:"\u7F51\u7EDC\u76F4\u64AD"}];new Set(BC.map(a=>a.value));function jC(a){return Re(a.normalize("NFKC").replace(/[“”„‟]/g,'"').replace(/[‘’‚‛]/g,"'").replace(/[‐‑‒–—―]/g,"-").replace(/[＆&]/g," and ").replace(/[／]/g,"/").replace(/[，、；·•]+/g,", ").replace(/[（）]/g," "))}function qC(a){return/[A-Za-z]/.test(a)}function Td(a){return Array.from(a.matchAll(/"([^"]{2,120})"/g)).map(e=>Re(e[1]))}function $C(a){return Array.from(a.matchAll(/([A-Za-z][A-Za-z0-9\-\s]{3,80})\s+([A-Z][A-Z0-9-]{1,9})\b/g)).filter(e=>!/^(?:AND|OR|NOT)$/i.test(e[2])).flatMap(e=>[e[1],e[2]]).map(e=>Re(e))}function cs(a){const e=Re(a.replace(/^[\s,;:|\-]+/,"").replace(/[\s,;:|\-]+$/,"").replace(/^topic\s*:/i,"").replace(/^focus(?: area)?\s*:/i,"").replace(/^keywords?\s*:/i,"").replace(/^description\s*:/i,""));return!e||!qC(e)||ls(e).length===0||e.length<3&&!/^[A-Z]{2,6}$/.test(e)?null:e}function OC(a){return a.includes(" ")||a.includes("-")||a.includes("/")?"phrase":"keyword"}function UC(a,e,t){const n=a.matchedRules.length>0,r=Ga(a.cleaned),i=FC.has(a.cleaned.toLowerCase())||n,o=e||t;if(r&&r.confidence>=.95&&(!i||o))return{kind:"journal",metadataNote:`"${a.cleaned}" \u2192 detected as journal`,queryTerms:as(r.entry)};const s=Wa(a.cleaned,{hasJournalSibling:e,hitsConceptRule:n});return s?{kind:"author",metadataNote:s.note,queryTerms:s.terms}:o&&r&&r.confidence>=.8?{kind:"journal",metadataNote:`"${a.cleaned}" \u2192 detected as journal (context-supported)`,queryTerms:as(r.entry)}:{kind:a.kind}}function Ed(a){const e=Re(a.toLowerCase());if(ss.has(e))return[a];if(!/\b(?:AND|OR|NOT)\b/i.test(a))return[a];if(ds(a,["OR"]))return[a];const r=[];let i="",o=!1,s=0;for(let c=0;c<a.length;c++){const u=a[c];if(u==='"')o=!o,i+=u;else if(u==="("&&!o)s++,i+=u;else if(u===")"&&!o)s--,i+=u;else if(!o&&s===0){const d=us(a,c,["AND","NOT"]);if(d){const p=i.trim();p&&r.push(p),i="",c+=d.length-1}else i+=u}else i+=u}const l=i.trim();return l&&r.push(l),r.length>0?r:[a]}function HC(a){return/\[[^\]]+\]/.test(a)||/PMID:\s*\d+/i.test(a)?!0:/(^|\s|\()\b(AND|OR|NOT)\b(\s|\)|$)/i.test(a)}function Kr(a){return Re(a).replace(/\b(and|or|not)\b/gi,e=>e.toUpperCase())}function us(a,e,t){const n=e>0?a[e-1]:"";if(n&&/[A-Za-z0-9_]/.test(n))return null;const i=a.slice(e).match(/^(AND|OR|NOT)\b/i);if(!i)return null;const o=i[1].toUpperCase();return t.includes(o)?o:null}function ds(a,e){const t=Kr(a);let n=!1,r=0;for(let i=0;i<t.length;i+=1){const o=t[i];if(o==='"'){n=!n;continue}if(!n&&o==="("){r+=1;continue}if(!n&&o===")"){r-=1;continue}if(!n&&r===0&&us(t,i,e))return!0}return!1}function ps(a){const e=Kr(a);return!e||!/\b(?:AND|OR|NOT)\b/.test(e)?!1:ds(e,["OR"])?!0:/[()]/.test(e)&&YC(e)&&ds(e,["AND","OR","NOT"])}function _d(a){const e=Re(a);if(!e)return null;if(is(e))return{value:e,isDoi:!0,isPmid:!1,pmidValue:null};const t=os(e);if(t.isValid&&t.pmid)return{value:t.pmid,isDoi:!1,isPmid:!0,pmidValue:t.pmid};if(ps(e))return{value:Kr(e),isDoi:!1,isPmid:!1,pmidValue:null};const n=cs(e);return n?{value:n,isDoi:!1,isPmid:!1,pmidValue:null}:null}function zC(a){const e=[];let t="",n="",r=!1,i=0,o=!1;const s=()=>{const l=n.trim();if(!l){n="";return}o?e.push(l):t+=l,n=""};for(let l=0;l<a.length;l+=1){const c=a[l];if(c==='"'){r=!r,n+=c;continue}if(!r&&c==="("){i+=1,n+=c;continue}if(!r&&c===")"){i-=1,n+=c;continue}if(!r&&i===0){const u=us(a,l,["AND","OR","NOT"]);if(u){s(),u==="NOT"?o=!0:(t&&!t.endsWith(" ")&&(t+=" "),t+=`${u} `,o=!1),l+=u.length-1;continue}}n+=c}return s(),{cleaned:Re(t).replace(/\b(?:AND|OR)\b$/i,"").trim(),exclusions:e.map(l=>Re(l)).filter(Boolean)}}function Dd(a){const e=a.trim();if(!/^[A-Za-z][A-Za-z'\-.]*(?:\s+[A-Za-z][A-Za-z'\-.]*)?,\s+[A-Za-z][A-Za-z'\-.]*(?:\s+[A-Za-z]\.?)?$/.test(e))return!1;const t=e.toLowerCase().split(/[^a-z]+/).filter(Boolean);return t.length>=2&&t.every(n=>!kC.has(n))}function Fd(a){const e=a.split(/[;\n|]+/).map(n=>n.trim()).filter(Boolean),t=[];for(const n of e){const r=n.split(",").map(o=>o.trim()).filter(Boolean);let i=0;for(;i<r.length;){const o=r[i];i+1<r.length&&Dd(`${o}, ${r[i+1]}`)?(t.push(`${o}, ${r[i+1]}`),i+=2):(o.length>=2&&t.push(o),i+=1)}}return t}function JC(a){const e=jC(a),t=e.trim();if(is(t))return[{value:t,isDoi:!0,isPmid:!1,pmidValue:null}];const n=os(t);if(n.isValid&&n.pmid)return[{value:n.pmid,isDoi:!1,isPmid:!0,pmidValue:n.pmid}];if(ps(t)){const s=Kr(t);if(/\([^)]*\b(?:AND|OR|NOT)\b[^)]*\)/i.test(s))return[{value:s,isDoi:!1,isPmid:!1,pmidValue:null}]}if(HC(e)){const s=Td(e),{cleaned:l}=zC(e),c=l.replace(/"[^"]+"/g," "),u=Fd(c).flatMap(p=>Ed(p)).map(p=>p.trim()).filter(Boolean),d=[...s,...u];return be(d).map(p=>_d(p)).filter(p=>p!==null)}const r=Td(e),i=e.replace(/"[^"]+"/g," "),o=Fd(i).flatMap(Ed).map(s=>Re(s)).filter(Boolean);return be([...r,...o]).map(s=>_d(s)).filter(s=>s!==null)}function VC(a,e){return Ad.filter(t=>t.patterns.some(n=>n.test(a))&&RC(t,e))}function hs(a,e,t,n,r,i=!1,o=!1,s=!1,l=!1,c=null){if(s){const y=cs(a);return y?{raw:a,cleaned:y,kind:"phrase",source:e,priority:0,order:r,matchedRules:[],variants:[y],isDoi:!0,isPmid:!1,metadataNote:`Detected DOI: ${y}`,queryTerms:[y]}:null}if(l&&c)return{raw:a,cleaned:c,kind:"phrase",source:e,priority:0,order:r,matchedRules:[],variants:[c],isDoi:!1,isPmid:!0,metadataNote:`Detected PMID: ${c}`,queryTerms:[c]};if(ps(a)){const y=Kr(a);return{raw:a,cleaned:y,kind:"phrase",source:e,priority:0,order:r,matchedRules:[],variants:[y],isLiteralBoolean:!0,metadataNote:"Preserved literal boolean expression",queryTerms:[y]}}const u=cs(a);if(!u)return null;const d=WC(VC(u,n),u),p=d.length>0?be(d.flatMap(y=>y.titleAbstractTerms)):Ya(u),m={raw:a,cleaned:u,kind:OC(u),source:e,priority:t,order:r,matchedRules:d,variants:p},h=UC(m,i,o);return{...m,kind:h.kind,metadataNote:h.metadataNote,queryTerms:h.queryTerms}}function WC(a,e=""){if(a.length<=1)return a;let t=[...a];t.some(o=>Cd.has(o.key))&&(t=t.filter(o=>o.key!=="generic-cancer"));const r=t.some(o=>o.key==="polygenic-risk-score"),i=/\b(polygenic|genetic|genomic|genome-wide|PRS)\b/i.test(e)&&!/\b(?:and|or|versus|vs)\b/i.test(e)&&!/[;,/]/.test(e)&&!/\bclinical\b/i.test(e);return r&&i&&(t=t.filter(o=>o.key!=="prediction-model")),t}function kd(a,e){const t=a.findIndex(n=>n.cleaned.toLowerCase()===e.cleaned.toLowerCase()&&n.source===e.source);if(t===-1){a.push(e);return}if(e.priority<a[t].priority){a[t]=e;return}a[t]={...a[t],order:Math.min(a[t].order,e.order)}}function GC(a){const e=Re(a);if(!e||!e.includes(" "))return[e];if(ss.has(e.toLowerCase()))return[e];const t=e.split(/\s+/),n=[];let r=[];for(const i of t)xd.has(i.toLowerCase())?r.length>0&&(n.push(r.join(" ")),r=[]):r.push(i);return r.length>0&&n.push(r.join(" ")),n.filter(i=>i.length>=2)}function Ld({topicText:a,focusAreaText:e,notesText:t,keywordTexts:n=[]}){const r=[],i=NC([a,e,...n]);let o=0;return[{value:a,source:"topic",priority:1},{value:e,source:"focusArea",priority:2},...n.map(l=>({value:l,source:"keywords",priority:2})),{value:t,source:"notes",priority:3}].forEach(l=>{const c=l.value?.trim();if(!c)return;const u=JC(c),d=u.map((h,y)=>{const x=u.filter((w,b)=>b!==y),T=x.some(w=>{const b=Ga(w.value);return b&&b.confidence>=.9}),F=x.some(w=>w.isDoi||w.isPmid||Dd(w.value)?!0:!!Ga(w.value));return{candidate:h,hasJournalSibling:T,hasMetadataSibling:F}});d.flatMap(({candidate:h,hasJournalSibling:y,hasMetadataSibling:x})=>{o+=1;const T=hs(h.value,l.source,h.isDoi||h.isPmid?0:l.priority,i,o,y,x,h.isDoi,h.isPmid,h.pmidValue);if(!T)return[];if(T.kind!=="author"&&T.kind!=="journal"&&!T.isDoi&&!T.isPmid&&!T.isLiteralBoolean&&T.kind==="phrase"&&T.matchedRules.length===0){const F=GC(h.value);if(F.length>=1&&F[0]!==h.value.trim()){const w=F.map(b=>(o+=1,hs(b,l.source,l.priority,i,o,y,x))).filter(b=>b!=null&&b.cleaned.length>=2);if(w.length>0)return w}}return[T]}).forEach(h=>kd(r,h));const p=d.some(h=>h.hasJournalSibling),m=d.some(h=>h.hasMetadataSibling);$C(c).map(h=>(o+=1,hs(h,l.source,l.priority+1,i,o,p,m))).filter(h=>!!h).forEach(h=>kd(r,h))}),r}function YC(a){let e=0;for(const t of a)if(t==="("&&(e+=1),t===")"&&(e-=1,e<0))return!1;return e===0}const Nd=[{value:"Abstract",query:"hasabstract"},{value:"Free full text",query:"free full text[sb]"},{value:"Full text",query:"full text[sb]"}],Rd=[{value:"Associated data",query:"data[sb]"}],ZC=["Adaptive Clinical Trial","Address","Biography","Books and Documents","Case Reports","Clinical Study","Clinical Trial","Clinical Trial Protocol","Clinical Trial, Phase I","Clinical Trial, Phase II","Clinical Trial, Phase III","Clinical Trial, Phase IV","Clinical Trial, Veterinary","Collected Work","Comment","Comparative Study","Conference Proceedings","Consensus Statement","Controlled Clinical Trial","Corrected and Republished Article","Dataset","Duplicate Publication","Editorial","Electronic Supplementary Materials","English Abstract","Equivalence Trial","Evaluation Study","Evidence Synthesis","Expression of Concern","Festschrift","Guideline","Historical Article","Interview","Introductory Journal Article","Lecture","Letter","Meta-Analysis","Multicenter Study","Network Meta-Analysis","News","Observational Study","Observational Study, Veterinary","Patient Education Handout","Personal Narrative","Practice Guideline","Pragmatic Clinical Trial","Preprint","Published Erratum","Randomized Controlled Trial","Randomized Controlled Trial, Veterinary","Research Support, American Recovery and Reinvestment Act","Research Support, N.I.H., Extramural","Research Support, N.I.H., Intramural","Research Support, Non-U.S. Gov't","Research Support, U.S. Gov't, Non-P.H.S.","Research Support, U.S. Gov't, P.H.S.","Research Support, U.S. Gov't","Retracted Publication","Retraction Notice","Review","Scoping Review","Systematic Review","Twin Study","Validation Study","Video-Audio Media","Webcast"],Pd=["Afrikaans","Albanian","Arabic","Armenian","Azerbaijani","Bosnian","Bulgarian","Catalan","Chinese","Croatian","Czech","Danish","Dutch","English","Esperanto","Estonian","Finnish","French","Georgian","German","Greek, Modern","Hebrew","Hindi","Hungarian","Icelandic","Indonesian","Italian","Japanese","Kinyarwanda","Korean","Latin","Latvian","Lithuanian","Macedonian","Malay","Malayalam","Maori","Multiple Languages","Norwegian","Persian","Polish","Portuguese","Pushto","Romanian","Russian","Sanskrit","Scottish gaelic","Serbian","Slovak","Slovenian","Spanish","Swedish","Thai","Turkish","Ukrainian","Undetermined","Vietnamese","Welsh"],Id=[{value:"humans",label:"Humans",query:"humans[mh]"},{value:"animals",label:"Other Animals",query:'"animals"[mh:noexp]'}],Md=[{value:"Female",query:"female[mh]"},{value:"Male",query:"male[mh]"}],Bd=[{value:"Child: birth-18 years",query:"(infant[mh] OR child[mh] OR adolescent[mh])"},{value:"Newborn: birth-1 month",query:"infant, newborn[mh]"},{value:"Infant: birth-23 months",query:"infant[mh]"},{value:"Infant: 1-23 months",query:"infant[mh:noexp]"},{value:"Preschool Child: 2-5 years",query:"child, preschool[mh]"},{value:"Child: 6-12 years",query:"child[mh:noexp]"},{value:"Adolescent: 13-18 years",query:"adolescent[mh]"},{value:"Adult: 19+ years",query:"adult[mh]"},{value:"Young Adult: 19-24 years",query:'"young adult"[mh]'},{value:"Adult: 19-44 years",query:"adult[mh:noexp]"},{value:"Middle Aged + Aged: 45+ years",query:"(middle aged[mh] OR aged[mh])"},{value:"Middle Aged: 45-64 years",query:"middle aged[mh]"},{value:"Aged: 65+ years",query:"aged[mh]"},{value:"80 and over: 80+ years",query:"aged, 80 and over[mh]"}],jd=[{value:"Exclude preprints",query:"NOT preprint[pt]"},{value:"MEDLINE",query:"medline[sb]"}];new Set(Nd.map(a=>a.value)),new Set(Rd.map(a=>a.value)),new Set(ZC),new Set(Pd),new Set(Md.map(a=>a.value)),new Set(Bd.map(a=>a.value)),new Set(jd.map(a=>a.value)),new Map(Nd.map(a=>[a.value,a.query])),new Map(Rd.map(a=>[a.value,a.query])),new Map(Pd.map(a=>[a,a])),new Map(Id.map(a=>[a.value,a.query])),new Map(Id.map(a=>[a.value,a.label])),new Map(Md.map(a=>[a.value,a.query])),new Map(Bd.map(a=>[a.value,a.query])),new Map(jd.map(a=>[a.value,a.query]));const qd="balanced",QC={strict:4,balanced:6},$d="Title/Abstract",KC="MeSH Terms";function XC(a){const e=Re(a).replace(/"/g,"");return/[^A-Za-z0-9]/.test(e)?`"${e}"[${$d}]`:`${e}[${$d}]`}function ev(a){return`"${a}"[${KC}]`}function tv(a,e){if(e!=="strict")return a;const t=be(a.sourceTerms.flatMap(r=>Ya(r))),n=be([...t,...a.titleAbstractTerms]).slice(0,Math.max(t.length,3));return{...a,titleAbstractTerms:n}}function nv(a,e=qd){const t=tv(a,e),n=be(t.titleAbstractTerms).map(XC),r=be(t.meshTerms).map(ev);return`(${be([...r,...n]).join(" OR ")})`}function rv(a,e=qd){return a.length===0?"":a.map(t=>nv(t,e)).join(" AND ")}function av(a,e="balanced"){const t=a.trim();if(!t)throw new Error("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u82F1\u6587\u5173\u952E\u8BCD\u6216 PubMed \u68C0\u7D22\u5F0F");if(/^[\u4e00-\u9fff\u3000-\u303f\uff00-\uffef\s,.;:!?]+$/.test(t))throw new Error("\u6682\u4E0D\u652F\u6301\u7EAF\u4E2D\u6587\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528\u82F1\u6587\u5173\u952E\u8BCD");const n=iv(t);if(n)return{query:n.query,tag:n.tag,mode:"special",concepts:[]};const r=sv(t,e);if(!r.query.trim())throw new Error("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u82F1\u6587\u5173\u952E\u8BCD\u6216 PubMed \u68C0\u7D22\u5F0F");return{query:r.query,tag:e==="strict"?"High Specificity":"Recommended",mode:e,concepts:r.concepts}}function iv(a){const e=a.trim();if(is(e))return{query:`${e}[doi]`,tag:"DOI"};const t=os(e);if(t.isValid&&t.pmid)return{query:`${t.pmid}[PMID]`,tag:"PMID"};const n=/\b(?:AND|OR|NOT)\b/i.test(e),r=/\[.*?\]/.test(e);if(r)return{query:e.replace(/\b(and|or|not)\b/gi,c=>c.toUpperCase()),tag:n?"Boolean":"PubMed Syntax"};if(n&&(r||/^["]?[A-Za-z0-9\s/\-_.]+["]?(?:\s+(?:AND|OR|NOT)\s+[\"']?[A-Za-z0-9\s/\-_.]+[\"']?\s*)*[\"']?$/i.test(e)||/\(/.test(e)))try{const c=Ld({topicText:e,focusAreaText:null,notesText:null,keywordTexts:[]});if(Sd(c).length===0)return{query:e.replace(/\b(and|or|not)\b/gi,p=>p.toUpperCase()),tag:"Boolean"}}catch{return{query:e.replace(/\b(and|or|not)\b/gi,c=>c.toUpperCase()),tag:"Boolean"}}const i=ov(e);if(i)return i;const o=Wa(e,{hasJournalSibling:!1,hitsConceptRule:!1});if(o&&o.terms.length>0)return{query:o.terms.map(c=>`"${c}"[Author]`).join(" OR "),tag:"Author"};const s=Ga(e);if(s&&s.confidence>=.9){const l=as(s.entry);if(l.length>0)return{query:l.map(u=>`"${u}"[Journal]`).join(" OR "),tag:"Journal"}}return null}function ov(a){const e=a.split(/[;,]+/).map(i=>i.trim()).filter(Boolean);if(e.length>=2){const i=e.map(o=>Wa(o,{hasJournalSibling:!1,hitsConceptRule:!1}));if(i.every(Boolean))return{query:i.flatMap(o=>o?.terms??[]).map(o=>`"${o}"[Author]`).join(" OR "),tag:"Author"}}const t=Array.from(a.matchAll(/\b[A-Z][A-Za-z'\-.]+\s+[A-Z]{1,4}\b/g)).map(i=>i[0].trim()).filter(Boolean);if(t.length<2||t.join(" ")!==a.trim())return null;const r=t.map(i=>Wa(i,{hasJournalSibling:!1,hitsConceptRule:!1}));return r.every(Boolean)?{query:r.flatMap(i=>i?.terms??[]).map(i=>`"${i}"[Author]`).join(" OR "),tag:"Author"}:null}function sv(a,e){const n=Ld({topicText:a,focusAreaText:null,notesText:null,keywordTexts:[]}),r=Sd(n),i=QC[e]??6,o=r.slice(0,i);for(const l of o)l.usedInRecommendedQuery=!0;return{query:rv(o,e),concepts:o}}const lv=`.pl-zotero-batch-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}

.pl-zotero-batch-btn:hover {
  background: #dbeafe;
}

.pl-zotero-batch-btn:active {
  background: #bfdbfe;
}

.pl-zotero-batch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
`,cv="paperlens-zotero-batch-host";async function Od(a){const e=await Kn();if(e.allowed){a.dataset.busy!=="true"&&(a.disabled=!1),a.title="",a.textContent="\u{1F4DA} \u6279\u91CF\u4FDD\u5B58 Zotero",a.removeAttribute("aria-disabled");return}a.disabled=!0,a.title=e.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA",a.textContent="\u{1F4DA} \u6279\u91CF\u4FDD\u5B58 Zotero Pro",a.setAttribute("aria-disabled","true")}function uv(a){const e=document.createElement("div");e.className=cv;const t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=lv,t.appendChild(n);const r=document.createElement("button");return r.type="button",r.className="pl-zotero-batch-btn",r.textContent="\u{1F4DA} \u6279\u91CF\u4FDD\u5B58 Zotero",t.appendChild(r),Od(r),r.addEventListener("click",async i=>{i.preventDefault(),i.stopPropagation();const o=await Kn();if(!o.allowed){k.error(o.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA"),await Od(r);return}const s=a();if(s.length===0){k.info("\u8BF7\u5148\u9009\u62E9\u8981\u4FDD\u5B58\u7684\u8BBA\u6587");return}r.disabled=!0,r.dataset.busy="true";try{await Rx(s)}finally{delete r.dataset.busy,r.disabled=!1}}),e}const Ud={Q1:"Q1",Q2:"Q2",Q3:"Q3",Q4:"Q4",Unknown:"\u672A\u5339\u914D"},dv={guideline:"\u6307\u5357",meta_analysis:"Meta-analysis",review:"\u7EFC\u8FF0 / \u7CFB\u7EDF\u7EFC\u8FF0",rct:"\u968F\u673A\u5BF9\u7167\u8BD5\u9A8C",clinical_trial:"\u4E34\u5E8A\u8BD5\u9A8C",observational:"\u89C2\u5BDF\u6027\u7814\u7A76",other:"\u5176\u4ED6"},pv=["guideline","meta_analysis","review","rct","clinical_trial","observational","other"],Hd={1:"1\u533A",2:"2\u533A",3:"3\u533A",4:"4\u533A",Unknown:"\u672A\u5339\u914D"};function Za(a,e){return e<=0?0:Number((a/e).toFixed(4))}function hv(a){const e=a?.trim().toUpperCase();return e==="Q1"||e==="Q2"||e==="Q3"||e==="Q4"?e:"Unknown"}function fv(a){const e=a?.trim().replace("\u533A","");return e==="1"||e==="2"||e==="3"||e==="4"?e:"Unknown"}function mv(a){if(!Array.isArray(a)||a.length===0)return[];const e=new Set,t=[];for(const n of a){const r=n.trim();if(!r)continue;const i=r.toLowerCase();e.has(i)||(e.add(i),t.push(r))}return t}function bv(a){const e=mv(a).map(t=>t.toLowerCase());return e.some(t=>t.includes("guideline"))?"guideline":e.some(t=>t.includes("meta-analysis"))?"meta_analysis":e.some(t=>t.includes("systematic review")||t==="review"||t.endsWith(" review"))?"review":e.some(t=>t.includes("randomized controlled trial"))?"rct":e.some(t=>t.includes("clinical trial"))?"clinical_trial":e.some(t=>t.includes("observational")||t.includes("cohort")||t.includes("case-control")||t.includes("comparative study")||t.includes("cross-sectional")||t.includes("retrospective")||t.includes("prospective"))?"observational":"other"}function gv(a){const e=new Map;for(const n of a){const r=n.year;typeof r!="number"||!Number.isFinite(r)||r<1800||r>2100||e.set(r,(e.get(r)??0)+1)}const t=Array.from(e.values()).reduce((n,r)=>n+r,0);return t===0?[]:Array.from(e.entries()).map(([n,r])=>({year:n,count:r,share:Za(r,t)})).sort((n,r)=>n.year-r.year)}function yv(a){const e=new Map;for(const n of a){const r=hv(n.jcrQuartile);e.set(r,(e.get(r)??0)+1)}const t=a.length;return t===0?[]:Object.keys(Ud).map(n=>{const r=e.get(n)??0;return{key:n,label:Ud[n],count:r,share:Za(r,t)}}).filter(n=>n.count>0)}function xv(a){const e=new Map;for(const n of a){const r=bv(n.articleTypes);e.set(r,(e.get(r)??0)+1)}const t=a.length;return t===0?[]:pv.map(n=>{const r=e.get(n)??0;return{key:n,label:dv[n],count:r,share:Za(r,t)}}).filter(n=>n.count>0)}function Av(a){const e=new Map;for(const n of a){const r=fv(n.casQuartile);e.set(r,(e.get(r)??0)+1)}const t=a.length;return t===0?[]:Object.keys(Hd).map(n=>({key:n,label:Hd[n],count:e.get(n)??0,share:Za(e.get(n)??0,t)})).filter(n=>n.count>0)}function fs(a){return a.scope==="global"?"\u5168\u91CF\u7B5B\u9009\u7ED3\u679C":"\u5F53\u524D\u9875\u7ED3\u679C"}function ir(a){if(a.scope==="global"){if(a.loading&&a.sourceTotal===0&&a.analyzed===0)return"\u6B63\u5728\u8BFB\u53D6 PubMed \u5168\u91CF\u7ED3\u679C...";const e=`\u5F53\u524D\u663E\u793A ${a.visible.toLocaleString()} \u6761\uFF0C\u5DF2\u5206\u6790 ${a.analyzed.toLocaleString()}/${a.sourceTotal.toLocaleString()} \u6761`;return a.done?`${e} \xB7 \u7EDF\u8BA1\u5B8C\u6210`:a.loading?`${e} \xB7 \u6301\u7EED\u5206\u6790\u4E2D`:`${e} \xB7 \u53EF\u7EE7\u7EED\u5206\u6790\u66F4\u591A`}return`\u5F53\u524D\u9875\u5171 ${a.visible.toLocaleString()} \u6761\u53EF\u89C1\u7ED3\u679C`}function zd(a){const e=a.records,t=gv(e),n=yv(e),r=Av(e),i=xv(e),o=t[0]?.year,s=t[t.length-1]?.year,l=n.find(d=>d.key==="Q1")?.count??0,c=n.filter(d=>d.key!=="Unknown").reduce((d,p)=>d+p.count,0),u=r.filter(d=>d.key!=="Unknown").reduce((d,p)=>d+p.count,0);return{snapshot:a,yearDistribution:t,quartileDistribution:n,casDistribution:r,evidenceDistribution:i,earliestYear:o,latestYear:s,q1Count:l,matchedQuartileCount:c,matchedCasCount:u}}const Jd=qe+`
`+`/**
 * Filter Toolbar Styles \u2014 injected into Shadow DOM
 *
 * \u7B5B\u9009\u6392\u5E8F\u5DE5\u5177\u6761\u6837\u5F0F\uFF0C\u4F7F\u7528 --pl-* Design Tokens\u3002
 * \u591A\u884C\u5DE5\u5177\u6761\u5E03\u5C40\uFF0C\u907F\u514D PubMed \u7ED3\u679C\u9875\u9876\u90E8\u6A2A\u5411\u6EDA\u52A8\u3002
 */

/* \u2500\u2500 \u5BBF\u4E3B\u5143\u7D20\uFF08\u63D2\u5165\u5230 PubMed DOM \u4E2D\u7684 div\uFF09 \u2500\u2500\u2500\u2500 */
:host {
  display: block;
  width: 100%;
  background-color: var(--pl-color-white);
  border-bottom: 1px solid var(--pl-color-gray-200);
  box-shadow: var(--pl-shadow-sm);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  color: var(--pl-color-gray-700);
  line-height: 1;
  z-index: 1;
  position: relative;
}

/* \u2500\u2500 \u5DE5\u5177\u6761\u5BB9\u5668 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toolbar {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 6px;
  padding: 8px 10px;
  min-height: 48px;
  box-sizing: border-box;
  overflow: visible;
}

.pl-toolbar * {
  box-sizing: border-box;
}

.pl-toolbar-row {
  display: flex;
  align-items: center;
  gap: var(--pl-space-sm);
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.pl-toolbar-row--primary {
  align-items: center;
}

.pl-toolbar-row--optimizer {
  align-items: stretch;
}

/* \u2500\u2500 \u5206\u7EC4\u6807\u7B7E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--pl-space-xs);
  min-width: 0;
}

.pl-toolbar-group + .pl-toolbar-group {
  padding-left: var(--pl-space-sm);
  border-left: 1px solid var(--pl-color-gray-200);
}

.pl-toolbar-label {
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-semibold);
  color: var(--pl-color-gray-500);
  white-space: nowrap;
  user-select: none;
}

/* \u2500\u2500 \u6392\u5E8F\u4E0B\u62C9\u6846 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-sort-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--pl-color-white);
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  padding: 4px 24px 4px 8px;
  font-size: var(--pl-font-xs);
  font-family: var(--pl-font-sans);
  color: var(--pl-color-gray-800);
  cursor: pointer;
  line-height: 1.4;
  height: 28px;
  max-width: 190px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: border-color var(--pl-transition-fast);
}

.pl-sort-select:hover {
  border-color: var(--pl-color-primary);
}

.pl-sort-select:focus {
  outline: none;
  border-color: var(--pl-color-primary);
  box-shadow: 0 0 0 2px var(--pl-color-primary-light);
}

/* \u2500\u2500 OA \u5F00\u5173 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-oa-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.pl-oa-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pl-oa-switch {
  display: inline-block;
  width: 32px;
  height: 18px;
  background-color: var(--pl-color-gray-300);
  border-radius: 9px;
  position: relative;
  transition: background-color var(--pl-transition-fast);
  flex-shrink: 0;
}

.pl-oa-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background-color: var(--pl-color-white);
  border-radius: 50%;
  transition: transform var(--pl-transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.pl-oa-toggle input:checked + .pl-oa-switch {
  background-color: var(--pl-color-success);
}

.pl-oa-toggle input:checked + .pl-oa-switch::after {
  transform: translateX(14px);
}

.pl-oa-toggle input:focus + .pl-oa-switch {
  box-shadow: 0 0 0 2px var(--pl-color-success-light);
}

.pl-oa-text {
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-medium);
  color: var(--pl-color-gray-700);
  white-space: nowrap;
}

/* \u2500\u2500 \u5206\u533A\u6309\u94AE\uFF08Q1/Q2/Q3/Q4 / 1\u533A/2\u533A/3\u533A/4\u533A\uFF09 \u2500\u2500 */
.pl-quartile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-medium);
  font-family: var(--pl-font-sans);
  color: var(--pl-color-gray-600);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  height: 24px;
  line-height: 1;
  transition: all var(--pl-transition-fast);
}

.pl-quartile-btn:hover {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
}

.pl-quartile-btn.active {
  border-color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
  color: var(--pl-color-primary);
  font-weight: var(--pl-weight-semibold);
}

/* JCR \u5206\u533A\u6FC0\u6D3B\u6001\u989C\u8272\u53D8\u4F53 */
.pl-quartile-btn[data-q="Q1"].active {
  border-color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
  color: var(--pl-color-primary);
}

.pl-quartile-btn[data-q="Q2"].active {
  border-color: var(--pl-color-success);
  background-color: var(--pl-color-success-light);
  color: var(--pl-color-success);
}

.pl-quartile-btn[data-q="Q3"].active {
  border-color: var(--pl-color-warning);
  background-color: var(--pl-color-warning-light);
  color: var(--pl-color-warning);
}

.pl-quartile-btn[data-q="Q4"].active {
  border-color: var(--pl-color-gray-500);
  background-color: var(--pl-color-gray-100);
  color: var(--pl-color-gray-600);
}

/* \u4E2D\u79D1\u9662\u5206\u533A\u6FC0\u6D3B\u6001\u989C\u8272\u53D8\u4F53 */
.pl-quartile-btn[data-cas="1"].active {
  border-color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
  color: var(--pl-color-primary);
}

.pl-quartile-btn[data-cas="2"].active {
  border-color: var(--pl-color-success);
  background-color: var(--pl-color-success-light);
  color: var(--pl-color-success);
}

.pl-quartile-btn[data-cas="3"].active {
  border-color: var(--pl-color-warning);
  background-color: var(--pl-color-warning-light);
  color: var(--pl-color-warning);
}

.pl-quartile-btn[data-cas="4"].active {
  border-color: var(--pl-color-gray-500);
  background-color: var(--pl-color-gray-100);
  color: var(--pl-color-gray-600);
}

/* \u2500\u2500 \u5E74\u4EFD\u8F93\u5165\u6846 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-year-input {
  width: 52px;
  padding: 3px 4px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  font-size: var(--pl-font-xs);
  font-family: var(--pl-font-mono);
  color: var(--pl-color-gray-800);
  text-align: center;
  height: 24px;
  line-height: 1;
  transition: border-color var(--pl-transition-fast);
}

.pl-year-input:hover {
  border-color: var(--pl-color-primary);
}

.pl-year-input:focus {
  outline: none;
  border-color: var(--pl-color-primary);
  box-shadow: 0 0 0 2px var(--pl-color-primary-light);
}

.pl-year-input::placeholder {
  color: var(--pl-color-gray-400);
  font-family: var(--pl-font-sans);
}

.pl-year-sep {
  color: var(--pl-color-gray-400);
  font-size: var(--pl-font-xs);
}

/* \u2500\u2500 \u6062\u590D\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-restore-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-medium);
  font-family: var(--pl-font-sans);
  color: var(--pl-color-gray-600);
  cursor: pointer;
  white-space: nowrap;
  height: 26px;
  line-height: 1;
  transition: all var(--pl-transition-fast);
}

.pl-restore-btn:hover {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
}

.pl-restore-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pl-apply-filter-btn {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
  font-weight: var(--pl-weight-semibold);
}

.pl-apply-filter-btn--pending {
  background-color: var(--pl-color-primary);
  color: var(--pl-color-white);
}

.pl-apply-filter-btn--pending:hover:not(:disabled) {
  background-color: #1d4ed8;
  color: var(--pl-color-white);
}

.pl-restore-btn-icon {
  font-size: 13px;
  line-height: 1;
}

/* \u2500\u2500 \u8FDB\u5EA6\u6761 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toolbar-progress {
  width: 120px;
  height: 4px;
  background: var(--pl-color-gray-200);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.pl-toolbar-progress-fill {
  height: 100%;
  background: var(--pl-color-primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

/* \u672A\u5F00\u59CB\u65F6\u7528 indeterminate \u52A8\u753B */
.pl-toolbar-progress-fill[style*="width: 100%"] {
  animation: pl-progress-indeterminate 1.5s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    var(--pl-color-primary) 0%,
    var(--pl-color-primary) 50%,
    var(--pl-color-gray-200) 50%,
    var(--pl-color-gray-200) 100%
  );
  background-size: 200% 100%;
}

@keyframes pl-progress-indeterminate {
  0% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}

/* \u2500\u2500 \u53D6\u6D88\u7B5B\u9009\u6309\u94AE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toolbar-cancel-btn {
 display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--pl-color-gray-400);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.15s ease;
}

.pl-toolbar-cancel-btn:hover {
  background: var(--pl-color-gray-100);
  color: var(--pl-color-red-500, #ef4444);
}

/* \u2500\u2500 \u4FE1\u606F\u63D0\u793A \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-toolbar-info {
  margin-left: auto;
  font-size: 10px;
  color: var(--pl-color-gray-400);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

/* \u2500\u2500 \u5185\u8054 PubMed \u68C0\u7D22\u8BCD\u4F18\u5316 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-query-optimizer-inline {
  display: grid;
  grid-template-columns: minmax(92px, 120px) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-md);
  background-color: var(--pl-color-gray-50);
}

.pl-query-optimizer-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  justify-content: center;
  min-width: 0;
}

.pl-query-optimizer-label {
  color: var(--pl-color-gray-700);
  line-height: 1.25;
  white-space: normal;
}

.pl-query-mode-group {
  display: inline-flex;
  width: fit-content;
  padding: 2px;
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-gray-50);
}

.pl-query-mode-btn {
  height: 22px;
  padding: 0 8px;
  border: none;
  border-radius: calc(var(--pl-radius-sm) - 1px);
  background: transparent;
  color: var(--pl-color-gray-500);
  font-family: var(--pl-font-sans);
  font-size: 11px;
  font-weight: var(--pl-weight-semibold);
  cursor: pointer;
  white-space: nowrap;
}

.pl-query-mode-btn.active {
  background-color: var(--pl-color-white);
  color: var(--pl-color-primary);
  box-shadow: var(--pl-shadow-sm);
}

.pl-query-optimizer-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.pl-query-input,
.pl-query-output {
  width: 100%;
  min-width: 0;
  min-height: 66px;
  max-height: 180px;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  color: var(--pl-color-gray-800);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  line-height: 1.35;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
}

.pl-query-output {
  background-color: var(--pl-color-gray-50);
  font-family: var(--pl-font-mono);
  grid-column: 1 / -1;
}

.pl-query-input:focus,
.pl-query-output:focus {
  outline: none;
  border-color: var(--pl-color-primary);
  box-shadow: 0 0 0 2px var(--pl-color-primary-light);
}

.pl-query-action-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.pl-query-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  color: var(--pl-color-gray-600);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-semibold);
  cursor: pointer;
  white-space: nowrap;
}

.pl-query-action-btn--primary {
  border-color: var(--pl-color-primary);
  background-color: var(--pl-color-primary);
  color: var(--pl-color-white);
}

.pl-query-action-btn:hover:not(:disabled) {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
  background-color: var(--pl-color-primary-light);
}

.pl-query-action-btn--primary:hover:not(:disabled) {
  background-color: #1d4ed8;
  color: var(--pl-color-white);
}

.pl-query-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* \u2500\u2500 \u5DE5\u5177\u680F\u5BFC\u51FA\u4E0B\u62C9 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-export-menu-group {
  position: relative;
}

.pl-toolbar-export-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background-color: var(--pl-color-white);
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-md);
  box-shadow: var(--pl-shadow-lg);
  z-index: var(--pl-z-dropdown);
  padding: var(--pl-space-xs) 0;
  overflow: hidden;
}

@media (max-width: 1120px) {
  .pl-query-optimizer-inline {
    grid-template-columns: minmax(0, 1fr);
  }

  .pl-query-optimizer-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .pl-query-optimizer-body {
    grid-template-columns: minmax(180px, 1fr) auto;
  }
}

@media (max-width: 720px) {
  .pl-query-action-group {
    width: 100%;
  }

  .pl-query-optimizer-body {
    grid-template-columns: 1fr;
  }
}

.pl-toolbar-info-count {
  font-weight: var(--pl-weight-medium);
  color: var(--pl-color-gray-500);
}

/* \u2500\u2500 \u6279\u91CF\u64CD\u4F5C\u680F \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-batch-bar {
  display: none;
  align-items: center;
  gap: var(--pl-space-sm);
  padding: var(--pl-space-xs) var(--pl-space-md);
  height: 40px;
  box-sizing: border-box;
  background-color: var(--pl-color-primary-light);
  border-top: 1px solid var(--pl-color-primary-light);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  position: relative;
}

.pl-batch-count {
  font-size: var(--pl-font-sm);
  font-weight: var(--pl-weight-semibold);
  color: var(--pl-color-primary);
  white-space: nowrap;
  user-select: none;
}

.pl-batch-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  background-color: var(--pl-color-white);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-medium);
  font-family: var(--pl-font-sans);
  color: var(--pl-color-gray-600);
  cursor: pointer;
  white-space: nowrap;
  height: 26px;
  line-height: 1;
  transition: all var(--pl-transition-fast);
}

.pl-batch-btn:hover {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
  background-color: var(--pl-color-white);
}

.pl-batch-btn--primary {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
  background-color: var(--pl-color-white);
}

.pl-batch-btn--primary:hover {
  background-color: var(--pl-color-primary);
  color: var(--pl-color-white);
}

.pl-batch-export-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.pl-batch-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  min-width: 180px;
  background-color: var(--pl-color-white);
  border: 1px solid var(--pl-color-gray-200);
  border-radius: var(--pl-radius-md);
  box-shadow: var(--pl-shadow-lg);
  z-index: var(--pl-z-dropdown);
  padding: var(--pl-space-xs) 0;
  overflow: hidden;
}

.pl-batch-dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 12px;
  border: none;
  background: none;
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  font-weight: var(--pl-weight-medium);
  color: var(--pl-color-gray-700);
  cursor: pointer;
  text-align: left;
  transition: background-color var(--pl-transition-fast);
}

.pl-batch-dropdown-item:hover {
  background-color: var(--pl-color-primary-light);
  color: var(--pl-color-primary);
}

.pl-batch-dropdown-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pl-batch-dropdown-item:disabled:hover {
  background: none;
  color: var(--pl-color-gray-700);
}

/* \u2500\u2500 \u671F\u520A\u7B5B\u9009\u8F93\u5165\u6846 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-journal-input {
  width: 140px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: var(--pl-radius-sm);
  font-family: var(--pl-font-sans);
  font-size: var(--pl-font-xs);
  color: var(--pl-color-gray-800);
  background-color: var(--pl-color-white);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.pl-journal-input::placeholder {
  color: var(--pl-color-gray-400);
}

.pl-journal-input:focus {
  border-color: var(--pl-color-primary);
  box-shadow: 0 0 0 2px var(--pl-color-primary-light);
}

/* \u2500\u2500 \u7ED3\u679C\u5206\u6790\u6D6E\u7A97 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.pl-analysis-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0f172a;
  z-index: 100000;
  pointer-events: auto;
}

.pl-analysis-overlay.is-open {
  display: flex;
}

.pl-analysis-panel {
  width: min(1080px, calc(100vw - 48px));
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  background: var(--pl-color-white);
  border: 1px solid var(--pl-color-gray-200);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 18px 18px 20px;
}

.pl-analysis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pl-analysis-header-text {
  min-width: 0;
}

.pl-analysis-title {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--pl-color-gray-900);
}

.pl-analysis-subtitle {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--pl-color-gray-500);
}

.pl-analysis-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pl-analysis-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--pl-color-gray-300);
  border-radius: 8px;
  background: var(--pl-color-white);
  color: var(--pl-color-gray-700);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pl-analysis-action-btn:hover {
  border-color: var(--pl-color-primary);
  color: var(--pl-color-primary);
}

.pl-analysis-action-btn--primary {
  border-color: var(--pl-color-primary);
  background: var(--pl-color-primary);
  color: var(--pl-color-white);
}

.pl-analysis-action-btn--primary:hover {
  opacity: 0.92;
  color: var(--pl-color-white);
}

.pl-analysis-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  line-height: 1.5;
}

.pl-analysis-body {
  margin-top: 16px;
}

.pl-analysis-loading,
.pl-analysis-error,
.pl-analysis-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border: 1px dashed var(--pl-color-gray-300);
  border-radius: 12px;
  background: var(--pl-color-gray-50);
  color: var(--pl-color-gray-500);
  font-size: 13px;
  text-align: center;
}

.pl-analysis-content {
  display: grid;
  gap: 16px;
}

.pl-analysis-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.pl-analysis-metric {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--pl-color-gray-200);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.pl-analysis-metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--pl-color-gray-500);
}

.pl-analysis-metric-value {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--pl-color-gray-900);
}

.pl-analysis-metric-hint {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--pl-color-gray-500);
}

.pl-analysis-sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pl-analysis-card {
  min-width: 0;
  padding: 14px 14px 16px;
  border: 1px solid var(--pl-color-gray-200);
  border-radius: 12px;
  background: var(--pl-color-white);
}

.pl-analysis-card--chart {
  grid-column: 1 / -1;
}

.pl-analysis-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--pl-color-gray-900);
}

.pl-analysis-card-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--pl-color-gray-500);
}

.pl-analysis-year-chart {
  position: relative;
  margin-top: 12px;
  border: 1px solid var(--pl-color-gray-100);
  border-radius: 10px;
  padding: 10px 8px 4px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.pl-analysis-year-svg {
  display: block;
  width: 100%;
  height: 240px;
  overflow: visible;
}

.pl-analysis-year-guide {
  stroke: #dbeafe;
  stroke-width: 1;
}

.pl-analysis-year-guide-label,
.pl-analysis-year-label {
  fill: var(--pl-color-gray-500);
  font-size: 11px;
}

.pl-analysis-year-line {
  fill: none;
  stroke: #0284c7;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pl-analysis-year-point {
  fill: #ffffff;
  stroke: #0284c7;
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.15s ease, stroke-width 0.15s ease, fill 0.15s ease;
}

.pl-analysis-year-point:hover,
.pl-analysis-year-point.is-active,
.pl-analysis-year-point:focus {
  fill: #0ea5e9;
  stroke: #0369a1;
  stroke-width: 3;
}

.pl-analysis-year-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  min-width: 88px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  pointer-events: none;
  text-align: center;
  z-index: 2;
}

.pl-analysis-year-tooltip-year {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.82;
}

.pl-analysis-year-tooltip-count {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
}

.pl-analysis-distribution-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.pl-analysis-distribution-row {
  display: grid;
  gap: 6px;
}

.pl-analysis-distribution-label,
.pl-analysis-distribution-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  font-size: 12px;
}

.pl-analysis-distribution-label {
  justify-content: flex-start;
  color: var(--pl-color-gray-700);
  font-weight: 600;
}

.pl-analysis-distribution-value {
  color: var(--pl-color-gray-500);
}

.pl-analysis-distribution-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.pl-analysis-distribution-track {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: var(--pl-color-gray-100);
  border-radius: 999px;
}

.pl-analysis-distribution-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

@media (max-width: 900px) {
  .pl-analysis-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  .pl-analysis-header {
    flex-direction: column;
    align-items: stretch;
  }

  .pl-analysis-actions {
    justify-content: flex-end;
  }

  .pl-analysis-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .pl-analysis-sections {
    grid-template-columns: 1fr;
  }
}
`,Vd="paperlens-filter-toolbar-host",Wd="data-pl-info",Gd="paperlens:analysis-refresh",Cv="http://www.w3.org/2000/svg",Xr=760,or=220,Qa=28,ms=16,bs=32,Yd={Q1:"#0f766e",Q2:"#0284c7",Q3:"#d97706",Q4:"#475569",1:"#dc2626",2:"#16a34a",3:"#d97706",4:"#475569",Unknown:"#94a3b8",guideline:"#0f766e",meta_analysis:"#0ea5e9",review:"#2563eb",rct:"#7c3aed",clinical_trial:"#f97316",observational:"#14b8a6",other:"#94a3b8"};function vv(){const a=document.createElement("div");a.className=Vd;const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=Jd,e.appendChild(t),{host:a,shadow:e}}function wv(){const a=document.createElement("div");a.className=`${Vd}__modal-root`,a.style.position="fixed",a.style.inset="0",a.style.zIndex="2147483647",a.style.pointerEvents="none",a.style.display="block",a.style.width="auto",a.style.height="auto",a.style.background="transparent",a.style.border="0",a.style.boxShadow="none",a.style.color="inherit",a.style.lineHeight="normal";const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=`${Jd}

:host {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  width: auto !important;
  height: auto !important;
  font-size: inherit !important;
  color: inherit !important;
  line-height: normal !important;
}
`,e.appendChild(t),{host:a,shadow:e}}function Zd(a){return{sortField:a.sortField,oaOnly:a.oaOnly,jcrQuartiles:Array.from(a.jcrQuartiles),casQuartiles:Array.from(a.casQuartiles),yearMin:a.yearMin,yearMax:a.yearMax,ifMin:a.ifMin,ifMax:a.ifMax,journalQuery:a.journalQuery}}function Sv(a){return a.sortField!=="default"||a.oaOnly||a.jcrQuartiles.length>0||a.casQuartiles.length>0||a.yearMin!==void 0||a.yearMax!==void 0||a.ifMin!==void 0||a.ifMax!==void 0||!!a.journalQuery}function Qd(){try{return new URL(window.location.href).searchParams.get("term")?.trim()??""}catch{return""}}async function Tv(a){try{return await navigator.clipboard.writeText(a),!0}catch{const e=document.createElement("textarea");e.value=a,e.style.position="fixed",e.style.left="-9999px",e.style.opacity="0",document.body.appendChild(e),e.select();try{return document.execCommand("copy")}catch{return!1}finally{e.remove()}}}function Kd(a){a.addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="a"&&(e.preventDefault(),e.stopPropagation(),a.select())})}function Zt(a){a.style.height="auto",a.style.height=`${a.scrollHeight}px`}function Ev(a){const e=a.trim();if(!e)return;const t=new URL(window.location.href);t.pathname="/",t.search="",t.hash="",t.searchParams.set("term",e),window.location.assign(t.toString())}function ea(a){return Number.isFinite(a)?`${Math.round(Math.max(0,Math.min(1,a))*100)}%`:"0%"}function nt(a){a.replaceChildren()}function rt(a){return document.createElementNS(Cv,a)}function sr(a,e,t){const n=document.createElement("div");n.className="pl-analysis-metric";const r=document.createElement("div");r.className="pl-analysis-metric-label",r.textContent=a;const i=document.createElement("div");if(i.className="pl-analysis-metric-value",i.textContent=e,n.append(r,i),t){const o=document.createElement("div");o.className="pl-analysis-metric-hint",o.textContent=t,n.appendChild(o)}return n}function _v(a){return a<=10?1:Math.ceil(a/10)}function Dv(a){const e=document.createElement("section");e.className="pl-analysis-card pl-analysis-card--chart";const t=document.createElement("div");t.className="pl-analysis-card-title",t.textContent="\u7814\u7A76\u65F6\u95F4\u5206\u5E03";const n=document.createElement("div");if(n.className="pl-analysis-card-subtitle",n.textContent="\u57FA\u4E8E\u5F53\u524D\u7ED3\u679C\u96C6\u6309\u5E74\u4EFD\u805A\u5408",e.append(t,n),a.length===0){const L=document.createElement("div");return L.className="pl-analysis-empty",L.textContent="\u5F53\u524D\u7ED3\u679C\u7F3A\u5C11\u7A33\u5B9A\u7684\u5E74\u4EFD\u5143\u6570\u636E",e.appendChild(L),e}const r=document.createElement("div");r.className="pl-analysis-year-chart";const i=document.createElement("div");i.className="pl-analysis-year-tooltip",i.hidden=!0;const o=rt("svg");o.setAttribute("viewBox",`0 0 ${Xr} ${or}`),o.setAttribute("class","pl-analysis-year-svg");const s=Xr-Qa*2,l=or-ms-bs,c=Math.max(...a.map(L=>L.count),1),u=_v(a.length),d=a.map((L,R)=>{const E=a.length===1?Xr/2:Qa+s*R/(a.length-1),I=L.count/c,M=ms+l-I*l;return{...L,x:E,y:M}});for(const L of[c,Math.round(c*.5),0]){const R=c>0?L/c:0,E=ms+l-R*l,I=rt("line");I.setAttribute("x1",String(Qa)),I.setAttribute("x2",String(Xr-Qa)),I.setAttribute("y1",E.toFixed(2)),I.setAttribute("y2",E.toFixed(2)),I.setAttribute("class","pl-analysis-year-guide"),o.appendChild(I);const M=rt("text");M.textContent=String(L),M.setAttribute("x","4"),M.setAttribute("y",String(E+4)),M.setAttribute("class","pl-analysis-year-guide-label"),o.appendChild(M)}const p=d.map((L,R)=>`${R===0?"M":"L"} ${L.x.toFixed(2)} ${L.y.toFixed(2)}`).join(" "),m=[`M ${d[0].x.toFixed(2)} ${(or-bs).toFixed(2)}`,`L ${d[0].x.toFixed(2)} ${d[0].y.toFixed(2)}`,...d.slice(1).map(L=>`L ${L.x.toFixed(2)} ${L.y.toFixed(2)}`),`L ${d[d.length-1].x.toFixed(2)} ${(or-bs).toFixed(2)}`,"Z"].join(" "),h=rt("defs"),y=rt("linearGradient");y.setAttribute("id","pl-analysis-year-fill"),y.setAttribute("x1","0"),y.setAttribute("x2","0"),y.setAttribute("y1","0"),y.setAttribute("y2","1");const x=rt("stop");x.setAttribute("offset","0%"),x.setAttribute("stop-color","#0ea5e9"),x.setAttribute("stop-opacity","0.24");const T=rt("stop");T.setAttribute("offset","100%"),T.setAttribute("stop-color","#0ea5e9"),T.setAttribute("stop-opacity","0.02"),y.append(x,T),h.appendChild(y),o.appendChild(h);const F=rt("path");F.setAttribute("d",m),F.setAttribute("fill","url(#pl-analysis-year-fill)"),o.appendChild(F);const w=rt("path");w.setAttribute("d",p),w.setAttribute("class","pl-analysis-year-line"),o.appendChild(w);let b=null,v=null;const D=L=>{v&&v!==L&&v.classList.remove("is-active"),v=L,v?.classList.add("is-active")},B=(L,R,E)=>{D(R),b=E?L.year:b,i.hidden=!1,i.innerHTML=`
      <div class="pl-analysis-year-tooltip-year">${L.year}</div>
      <div class="pl-analysis-year-tooltip-count">${L.count.toLocaleString()} \u7BC7</div>
    `;const I=L.x/Xr*100,M=Math.max(12,L.y/or*100-10);i.style.left=`${I}%`,i.style.top=`${M}%`},U=()=>{b===null&&(i.hidden=!0,v&&(v.classList.remove("is-active"),v=null))};return d.forEach((L,R)=>{const E=rt("circle");E.setAttribute("cx",L.x.toFixed(2)),E.setAttribute("cy",L.y.toFixed(2)),E.setAttribute("r","4"),E.setAttribute("class","pl-analysis-year-point"),E.setAttribute("tabindex","0"),E.setAttribute("role","button"),E.setAttribute("aria-label",`${L.year} \u5E74 ${L.count.toLocaleString()} \u7BC7`);const I=rt("title");if(I.textContent=`${L.year}: ${L.count.toLocaleString()} \u7BC7`,E.appendChild(I),E.addEventListener("mouseenter",()=>{b!==null&&b!==L.year||B(L,E,!1)}),E.addEventListener("focus",()=>{b!==null&&b!==L.year||B(L,E,!1)}),E.addEventListener("mouseleave",U),E.addEventListener("blur",U),E.addEventListener("click",()=>{if(b===L.year){b=null,U();return}b=L.year,B(L,E,!0)}),o.appendChild(E),R%u===0||R===d.length-1){const M=rt("text");M.textContent=String(L.year),M.setAttribute("x",L.x.toFixed(2)),M.setAttribute("y",String(or-8)),M.setAttribute("text-anchor","middle"),M.setAttribute("class","pl-analysis-year-label"),o.appendChild(M)}}),r.addEventListener("mouseleave",U),r.append(o,i),e.appendChild(r),e}function gs(a,e,t){const n=document.createElement("section");n.className="pl-analysis-card";const r=document.createElement("div");r.className="pl-analysis-card-title",r.textContent=a;const i=document.createElement("div");if(i.className="pl-analysis-card-subtitle",i.textContent=e,n.append(r,i),t.length===0){const s=document.createElement("div");return s.className="pl-analysis-empty",s.textContent="\u5F53\u524D\u7ED3\u679C\u7F3A\u5C11\u53EF\u7EDF\u8BA1\u7684\u6837\u672C",n.appendChild(s),n}const o=document.createElement("div");o.className="pl-analysis-distribution-list";for(const s of t){const l=document.createElement("div");l.className="pl-analysis-distribution-row";const c=document.createElement("div");c.className="pl-analysis-distribution-label";const u=document.createElement("span");u.className="pl-analysis-distribution-dot",u.style.backgroundColor=Yd[s.key]??"#94a3b8";const d=document.createElement("span");d.textContent=s.label,c.append(u,d);const p=document.createElement("div");p.className="pl-analysis-distribution-value",p.textContent=`${s.count.toLocaleString()} \xB7 ${ea(s.share)}`;const m=document.createElement("div");m.className="pl-analysis-distribution-track";const h=document.createElement("div");h.className="pl-analysis-distribution-fill",h.style.width=ea(s.share),h.style.backgroundColor=Yd[s.key]??"#94a3b8",m.appendChild(h),l.append(c,p,m),o.appendChild(l)}return n.appendChild(o),n}function Xd(a){const e=document.createElement("div");e.className="pl-analysis-content";const t=document.createElement("div");t.className="pl-analysis-summary-grid";const n=a.earliestYear&&a.latestYear?a.earliestYear===a.latestYear?String(a.latestYear):`${a.earliestYear} - ${a.latestYear}`:"\u6682\u65E0",r=a.snapshot.records.length>0?ea(a.q1Count/a.snapshot.records.length):"0%",i=`${a.matchedQuartileCount.toLocaleString()}/${a.snapshot.records.length.toLocaleString()} \u6761\u5DF2\u5339\u914D`,o=`${a.matchedCasCount.toLocaleString()}/${a.snapshot.records.length.toLocaleString()} \u6761\u5DF2\u5339\u914D`,s=a.evidenceDistribution[0]?.label??"\u6682\u65E0";t.append(sr("\u6837\u672C\u6570",a.snapshot.records.length.toLocaleString(),fs(a.snapshot)),sr("\u65F6\u95F4\u8DE8\u5EA6",n,a.yearDistribution.length>0?"\u6309\u5E74\u4EFD\u7EDF\u8BA1":"\u7F3A\u5C11\u5E74\u4EFD\u6570\u636E"),sr("Q1 \u5360\u6BD4",r,`${a.q1Count.toLocaleString()} \u6761\u843D\u5165 Q1`),sr("JCR \u5339\u914D",ea(a.snapshot.records.length>0?a.matchedQuartileCount/a.snapshot.records.length:0),i),sr("\u4E2D\u79D1\u9662\u5339\u914D",ea(a.snapshot.records.length>0?a.matchedCasCount/a.snapshot.records.length:0),o),sr("\u4E3B\u5BFC\u8BC1\u636E",s,a.evidenceDistribution[0]?`${a.evidenceDistribution[0].count.toLocaleString()} \u6761`:void 0));const l=document.createElement("div");return l.className="pl-analysis-sections",l.append(Dv(a.yearDistribution),gs("JCR \u5206\u533A\u5206\u5E03","\u6309\u5F53\u524D\u7ED3\u679C\u96C6\u7684 JCR \u5206\u533A\u7EDF\u8BA1",a.quartileDistribution),gs("\u4E2D\u79D1\u9662\u5206\u533A\u5206\u5E03","\u6309\u5F53\u524D\u7ED3\u679C\u96C6\u7684\u4E2D\u79D1\u9662\u5206\u533A\u7EDF\u8BA1",a.casDistribution),gs("\u8BC1\u636E\u7C7B\u578B\u5206\u5E03","\u57FA\u4E8E PubMed publication type / article type \u5F52\u7C7B",a.evidenceDistribution)),e.append(t,l),e}function Fv(a,e,t){const{host:n,shadow:r}=vv(),{host:i,shadow:o}=wv();document.body.appendChild(i);const s={sortField:"default",oaOnly:!1,jcrQuartiles:new Set,casQuartiles:new Set},l=()=>{a(Zd(s))};let c=!1,u=null,d=null,p=!1,m=0,h=!1,y=!1;const x=document.body.style.overflow,T=document.documentElement.style.overflow,F=A=>{c=A,n.dataset.plFilterPending=A?"true":"false",u&&(u.disabled=!A,u.classList.toggle("pl-apply-filter-btn--pending",A))},w=()=>{F(!0),d&&(d.textContent="\u7B5B\u9009\u6761\u4EF6\u5DF2\u4FEE\u6539\uFF0C\u70B9\u51FB\u6267\u884C\u7B5B\u9009")},b=async()=>{if(!c)return;const A=Zd(s);if(Sv(A)){u?.setAttribute("disabled","true"),d&&(d.textContent="\u6B63\u5728\u6821\u9A8C\u9AD8\u7EA7\u7B5B\u9009\u6743\u9650...");const S=await ax();if(!S.allowed){const Tt=S.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528 PubMed \u9AD8\u7EA7\u7B5B\u9009";d&&(d.textContent=Tt),k.error(Tt),F(!0);return}}F(!1),a(A)},v=document.createElement("div");v.className="pl-toolbar";const D=document.createElement("div");D.className="pl-toolbar-group";const B=document.createElement("span");B.className="pl-toolbar-label",B.textContent="\u6392\u5E8F";const U=document.createElement("select");U.className="pl-sort-select";const L=[{value:"default",label:"PubMed \u9ED8\u8BA4\u6392\u5E8F"},{value:"impactFactor",label:"IF \u964D\u5E8F \u2193"},{value:"citationCount",label:"\u88AB\u5F15\u6570\u964D\u5E8F \u2193"},{value:"year-desc",label:"\u5E74\u4EFD\u964D\u5E8F \u2193"},{value:"year-asc",label:"\u5E74\u4EFD\u5347\u5E8F \u2191"}];for(const A of L){const S=document.createElement("option");S.value=A.value,S.textContent=A.label,U.appendChild(S)}U.addEventListener("change",()=>{s.sortField=U.value,w()}),D.append(B,U);const R=document.createElement("div");R.className="pl-toolbar-group";const E=document.createElement("label");E.className="pl-oa-toggle";const I=document.createElement("input");I.type="checkbox";const M=document.createElement("span");M.className="pl-oa-switch";const j=document.createElement("span");j.className="pl-oa-text",j.textContent="\u4EC5 OA",E.append(I,M,j),I.addEventListener("change",()=>{s.oaOnly=I.checked,w()}),R.appendChild(E);const z=document.createElement("div");z.className="pl-toolbar-group";const ce=document.createElement("span");ce.className="pl-toolbar-label",ce.textContent="JCR",z.appendChild(ce);for(const A of["Q1","Q2","Q3","Q4"]){const S=document.createElement("button");S.className="pl-quartile-btn",S.setAttribute("data-q",A),S.textContent=A,S.addEventListener("click",()=>{s.jcrQuartiles.has(A)?(s.jcrQuartiles.delete(A),S.classList.remove("active")):(s.jcrQuartiles.add(A),S.classList.add("active")),w()}),z.appendChild(S)}const ue=document.createElement("div");ue.className="pl-toolbar-group";const Je=document.createElement("span");Je.className="pl-toolbar-label",Je.textContent="\u4E2D\u79D1\u9662\u5206\u533A",ue.appendChild(Je);for(const A of["1","2","3","4"]){const S=document.createElement("button");S.className="pl-quartile-btn",S.setAttribute("data-cas",A),S.textContent=`${A}\u533A`,S.addEventListener("click",()=>{s.casQuartiles.has(A)?(s.casQuartiles.delete(A),S.classList.remove("active")):(s.casQuartiles.add(A),S.classList.add("active")),w()}),ue.appendChild(S)}const Rt=document.createElement("div");Rt.className="pl-toolbar-group";const yt=document.createElement("span");yt.className="pl-toolbar-label",yt.textContent="\u5E74\u4EFD";const J=document.createElement("input");J.className="pl-year-input",J.type="number",J.placeholder="\u8D77",J.min="1900",J.max="2100";const mn=document.createElement("span");mn.className="pl-year-sep",mn.textContent="\u2013";const G=document.createElement("input");G.className="pl-year-input",G.type="number",G.placeholder="\u6B62",G.min="1900",G.max="2100";const bn=()=>{const A=J.value?parseInt(J.value,10):void 0,S=G.value?parseInt(G.value,10):void 0;s.yearMin=A!==void 0&&!isNaN(A)&&A>=1900&&A<=2100?A:void 0,s.yearMax=S!==void 0&&!isNaN(S)&&S>=1900&&S<=2100?S:void 0,w()};J.addEventListener("input",bn),J.addEventListener("change",bn),G.addEventListener("input",bn),G.addEventListener("change",bn),Rt.append(yt,J,mn,G);const ne=document.createElement("div");ne.className="pl-toolbar-group";const Pt=document.createElement("span");Pt.className="pl-toolbar-label",Pt.textContent="IF \u8303\u56F4";const ye=document.createElement("input");ye.className="pl-year-input pl-if-input",ye.type="number",ye.placeholder="\u6700\u4F4E",ye.min="0",ye.max="500",ye.step="0.5";const at=document.createElement("span");at.className="pl-year-sep",at.textContent="\u2013";const De=document.createElement("input");De.className="pl-year-input pl-if-input",De.type="number",De.placeholder="\u6700\u9AD8",De.min="0",De.max="500",De.step="0.5";const Xt=()=>{let A=ye.value?parseFloat(ye.value):void 0,S=De.value?parseFloat(De.value):void 0;A=A!==void 0&&!isNaN(A)&&A>=0?A:void 0,S=S!==void 0&&!isNaN(S)&&S>=0?S:void 0,A!==void 0&&S!==void 0&&A>S&&([A,S]=[S,A],ye.value=String(A),De.value=String(S)),s.ifMin=A,s.ifMax=S,w()};ye.addEventListener("change",Xt),ye.addEventListener("input",Xt),De.addEventListener("change",Xt),De.addEventListener("input",Xt),ne.append(Pt,ye,at,De);const pr=document.createElement("div");pr.className="pl-toolbar-group";const hr=document.createElement("span");hr.className="pl-toolbar-label",hr.textContent="\u671F\u520A";const Fe=document.createElement("input");Fe.className="pl-journal-input",Fe.type="text",Fe.placeholder="\u8F93\u5165\u671F\u520A\u540D";const gn=()=>{const A=Fe.value.trim();s.journalQuery=A||void 0,w()};Fe.addEventListener("input",gn),Fe.addEventListener("keydown",A=>{A.key==="Enter"&&(A.preventDefault(),b())}),pr.append(hr,Fe);const ft=document.createElement("div");ft.className="pl-toolbar-group",u=document.createElement("button"),u.className="pl-restore-btn pl-apply-filter-btn",u.type="button",u.textContent="\u6267\u884C\u7B5B\u9009",u.disabled=!0,u.addEventListener("click",()=>{b()}),ft.appendChild(u);const yn=document.createElement("div");yn.className="pl-toolbar-group";const It=document.createElement("button");It.className="pl-restore-btn",It.setAttribute("data-pl-action","restore");const xt=document.createElement("span");xt.className="pl-restore-btn-icon",xt.textContent="\u21A9";const xn=document.createElement("span");xn.textContent="\u6062\u590D",It.append(xt,xn),It.addEventListener("click",()=>{U.value="default",s.sortField="default",I.checked=!1,s.oaOnly=!1;for(const A of z.querySelectorAll(".pl-quartile-btn"))A.classList.remove("active");s.jcrQuartiles.clear();for(const A of ue.querySelectorAll(".pl-quartile-btn"))A.classList.remove("active");s.casQuartiles.clear(),J.value="",G.value="",s.yearMin=void 0,s.yearMax=void 0,ye.value="",De.value="",s.ifMin=void 0,s.ifMax=void 0,Fe.value="",s.journalQuery=void 0,F(!1),l()}),yn.appendChild(It);const An=[{value:"ris",label:"RIS (EndNote/Zotero)"},{value:"bibtex",label:"BibTeX (LaTeX)"},{value:"medline",label:"MEDLINE"},{value:"csv",label:"CSV (Excel)"}],Cn=document.createElement("div");Cn.className="pl-toolbar-group pl-export-menu-group";const At=document.createElement("button");At.type="button",At.className="pl-restore-btn",At.textContent="\u6279\u91CF\u5BFC\u51FA",At.title="\u4F18\u5148\u5BFC\u51FA\u5DF2\u9009\u6587\u732E\uFF0C\u5426\u5219\u5BFC\u51FA\u5F53\u524D\u53EF\u89C1\u7ED3\u679C",At.setAttribute("aria-label","\u6279\u91CF\u5BFC\u51FA\u6587\u732E");const Ve=document.createElement("div");Ve.className="pl-toolbar-export-dropdown",Ve.style.display="none";for(const A of An){const S=document.createElement("button");S.type="button",S.className="pl-batch-dropdown-item",S.textContent=A.label,S.dataset.exportFormat=A.value,S.dataset.defaultLabel=A.label,S.addEventListener("click",async()=>{Ve.style.display="none",await np(A.value)}),Ve.appendChild(S)}At.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const S=Ve.style.display!=="none";Ve.style.display=S?"none":"block",!S&&rp(Ve)}),Cn.append(At,Ve);const vn=document.createElement("div");vn.className="pl-toolbar-group";const We=document.createElement("button");We.type="button",We.className="pl-restore-btn",We.textContent="\u7ED3\u679C\u5206\u6790",We.title="\u5206\u6790\u5F53\u524D\u7B5B\u9009\u7ED3\u679C\u7684\u5E74\u4EFD\u3001JCR \u5206\u533A\u548C\u8BC1\u636E\u7C7B\u578B\u5206\u5E03",We.disabled=!t,vn.appendChild(We);const Se=document.createElement("div");Se.className="pl-analysis-overlay",Se.setAttribute("aria-hidden","true");const Te=document.createElement("div");Te.className="pl-analysis-panel",Te.setAttribute("role","dialog"),Te.setAttribute("aria-modal","true"),Te.setAttribute("aria-label","PubMed \u7ED3\u679C\u5206\u6790");const wn=document.createElement("div");wn.className="pl-analysis-header";const fr=document.createElement("div");fr.className="pl-analysis-header-text";const mr=document.createElement("div");mr.className="pl-analysis-title",mr.textContent="\u5168\u91CF\u7ED3\u679C\u5206\u6790";const Sn=document.createElement("div");Sn.className="pl-analysis-subtitle",Sn.textContent="\u57FA\u4E8E\u5F53\u524D\u7B5B\u9009\u7ED3\u679C\u5B9E\u65F6\u7EDF\u8BA1",fr.append(mr,Sn);const br=document.createElement("div");br.className="pl-analysis-actions";const Ct=document.createElement("button");Ct.type="button",Ct.className="pl-analysis-action-btn",Ct.textContent="\u5237\u65B0";const vt=document.createElement("button");vt.type="button",vt.className="pl-analysis-action-btn pl-analysis-action-btn--primary",vt.textContent="\u5173\u95ED",br.append(Ct,vt),wn.append(fr,br);const re=document.createElement("div");re.className="pl-analysis-status";const de=document.createElement("div");de.className="pl-analysis-body",Te.append(wn,re,de),Se.appendChild(Te);const en=A=>{nt(re),re.textContent=A,nt(de);const S=document.createElement("div");S.className="pl-analysis-loading",S.textContent="\u6B63\u5728\u6574\u7406\u7ED3\u679C\u5206\u5E03...",de.appendChild(S)},tn=A=>{nt(re),re.textContent=A,nt(de);const S=document.createElement("div");S.className="pl-analysis-empty",S.textContent="\u5F53\u524D\u6CA1\u6709\u53EF\u7EDF\u8BA1\u7684\u7B5B\u9009\u7ED3\u679C",de.appendChild(S)},$s=A=>{nt(re),re.textContent=A,nt(de);const S=document.createElement("div");S.className="pl-analysis-error",S.textContent="\u7ED3\u679C\u5206\u6790\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",de.appendChild(S)},sa=A=>{nt(re),re.textContent=A,nt(de);const S=document.createElement("div");S.className="pl-analysis-error",S.textContent=A,de.appendChild(S)},nn=async(A=!1)=>{if(h){y=!0;return}if(!t){tn("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u7ED3\u679C\u5206\u6790");return}const S=++m;h=!0,y=!1,en("\u6B63\u5728\u6821\u9A8C\u7ED3\u679C\u5206\u6790\u6743\u9650...");try{const Tt=await ix();if(S!==m)return;if(!Tt.allowed){const st=Tt.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528 PubMed \u5168\u91CF\u7ED3\u679C\u5206\u6790";sa(st),k.error(st);return}en("\u6B63\u5728\u6C47\u603B\u5F53\u524D\u7B5B\u9009\u7ED3\u679C...");const Ge=await t(st=>{if(S!==m)return;if(st.records.length===0&&(st.loading||!st.done)){en(ir(st));return}if(st.records.length===0){tn(ir(st));return}const nT=zd(st);nt(re),re.textContent=`${fs(st)} \xB7 ${ir(st)}`,nt(de),de.appendChild(Xd(nT))});if(S!==m)return;if(!Ge){tn("\u5F53\u524D\u6CA1\u6709\u7ED3\u679C\u6570\u636E");return}if(Ge.records.length===0&&(Ge.loading||!Ge.done)){en(ir(Ge));return}if(Ge.records.length===0){tn(Ge?ir(Ge):"\u5F53\u524D\u6CA1\u6709\u7ED3\u679C\u6570\u636E");return}const $t=zd(Ge);nt(re),re.textContent=`${fs(Ge)} \xB7 ${ir(Ge)}`,nt(de),de.appendChild(Xd($t))}catch(Tt){if(S!==m)return;console.error("[PaperLens] result analysis render failed:",Tt),$s("\u7ED3\u679C\u5206\u6790\u6E32\u67D3\u5931\u8D25")}finally{S===m&&(h=!1,p&&y&&(y=!1,nn(A)))}},Os=()=>{p=!0,document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",Se.classList.add("is-open"),Se.setAttribute("aria-hidden","false"),nn()},Mt=()=>{p=!1,y=!1,document.body.style.overflow=x,document.documentElement.style.overflow=T,Se.classList.remove("is-open"),Se.setAttribute("aria-hidden","true")};We.addEventListener("click",()=>{Os()}),Ct.addEventListener("click",()=>{nn(!0)}),vt.addEventListener("click",Mt),Se.addEventListener("click",A=>{A.target===Se&&Mt()}),document.addEventListener("keydown",A=>{if(p){if((A.metaKey||A.ctrlKey)&&A.key.toLowerCase()==="a"){A.preventDefault(),A.stopPropagation();return}A.key==="Escape"&&p&&(A.preventDefault(),A.stopPropagation(),Mt())}},!0),n.addEventListener(Gd,()=>{p&&nn()});const gr=document.createElement("div");gr.className="pl-toolbar-progress",gr.style.display="none";const hi=document.createElement("div");hi.className="pl-toolbar-progress-fill",gr.appendChild(hi);const X=document.createElement("button");X.className="pl-toolbar-cancel-btn",X.type="button",X.title="\u505C\u6B62\u7B5B\u9009",X.style.display="none",X.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>',e&&X.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation(),e()});const it=document.createElement("span");it.className="pl-toolbar-info",it.setAttribute(Wd,""),it.textContent="\u9ED8\u8BA4\u5168\u91CF\u7B5B\u9009",d=it;const Tn=document.createElement("div");Tn.className="pl-batch-bar",Tn.style.display="none";const En=document.createElement("span");En.className="pl-batch-count",En.textContent="\u5DF2\u9009 0 \u7BC7";const Bt=document.createElement("button");Bt.type="button",Bt.className="pl-batch-btn",Bt.textContent="\u5168\u9009\u5F53\u524D\u9875";const rn=document.createElement("button");rn.type="button",rn.className="pl-batch-btn",rn.textContent="\u53D6\u6D88\u9009\u62E9";const _n=document.createElement("div");_n.className="pl-batch-export-group";const jt=document.createElement("button");jt.type="button",jt.className="pl-batch-btn pl-batch-btn--primary",jt.textContent="\u6279\u91CF\u5BFC\u51FA",jt.title="\u5BFC\u51FA\u5DF2\u9009\u6587\u732E",jt.setAttribute("aria-label","\u6279\u91CF\u5BFC\u51FA\u5DF2\u9009\u6587\u732E");const pe=document.createElement("div");pe.className="pl-batch-dropdown",pe.style.display="none";for(const A of An){const S=document.createElement("button");S.type="button",S.className="pl-batch-dropdown-item",S.textContent=A.label,S.dataset.exportFormat=A.value,S.dataset.defaultLabel=A.label,S.addEventListener("click",async()=>{pe.style.display="none",await np(A.value)}),pe.appendChild(S)}jt.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const S=pe.style.display!=="none";Ve.style.display="none",pe.style.display=S?"none":"block",!S&&rp(pe)}),_n.append(jt,pe);const qt=uv(()=>{const S=He.getInstance().getSelected(),Tt=[];for(const[Ge,$t]of S)Tt.push({pmid:Ge,title:$t.title,authors:$t.authors,doi:$t.DOI,journal:$t.journal,year:$t.year,publicationDate:$t.publicationDate,abstract:$t.abstractSnippet});return Tt});Tn.append(En,Bt,rn,_n,qt);const Dn=document.createElement("div");Dn.className="pl-query-optimizer-inline";const yr=document.createElement("div");yr.className="pl-query-optimizer-header";const Fn=document.createElement("span");Fn.className="pl-toolbar-label pl-query-optimizer-label",Fn.textContent="PubMed \u68C0\u7D22\u8BCD\u4F18\u5316";const kn=document.createElement("div");kn.className="pl-query-mode-group";let ot="balanced";const wt=document.createElement("button");wt.type="button",wt.className="pl-query-mode-btn active",wt.textContent="\u5E73\u8861";const St=document.createElement("button");St.type="button",St.className="pl-query-mode-btn",St.textContent="\u7CBE\u51C6";const fi=A=>{ot=A,wt.classList.toggle("active",A==="balanced"),St.classList.toggle("active",A==="strict")};wt.addEventListener("click",()=>fi("balanced")),St.addEventListener("click",()=>fi("strict")),kn.append(wt,St),yr.append(Fn,kn);const xr=document.createElement("div");xr.className="pl-query-optimizer-body";const xe=document.createElement("textarea");xe.className="pl-query-input",xe.rows=3,xe.placeholder="\u8F93\u5165\u5173\u952E\u8BCD / PMID / DOI / \u4F5C\u8005 / \u671F\u520A",xe.value=Qd(),Kd(xe);const Ar=document.createElement("div");Ar.className="pl-query-action-group";const P=document.createElement("button");P.type="button",P.className="pl-query-action-btn pl-query-action-btn--primary",P.textContent="\u751F\u6210";const f=document.createElement("button");f.type="button",f.className="pl-query-action-btn",f.textContent="\u590D\u5236\u68C0\u7D22\u8BCD",f.disabled=!0;const C=document.createElement("button");C.type="button",C.className="pl-query-action-btn pl-query-action-btn--primary",C.textContent="\u5E94\u7528\u68C0\u7D22",C.disabled=!0;const N=document.createElement("button");N.type="button",N.className="pl-query-action-btn",N.textContent="\u91CD\u7F6E",Ar.append(P,f,C,N);const q=document.createElement("textarea");q.className="pl-query-output",q.rows=3,q.readOnly=!0,q.placeholder="\u751F\u6210\u540E\u7684 PubMed \u68C0\u7D22\u5F0F\u4F1A\u663E\u793A\u5728\u8FD9\u91CC",Kd(q);let ee="";const ae=(A,S="")=>{Dn.classList.toggle("pl-query-optimizer-inline--locked",!A),xe.disabled=!A,wt.disabled=!A,St.disabled=!A,P.disabled=!A,A?q.placeholder="\u751F\u6210\u540E\u7684 PubMed \u68C0\u7D22\u5F0F\u4F1A\u663E\u793A\u5728\u8FD9\u91CC":(ee="",q.value="",f.disabled=!0,C.disabled=!0,q.placeholder=S||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528 PubMed \u68C0\u7D22\u8BCD\u4F18\u5316")};Wc().then(A=>ae(A.allowed,A.error)).catch(()=>ae(!1,"\u8BF7\u5148\u767B\u5F55\u8D26\u6237\uFF0C\u6216\u7A0D\u540E\u91CD\u8BD5"));const Ee=async()=>{const A=await Wc();if(!A.allowed){ae(!1,A.error),k.error(A.error??"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528 PubMed \u68C0\u7D22\u8BCD\u4F18\u5316");return}ae(!0);try{const S=av(xe.value,ot);ee=S.query,q.value=S.query,f.disabled=!1,C.disabled=!1,Zt(q),k.success("\u5DF2\u751F\u6210 PubMed \u68C0\u7D22\u5F0F")}catch(S){ee="",q.value="",f.disabled=!0,C.disabled=!0,Zt(q),k.error(S instanceof Error?S.message:"\u68C0\u7D22\u5F0F\u751F\u6210\u5931\u8D25")}};P.addEventListener("click",()=>{Ee()}),xe.addEventListener("input",()=>{ee="",q.value="",f.disabled=!0,C.disabled=!0,Zt(xe),Zt(q)}),xe.addEventListener("keydown",A=>{(A.metaKey||A.ctrlKey)&&A.key==="Enter"&&(A.preventDefault(),Ee())}),f.addEventListener("click",async()=>{if(!ee){k.info("\u8BF7\u5148\u751F\u6210\u68C0\u7D22\u8BCD");return}try{if(!await Tv(ee))throw new Error("copy failed");f.textContent="\u5DF2\u590D\u5236",k.success("\u68C0\u7D22\u8BCD\u5DF2\u590D\u5236"),setTimeout(()=>{f.textContent="\u590D\u5236\u68C0\u7D22\u8BCD"},1600)}catch{k.error("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9\u68C0\u7D22\u8BCD")}}),C.addEventListener("click",()=>{if(!ee){k.info("\u8BF7\u5148\u751F\u6210\u68C0\u7D22\u8BCD");return}Ev(ee)}),N.addEventListener("click",()=>{xe.value=Qd(),q.value="",ee="",f.disabled=!0,C.disabled=!0,Zt(xe),Zt(q),xe.focus()}),xr.append(xe,Ar,q),Dn.append(yr,xr),requestAnimationFrame(()=>{Zt(xe),Zt(q)});const ke=document.createElement("div");ke.className="pl-toolbar-row pl-toolbar-row--optimizer",ke.appendChild(Dn);const Pe=document.createElement("div");Pe.className="pl-toolbar-row pl-toolbar-row--primary",Pe.append(D,R,z,ue);const Ln=document.createElement("div");Ln.className="pl-toolbar-row pl-toolbar-row--secondary",Ln.append(pr,ne,Rt,ft,yn,Cn,vn,gr,X,it),v.append(ke,Pe,Ln),r.appendChild(v),r.appendChild(Tn),o.appendChild(Se);const oe=He.getInstance();return Bt.addEventListener("click",()=>{const A=ep();oe.selectAll(A),tp()}),rn.addEventListener("click",()=>{oe.deselectAll(),tp()}),oe.onChange(()=>{const A=oe.getCount();En.textContent=`\u5DF2\u9009 ${A} \u7BC7`,Tn.style.display=A>0?"flex":"none"}),document.addEventListener("click",A=>{Cn.contains(A.target)||(Ve.style.display="none"),_n.contains(A.target)||(pe.style.display="none")}),window.addEventListener("pagehide",()=>{document.body.style.overflow=x,document.documentElement.style.overflow=T,i.remove()},{once:!0}),n}function lr(a,e,t,n={}){const r=a.shadowRoot;if(!r)return;const i=r.querySelector(`[${Wd}]`),o=r.querySelector(gh),s=r.querySelector(".pl-toolbar-progress-fill"),l=r.querySelector(yh),c=a.dataset.plFilterPending==="true";if(l){const u=n.scope==="global"&&!n.done&&(n.loading||(n.analyzed??0)>0);l.style.display=u?"":"none"}if(n.scope==="global"){const u=n.analyzed??0,d=e>0?Math.min(u/e*100,100):0;if(n.loading&&e===0){i&&!c&&(i.textContent="\u8BFB\u53D6 PubMed \u5168\u91CF\u7ED3\u679C..."),o&&(o.style.display="block"),s&&(s.style.width="100%");return}const p=`\u5168\u91CF\u7B5B\u9009\uFF1A\u663E\u793A ${t.toLocaleString()} \xB7 \u5DF2\u5206\u6790 ${u.toLocaleString()}/${e.toLocaleString()}`;n.done?(i&&!c&&(i.textContent=`${p} \xB7 \u5B8C\u6210`),o&&(o.style.display="none")):(i&&!c&&(i.textContent=n.loading?`${p} \xB7 \u5206\u6790\u4E2D`:`${p} \xB7 \u53EF\u7EE7\u7EED\u5206\u6790\u66F4\u591A`),o&&(o.style.display="block"),s&&(s.style.width=`${Math.max(d,u>0?4:0)}%`));return}if(o&&(o.style.display="none"),e===t)i&&!c&&(i.textContent=`\u5F53\u524D\u9875 ${e} \u6761 \xB7 \u7B5B\u9009\u9ED8\u8BA4\u5168\u91CF`);else{const u=`\u663E\u793A ${t}/${e}`;i&&!c&&(i.textContent=`${u} \xB7 \u5F53\u524D\u9875`)}}function cr(a){a.dispatchEvent(new CustomEvent(Gd))}function ep(){const a=document.querySelectorAll("article.full-docsum"),e=[];for(const t of a){if(!kv(t))continue;const r=t.querySelector("a.docsum-title"),i=r?.getAttribute("data-article-id");if(!i)continue;const o=r?.textContent?.trim()??"",l=t.querySelector("span.docsum-journal-citation.full-journal-citation")?.textContent?.trim()??"",c=l.split(".")[0]?.trim()??"",u=l.match(/\b(19|20)\d{2}\b/),d=u?parseInt(u[0],10):void 0;e.push({PMID:i,title:o,journal:c,year:d})}return e}function kv(a){return a.style.display==="none"?!1:a.closest("#paperlens-global-results-root")?!0:a.offsetParent!==null||getComputedStyle(a).display!=="none"}function tp(){const a=He.getInstance();document.querySelectorAll(mh).forEach(e=>{const t=e,n=t.dataset.pmid;if(!n)return;const r=a.isSelected(n),i=t.shadowRoot;if(!i)return;const o=i.querySelector(".pl-checkbox");o&&(o.setAttribute("aria-checked",String(r)),o.setAttribute("data-pl-checked",String(r)))})}async function np(a){const e=await Et(a);if(!e.allowed){k.error(e.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u8BE5\u5BFC\u51FA\u683C\u5F0F");return}const n=He.getInstance().getSelectedPmids(),r=ep().map(s=>s.PMID).filter(s=>!!s),i=n.length>0?n:r;if(i.length===0){k.info("\u5F53\u524D\u9875\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u6587\u732E");return}const o={type:"EXPORT_PUBMED_RECORDS",payload:{pmids:i,format:a}};try{const s=await $.runtime.sendMessage(o);if(!s?.success||!s.data){k.error("\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");return}const{downloadFile:l,EXPORT_MIME_TYPES:c,EXPORT_EXTENSIONS:u}=await Promise.resolve().then(()=>Co),d=u[a]??".txt",p=c[a]??"text/plain",m=new Date().toISOString().slice(0,10),y=`paperlens_${n.length>0?"selected":"current_page"}_${m}_${i.length}\u7BC7${d}`;l(s.data,y,p),k.success(`\u5DF2\u5BFC\u51FA ${i.length} \u7BC7\u6587\u732E`)}catch{k.error("\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}function Lv(a){return a==="ris"||a==="bibtex"||a==="medline"||a==="csv"}async function rp(a){const e=Array.from(a.querySelectorAll(".pl-batch-dropdown-item[data-export-format]"));await Promise.all(e.map(async t=>{const n=t.dataset.exportFormat;if(!Lv(n))return;const r=t.dataset.defaultLabel||t.textContent||"",i=await Et(n);if(i.allowed){t.disabled=!1,t.title="",t.textContent=r,t.removeAttribute("aria-disabled");return}t.disabled=!0,t.title=i.error||"\u8BE5\u5BFC\u51FA\u683C\u5F0F\u6682\u4E0D\u53EF\u7528",t.textContent=`${r} \xB7 Pro`,t.setAttribute("aria-disabled","true")}))}const ap="http://47.102.208.204/api/v1";function ip(a){return(a?.trim()||ap).replace(/\/+$/,"")}ip(ap);const Nv=ip("http://47.102.208.204");function Rv(a,e){const t=new URL(a.startsWith("/")?a:`/${a}`,`${Nv}/`);if(e)for(const[n,r]of Object.entries(e))r&&t.searchParams.set(n,r);return t.toString()}const Pv=`.pl-selection-ai-toolbar {
  position: fixed;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  pointer-events: auto;
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.pl-selection-ai-toolbar[hidden],
.pl-selection-ai-panel[hidden] {
  display: none;
}

.pl-selection-ai-button {
  min-height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 0 9px;
  white-space: nowrap;
}

.pl-selection-ai-button:hover {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
}

.pl-selection-ai-panel {
  position: fixed;
  z-index: 2147483647;
  width: min(420px, calc(100vw - 24px));
  min-width: min(320px, calc(100vw - 24px));
  min-height: 160px;
  max-height: min(420px, calc(100vh - 24px));
  overflow: auto;
  resize: both;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  color: #111827;
  pointer-events: auto;
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.pl-selection-ai-panel__header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.pl-selection-ai-panel__title {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}

.pl-selection-ai-panel__close {
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}

.pl-selection-ai-panel__body {
  padding: 12px 14px 14px;
}

.pl-selection-ai-panel__selected {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 6px;
  background: #f9fafb;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.55;
}

.pl-selection-ai-panel__label {
  display: block;
  margin-bottom: 4px;
  color: #6b7280;
  font-weight: 700;
}

.pl-selection-ai-panel__selected-text {
  display: block;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

.pl-selection-ai-panel__result {
  white-space: pre-wrap;
}

.pl-selection-ai-panel__loading {
  color: #4b5563;
}

.pl-selection-ai-panel__error {
  color: #dc2626;
}
`,op="paperlens-selection-ai-toolbar",sp="paperlens-selection-ai-panel",lp="paperlens-selection-ai-style",cp=4e3,up=12e3,dp=600,Iv=3e3,pp=2e3,hp=10,ys=12,Mv=460,xs=420,Bv=44,As=360;let Cs="",fp=!1,Ka=null,mp=!1,bp=0,gp=0;const jv=[{action:"translate",label:"\u7FFB\u8BD1"},{action:"summarize",label:"\u603B\u7ED3"},{action:"article-abstract",label:"\u6458\u8981\u89E3\u8BFB"}];function qv(a,e){if(mp)return;mp=!0,$v(a);const t=vs(a,e),n=yp(a);Lt(t),ei(n);let r=null;const i=()=>{r&&clearTimeout(r),r=setTimeout(()=>{r=null,Ov(a,e)},80)};document.addEventListener("mouseup",i),document.addEventListener("keyup",o=>{if(o.key==="Escape"){Xa(),Lt(t),ei(n);return}i()}),document.addEventListener("selectionchange",i),window.addEventListener("scroll",()=>Lt(t),{passive:!0}),window.addEventListener("resize",()=>{Lt(t),n.hidden||ws(n)},{passive:!0})}function $v(a){if(a.getElementById(lp))return;const e=document.createElement("style");e.id=lp,e.textContent=Pv,a.appendChild(e)}function vs(a,e){const t=a.getElementById(op);if(t)return t;const n=document.createElement("div");n.id=op,n.className="pl-selection-ai-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label","\u9009\u4E2D\u6587\u672C AI \u64CD\u4F5C");for(const r of jv){const i=document.createElement("button");i.type="button",i.className="pl-selection-ai-button",i.textContent=r.label,i.dataset.action=r.action,i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),zv(a,r.action,e)}),n.appendChild(i)}return a.appendChild(n),n}function yp(a){const e=a.getElementById(sp);if(e)return e;const t=document.createElement("section");return t.id=sp,t.className="pl-selection-ai-panel",t.setAttribute("role","dialog"),t.setAttribute("aria-live","polite"),a.appendChild(t),t}function Ov(a,e){const t=vs(a,e),n=window.getSelection();if(!n||n.rangeCount===0||n.isCollapsed){Lt(t);return}if(xp(n.anchorNode)||xp(n.focusNode)){Lt(t);return}const r=Uv(n.toString());if(r.length<2){Lt(t);return}const i=n.getRangeAt(0),o=Hv(i);if(!o){Lt(t);return}r!==Cs&&Xa(),Cs=r,fp=r.length>cp,Ka=o,Ap(t,o,"toolbar"),t.hidden=!1}function Uv(a){return a.replace(/[ \t\f\v]+/g," ").replace(/\s*\n\s*/g,`
`).replace(/\n{3,}/g,`

`).trim()}function Hv(a){return Array.from(a.getClientRects()).filter(t=>t.width>0&&t.height>0)[0]??(a.getBoundingClientRect().width>0?a.getBoundingClientRect():null)}function xp(a){return!!(a instanceof Element?a:a?.parentElement)?.closest('input, textarea, select, button, [contenteditable=""], [contenteditable="true"]')}function Ap(a,e,t){const n=ys,r=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,s=Math.min(t==="toolbar"?Mv:xs,r-n*2);let l=e.left+e.width/2-s/2;l=pn(l,n,r-s-n);const c=a.getBoundingClientRect(),u=Math.min(c.height||(t==="toolbar"?Bv:As),i-n*2),d=e.bottom+hp,p=e.top-u-hp;let m;t==="toolbar"?m=p>=n?p:d:d+u<=i-n?m=d:p>=n?m=p:m=pn(d,n,i-u-n),a.style.left=`${l}px`,a.style.top=`${pn(m,n,i-u-n)}px`,t==="toolbar"&&(a.style.maxWidth=`${s}px`)}function ws(a){const e=ys,t=window.innerWidth||document.documentElement.clientWidth,n=window.innerHeight||document.documentElement.clientHeight,r=a.getBoundingClientRect(),i=Math.min(r.width||xs,t-e*2),o=Math.min(r.height||As,n-e*2),s=Number.parseFloat(a.style.left)||r.left||e,l=Number.parseFloat(a.style.top)||r.top||e;a.style.left=`${pn(s,e,t-i-e)}px`,a.style.top=`${pn(l,e,n-o-e)}px`}function pn(a,e,t){return t<e?e:Math.max(e,Math.min(a,t))}async function zv(a,e,t){const n=yp(a),r=vs(a,t),i=Cs.trim();if(!i)return;Xa();const o=++bp,s=Ka?Gv(Ka):null;if(n.dataset.plManualPosition="false",Lt(r),e==="article-abstract"){await Jv(n,i,t,s);return}if(fp||i.length>cp){Qt(n,e,i,{status:"error",error:"\u9009\u4E2D\u6587\u672C\u6700\u591A 4000 \u4E2A\u5B57\u7B26\uFF0C\u8BF7\u7F29\u77ED\u540E\u91CD\u8BD5"},s);return}Qt(n,e,i,{status:"loading"},s);try{const l=await $.runtime.sendMessage({type:"SELECTION_AI_REQUEST",payload:{text:i,action:e,context:vp(t?.())}});if(Cp(o))return;if(!l?.success){Qt(n,e,i,{status:"error",error:l?.error==="NOT_AUTHENTICATED"?"\u8BF7\u5148\u767B\u5F55 PaperLens \u8D26\u6237":l?.error||"\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},s);return}Qt(n,e,i,{status:"success",data:l.data},s)}catch{if(Cp(o))return;Qt(n,e,i,{status:"error",error:"\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},s)}}async function Jv(a,e,t,n){if(e.length>up){Qt(a,"article-abstract",e,{status:"error",error:"\u9009\u4E2D\u6458\u8981\u6700\u591A 12000 \u4E2A\u5B57\u7B26\uFF0C\u8BF7\u7F29\u77ED\u540E\u91CD\u8BD5"},n);return}Qt(a,"article-abstract",e,{status:"loading"},n);try{await qx(Vv(e,t?.())),ei(a)}catch{Qt(a,"article-abstract",e,{status:"error",error:"\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},n)}}function Vv(a,e){const t=vp(e)??{},n=t.source_url??Be(location.href,pp),r=Be(Wv(document.title),dp)||"\u9009\u4E2D\u6458\u8981\u89E3\u8BFB",i=t.title||r,o=t.paper_id??t.pmid??t.doi??n;return{...t,paper_id:Be(o,256),title:i,abstract:Be(a,up),source_url:n}}function Wv(a){return a.replace(/\s*[|-]\s*(PubMed|Science|PNAS|JAMA Network|ACS Publications).*$/i,"").trim()}function Gv(a){return new DOMRect(a.x,a.y,a.width,a.height)}function Xa(){gp=bp}function Cp(a){return a<=gp}function vp(a){if(a)return{paper_id:Be(a.paper_id,256),pmid:Be(a.pmid,64),doi:Be(a.doi,256),title:Be(a.title,dp),abstract:Be(a.abstract,Iv),journal:Be(a.journal,512),authors:a.authors?.slice(0,20).map(e=>Be(e,160)).filter(Boolean),year:a.year,publication_date:Be(a.publication_date,64),source:Be(a.source,80),source_url:Be(a.source_url??location.href,pp)}}function Be(a,e){const t=a?.trim();if(t)return t.length>e?t.slice(0,e):t}function Qt(a,e,t,n,r=Ka){const i=a.dataset.plManualPosition==="true";a.textContent="";const o=document.createElement("div");o.className="pl-selection-ai-panel__header",o.title="\u62D6\u52A8\u8C03\u6574\u4F4D\u7F6E";const s=document.createElement("p");s.className="pl-selection-ai-panel__title",s.textContent=Kv(e);const l=document.createElement("button");l.type="button",l.className="pl-selection-ai-panel__close",l.setAttribute("aria-label","\u5173\u95ED"),l.textContent="\xD7",l.addEventListener("click",()=>{Xa(),ei(a)}),o.append(s,l),Yv(a,o);const c=document.createElement("div");if(c.className="pl-selection-ai-panel__body",c.appendChild(Zv(t)),n.status==="loading"){const u=document.createElement("div");u.className="pl-selection-ai-panel__loading",u.textContent="\u6B63\u5728\u5904\u7406\u2026",c.appendChild(u)}else if(n.status==="error"){const u=document.createElement("div");u.className="pl-selection-ai-panel__error",u.textContent=n.error,c.appendChild(u)}else c.appendChild(Qv(n.data));a.append(o,c),a.hidden=!1,r&&!i?Ap(a,r,"panel"):ws(a)}function Yv(a,e){e.addEventListener("pointerdown",t=>{if(t.target?.closest("button"))return;t.preventDefault(),a.dataset.plManualPosition="true";const r=a.getBoundingClientRect(),i=t.clientX,o=t.clientY,s=c=>{const u=r.left+c.clientX-i,d=r.top+c.clientY-o,p=ys,m=window.innerWidth||document.documentElement.clientWidth,h=window.innerHeight||document.documentElement.clientHeight,y=Math.min(r.width||xs,m-p*2),x=Math.min(r.height||As,h-p*2);a.style.left=`${pn(u,p,m-y-p)}px`,a.style.top=`${pn(d,p,h-x-p)}px`},l=()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),ws(a)};window.addEventListener("pointermove",s),window.addEventListener("pointerup",l,{once:!0}),window.addEventListener("pointercancel",l,{once:!0})})}function Zv(a){const e=document.createElement("div");e.className="pl-selection-ai-panel__selected";const t=document.createElement("span");t.className="pl-selection-ai-panel__label",t.textContent="\u9009\u4E2D\u6587\u672C";const n=document.createElement("span");return n.className="pl-selection-ai-panel__selected-text",n.textContent=a,e.append(t,n),e}function Qv(a){const e=document.createElement("div");e.className="pl-selection-ai-panel__result";const t=a.result.translation??a.result.explanation??a.result.summary??a.result.text;return t?(e.textContent=t,e):(e.textContent="\u672A\u8FD4\u56DE\u53EF\u663E\u793A\u5185\u5BB9",e)}function Kv(a){switch(a){case"translate":return"\u7FFB\u8BD1";case"summarize":return"\u603B\u7ED3\u8FD9\u6BB5";case"article-abstract":return"\u6458\u8981\u89E3\u8BFB"}}function Lt(a){a.hidden=!0}function ei(a){a.hidden=!0}const Xv=qe+`
`+`/**
 * Journal Detail Card Styles
 *
 * \u671F\u520A\u8BE6\u60C5\u5361\u7247 \u2014 \u589E\u5F3A\u7248\u5E03\u5C40
 */

:host {
  display: block;
  position: relative;
  font-family: var(--pl-font-sans);
}

.pl-journal-card {
  background: var(--pl-color-bg);
  border: 1px solid var(--pl-color-border);
  border-radius: var(--pl-radius-md);
  overflow: hidden;
}

.pl-journal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--pl-color-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--pl-color-text);
}

.pl-journal-header .icon {
  font-size: 14px;
}

.pl-journal-body {
  padding: 12px 14px;
}

/* \u2500\u2500 Journal Name \u2500\u2500 */
.pl-journal-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--pl-color-text);
  margin-bottom: 4px;
  line-height: 1.3;
}

/* \u2500\u2500 ISSN \u2500\u2500 */
.pl-journal-issn {
  font-size: 11px;
  color: var(--pl-color-text-secondary);
  margin-bottom: 8px;
}

/* \u2500\u2500 Tags Row \u2500\u2500 */
.pl-journal-tags {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pl-journal-tag {
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--pl-color-border);
  background: var(--pl-color-surface);
  color: var(--pl-color-text-secondary);
}

.pl-journal-tag--jcr {
  color: #fff;
  font-weight: 700;
}
.pl-journal-tag--q1 { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.pl-journal-tag--q2 { background: #15803d; border-color: #15803d; color: #fff; }
.pl-journal-tag--q3 { background: #b45309; border-color: #b45309; color: #fff; }
.pl-journal-tag--q4 { background: #475569; border-color: #475569; color: #fff; }

.pl-journal-tag--if {
  background: #ffedd5;
  color: #7c2d12;
  border-color: #fdba74;
}

.pl-journal-tag--if5 {
  background: #fef3c7;
  color: #78350f;
  border-color: #fcd34d;
}

.pl-journal-tag--cas {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #c4b5fd;
}

.pl-journal-tag--sjr {
  font-weight: 700;
}
.pl-journal-tag--sjr.pl-journal-tag--q1 { background: #dc2626; border-color: #dc2626; color: #fff; }
.pl-journal-tag--sjr.pl-journal-tag--q2 { background: #16a34a; border-color: #16a34a; color: #fff; }
.pl-journal-tag--sjr.pl-journal-tag--q3 { background: #d97706; border-color: #d97706; color: #fff; }
.pl-journal-tag--sjr.pl-journal-tag--q4 { background: #64748b; border-color: #64748b; color: #fff; }

/* \u2500\u2500 Homepage Link \u2500\u2500 */
.pl-journal-homepage {
  margin-bottom: 8px;
}

.pl-journal-homepage-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--pl-color-primary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--pl-transition-fast);
}

.pl-journal-homepage-link:hover {
  color: var(--pl-color-primary-hover);
  text-decoration: underline;
}

.pl-journal-homepage-icon {
  font-size: 13px;
}

.pl-journal-homepage-text {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* \u2500\u2500 Info Row (country, OA, docs) \u2500\u2500 */
.pl-journal-info-row {
  font-size: 11px;
  color: var(--pl-color-text-secondary);
  margin-bottom: 6px;
  line-height: 1.5;
}

/* \u2500\u2500 Metrics Row (H-index, Cite/Doc) \u2500\u2500 */
.pl-journal-metrics-row {
  font-size: 11px;
  color: var(--pl-color-text);
  font-weight: 500;
  margin-bottom: 8px;
  line-height: 1.5;
}

/* \u2500\u2500 Trend Actions \u2500\u2500 */
.pl-trend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.pl-trend-actions-label {
  color: var(--pl-color-text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.pl-trend-open-btn {
  border: 1px solid var(--pl-color-border);
  border-radius: 5px;
  background: var(--pl-color-bg);
  color: var(--pl-color-primary);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  cursor: pointer;
}

.pl-trend-open-btn:hover {
  border-color: var(--pl-color-primary);
  background: var(--pl-color-primary-light);
}

/* \u2500\u2500 Trend Dialog \u2500\u2500 */
.pl-trend-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.22);
}

.pl-trend-dialog {
  width: min(590px, calc(100vw - 48px));
  max-height: min(88vh, 720px);
  overflow: auto;
  border: 1px solid var(--pl-color-border);
  border-radius: 10px;
  background: var(--pl-color-bg);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.24);
  padding: 14px;
}

.pl-trend-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pl-trend-dialog-title-wrap {
  min-width: 0;
}

.pl-trend-dialog-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--pl-color-text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.pl-trend-dialog-subtitle {
  color: var(--pl-color-text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.pl-trend-dialog-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--pl-color-border);
  border-radius: 50%;
  background: var(--pl-color-surface);
  color: var(--pl-color-text-secondary);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.pl-trend-dialog-close:hover {
  color: var(--pl-color-text);
  background: var(--pl-color-bg);
}

.pl-trend-dialog-canvas {
  display: block;
  width: 100%;
  cursor: crosshair;
}

.pl-no-trend {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--pl-color-text-secondary);
}

/* \u2500\u2500 IF Hover Preview \u2500\u2500 */
.pl-if-hover-preview {
  position: absolute;
  z-index: 100;
  background: var(--pl-color-bg);
  border: 1px solid var(--pl-color-border);
  border-radius: var(--pl-radius-sm);
  padding: 6px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.pl-if-hover-preview canvas {
  display: block;
}

.pl-journal-tag--if-previewable {
  cursor: help;
}

/* \u2500\u2500 Similar Journals Section \u2500\u2500 */
.pl-similar-section {
  border-top: 1px solid var(--pl-color-border);
  padding-top: 8px;
  margin-top: 4px;
}

.pl-similar-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--pl-color-text);
  margin-bottom: 6px;
}

.pl-similar-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pl-similar-item {
  padding: 5px 8px;
  border-radius: var(--pl-radius-sm);
  background: var(--pl-color-surface);
  border: 1px solid var(--pl-color-border);
  font-size: 11px;
  line-height: 1.4;
}

.pl-similar-name {
  font-weight: 600;
  color: var(--pl-color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-similar-meta {
  color: var(--pl-color-text-secondary);
  font-size: 10px;
  margin-top: 2px;
}

.pl-similar-more {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  border: none;
  border-radius: var(--pl-radius-sm);
  background: transparent;
  color: var(--pl-color-primary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--pl-transition-fast);
  font-family: inherit;
}

.pl-similar-more:hover {
  background: var(--pl-color-primary-light);
}
`,ew="paperlens-journal-detail-card",tw=260,wp=54,nw=520,rw=204,aw={"United States":"\u{1F1FA}\u{1F1F8}",US:"\u{1F1FA}\u{1F1F8}","United Kingdom":"\u{1F1EC}\u{1F1E7}",UK:"\u{1F1EC}\u{1F1E7}",China:"\u{1F1E8}\u{1F1F3}",CN:"\u{1F1E8}\u{1F1F3}",Germany:"\u{1F1E9}\u{1F1EA}",DE:"\u{1F1E9}\u{1F1EA}",Japan:"\u{1F1EF}\u{1F1F5}",JP:"\u{1F1EF}\u{1F1F5}",France:"\u{1F1EB}\u{1F1F7}",FR:"\u{1F1EB}\u{1F1F7}",Netherlands:"\u{1F1F3}\u{1F1F1}",NL:"\u{1F1F3}\u{1F1F1}",Switzerland:"\u{1F1E8}\u{1F1ED}",CH:"\u{1F1E8}\u{1F1ED}",Canada:"\u{1F1E8}\u{1F1E6}",CA:"\u{1F1E8}\u{1F1E6}",Australia:"\u{1F1E6}\u{1F1FA}",AU:"\u{1F1E6}\u{1F1FA}","South Korea":"\u{1F1F0}\u{1F1F7}",KR:"\u{1F1F0}\u{1F1F7}",India:"\u{1F1EE}\u{1F1F3}",IN:"\u{1F1EE}\u{1F1F3}",Italy:"\u{1F1EE}\u{1F1F9}",IT:"\u{1F1EE}\u{1F1F9}",Spain:"\u{1F1EA}\u{1F1F8}",ES:"\u{1F1EA}\u{1F1F8}",Brazil:"\u{1F1E7}\u{1F1F7}",BR:"\u{1F1E7}\u{1F1F7}",Sweden:"\u{1F1F8}\u{1F1EA}",SE:"\u{1F1F8}\u{1F1EA}",Norway:"\u{1F1F3}\u{1F1F4}",NO:"\u{1F1F3}\u{1F1F4}",Denmark:"\u{1F1E9}\u{1F1F0}",DK:"\u{1F1E9}\u{1F1F0}",Finland:"\u{1F1EB}\u{1F1EE}",FI:"\u{1F1EB}\u{1F1EE}",Ireland:"\u{1F1EE}\u{1F1EA}",IE:"\u{1F1EE}\u{1F1EA}",Singapore:"\u{1F1F8}\u{1F1EC}",SG:"\u{1F1F8}\u{1F1EC}",Taiwan:"\u{1F1F9}\u{1F1FC}",TW:"\u{1F1F9}\u{1F1FC}","New Zealand":"\u{1F1F3}\u{1F1FF}",NZ:"\u{1F1F3}\u{1F1FF}",Russia:"\u{1F1F7}\u{1F1FA}",RU:"\u{1F1F7}\u{1F1FA}",Israel:"\u{1F1EE}\u{1F1F1}",IL:"\u{1F1EE}\u{1F1F1}",Poland:"\u{1F1F5}\u{1F1F1}",PL:"\u{1F1F5}\u{1F1F1}",Austria:"\u{1F1E6}\u{1F1F9}",AT:"\u{1F1E6}\u{1F1F9}",Belgium:"\u{1F1E7}\u{1F1EA}",BE:"\u{1F1E7}\u{1F1EA}",Portugal:"\u{1F1F5}\u{1F1F9}",PT:"\u{1F1F5}\u{1F1F9}"};function Sp(a){return a?aw[a]??"":""}function Tp(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"")}function iw(a){if(a==null)return null;const e=String(a).trim();return/^[1-4]区?$/.test(e)?e.replace("\u533A",""):/^\d$/.test(e)&&Number(e)>=1&&Number(e)<=4?e:e==="?"?null:e}function ow(){const a=document.createElement("div");a.className=ew;const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=Xv,e.appendChild(t),{host:a,shadow:e}}function sw(a){const{host:e,shadow:t}=ow(),n=a.journal,r=a.showScimagoSJR!==!1,i=document.createElement("div");i.className="pl-journal-card";const o=document.createElement("div");o.className="pl-journal-header";const s=document.createElement("span");s.className="icon",s.textContent="\u{1F4F0}",o.appendChild(s),o.appendChild(document.createTextNode(" \u671F\u520A\u8BE6\u60C5")),i.appendChild(o);const l=document.createElement("div");l.className="pl-journal-body";const c=document.createElement("div");if(c.className="pl-journal-name",c.textContent=n.journalName,l.appendChild(c),n.issn?.length){const b=document.createElement("div");b.className="pl-journal-issn",b.textContent=`ISSN: ${n.issn.join(", ")}`,l.appendChild(b)}const u=document.createElement("div");u.className="pl-journal-tags";const d=document.createElement("span");d.className=`pl-journal-tag pl-journal-tag--jcr pl-journal-tag--${n.jcrQuartile.toLowerCase()}`,d.textContent=`JCR ${n.jcrQuartile}`,u.appendChild(d);const p=document.createElement("span");if(p.className="pl-journal-tag pl-journal-tag--if",p.textContent=`IF ${n.impactFactor.toFixed(1)}`,u.appendChild(p),a.if5yr){const b=document.createElement("span");b.className="pl-journal-tag pl-journal-tag--if5",b.textContent=`5yr IF ${a.if5yr.toFixed(1)}`,u.appendChild(b)}const m=iw(n.casQuartile);if(m){const b=document.createElement("span");b.className="pl-journal-tag pl-journal-tag--cas",b.textContent=`CAS ${m}\u533A`,u.appendChild(b)}if(r&&n.sjrQuartile){const b=document.createElement("span");b.className=`pl-journal-tag pl-journal-tag--sjr pl-journal-tag--${n.sjrQuartile.toLowerCase()}`,b.textContent=`SJR ${n.sjrQuartile}`,u.appendChild(b)}l.appendChild(u);const h=fw(n,a.trendData);c.title=`${n.journalName} \xB7 \u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF`,p.title=`IF ${n.impactFactor.toFixed(1)} \xB7 \u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF`,p.classList.add("pl-journal-tag--if-previewable"),Hn(c,{journalName:n.journalName,journal:n,getTrendData:h,delayMs:280}),Hn(p,{journalName:n.journalName,journal:n,getTrendData:h,delayMs:280});const y=a.homepageUrl;if(y){const b=document.createElement("div");b.className="pl-journal-homepage";const v=document.createElement("a");v.className="pl-journal-homepage-link",v.href=y,v.target="_blank",v.rel="noopener noreferrer",v.title=y;const D=document.createElement("span");D.className="pl-journal-homepage-icon",D.textContent="\u{1F3E0}";const B=document.createElement("span");B.className="pl-journal-homepage-text";try{const U=new URL(y);B.textContent=U.hostname.replace(/^www\./,"")}catch{B.textContent=y}v.appendChild(D),v.appendChild(B),b.appendChild(v),l.appendChild(b)}const x=[],T=Sp(n.country);if(n.country&&x.push(`${T} ${n.country}`),n.openAccess!==void 0&&x.push(n.openAccess?"\u2705 OA":"\u{1F512} \u975E OA"),n.openAccessDiamond&&x.push("\u{1F48E} Diamond OA"),n.totalDocs2025&&n.totalDocs2025>0&&x.push(`\u{1F4DD} ${Math.round(n.totalDocs2025)} \u7BC7 (2025)`),x.length>0){const b=document.createElement("div");b.className="pl-journal-info-row",b.textContent=x.join("  \xB7  "),l.appendChild(b)}if(r){const b=[];if(n.sjrHIndex&&b.push(`H-index: ${Math.round(n.sjrHIndex)}`),n.citationsPerDoc&&b.push(`Cite/Doc: ${n.citationsPerDoc.toFixed(1)}`),b.length>0){const v=document.createElement("div");v.className="pl-journal-metrics-row",v.textContent=b.join(" \xB7 "),l.appendChild(v)}}const F=!!(a.trendData&&a.trendData.length>=2),w=!!(r&&a.sjrTrendData&&a.sjrTrendData.length>=2);if(F||w){const b=document.createElement("div");b.className="pl-trend-actions";const v=document.createElement("span");v.className="pl-trend-actions-label",v.textContent="\u8D8B\u52BF",b.appendChild(v),F&&b.appendChild(Ep("IF Trend",()=>{_p({shadow:t,host:e,journalName:n.journalName,trendData:a.trendData,sjrTrendData:a.sjrTrendData},"if")})),w&&b.appendChild(Ep("SJR Trend",()=>{_p({shadow:t,host:e,journalName:n.journalName,trendData:a.trendData,sjrTrendData:a.sjrTrendData},"sjr")})),l.appendChild(b)}if(a.similarJournals&&a.similarJournals.length>0){const b=document.createElement("div");b.className="pl-similar-section";const v=document.createElement("div");v.className="pl-similar-header",v.textContent="\u{1F4D1} \u540C\u7C7B\u671F\u520A\u63A8\u8350",b.appendChild(v);const D=3,B=new Set([Tp(n.journalName)]),U=a.similarJournals.filter(L=>{const R=Tp(L.journalName);return!R||B.has(R)?!1:(B.add(R),!0)}).slice(0,5);if(U.length>0){const L=U.length>D,R=document.createElement("div");R.className="pl-similar-list";const E=I=>{R.innerHTML="";for(const M of I){const j=document.createElement("div");j.className="pl-similar-item";const z=document.createElement("div");z.className="pl-similar-name",z.textContent=M.journalName;const ce=document.createElement("div");ce.className="pl-similar-meta";const ue=[];M.impactFactor&&ue.push(`IF ${M.impactFactor.toFixed(1)}`),M.jcrQuartile&&ue.push(`JCR ${M.jcrQuartile}`),r&&M.sjrQuartile&&ue.push(`SJR ${M.sjrQuartile}`);const Je=Sp(M.country);Je&&ue.push(Je),ce.textContent=ue.join(" \xB7 "),j.appendChild(z),j.appendChild(ce),R.appendChild(j)}};if(E(U.slice(0,D)),b.appendChild(R),L){const I=document.createElement("button");I.className="pl-similar-more",I.type="button",I.textContent="\u67E5\u770B\u66F4\u591A \u25B8";let M=!1;I.addEventListener("click",()=>{M=!M,E(M?U:U.slice(0,D)),I.textContent=M?"\u6536\u8D77 \u25BE":"\u67E5\u770B\u66F4\u591A \u25B8"}),b.appendChild(I)}l.appendChild(b)}}return i.appendChild(l),t.appendChild(i),e}function Ep(a,e){const t=document.createElement("button");return t.className="pl-trend-open-btn",t.type="button",t.textContent=a,t.addEventListener("click",e),t}function _p(a,e){a.shadow.querySelector(".pl-trend-dialog-overlay")?.remove();const t=e==="sjr",n=t?"SJR Trend":"IF Trend",r=t?a.sjrTrendData:a.trendData;if(!r||r.length<2)return;const i=document.createElement("div");i.className="pl-trend-dialog-overlay";const o=document.createElement("div");o.className="pl-trend-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-label",`${a.journalName} ${n}`);const s=document.createElement("div");s.className="pl-trend-dialog-header";const l=document.createElement("div");l.className="pl-trend-dialog-title-wrap";const c=document.createElement("div");c.className="pl-trend-dialog-title",c.textContent=n;const u=document.createElement("div");u.className="pl-trend-dialog-subtitle",u.textContent=`${a.journalName} \xB7 ${lw(r)}`,l.append(c,u);const d=document.createElement("button");d.className="pl-trend-dialog-close",d.type="button",d.setAttribute("aria-label","\u5173\u95ED\u8D8B\u52BF\u56FE"),d.textContent="\xD7",s.append(l,d);const p=document.createElement("canvas");p.className="pl-trend-dialog-canvas";const m=()=>{if(cw(p),t){mw(p,r,a.host);return}uw(p,r,a.host)};d.addEventListener("click",()=>i.remove()),i.addEventListener("click",h=>{h.target===i&&i.remove()}),o.append(s,p),i.appendChild(o),a.shadow.appendChild(i),requestAnimationFrame(m)}function lw(a){const e=a[0],t=a[a.length-1];return e&&t?`${e.year} - ${t.year}`:""}function cw(a,e){a.dataset.plTrendWidth=String(nw),a.dataset.plTrendHeight=String(rw)}function Dp(a){const e=Number(a.dataset.plTrendWidth)||tw,t=Number(a.dataset.plTrendHeight)||wp;return{w:e,h:t,expanded:t>wp}}function Fp(a,e){const{w:t,h:n,expanded:r}=Dp(a),i=r?{t:14,b:26,l:34,r:14}:{t:5,b:13,l:5,r:5},o=t-i.l-i.r,s=n-i.t-i.b,l=e.map(p=>p.if),c=Math.max(...l)*1.15,u=Math.min(...l)*.85,d=c-u||1;return{w:t,h:n,expanded:r,pad:i,plotW:o,plotH:s,maxV:c,minV:u,range:d,xScale:p=>i.l+p/(e.length-1)*o,yScale:p=>i.t+(1-(p-u)/d)*s}}function uw(a,e,t){ti(a,e,t);const n=a;n._ifTrendHandler&&(a.removeEventListener("mousemove",n._ifTrendHandler),a.removeEventListener("mouseleave",n._ifTrendHandler));const r=dw(a,e,t);n._ifTrendHandler=r,a.addEventListener("mousemove",r),a.addEventListener("mouseleave",r)}function ti(a,e,t,n=-1){const r=a.getContext("2d");if(!r||e.length<2)return;const i=window.devicePixelRatio||1,o=Fp(a,e),{w:s,h:l,expanded:c,pad:u,minV:d,range:p,xScale:m,yScale:h}=o;a.width=s*i,a.height=l*i,a.style.width="100%",a.style.height=`${l}px`,r.scale(i,i);const y=ta("--pl-color-primary","#2563eb",t),x=ta("--pl-color-text-secondary","#9ca3af",t),T=ta("--pl-color-border","#e5e7eb",t);if(c){r.strokeStyle=T,r.lineWidth=.6,r.font="10px -apple-system, BlinkMacSystemFont, sans-serif",r.fillStyle=x,r.textAlign="right",r.textBaseline="middle";for(let b=0;b<=3;b++){const v=d+p/3*b,D=h(v);r.beginPath(),r.moveTo(u.l,D),r.lineTo(s-u.r,D),r.stroke(),r.fillText(v.toFixed(v>=10?1:2),u.l-5,D)}}const F=r.createLinearGradient(0,0,0,l);F.addColorStop(0,"rgba(37, 99, 235, 0.12)"),F.addColorStop(1,"rgba(37, 99, 235, 0)"),r.beginPath(),e.forEach((b,v)=>{const D=m(v),B=h(b.if);v===0?r.moveTo(D,B):r.lineTo(D,B)}),r.lineTo(m(e.length-1),l-u.b),r.lineTo(u.l,l-u.b),r.closePath(),r.fillStyle=F,r.fill(),r.strokeStyle=y,r.lineWidth=1.5,r.beginPath(),e.forEach((b,v)=>{const D=m(v),B=h(b.if);v===0?r.moveTo(D,B):r.lineTo(D,B)}),r.stroke(),r.font=c?"10px -apple-system, BlinkMacSystemFont, sans-serif":"8px -apple-system, BlinkMacSystemFont, sans-serif",r.textAlign="center";const w=Np(r,{years:e.map(b=>b.year),plotW:o.plotW,expanded:c});e.forEach((b,v)=>{const D=m(v),B=h(b.if);r.fillStyle=y,r.beginPath(),r.arc(D,B,v===n?5:2.5,0,Math.PI*2),r.fill(),v===n&&(r.strokeStyle="#ffffff",r.lineWidth=1.8,r.stroke()),w.has(v)&&(r.fillStyle=x,r.fillText(String(b.year),D,l-(c?7:1)))}),c&&Lp(r,{data:e.map((b,v)=>({value:b.if,x:m(v),y:h(b.if)})),w:s,h:l,pad:u,color:x,formatter:pw}),n>=0&&kp(r,{label:`${e[n].year}: IF ${e[n].if.toFixed(2)}`,x:m(n),y:h(e[n].if),w:s})}function dw(a,e,t){let n=-1;return r=>{if(r.type==="mouseleave"){n=-1,ti(a,e,t);return}const i=Fp(a,e),o=a.getBoundingClientRect(),s=(r.clientX-o.left)*(i.w/o.width),l=(r.clientY-o.top)*(i.h/o.height);let c=-1,u=1/0;for(let d=0;d<e.length;d++){const p=i.xScale(d),m=i.yScale(e[d].if),h=Math.hypot(s-p,l-m);h<u&&(u=h,c=d)}if(u>(i.expanded?18:24)||c<0){n!==-1&&(n=-1,ti(a,e,t));return}c!==n&&(n=c,ti(a,e,t,c))}}function kp(a,e){a.save(),a.font="10px -apple-system, BlinkMacSystemFont, sans-serif";const t=a.measureText(e.label).width+12,n=18;let r=e.x-t/2,i=e.y-n-8;i<2&&(i=e.y+10),r<2&&(r=2),r+t>e.w-2&&(r=e.w-t-2),a.fillStyle="#1f2937",a.beginPath(),a.roundRect(r,i,t,n,3),a.fill(),a.fillStyle="#ffffff",a.textAlign="center",a.textBaseline="middle",a.fillText(e.label,r+t/2,i+n/2),a.restore()}function Lp(a,e){a.save(),a.font="9px -apple-system, BlinkMacSystemFont, sans-serif",a.fillStyle=e.color,a.textAlign="center",a.textBaseline="middle";for(const t of e.data){const n=e.formatter(t.value),r=a.measureText(n).width;let i=t.x;i-r/2<e.pad.l&&(i=e.pad.l+r/2),i+r/2>e.w-e.pad.r&&(i=e.w-e.pad.r-r/2);let s=t.y-e.pad.t<14?t.y+13:t.y-12;s=Math.max(e.pad.t+8,Math.min(e.h-e.pad.b-8,s)),a.fillText(n,i,s)}a.restore()}function Np(a,e){const{years:t,plotW:n,expanded:r}=e,i=t.length;if(i<=2)return new Set(t.map((d,p)=>p));const o=t.reduce((d,p)=>Math.max(d,a.measureText(String(p)).width),0),l=Math.max(2,Math.floor(n/Math.max(1,o+(r?12:10))));if(i<=l)return new Set(t.map((d,p)=>p));const c=Math.max(1,Math.ceil((i-1)/Math.max(1,l-1))),u=new Set([0,i-1]);for(let d=0;d<i;d+=c)u.add(d);return u}function pw(a){return a>=10?a.toFixed(1):a.toFixed(2).replace(/\.?0+$/,"")}function hw(a){return a>=10?a.toFixed(1):a.toFixed(2).replace(/\.?0+$/,"")}function fw(a,e){let t=e&&e.length>=2?e:void 0,n=null;return()=>{if(t)return Promise.resolve(t);if(n)return n;const r=$.runtime.sendMessage({type:"GET_JOURNAL_TREND_DATA",payload:{normalizedName:a.normalizedName,journalName:a.journalName}}).then(i=>{const o=i?.success&&Array.isArray(i.data?.trendData)?i.data.trendData:[];return o.length>=2&&(t=o),n=null,o}).catch(()=>(n=null,[]));return n=r,r}}const Rp={Q1:"rgba(34, 197, 94, 0.10)",Q2:"rgba(59, 130, 246, 0.10)",Q3:"rgba(251, 191, 36, 0.10)",Q4:"rgba(239, 68, 68, 0.10)"};function mw(a,e,t){ni(a,e,t);const n=a;n._sjrTrendHandler&&(a.removeEventListener("mousemove",n._sjrTrendHandler),a.removeEventListener("mouseleave",n._sjrTrendHandler));const r=bw(a,e,t);n._sjrTrendHandler=r,a.addEventListener("mousemove",r),a.addEventListener("mouseleave",r)}function Pp(a,e){const{w:t,h:n,expanded:r}=Dp(a),i=r?{t:14,b:26,l:34,r:14}:{t:5,b:13,l:5,r:5},o=t-i.l-i.r,s=n-i.t-i.b,l=e.map(p=>p.sjr),c=Math.max(...l)*1.15,u=Math.min(...l)*.85,d=c-u||1;return{w:t,h:n,expanded:r,pad:i,plotW:o,plotH:s,maxV:c,minV:u,range:d,xScale:p=>i.l+p/(e.length-1)*o,yScale:p=>i.t+(1-(p-u)/d)*s}}function ni(a,e,t,n=-1){const r=a.getContext("2d");if(!r||e.length<2)return;const i=window.devicePixelRatio||1,o=Pp(a,e),{w:s,h:l,expanded:c,pad:u,plotH:d,xScale:p,yScale:m}=o;a.width=s*i,a.height=l*i,a.style.width="100%",a.style.height=`${l}px`,r.scale(i,i);const h="#ea580c",y=ta("--pl-color-text-secondary","#9ca3af",t),x=ta("--pl-color-border","#e5e7eb",t);if(c){r.strokeStyle=x,r.lineWidth=.6,r.font="10px -apple-system, BlinkMacSystemFont, sans-serif",r.fillStyle=y,r.textAlign="right",r.textBaseline="middle";for(let w=0;w<=3;w++){const b=o.minV+o.range/3*w,v=m(b);r.beginPath(),r.moveTo(u.l,v),r.lineTo(s-u.r,v),r.stroke(),r.fillText(b.toFixed(b>=10?1:2),u.l-5,v)}}if(e.length>2){let w=0;for(;w<e.length;){const b=e[w].sjrQuartile;if(b&&Rp[b]){let v=w;for(;v<e.length&&e[v].sjrQuartile===b;)v++;const D=w===0?p(0):(p(w-1)+p(w))/2,B=v-1,U=B>=e.length-1?p(e.length-1):(p(B)+p(B+1))/2;r.fillStyle=Rp[b],r.fillRect(D,u.t,U-D,d),w=v}else w++}}const T=r.createLinearGradient(0,0,0,l);T.addColorStop(0,"rgba(234, 88, 12, 0.12)"),T.addColorStop(1,"rgba(234, 88, 12, 0)"),r.beginPath(),e.forEach((w,b)=>{const v=p(b),D=m(w.sjr);b===0?r.moveTo(v,D):r.lineTo(v,D)}),r.lineTo(p(e.length-1),l-u.b),r.lineTo(u.l,l-u.b),r.closePath(),r.fillStyle=T,r.fill(),r.strokeStyle=h,r.lineWidth=1.5,r.beginPath(),e.forEach((w,b)=>{const v=p(b),D=m(w.sjr);b===0?r.moveTo(v,D):r.lineTo(v,D)}),r.stroke(),r.font=c?"10px -apple-system, BlinkMacSystemFont, sans-serif":"8px -apple-system, BlinkMacSystemFont, sans-serif",r.textAlign="center";const F=Np(r,{years:e.map(w=>w.year),plotW:o.plotW,expanded:c});if(e.forEach((w,b)=>{const v=p(b),D=m(w.sjr);r.fillStyle=h,r.beginPath(),r.arc(v,D,b===n?5:2.5,0,Math.PI*2),r.fill(),b===n&&(r.strokeStyle="#ffffff",r.lineWidth=1.8,r.stroke()),F.has(b)&&(r.fillStyle=y,r.fillText(String(w.year),v,l-(c?7:1)))}),c&&Lp(r,{data:e.map((w,b)=>({value:w.sjr,x:p(b),y:m(w.sjr)})),w:s,h:l,pad:u,color:y,formatter:hw}),n>=0){const w=e[n],b=w.sjrQuartile?` \xB7 ${w.sjrQuartile}`:"";kp(r,{label:`${w.year}: SJR ${w.sjr.toFixed(2)}${b}`,x:p(n),y:m(w.sjr),w:s})}}function bw(a,e,t){let n=-1;return r=>{if(r.type==="mouseleave"){n=-1,ni(a,e,t);return}const i=Pp(a,e),o=a.getBoundingClientRect(),s=(r.clientX-o.left)*(i.w/o.width),l=(r.clientY-o.top)*(i.h/o.height);let c=-1,u=1/0;for(let d=0;d<e.length;d++){const p=i.xScale(d),m=i.yScale(e[d].sjr),h=Math.hypot(s-p,l-m);h<u&&(u=h,c=d)}if(u>(i.expanded?18:24)||c<0){n!==-1&&(n=-1,ni(a,e,t));return}c!==n&&(n=c,ni(a,e,t,c))}}function ta(a,e,t){try{const n=t??document.documentElement;return getComputedStyle(n).getPropertyValue(a).trim()||e}catch{return e}}const gw=`.pl-export-save-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.pl-export-save-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}

.pl-export-save-card-header-icon {
  font-size: 14px;
}

.pl-export-save-card-body {
  padding: 12px 14px;
}

.pl-export-save-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.pl-export-formats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.pl-export-format-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pl-export-format-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.pl-export-format-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pl-zotero-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 34px;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.pl-zotero-save-btn:hover {
  background: #2563eb;
}

.pl-zotero-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pl-zotero-last-target {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
  text-align: center;
}
`,yw="paperlens-export-save-card",Ss="paperlens_zotero_last_collection",Ts="paperlens_zotero_last_collection_name",xw=[{value:"ris",label:"RIS"},{value:"bibtex",label:"BibTeX"},{value:"medline",label:"MEDLINE"},{value:"csv",label:"CSV"}];async function Ip(){try{const a=await $.storage.local.get([Ss,Ts]);return{key:a[Ss]||"",name:a[Ts]||""}}catch{return{key:"",name:""}}}async function Aw(a,e){try{await $.storage.local.set({[Ss]:a,[Ts]:e})}catch{}}function Mp(a,e){a.disabled=!0,a.title=e,a.setAttribute("aria-disabled","true")}async function Cw(a,e,t){const n=await Et(e);if(n.allowed){a.disabled=!1,a.title="",a.textContent=t,a.removeAttribute("aria-disabled");return}Mp(a,n.error||`${t} \u6682\u4E0D\u53EF\u7528`),a.textContent=`${t} Pro`}async function vw(a){const e=await Et(a);return e.allowed?!0:(k.error(e.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u8BE5\u5BFC\u51FA\u683C\u5F0F"),!1)}async function Bp(a,e){const t=await Kn();if(t.allowed){a.dataset.busy!=="true"&&(a.disabled=!1),a.title="",e.textContent="\u4FDD\u5B58\u5230 Zotero",a.removeAttribute("aria-disabled");return}Mp(a,t.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA"),e.textContent="\u4FDD\u5B58\u5230 Zotero Pro"}async function ww(){const a=await Kn();return a.allowed?!0:(k.error(a.error||"Zotero \u5BFC\u51FA\u662F Pro \u6C38\u4E45\u7248\u6743\u76CA"),!1)}function Sw(a){const e=document.createElement("div");e.className=yw;const t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=gw,t.appendChild(n);const r=document.createElement("div");r.className="pl-export-save-card";const i=document.createElement("div");i.className="pl-export-save-card-header";const o=document.createElement("span");o.className="pl-export-save-card-header-icon",o.textContent="\u{1F4E4}";const s=document.createElement("span");s.textContent="\u5BFC\u51FA\u4E0E\u4FDD\u5B58",i.append(o,s);const l=document.createElement("div");l.className="pl-export-save-card-body";const c=document.createElement("div");c.className="pl-export-save-section-label",c.textContent="\u5BFC\u51FA\u683C\u5F0F";const u=document.createElement("div");u.className="pl-export-formats";for(const x of xw){const T=document.createElement("button");T.type="button",T.className="pl-export-format-btn",T.textContent=x.label,T.addEventListener("click",async()=>{await vw(x.value)&&await Tw(a.pmid,x.value)}),u.appendChild(T),Cw(T,x.value,x.label)}const d=document.createElement("div");d.className="pl-export-save-section-label",d.style.marginTop="4px",d.textContent="\u4FDD\u5B58\u5230 Zotero";const p=document.createElement("button");p.type="button",p.className="pl-zotero-save-btn";const m=document.createElement("span");m.textContent="\u{1F4DA}";const h=document.createElement("span");h.textContent="\u4FDD\u5B58\u5230 Zotero",p.append(m,h);const y=document.createElement("div");return y.className="pl-zotero-last-target",Ip().then(x=>{x.name&&(y.textContent=`\u4E0A\u6B21\u76EE\u6807: ${x.name}`)}),p.addEventListener("click",async()=>{if(!await ww()){await Bp(p,h);return}p.disabled=!0,p.dataset.busy="true";try{k.info("\u6B63\u5728\u8FDE\u63A5 Zotero...");const x=await dt({type:"ZOTERO_PING"});(!x?.success||!x?.data)&&k.info(`\u672A\u68C0\u6D4B\u5230 Zotero\uFF0C\u5C06\u76F4\u63A5\u5C1D\u8BD5\u4FDD\u5B58${x?.error?`\uFF1A${x.error}`:""}`);const T=await Ip();wo({defaultCollectionKey:T.key,defaultCollectionName:T.name,onConfirm:async(F,w,b)=>{const v=vo(a.paper),D=F?[F]:void 0;k.info("\u6B63\u5728\u4FDD\u5B58\u5230 Zotero...");const B=await dt({type:"ZOTERO_SAVE_ITEMS",payload:{items:[v],collections:D}});B?.success?(B.warning?k.info(B.warning):k.success(`\u5DF2\u4FDD\u5B58\u5230 Zotero${w?` \u2192 ${w}`:""}`),b&&F&&await Aw(F,w),y.textContent=w?`\u76EE\u6807: ${w}`:""):k.error(`\u4FDD\u5B58\u5931\u8D25\uFF1A${B?.error||B?.message||"\u672A\u77E5\u9519\u8BEF"}`)}})}catch(x){k.error(x instanceof Error&&x.message==="runtime message timed out"?"Zotero \u68C0\u6D4B\u8D85\u65F6\uFF0C\u8BF7\u5237\u65B0\u6269\u5C55\u540E\u91CD\u8BD5":"\u65E0\u6CD5\u8FDE\u63A5 Zotero\uFF0C\u8BF7\u68C0\u67E5 Zotero \u662F\u5426\u8FD0\u884C")}finally{delete p.dataset.busy,p.disabled=!1}}),Bp(p,h),l.append(c,u,d,p,y),r.append(i,l),t.appendChild(r),e}async function Tw(a,e){const t={type:"EXPORT_PUBMED_RECORDS",payload:{pmids:[a],format:e}};try{k.info("\u6B63\u5728\u5BFC\u51FA...");const n=await $.runtime.sendMessage(t);if(!n?.success||!n.data){k.error(n?.error?`\u5BFC\u51FA\u5931\u8D25\uFF1A${n.error}`:"\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");return}const{downloadFile:r,EXPORT_MIME_TYPES:i,EXPORT_EXTENSIONS:o}=await Promise.resolve().then(()=>Co),s=o[e]??".txt",l=i[e]??"text/plain",c=`PMID${a}${s}`;r(n.data,c,l),k.success("\u5DF2\u5BFC\u51FA")}catch{k.error("\u5BFC\u51FA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}const Ew=qe+`
`+`/**
 * Article Sidebar Styles
 *
 * PubMed \u6587\u7AE0\u9875\u53F3\u4FA7\u539F\u751F\u680F\u5185\u7684 PaperLens \u589E\u5F3A\u9762\u677F\u3002
 */

:host {
  display: block;
  font-family: var(--pl-font-sans);
}

.pl-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 16px;
}
`,_w="paperlens-article-sidebar";function Dw(){const a=document.createElement("div");a.className=_w;const e=a.attachShadow({mode:"open"}),t=document.createElement("style");return t.textContent=Ew,e.appendChild(t),{host:a,shadow:e}}function Fw(a){const{host:e,shadow:t}=Dw(),n=document.createElement("div");if(n.className="pl-sidebar",a.exportSave){const r=Sw(a.exportSave);n.appendChild(r)}if(a.journal){const r=sw(a.journal);n.appendChild(r)}return t.appendChild(n),e}function kw(a){const e=a.replace(/\.$/,"").trim();return!e||e.includes(",")||e.includes(";")||/https?:\/\//i.test(e)||/\b(?:doi|pmid|pmc|epub|published|online|accessed)\b/i.test(e)||/^(accessed|vol|volume|edition|ed|eds)$/i.test(e)||!/[A-Za-z]/.test(e)?"":e.replace(/[;:\s]+$/,"").trim()}function Lw(a){const e=a.replace(/\s+/g," ").trim();if(!e)return"";const t=[],n=/\b(?:18|19|20)\d{2}\b/g;let r;for(;(r=n.exec(e))!==null;){const o=e.slice(0,r.index).trim().split(/\.\s+/).map(kw).filter(Boolean),s=o[o.length-1];s&&s.length>=2&&s.length<=90&&t.push(s)}return t[t.length-1]??""}const jp="paperlens-article-page-style",ur={abstract:10,citations:20,save:40,translate:60},Es="data-paperlens-related-metrics",na="data-paperlens-related-metrics-pending",Nw=[".similar-cited-articles","#similar","#similar-articles","#citedby","#references",".similar-articles",".citedby-articles",".cited-by-articles",".cited-by"].join(", ");let _s=null,Ds=null;function qp(){return window.location.pathname.match(/\/(\d+)\/?$/)?.[1]??""}function Nt(a){return document.querySelector(`meta[name="${a}"]`)?.getAttribute("content")?.trim()??""}function Rw(a){return Array.from(document.querySelectorAll(`meta[name="${a}"]`)).map(e=>e.getAttribute("content")?.trim()??"").filter(Boolean)}function Pw(a){return document.querySelector(a)?.textContent?.replace(/\s+/g," ").trim()??""}function Fs(a){return a.replace(/\s*[:：]\s*[^:：]+$/,"").trim()||a}function ks(){if(document.getElementById(jp))return;const a=document.createElement("style");a.id=jp,a.textContent=`
    .paperlens-article-action-row {
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
      gap: 8px;
      margin: 8px 0 14px;
      max-width: 100%;
      overflow-x: auto;
      scrollbar-width: none;
    }
    .paperlens-article-action-row::-webkit-scrollbar {
      display: none;
    }
    .paperlens-article-action-row > * {
      flex: 0 0 auto;
      align-self: center;
    }
    .paperlens-article-action-row .pl-translate-wrapper--article-page {
      display: inline-flex;
      align-items: center;
      flex-wrap: nowrap;
      margin: 0;
      max-width: 100%;
      line-height: 1;
      vertical-align: middle;
    }
    .paperlens-article-action-row .pl-translate-result,
    .paperlens-article-action-row .pl-translate-error {
      flex-basis: 100%;
      width: min(760px, calc(100vw - 48px));
      box-sizing: border-box;
    }
    .paperlens-article-citation-fallback {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 11px;
      border: 1px solid #e5e7eb;
      border-radius: 7px;
      background: #f8fafc;
      color: #64748b;
      font-size: 13px;
      font-weight: 650;
      line-height: 1;
      white-space: nowrap;
    }
    .paperlens-article-link-action,
    .paperlens-article-disabled-action {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 11px;
      border: 1px solid #d5dbe7;
      border-radius: 7px;
      font-size: 13px;
      font-weight: 650;
      line-height: 1;
      white-space: nowrap;
      text-decoration: none;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    }
    .paperlens-article-link-action {
      background: #f8fafc;
      color: #334155;
    }
    .paperlens-article-link-action:hover {
      border-color: #93c5fd;
      background: #eff6ff;
      color: #1d4ed8;
      text-decoration: none;
    }
    .paperlens-article-disabled-action {
      border-color: #e5e7eb;
      background: #f8fafc;
      color: #94a3b8;
      cursor: not-allowed;
      font-family: inherit;
    }
    .paperlens-article-citation-inline {
      display: inline-flex;
      align-items: center;
      flex-wrap: nowrap;
      gap: 0.35em;
      max-width: 100%;
      white-space: nowrap;
      vertical-align: baseline;
    }
    .paperlens-article-citation-inline > .publication-type {
      display: inline-flex;
      align-items: center;
      flex: 0 0 auto;
      margin: 0;
      vertical-align: middle;
      white-space: nowrap;
    }
    .paperlens-article-citation-inline > .article-source {
      display: inline;
      min-width: 0;
      vertical-align: baseline;
      white-space: nowrap;
    }
    .paperlens-native-fulltext-link .text {
      font-weight: 600;
    }
    .paperlens-native-fulltext-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 56px;
      min-width: 56px;
      height: 34px;
      margin-right: 8px;
      border-radius: 2px;
      border: 1px solid #d1d5db;
      background: #ffffff;
      color: #374151;
      font-family: inherit;
      font-size: 20px;
      font-weight: 700;
      letter-spacing: 0;
    }
    .paperlens-native-fulltext-link--pmc .paperlens-native-fulltext-icon {
      background: #111827;
      color: #ffffff;
    }
    .paperlens-native-fulltext-link--extra-download,
    .paperlens-native-fulltext-link--oa-pdf {
      position: relative;
      display: inline-flex !important;
      align-items: center;
      width: 136px !important;
      max-width: 136px !important;
      min-width: 0 !important;
      padding: 0 !important;
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-icon,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-icon {
      width: 100%;
      min-width: 0;
      height: 38px;
      margin-right: 0;
      padding: 4px 6px;
      box-sizing: border-box;
      gap: 6px;
      justify-content: flex-start;
      border-color: #7dd3fc;
      background:
        linear-gradient(135deg, #ecfeff 0%, #ffffff 52%, #eff6ff 100%);
      color: #0f3b57;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
      text-align: left;
    }
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-icon {
      border-color: #86efac;
      background:
        linear-gradient(135deg, #ecfdf5 0%, #ffffff 52%, #f0fdf4 100%);
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-logo-mark,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-mark {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 27px;
      flex: 0 0 24px;
      border-radius: 5px;
      background: linear-gradient(180deg, #0ea5e9 0%, #0369a1 100%);
      color: #ffffff;
      font-size: 15px;
      font-weight: 900;
      line-height: 1;
      box-shadow: 0 1px 3px rgba(3, 105, 161, 0.25);
    }
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-mark {
      background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
      box-shadow: 0 1px 3px rgba(21, 128, 61, 0.25);
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-logo-mark::after,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-mark::after {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      width: 7px;
      height: 7px;
      border-bottom-left-radius: 3px;
      background: rgba(255, 255, 255, 0.78);
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-logo-copy,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-copy {
      display: inline-flex;
      min-width: 0;
      flex-direction: column;
      gap: 1px;
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-logo-kicker,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-kicker {
      display: block;
      width: 100%;
      color: #0284c7;
      font-size: 8.5px;
      font-weight: 800;
      line-height: 1;
    }
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-kicker {
      color: #059669;
    }
    .paperlens-native-fulltext-link--extra-download .paperlens-native-fulltext-logo-main,
    .paperlens-native-fulltext-link--oa-pdf .paperlens-native-fulltext-logo-main {
      display: block;
      width: 100%;
      color: #0f172a;
      font-size: 13px;
      font-weight: 800;
      line-height: 1.05;
    }
    .paperlens-native-fulltext-link--extra-download .text,
    .paperlens-native-fulltext-link--oa-pdf .text {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      padding: 0;
      overflow: hidden;
      clip: rect(0 0 0 0);
      white-space: nowrap;
      border: 0;
    }
    .paperlens-inline-journal-metrics {
      display: inline-flex;
      align-items: baseline;
      max-width: 100%;
      margin: 0 0.35em 0 0;
      vertical-align: baseline;
      overflow: hidden;
      border: 1px solid var(--paperlens-inline-metric-border, #fdba74);
      border-radius: 3px;
      background: var(--paperlens-inline-metric-bg, #fff7ed);
      color: var(--paperlens-inline-metric-text, #7c2d12);
      font: inherit;
      line-height: 1;
      white-space: nowrap;
    }
    .paperlens-inline-journal-metrics__cell {
      display: inline-flex;
      align-items: center;
      min-height: 1.25em;
      padding: 0 0.4em;
      border-right: 1px solid color-mix(in srgb, var(--paperlens-inline-metric-border, #fdba74), transparent 35%);
      color: inherit;
      font: inherit;
      font-weight: 600;
      line-height: 1;
      white-space: nowrap;
    }
    .paperlens-inline-journal-metrics__cell:last-child {
      border-right: 0;
    }
    .paperlens-inline-journal-metrics__cell--if {
      background: var(--paperlens-inline-metric-soft-bg, #ffedd5);
    }
    .paperlens-inline-journal-metrics__cell--jcr {
      background: var(--paperlens-inline-jcr-bg, #b91c1c);
      color: #ffffff;
      font-weight: 700;
    }
    .paperlens-inline-journal-metrics__cell--cas {
      background: rgba(255, 255, 255, 0.55);
    }
    .paperlens-inline-journal-metrics--q1 {
      --paperlens-inline-metric-bg: #fff7ed;
      --paperlens-inline-metric-soft-bg: #ffedd5;
      --paperlens-inline-metric-border: #fdba74;
      --paperlens-inline-metric-text: #7c2d12;
      --paperlens-inline-jcr-bg: #b91c1c;
    }
    .paperlens-inline-journal-metrics--q2 {
      --paperlens-inline-metric-bg: #f0fdf4;
      --paperlens-inline-metric-soft-bg: #dcfce7;
      --paperlens-inline-metric-border: #86efac;
      --paperlens-inline-metric-text: #14532d;
      --paperlens-inline-jcr-bg: #15803d;
    }
    .paperlens-inline-journal-metrics--q3 {
      --paperlens-inline-metric-bg: #fffbeb;
      --paperlens-inline-metric-soft-bg: #fef3c7;
      --paperlens-inline-metric-border: #fcd34d;
      --paperlens-inline-metric-text: #78350f;
      --paperlens-inline-jcr-bg: #b45309;
    }
    .paperlens-inline-journal-metrics--q4 {
      --paperlens-inline-metric-bg: #f8fafc;
      --paperlens-inline-metric-soft-bg: #e2e8f0;
      --paperlens-inline-metric-border: #94a3b8;
      --paperlens-inline-metric-text: #1e293b;
      --paperlens-inline-jcr-bg: #475569;
    }
  `,document.head.appendChild(a)}function Iw(){const a=document.querySelector("div.article-source");if(!a)return"";const e=a.cloneNode(!0);e.querySelectorAll(".journal-actions-dropdown, .dropdown, script, style").forEach(o=>o.remove());const n=e.querySelector("button.journal-actions-trigger")?.textContent?.replace(/\s+/g," ").trim();if(n)return n;const r=e.textContent?.replace(/\s+/g," ").trim()??"",i=r.indexOf(".");return i>0?r.substring(0,i).trim():r}function Mw(){const a=Pw("span.cit");if(a){const t=a.split(/[;.]/)[0]?.trim();if(t)return t}return Nt("citation_date")||void 0}function Bw(){const a=Nt("citation_article_type");if(a)return a;const e=["Review","Systematic Review","Meta-Analysis","Clinical Trial","Randomized Controlled Trial","Guideline","Editorial","Case Report","Letter","Comment"],t=Array.from(document.querySelectorAll(".publication-types button")).map(n=>n.textContent?.replace(/\s+/g," ").trim()??"").filter(Boolean);return e.find(n=>t.some(r=>r.toLowerCase()===n.toLowerCase()))}function jw(){const a=Rw("citation_author");if(a.length>0)return a;const e=Array.from(document.querySelectorAll(".authors-list .full-name, .authors .full-name")).map(t=>t.textContent?.replace(/\s+/g," ").trim()??"").filter(Boolean);return e.length>0?e:void 0}function qw(){const a=qp();let e=Nt("citation_title"),t=Nt("citation_journal_title")||Nt("citation_journal_abbrev");const n=Nt("citation_issn")||void 0;let r=Nt("citation_doi")||void 0,i=Nt("citation_pmcid")||void 0;const o=jw(),s=Mw(),l=Bw();if(e||(e=document.querySelector("h1.heading-title, h1.title, h1.document-title")?.textContent?.trim()??""),!t){const c=document.querySelector("button#full-view-journal-trigger, button.journal-actions-trigger, button.journal-link, a.journal-link, div.journal-info, div.current-journal, a#journal-link");c&&(t=(c.getAttribute("title")||c.textContent||"").trim())}if(t||(t=Iw()),!r){const c=document.querySelector(el);if(c){const u=c.textContent?.trim()??"",d=c.href??"";u.startsWith("10.")?r=u:d.includes("doi.org/")&&(r=d.replace(/^.*doi\.org\//,""))}}if(!r){const u=document.body.innerText.match(/doi:\s*(10\.\d{4,}\/[^\s]+)/i);u&&(r=u[1])}if(!i){const c=document.querySelector(jh);if(c){const u=c.textContent?.trim()??"";u.startsWith("PMC")&&(i=u)}}if(!i){const u=document.body.innerText.match(/PMCID:\s*(PMC\d+)/i);u&&(i=u[1])}return{pmid:a,title:e,journal:t,authors:o,issn:n,doi:r,pmcid:i,publicationDate:s,articleType:l}}function $w(a){try{return new URL(a,window.location.href).toString()}catch{return null}}function Ls(a){try{const e=new URL(a,window.location.href);return e.protocol==="http:"||e.protocol==="https:"?e.toString():null}catch{return null}}function Ow(a){const e=a.querySelector("img");return(a.getAttribute("aria-label")||a.getAttribute("title")||e?.getAttribute("alt")||e?.getAttribute("title")||a.textContent||"").replace(/\s+/g," ").trim()}function Uw(a,e,t){const n=Up(a),r=t?Up(ri(t)??""):"";return!!(r&&n===r)}function $p(a,e){return/\/pmc\/articles\//i.test(a)||/\bPMC\b/i.test(e)}function Op(a,e){return/\.pdf(?:[?#]|$)/i.test(a)||/\b(?:PDF|OA)\b/i.test(e)}function Up(a){try{return new URL(a).hostname.replace(/^www\./,"")}catch{return""}}function ri(a){const e=a.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:null}function Hw(a){const e=a.match(/[A-Za-z]/g)?.length??0,t=a.match(/[\u3400-\u9fff]/g)?.length??0;return e>=12&&e>t}function zw(a,e,t={}){const n=Jw();if(!n)return;const r=t.openAccessPdfUrl?Ls(t.openAccessPdfUrl):null,i=!!a.pmcid||!!r||ra(n,$p)||ra(n,(c,u)=>Op(c,u));a.pmcid&&!ra(n,$p)&&Ns(n,{variant:"pmc",icon:"PMC",label:"Free PMC article",href:`https://pmc.ncbi.nlm.nih.gov/articles/${a.pmcid}/`,title:"Free full text at PubMed Central"}),r&&!ra(n,(c,u)=>Op(c,u))&&Ns(n,{variant:"oa-pdf",icon:"PDF",label:"Open access PDF",href:r,title:"\u6253\u5F00\u5F00\u653E\u83B7\u53D6 PDF"});const o=e.extraDownloadUrl?ri(e.extraDownloadUrl):null,s=!!a.doi||Hw(a.title),l=t.journalOpenAccess===!0;if(!i&&e.showExtraDownload&&(o||l&&a.doi)&&s){const c=o;if(n.querySelector('[data-paperlens-fulltext="extra-download"]')||c&&ra(n,(p,m)=>Uw(p,m,c)))return;const u=a.doi?l?Gw(a.doi):Vw(c??"",a.doi):c?Ww(c,a.title):null,d=u?Ls(u):null;d&&Ns(n,{variant:"extra-download",icon:"",label:l?"\u5F00\u653E\u83B7\u53D6\u5168\u6587":"\u81EA\u52A9\u5168\u6587\u4E0B\u8F7D",href:d,title:l?"\u901A\u8FC7 DOI \u6253\u5F00\u5F00\u653E\u83B7\u53D6\u5168\u6587":"\u901A\u8FC7\u81EA\u5B9A\u4E49\u6E90\u83B7\u53D6\u5168\u6587",resolvePayload:{pmid:a.pmid,doi:a.doi,title:a.title,pmcid:a.pmcid,openAccessPdfUrl:t.openAccessPdfUrl,fallbackDomain:c??void 0,journalOpenAccess:t.journalOpenAccess}})}}function Jw(){const a=Array.from(document.querySelectorAll(".full-text-links-list")).find(o=>!o.closest(".dialog, .overlay"));if(a)return a;const e=document.querySelector("aside.page-sidebar .inner-wrap, .page-sidebar .inner-wrap, aside.page-sidebar, aside#right-col, aside.right-rail, div.right-rail");if(!e)return null;const t=document.createElement("div");t.className="full-text-links paperlens-created-full-text-links";const n=document.createElement("div");n.className="full-view";const r=document.createElement("h3");r.className="title",r.textContent="Full text links";const i=document.createElement("div");return i.className="full-text-links-list",n.append(r,i),t.appendChild(n),e.insertBefore(t,e.firstChild),i}function ra(a,e){return Array.from(a.querySelectorAll("a[href]")).some(t=>{const n=$w(t.getAttribute("href")??"");return n?e(n,Ow(t)):!1})}function Ns(a,e){const t=Ls(e.href);if(!t)return;const n=document.createElement("a");n.className=`link-item paperlens-native-fulltext-link paperlens-native-fulltext-link--${e.variant}`,n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.title=e.title,n.setAttribute("data-paperlens-fulltext",e.variant),e.variant==="extra-download"&&e.resolvePayload&&n.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),Yw(n.href,e.resolvePayload)});const r=document.createElement("span");if(r.className="paperlens-native-fulltext-icon",e.variant==="extra-download"||e.variant==="oa-pdf"){const o=document.createElement("span");o.className="paperlens-native-fulltext-logo-mark",o.textContent=e.variant==="oa-pdf"?"OA":"\u2193";const s=document.createElement("span");s.className="paperlens-native-fulltext-logo-copy";const l=document.createElement("span");l.className="paperlens-native-fulltext-logo-kicker",l.textContent=e.variant==="oa-pdf"?"\u5F00\u653E\u83B7\u53D6":"\u81EA\u52A9";const c=document.createElement("span");c.className="paperlens-native-fulltext-logo-main",c.textContent="\u5168\u6587\u4E0B\u8F7D",s.append(l,c),r.append(o,s)}else r.textContent=e.icon;const i=document.createElement("span");i.className="text",i.textContent=e.label,n.setAttribute("aria-label",e.title),n.append(r,i),a.appendChild(n)}function Vw(a,e){const t=ri(a);return t?`${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`:null}function Ww(a,e){const t=ri(a);return t?`${t.replace(/\/+$/,"")}/search?q=${encodeURIComponent(e)}`:null}function Gw(a){return`https://doi.org/${a.replace(/^\/+/,"")}`}async function Yw(a,e){const t=window.open("","_blank");try{const n=await dt({type:"RESOLVE_FULLTEXT_DOWNLOAD",payload:e},12e3);if(n?.success===!1&&n.error!=="No full text target found"){t?.close(),k.error(n.error||"\u5F53\u524D\u8D26\u6237\u6682\u4E0D\u80FD\u4F7F\u7528\u5168\u6587\u4E0B\u8F7D");return}const r=n?.success&&n.data?.url?n.data.url:a;Zw(t,r)}catch{t?.close(),k.error("\u5728\u7EBF\u6743\u9650\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}}function Zw(a,e){if(a&&!a.closed){a.opener=null,a.location.href=e;return}window.open(e,"_blank","noopener,noreferrer")}function Qw(a){const e=Mr(a.casQuartile),t=document.createElement("span");t.className=`paperlens-inline-journal-metrics paperlens-inline-journal-metrics--${a.jcrQuartile.toLowerCase()}`,t.title=[a.journalName,`IF ${a.impactFactor.toFixed(1)}`,a.jcrQuartile,e?`\u4E2D\u79D1\u9662 ${e.label}`:void 0].filter(Boolean).join(" | "),t.setAttribute("data-paperlens-inline-metrics","");const n=document.createElement("span");n.className="paperlens-inline-journal-metrics__cell paperlens-inline-journal-metrics__cell--if",n.textContent=`IF ${a.impactFactor.toFixed(1)}`,n.title=`IF ${a.impactFactor.toFixed(1)} \xB7 \u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF`,Hn(n,{journalName:a.journalName,journal:a,getTrendData:zp(a),delayMs:280});const r=document.createElement("span");if(r.className="paperlens-inline-journal-metrics__cell paperlens-inline-journal-metrics__cell--jcr",r.textContent=a.jcrQuartile,t.append(n,r),e){const i=document.createElement("span");i.className="paperlens-inline-journal-metrics__cell paperlens-inline-journal-metrics__cell--cas",i.textContent=e.label,t.appendChild(i)}return t}function Kw(a){const e=a.querySelector("button#full-view-journal-trigger, button.journal-actions-trigger, button.journal-link, a.journal-link, div.journal-info, div.current-journal, a#journal-link");return e||(a instanceof HTMLElement?a:null)}function Xw(a,e,t){const n=e.trim().toLowerCase();if(!n)return!1;const r=document.createTreeWalker(a,NodeFilter.SHOW_TEXT);let i=r.nextNode();for(;i;){const o=i,l=(o.nodeValue??"").toLowerCase().indexOf(n);if(l>=0){const c=o.splitText(l);return c.parentNode?.insertBefore(t,c),!0}i=r.nextNode()}return!1}function eS(a){const e=a.querySelector(Tr)?.textContent?.replace(/\s+/g," ").trim()??"",t=a.querySelector(xi)?.textContent?.replace(/\s+/g," ").trim()??"",n=e||t;if(!n)return"";const r=n.indexOf(".");return(r>0?n.slice(0,r):n).trim()}function tS(){const a=Array.from(document.querySelectorAll(Nw)),e=new Set;for(const r of a)r.matches("article.full-docsum, li.full-docsum, div.full-docsum")&&e.add(r),r.querySelectorAll("article.full-docsum, li.full-docsum, div.full-docsum").forEach(i=>e.add(i));const t=[];let n=0;for(const r of e){if(!(r instanceof HTMLElement)||r.hasAttribute(Es)||r.hasAttribute(na))continue;const i=eS(r);if(!i)continue;const o=r.querySelector(Tr)??r.querySelector(xi);if(!(o instanceof HTMLElement))continue;let s="";try{s=ya(r).PMID}catch{s=""}t.push({id:s||`docsum-${n++}-${i}`,journal:i,element:r,insert:l=>o.insertBefore(l,o.firstChild)})}return t}function nS(){const a=document.querySelector("#references");if(!a)return[];const e=Array.from(a.querySelectorAll(".references-list > li, .references-and-notes-list > li")),t=[],n=new Set;let r=0;for(const i of e){const o=i.matches(".references-and-notes-list > li")?i:i.querySelector(".references-and-notes-list > li");if(!o||n.has(o)||(n.add(o),o.hasAttribute(Es)||o.hasAttribute(na))||o.querySelector(".paperlens-inline-journal-metrics"))continue;const s=Lw(o.textContent??"");s&&t.push({id:`reference-${r++}-${s}`,journal:s,element:o,insert:l=>{Xw(o,s,l)||o.append(document.createTextNode(" "),l)}})}return t}async function Hp(){ks();const a=[...tS(),...nS()];if(a.length!==0){for(const e of a)e.element.setAttribute(na,"");try{const e=await wa(a.map(t=>({id:t.id,journal:Fs(t.journal)})));for(const t of a){t.element.removeAttribute(na);const n=e.get(t.id);n&&t.insert(Qw(n.journal)),t.element.setAttribute(Es,"")}}catch(e){for(const t of a)t.element.removeAttribute(na);console.warn("[PaperLens] Failed to enhance related article journal metrics:",e)}}}function rS(){_s===null&&(_s=window.setTimeout(()=>{_s=null,Hp()},150))}function aS(){Ds||(Hp(),Ds=new MutationObserver(a=>{a.some(e=>e.addedNodes.length>0)&&rS()}),Ds.observe(document.body,{childList:!0,subtree:!0}))}function hn(a,e){return $.runtime.sendMessage({type:a,payload:e})}async function iS(a,e){const t=await hn("GET_ARTICLE_PAGE_DATA",{pmid:a.pmid,journalName:Fs(a.journal),...a.issn?{issn:a.issn}:{},...a.doi?{doi:a.doi}:{},...e!==void 0?{showScimagoSJR:e}:{}});return!t.success||!t.data?{}:t.data}async function oS(a,e){const t=await hn("GET_JOURNAL_TREND_DATA",{normalizedName:a.normalizedName,journalName:a.journalName,includeSJR:e});if(!t.success||!t.data)return{};const n=t.data;return{trendData:Array.isArray(n.trendData)?n.trendData:void 0,sjrTrendData:Array.isArray(n.sjrTrendData)?n.sjrTrendData:void 0}}function zp(a,e){let t=e&&e.length>=2?e:void 0,n=null;return()=>t?Promise.resolve(t):n||(n=hn("GET_JOURNAL_TREND_DATA",{normalizedName:a.normalizedName,journalName:a.journalName}).then(r=>{const i=r.success&&Array.isArray(r.data?.trendData)?r.data.trendData:[];return i.length>=2&&(t=i),n=null,i}).catch(()=>(n=null,[])),n)}async function sS(a,e){const t=[a.issn??"",Fs(a.journal),a.journal,Nt("citation_publisher"),e?.journal?.name??"",e?.venue??""].map(r=>r.trim()).filter(Boolean),n=new Set;for(const r of t){const i=r.toLowerCase();if(n.has(i))continue;n.add(i);const o=await Ir(r,a.issn);if(o)return o.journal}if(a.issn){const r=await Ir("",a.issn);if(r)return r.journal}}function lS(a,e,t){ks();const n=document.querySelector("#full-view-heading > .article-citation, header#heading .full-view .article-citation, .article-citation");if(!n||n.querySelector(".paperlens-article-metrics-host"))return;const r=n.querySelector(".article-source");if(!r)return;const i=document.createElement("span");i.className="paperlens-article-metrics-host",i.dataset.plIf=String(e.impactFactor),i.dataset.plJcr=e.jcrQuartile;const o=Mr(e.casQuartile);o&&(i.dataset.plCas=o.value);const s=i.attachShadow({mode:"open"}),l=document.createElement("style");l.textContent=`
    :host {
      display: inline-flex;
      align-items: center;
      vertical-align: middle;
      margin: 0;
      max-width: 100%;
      font: inherit;
      flex: 0 0 auto;
    }
    .pl-article-metrics {
      display: inline-flex;
      align-items: center;
      overflow: hidden;
      border: 1px solid var(--pl-article-metric-border, #fdba74);
      border-radius: 4px;
      background: var(--pl-article-metric-bg, #fff7ed);
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
      font: inherit;
      line-height: 1;
    }
    .pl-article-metric {
      display: inline-flex;
      align-items: center;
      min-height: 1.55em;
      padding: 0 0.6em;
      border-right: 1px solid color-mix(in srgb, var(--pl-article-metric-border, #fdba74), transparent 35%);
      color: var(--pl-article-metric-text, #7c2d12);
      font: inherit;
      font-weight: 700;
      line-height: 1;
      white-space: nowrap;
    }
    .pl-article-metric:last-child {
      border-right: 0;
    }
    .pl-article-metric--if {
      background: var(--pl-article-metric-soft-bg, #ffedd5);
      cursor: help;
    }
    .pl-article-metric--jcr {
      color: #fff;
    }
    .pl-article-metric--cas {
      background: rgba(255, 255, 255, 0.55);
    }
    .pl-article-metrics--q1 {
      --pl-article-metric-bg: #fff7ed;
      --pl-article-metric-soft-bg: #ffedd5;
      --pl-article-metric-border: #fdba74;
      --pl-article-metric-text: #7c2d12;
      --pl-article-jcr-bg: #b91c1c;
    }
    .pl-article-metrics--q2 {
      --pl-article-metric-bg: #f0fdf4;
      --pl-article-metric-soft-bg: #dcfce7;
      --pl-article-metric-border: #86efac;
      --pl-article-metric-text: #14532d;
      --pl-article-jcr-bg: #15803d;
    }
    .pl-article-metrics--q3 {
      --pl-article-metric-bg: #fffbeb;
      --pl-article-metric-soft-bg: #fef3c7;
      --pl-article-metric-border: #fcd34d;
      --pl-article-metric-text: #78350f;
      --pl-article-jcr-bg: #b45309;
    }
    .pl-article-metrics--q4 {
      --pl-article-metric-bg: #f8fafc;
      --pl-article-metric-soft-bg: #e2e8f0;
      --pl-article-metric-border: #94a3b8;
      --pl-article-metric-text: #1e293b;
      --pl-article-jcr-bg: #475569;
    }
    .pl-article-metric--jcr {
      background: var(--pl-article-jcr-bg, #475569);
    }
    @media (max-width: 760px) {
      .pl-article-metric {
        min-height: 1.45em;
        padding: 0 0.45em;
      }
    }
  `;const c=document.createElement("span");c.className=`pl-article-metrics pl-article-metrics--${e.jcrQuartile.toLowerCase()}`,c.title=[e.journalName,`IF ${e.impactFactor.toFixed(1)}`,e.jcrQuartile,o?.label].filter(Boolean).join(" | ");const u=document.createElement("span");u.className="pl-article-metric pl-article-metric--if",u.textContent=`IF ${e.impactFactor.toFixed(1)}`,u.title="\u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF";const d=zp(e,t);Hn(u,{journalName:e.journalName,journal:e,getTrendData:d,delayMs:280});const p=Kw(r);p&&(p.title=[p.title||e.journalName,"\u60AC\u505C\u67E5\u770B IF \u8D8B\u52BF"].filter(Boolean).join(" \xB7 "),Hn(p,{journalName:e.journalName,journal:e,getTrendData:d,delayMs:280}));const m=document.createElement("span");if(m.className="pl-article-metric pl-article-metric--jcr",m.textContent=e.jcrQuartile,c.append(u,m),o){const h=document.createElement("span");h.className="pl-article-metric pl-article-metric--cas",h.textContent=o.label,c.appendChild(h)}if(e.casWarning||e.wosStatus){tc(s);const h=document.createElement("span");h.className="pl-article-metric pl-article-metric--warnings",h.style.display="inline-flex",h.style.gap="3px",h.appendChild(ec(e)),c.appendChild(h)}s.append(l,c),cS(n,r,i,a.articleType)}function cS(a,e,t,n){const r=a.querySelector(".paperlens-article-citation-inline");if(r){r.insertBefore(t,r.firstChild);return}let i=a.querySelector(".publication-type");!i&&n&&(i=document.createElement("span"),i.className="publication-type paperlens-created-publication-type",i.textContent=n);const o=document.createElement("span");o.className="paperlens-article-citation-inline";const s=e.parentNode;s&&(s.insertBefore(o,e),o.appendChild(t),i&&o.appendChild(i),o.appendChild(e))}function aa(a,e){a.style.order=String(e),Jp()?.appendChild(a)}function uS(a,e,t){const n=document.createElement("a");return n.className="paperlens-article-link-action",n.href=e,/^https?:\/\//i.test(e)&&(n.target="_blank",n.rel="noopener noreferrer"),n.textContent=a,n.title=t,n}function dS(a,e){const t=document.createElement("button");return t.className="paperlens-article-disabled-action",t.type="button",t.disabled=!0,t.textContent=a,t.title=e,t}function pS(a,e,t){const n={source:"PubMed",pmid:a.pmid,doi:a.doi,title:a.title,journal:a.journal,impactFactor:t?.impactFactor,jcrQuartile:t?.jcrQuartile,casQuartile:t?.casQuartile?String(t.casQuartile).replace("\u533A",""):void 0,year:e?.year,citationCount:e?.citationCount,url:window.location.href,authors:a.authors,abstract:e?.abstract,publicationTypes:a.articleType?[a.articleType]:void 0,volume:e?.journal?.volume,pages:e?.journal?.pages,issn:a.issn,pmcid:a.pmcid,pdfUrl:e?.openAccessPdf?.url,oaUrl:e?.openAccessPdf?.url,sourceUrl:window.location.href},r=bo(n,!1);return Ra(a.pmid).then(i=>Gr(r,i)).catch(()=>{}),r}function Jp(){const a=document.querySelector(".paperlens-article-action-row");if(a instanceof HTMLElement)return a;const e=document.querySelector(".abstract-content, #enc-abstract, #eng-abstract");if(!e)return null;ks();const t=document.createElement("div");t.className="paperlens-article-action-row";const n=document.querySelector("#full-view-identifiers, ul.identifiers");if(n?.parentElement)return n.insertAdjacentElement("afterend",t),t;const r=document.querySelector("#abstract");return r?.parentElement?(r.parentElement.insertBefore(t,r),t):(e.parentElement?.insertBefore(t,e),t)}function hS(a,e,t,n,r){const i=Jp();if(i){if(!i.querySelector(".paperlens-article-abstract-action")){const o=uS("\u6458\u8981","#abstract","\u8DF3\u8F6C\u5230\u6458\u8981");o.classList.add("paperlens-article-abstract-action"),aa(o,ur.abstract)}if(a.title&&!i.querySelector(Pn+"--article-page")){const o=document.querySelector(".abstract-content, #enc-abstract, #eng-abstract"),s=Do(a.pmid,a.title,o?.textContent||"",{journal:a.journal,authors:a.authors,doi:a.doi,publicationDate:a.publicationDate,articleType:a.articleType,hasFullAbstract:!!o?.textContent?.trim()});s.classList.add("pl-translate-wrapper--article-page"),aa(s,ur.translate)}if(e.showCitations&&t&&ju(t)&&!i.querySelector(Ut)){const o=Bu(t,{paperId:t.paperId,pmid:a.pmid,paperTitle:a.title,sendToBackground:hn});aa(o,ur.citations)}else if(e.showCitations&&typeof n=="number"&&!i.querySelector(".paperlens-article-citation-fallback")){const o=document.createElement("span");o.className="paperlens-article-citation-fallback",o.style.order=String(ur.citations),o.textContent=`\u88AB\u5F15 ${n.toLocaleString("en-US")}`,i.appendChild(o)}else e.showCitations&&!i.querySelector(Ut)&&!i.querySelector(".paperlens-article-citation-fallback")&&aa(dS("\u88AB\u5F15 \u2014","\u6682\u65E0\u88AB\u5F15\u6570\u636E"),ur.citations);i.querySelector(Nn)||aa(pS(a,t,r),ur.save)}}function fS(a){if(document.querySelector(".paperlens-article-sidebar"))return;const e=Fw(a),t=document.querySelector(".actions-buttons.sidebar");if(t?.parentElement){t.insertAdjacentElement("afterend",e);return}const n=document.querySelector("nav.page-navigator");if(n?.parentElement){n.parentElement.insertBefore(e,n);return}const r=document.querySelector("aside#right-col, aside.right-rail, div.right-rail");if(r){r.insertBefore(e,r.firstChild);return}(document.querySelector("main")??document.body).appendChild(e)}async function mS(){const a=qp();if(!a){console.warn("[PaperLens] Article page: no PMID found in URL");return}console.log("[PaperLens] Article page enhancement starting, PMID:",a),await gS();const e=qw();e.title||console.warn("[PaperLens] Article page: could not extract title");const t=await pt();try{const n=await et("metrics.basic","\u57FA\u7840\u671F\u520A\u6307\u6807"),r=n.allowed;r||console.warn("[PaperLens] Article page metrics disabled by entitlement:",n.error);const i=r?await iS(e,t.showScimagoSJR):{};let o=i.journalMatch?.journal;if(r&&!o&&(o=await sS(e,i.s2Paper)),r&&!o&&i.s2Paper){const h=i.s2Paper.journal?.name||i.s2Paper.venue;if(h){const y=await hn("JOURNAL_LOOKUP",{journal:h});y.success&&y.data?.matched&&(o=y.data.journal)}}let s=i.trendData,l=i.sjrTrendData;if(r&&t.showImpactFactor&&o&&(!s?.length||t.showScimagoSJR!==!1&&!l?.length)){const h=await oS(o,t.showScimagoSJR!==!1);s=s?.length?s:h.trendData,l=l?.length?l:h.sjrTrendData}r&&o&&t.showImpactFactor&&lS(e,o,s);const c=i.s2Paper,u=r?i.journalMatch?.journal??o:void 0,d=bS();zw(e,t,{openAccessPdfUrl:c?.openAccessPdf?.url,journalOpenAccess:u?.openAccess===!0});const p={};if(u){let h;if(u.issn?.length){const x=await hn("GET_JOURNAL_LINKS",{issn:u.issn[0]});x.success&&x.data?.homepageUrl&&(h=x.data.homepageUrl)}let y;if(u.scimagoCategories?.length){const x=await hn("GET_SIMILAR_JOURNALS",{issn:u.issn?.[0]??"",issns:u.issn??[],journalName:u.journalName,normalizedName:u.normalizedName,scimagoCategories:u.scimagoCategories,sjrQuartile:u.sjrQuartile,count:5});x.success&&x.data?.journals&&(y=x.data.journals)}p.journal={journal:u,trendData:s,sjrTrendData:l,if5yr:u.if5yr,publisher:u.publisher,homepageUrl:h,showScimagoSJR:t.showScimagoSJR,similarJournals:y}}const m={pmid:e.pmid,paper:{pmid:e.pmid,title:e.title,authors:e.authors,doi:e.doi,pmcid:e.pmcid,journal:e.journal,publicationDate:e.publicationDate,abstract:document.querySelector(".abstract-content, #enc-abstract, #eng-abstract")?.textContent?.trim()||void 0}};p.exportSave=m,(p.journal||p.exportSave)&&fS(p),hS(e,t,c,d,u),r&&t.showImpactFactor&&aS(),console.log("[PaperLens] Article page enhancement complete")}catch(n){console.error("[PaperLens] Article page enhancement failed:",n)}}function bS(){const a=["#core-citation-count",".citation-count","[data-citation-count]",'a[href*="citedby"]',".cited-by-count"];for(const n of a){const r=document.querySelector(n);if(r){const o=(r.textContent?.trim()??"").match(/(\d+(?:,\d+)*)/);if(o){const s=parseInt(o[1].replace(/,/g,""),10);if(!isNaN(s)&&s>0)return s}}}const t=document.body.innerText.match(/Cited by\s+(\d+(?:,\d+)*)/i);if(t){const n=parseInt(t[1].replace(/,/g,""),10);if(!isNaN(n)&&n>0)return n}}function gS(){return new Promise(a=>{if(document.querySelector("h1.heading-title, h1.title, h1.document-title")){a();return}const e=Date.now(),t=5e3,r=setInterval(()=>{if(document.querySelector("h1.heading-title, h1.title, h1.document-title")){clearInterval(r),a();return}Date.now()-e>t&&(clearInterval(r),console.warn("[PaperLens] Timed out waiting for article page"),a())},100)})}const yS=qe+`
`+OA;function Vp(a){const e=a?.trim()??"";return/^10\./i.test(e)?e.toLowerCase():e}const Rs="paperlens-root",ai="paperlens-login-reminder",Wp="paperlens-login-reminder-style",Gp=new Set(["semantic-scholar","wanfang","baidu-scholar","dblp","ieee-xplore","sciencedirect","springerlink","wiley","taylor-francis","oxford-academic","cambridge-core","sage-journals","nature","science-org","preprint-servers","plos","openreview","cell-com","acm-dl","jstor","mdpi","lancet","bmj","nejm","jama-network","lww","publisher-network"]);function xS(a){return Gp.has(a.id)&&Ae()}function AS(a){if(a.getElementById(Wp))return;const e=document.createElement("style");e.id=Wp,e.textContent=`
    #${ai} {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 2147483647;
      pointer-events: auto;
      width: min(430px, calc(100vw - 32px));
      max-height: calc(100vh - 32px);
      overflow: auto;
      box-sizing: border-box;
      border: 1px solid rgba(15, 23, 42, 0.12);
      border-radius: 8px;
      background: #fff;
      box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
      color: #111827;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
      padding: 18px;
    }

    .paperlens-login-reminder__header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 6px;
    }

    .paperlens-login-reminder__title {
      font-size: 15px;
      font-weight: 700;
      line-height: 1.35;
      margin: 0;
    }

    .paperlens-login-reminder__close {
      border: 0;
      background: transparent;
      color: #6b7280;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      padding: 0 2px;
    }

    .paperlens-login-reminder__body {
      color: #4b5563;
      font-size: 14px;
      line-height: 1.55;
      margin: 0 0 10px;
    }

    .paperlens-login-reminder__hint {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: 6px;
      color: #1d4ed8;
      font-size: 13px;
      line-height: 1.45;
      margin: 0 0 14px;
      padding: 8px 10px;
    }

    .paperlens-login-reminder__actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .paperlens-login-reminder__button {
      align-items: center;
      border-radius: 6px;
      cursor: pointer;
      display: inline-flex;
      flex: 1;
      font-size: 14px;
      font-weight: 700;
      justify-content: center;
      line-height: 1;
      min-height: 40px;
      padding: 0 12px;
      user-select: none;
    }

    .paperlens-login-reminder__button--primary {
      background: #2563eb;
      border: 1px solid #2563eb;
      color: #fff;
      flex-basis: 100%;
    }

    .paperlens-login-reminder__button--secondary {
      background: #fff;
      border: 1px solid #d1d5db;
      color: #111827;
    }

    .paperlens-login-reminder__button--ghost {
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      color: #4b5563;
    }
  `,a.appendChild(e)}function Yp(a){window.open(a,"_blank","noopener,noreferrer")}async function CS(){try{if((await $.runtime.sendMessage({type:"OPEN_EXTENSION_LOGIN"}))?.success)return}catch(a){console.warn("[PaperLens] Failed to request extension login popup:",a)}Yp($.runtime.getURL("/popup.html"))}function vS(a){if(a.getElementById(ai))return;AS(a);const e=document.createElement("aside");e.id=ai,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.dataset.paperlensLoginReminder="true";const t=document.createElement("div");t.className="paperlens-login-reminder__header";const n=document.createElement("p");n.className="paperlens-login-reminder__title",n.textContent="\u767B\u5F55 PaperLens \xB7 \u7814\u955C";const r=document.createElement("button");r.type="button",r.className="paperlens-login-reminder__close",r.title="\u5173\u95ED\u63D0\u9192",r.setAttribute("aria-label","\u5173\u95ED\u767B\u5F55\u63D0\u9192"),r.textContent="\xD7",r.addEventListener("click",()=>{e.remove()}),t.append(n,r);const i=document.createElement("p");i.className="paperlens-login-reminder__body",i.textContent="\u8BF7\u5148\u767B\u5F55\u540E\u4F7F\u7528\u671F\u520A\u6307\u6807\u3001\u6536\u85CF\u3001\u5BFC\u51FA\u548C AI \u529F\u80FD\u3002";const o=document.createElement("p");o.className="paperlens-login-reminder__hint",o.textContent="\u767B\u5F55\u6210\u529F\u540E\u5237\u65B0\u5F53\u524D\u9875\u9762\u5373\u53EF\u542F\u7528\u529F\u80FD\u3002";const s=document.createElement("div");s.className="paperlens-login-reminder__actions";const l=document.createElement("button");l.type="button",l.className="paperlens-login-reminder__button paperlens-login-reminder__button--primary",l.textContent="\u767B\u5F55\u63D2\u4EF6",l.addEventListener("click",()=>{o.textContent="\u5DF2\u6253\u5F00\u767B\u5F55\u7A97\u53E3\u3002\u767B\u5F55\u6210\u529F\u540E\u5237\u65B0\u5F53\u524D\u9875\u9762\u5373\u53EF\u542F\u7528\u529F\u80FD\u3002",CS()});const c=document.createElement("button");c.type="button",c.className="paperlens-login-reminder__button paperlens-login-reminder__button--secondary",c.textContent="\u6CE8\u518C",c.addEventListener("click",()=>{Yp(Rv("/auth/register",{source:"extension_content"}))});const u=document.createElement("button");u.type="button",u.className="paperlens-login-reminder__button paperlens-login-reminder__button--ghost",u.textContent="\u53D6\u6D88",u.addEventListener("click",()=>{e.remove()}),s.append(l,c,u),e.append(t,i,o,s),a.appendChild(e)}function wS(a){a.getElementById(ai)?.remove()}async function SS(a){return await Oc()?(wS(a),!1):(vS(a),console.log("[PaperLens] Login required; page enhancement skipped"),!0)}function ze(a){return document.querySelector(`meta[name="${a}"], meta[property="${a}"]`)?.content?.trim()??""}function gt(a){return a?.replace(/\s+/g," ").trim()||void 0}function TS(a){let e;try{e=a.isArticlePage()?a.parseArticlePage():null}catch{e=null}const t=gt(ze("citation_title")||ze("og:title")||document.title),n=gt(ze("citation_journal_title")||ze("citation_publisher")),r=gt(ze("citation_doi")||ze("dc.Identifier")),i=gt(ze("citation_abstract")||ze("dc.description")||ze("description")||ze("og:description")),o=gt(ze("citation_publication_date")||ze("citation_online_date")||ze("dc.Date")),s=Array.from(document.querySelectorAll('meta[name="citation_author"]')).map(l=>gt(l.content)).filter(l=>!!l).slice(0,20);return{paper_id:e?.pmid??e?.doi??e?.sourceId??r??location.href,pmid:e?.pmid,doi:e?.doi??r,title:gt(e?.title)??t,abstract:gt(e?.abstractSnippet)??i,journal:gt(e?.journalName)??n,authors:e?.authors?.length?e.authors:s,year:e?.year,publication_date:gt(e?.publicationDate)??o,source:e?.source??a.id,source_url:e?.url??location.href}}const ES=200,_S=300;let dr=N0(),le=null,ii=null,Kt=null,oi=null,fn=null,ia=null;function DS(a){if(dr=a,Qp(),Ps(),Kt&&clearTimeout(Kt),td(a)){if(Kt=null,es(),ed(),le){const e=document.querySelectorAll(`${lt} ${_e}`);lr(le,e.length,e.length),cr(le)}}else Kt=setTimeout(()=>{Kt=null,(async()=>{const e=await sC(a);le&&(lr(le,e.sourceTotal,e.visible,{scope:"global",analyzed:e.analyzed,done:e.done,loading:e.loading}),cr(le))})()},300)}function FS(a){if(!le)return;const e=a.detail;e&&(lr(le,e.sourceTotal,e.visible,{scope:"global",analyzed:e.analyzed,done:e.done,loading:e.loading}),cr(le))}function kS(){try{return new URL(window.location.href).searchParams.get("term")?.trim()??""}catch{return""}}function Zp(a){return JSON.stringify({term:kS(),state:a})}function Qp(){oi=null,fn=null}function Ps(){ia?.abort(),ia=null}function LS(a){const e=aC();if(e)return fn=e,oi=Zp(dr),a?.(e),e;const t=Zp(dr);if(oi===t&&fn?.done)return a?.(fn),fn;Ps();const n=new AbortController;return ia=n,oi=t,iC(dr,{signal:n.signal,onUpdate:r=>{fn=r,a?.(r)}}).then(r=>(ia===n&&(ia=null),fn=r,r))}function NS(){if(le)return;let a=document.querySelector(Lh)??document.querySelector(Nh);if(!a){console.warn("[PaperLens] No suitable insertion target found for toolbar");return}le=Fv(DS,()=>{if(Kt&&(clearTimeout(Kt),Kt=null),Qp(),Ps(),oC(),ed(),le){const t=document.querySelectorAll(`${lt} ${_e}`);lr(le,t.length,t.length),cr(le)}},LS),a.before(le);const e=document.querySelectorAll(`${lt} ${_e}`);lr(le,e.length,e.length),console.log("[PaperLens] Filter toolbar injected")}function RS(){ii&&clearTimeout(ii),ii=setTimeout(()=>{if(!td(dr)&&!nC()){const{total:a,visible:e}=K0(dr);le&&(lr(le,a,e),cr(le))}pt().then(a=>ui(a)).catch(()=>{}),le&&cr(le),ii=null},300)}function PS(a){return a.style.display==="none"?!1:a.closest("#paperlens-global-results-root")?!0:a.offsetParent!==null||getComputedStyle(a).display!=="none"}function IS(){document.addEventListener("keydown",a=>{const e=a.target,t=e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"||e.isContentEditable;if((a.ctrlKey||a.metaKey)&&a.key==="a"&&!t){a.preventDefault();const n=He.getInstance(),r=document.querySelectorAll(`${lt} ${_e}`),i=[];for(const o of r){if(!PS(o))continue;const l=o.querySelector(Ht),c=l?.getAttribute(sn);if(!c)continue;const u=l?.textContent?.trim()??"",p=o.querySelector("span.docsum-journal-citation.full-journal-citation")?.textContent?.trim()??"",m=p.split(".")[0]?.trim()??"",h=p.match(/\b(19|20)\d{2}\b/),y=h?parseInt(h[0],10):void 0;i.push({PMID:c,title:u,journal:m,year:y})}n.selectAll(i),document.querySelectorAll(`.${Vo().split(" ").join(".")}`).forEach(o=>{const s=o,l=s.dataset.pmid;l&&Jo(s,n.isSelected(l))})}if(a.key==="Escape"){const n=He.getInstance();n.getCount()>0&&(n.deselectAll(),document.querySelectorAll(`.${Vo().split(" ").join(".")}`).forEach(r=>{Jo(r,!1)}))}}),console.log("[PaperLens] Keyboard shortcuts registered")}function MS(){return window.location.hostname==="pubmed.ncbi.nlm.nih.gov"}function BS(){return MS()&&(window.location.pathname==="/"||new URLSearchParams(window.location.search).has("term"))}function jS(){const a=document.getElementById(Rs);if(a)return Kp(a),a.shadowRoot;const e=document.createElement("div");e.id=Rs,Kp(e),document.body.appendChild(e);const t=e.attachShadow({mode:"open"});return console.log("[PaperLens] Shadow DOM container created (mode: open)"),t}function Kp(a){a.style.position="fixed",a.style.inset="0",a.style.width="100vw",a.style.height="100vh",a.style.zIndex="2147483647",a.style.pointerEvents="none",a.style.background="transparent"}function qS(a){const e=document.createElement("style");e.textContent=yS,a.appendChild(e)}async function $S(){if(S0()===0)return;const e=setTimeout(()=>{E0()>0&&T0()},_S);try{await _0()}catch(t){console.error("[PaperLens] resolveMetrics failed:",t),k0()}finally{clearTimeout(e)}}let Xp=null,si=null,li=[];async function OS(){if(li.length===0)return;const a=li;li=[],si=null;try{await Zu(a);const e=await pt();ui(e)}catch(e){console.error("[PaperLens] enhanceNewArticles failed:",e)}}function US(a){const e=[];for(const t of a)if(t.type==="childList")for(const n of t.addedNodes){if(!(n instanceof Element))continue;n.matches(_e)&&e.push(n);const r=n.querySelectorAll?.(_e);if(r)for(const i of r)e.push(i)}e.length!==0&&(li.push(...e),si&&clearTimeout(si),si=setTimeout(()=>{OS()},ES))}let ci=0;const eh=8;function th(){const a=document.querySelector(fa);if(!a){if(ci>=eh){console.warn("[PaperLens] search-results-chunks not found after retries, giving up");return}ci++,console.warn(`[PaperLens] search-results-chunks container not found, retrying in 2s (${ci}/${eh})`),setTimeout(th,2e3);return}ci=0,Xp=new MutationObserver(US),Xp.observe(a,{childList:!0,subtree:!0}),console.log("[PaperLens] MutationObserver started on",fa)}function ui(a){if(document.getElementById(Rs)){if(a.showImpactFactor!==void 0&&(document.querySelectorAll(Ot).forEach(n=>{n.style.display=a.showImpactFactor?"":"none"}),document.querySelectorAll("[data-paperlens-inline-metrics]").forEach(n=>{n.style.display=a.showImpactFactor?"":"none"})),a.showCitations!==void 0&&document.querySelectorAll(Ut).forEach(n=>{n.style.display=a.showCitations?"":"none"}),a.showReferences!==void 0&&document.querySelectorAll(".paperlens-citation-panel").forEach(n=>{n.style.display=a.showReferences?"":"none"}),(a.showExtraDownload!==void 0||a.extraDownloadUrl!==void 0)&&(async()=>{try{const t=await pt();Ny(t.showExtraDownload,t.extraDownloadUrl),document.querySelectorAll('[data-paperlens-fulltext="extra-download"]').forEach(n=>{n.style.display=t.showExtraDownload&&t.extraDownloadUrl?"":"none"})}catch{}})(),a.showOpenAccess!==void 0&&document.querySelectorAll(Ut).forEach(n=>{n.shadowRoot?.querySelectorAll("[data-pl-oa-badge]").forEach(r=>{r.style.display=a.showOpenAccess?"":"none"})}),a.quartileSource!==void 0){const t=a.quartileSource;document.querySelectorAll(Ot).forEach(n=>{n.shadowRoot?.querySelectorAll("[data-pl-jcr-quartile]").forEach(r=>{r.style.display=t==="cas"?"none":""}),n.shadowRoot?.querySelectorAll("[data-pl-cas-quartile]").forEach(r=>{r.style.display=t==="jcr"?"none":""})}),document.querySelectorAll(".paperlens-inline-journal-metrics__cell--jcr").forEach(n=>{n.style.display=t==="cas"?"none":""}),document.querySelectorAll(".paperlens-inline-journal-metrics__cell--cas").forEach(n=>{n.style.display=t==="jcr"?"none":""})}console.log("[PaperLens] Settings applied:",a)}}function HS(){$.runtime.onMessage.addListener((a,e,t)=>{switch(a.type){case"PING":{const r={success:!0,data:{bgTimestamp:a.payload?.bgTimestamp??0,csReceivedAt:Date.now()}};t(r);break}case"SETTINGS_UPDATED":{const n=a.payload;ui(n),t({success:!0});break}case"LIBRARY_PAPER_REMOVED":{const n=a.payload,r=Array.from(new Set([n?.pmid,...n?.ids??[]].map(Vp).filter(Boolean)));r.length>0&&document.querySelectorAll(".paperlens-save-host").forEach(i=>{const o=new Set([i.dataset.pmid,...i.dataset.paperlensIds?.split("	")??[]].map(Vp).filter(Boolean));r.some(s=>o.has(s))&&Gr(i,!1)}),t({success:!0});break}case"ONBOARDING_RESET":{const n=an.getInstance();(async()=>(await n.reset(),wh(),BS()?zs(async()=>{await n.markComplete()}):console.log("[PaperLens] Onboarding reset, but not on search results page \u2014 state cleared only")))(),t({success:!0});break}}}),console.log("[PaperLens] Background message listener registered")}async function nh(){V(new Jh),V(new Zh),V(new Kh),V(new Xh),V(new of),V(new cf),V(new bf),V(new Sf),V(new kf),V(new Bf),V(new Of),V(new Zf),V(new nm),V(new sm),V(new um),V(new mm),V(new ym),V(new Tm),V(new Fm),V(new Rm),V(new Mm),V(new Om),V(new Wm),V(new Zm),V(new Km),V(new ab),V(new db),V(new bb),V(new vb),V(new Fb),V(new Pb);const a=kh();if(!a){console.log("[PaperLens] No matching adapter for",location.href,"- skipping");return}console.log("[PaperLens] Initializing with adapter:",a.name);const e=jS();if(e&&(qS(e),HS(),!await SS(e))){if(qv(e,()=>TS(a)),a.isArticlePage()){console.log("[PaperLens] Article page detected, starting enhancement"),a.id==="pubmed"?await mS():a.id==="cnki"?(await Q(a),await Z(a)):a.id==="wos"?(await Q(a),await Z(a)):a.id==="semantic-scholar"?(await Q(a),await Z(a),K(a)):a.id==="wanfang"?(await Q(a),await Z(a),K(a)):a.id==="dblp"?(await Q(a),await Z(a),K(a)):a.id==="ieee-xplore"?(await Q(a),await Z(a),K(a)):a.id==="sciencedirect"?(await Q(a),await Z(a),K(a)):a.id==="springerlink"?(await Q(a),await Z(a),K(a)):a.id==="wiley"?(await Q(a),await Z(a),K(a)):a.id==="taylor-francis"?(await Q(a),await Z(a),K(a)):a.id==="oxford-academic"?(await Q(a),await Z(a),K(a)):a.id==="cambridge-core"?(await Q(a),await Z(a),K(a)):a.id==="sage-journals"?(await Q(a),await Z(a),K(a)):a.id==="nature"?(await Q(a),await Z(a),K(a)):a.id==="science-org"?(await Q(a),await Z(a),K(a)):a.id==="preprint-servers"?(await Q(a),await Z(a),K(a)):a.id==="plos"?(await Q(a),await Z(a),K(a)):a.id==="openreview"?(await Q(a),await Z(a),K(a)):a.id==="cell-com"?(await Q(a),await Z(a),K(a)):a.id==="acm-dl"?(await Q(a),await Z(a),K(a)):a.id==="jstor"?(await Q(a),await Z(a),K(a)):a.id==="mdpi"?(await Q(a),await Z(a),K(a)):a.id==="lancet"?(await Q(a),await Z(a),K(a)):a.id==="bmj"?(await Q(a),await Z(a),K(a)):a.id==="nejm"?(await Q(a),await Z(a),K(a)):a.id==="jama-network"?(await Q(a),await Z(a),K(a)):a.id==="lww"?(await Q(a),await Z(a),K(a)):a.id==="publisher-network"&&(await Q(a),await Z(a),K(a));return}if(a.isSearchPage())if(a.id==="pubmed"){console.log("[PaperLens] PubMed search results detected, starting full enhancement"),Un().catch(()=>{}),await zS(),NS(),document.addEventListener("paperlens:data-updated",RS),document.addEventListener("paperlens:global-filter-updated",FS),await $S(),th(),IS();try{const n=await pt();ui(n)}catch{}console.log("[PaperLens] Enhancement pipeline active");const t=an.getInstance();await t.shouldShow()&&setTimeout(()=>{zs(async()=>{await t.markComplete()})},1500)}else console.log(`[PaperLens] ${a.name} search page detected, starting multi-site enhancement`),await Is(a),await Uo(a),Gp.has(a.id)?K(a):GS(a);else a.id==="google-scholar"?a.isCitationLibraryPage()?(console.log("[PaperLens] Google Scholar citation library page detected"),await $A(a)):console.log(`[PaperLens] ${a.name} page detected but not a recognized page, skipping`):xS(a)?(console.log(`[PaperLens] ${a.name} is behind a challenge page, arming deferred enhancement`),K(a)):console.log(`[PaperLens] ${a.name} page detected but not a search page, skipping`)}}function zS(){return new Promise(a=>{if(document.querySelector(_e)){a();return}const e=Date.now(),t=15e3,r=setInterval(()=>{if(document.querySelector(_e)){clearInterval(r),a();return}Date.now()-e>t&&(clearInterval(r),console.warn("[PaperLens] Timed out waiting for search results"),a())},100)})}function rh(a){if(a.id==="baidu-scholar"){const e=a.getResultsContainer()??document.body;return!!(e?.querySelector(Bs)||e?.querySelector(Ms))}return a.parseSearchResults().length>0}function Is(a){return new Promise(e=>{if(rh(a)){e();return}const t=Date.now(),n=1e4,i=setInterval(()=>{if(rh(a)){clearInterval(i),e();return}Date.now()-t>n&&(clearInterval(i),console.warn(`[PaperLens] Timed out waiting for ${a.name} search results`),e())},150)})}function Q(a){return new Promise(e=>{if(a.parseArticlePage()){e();return}const t=Date.now(),n=1e4,i=setInterval(()=>{if(a.parseArticlePage()){clearInterval(i),e();return}Date.now()-t>n&&(clearInterval(i),console.warn(`[PaperLens] Timed out waiting for ${a.name} article page`),e())},150)})}const ah=["#resultsList","#paper-content-wrap",".mod-results-list",".result-list","[data-paperlens-results]"].join(","),ih=['iframe[src*="verify"]','iframe[src*="captcha"]','iframe[src*="challenge"]','iframe[src*="access-check"]','iframe[src*="security-check"]','form[action*="verify"]','form[action*="captcha"]','form[action*="challenge"]','form[action*="access-check"]','form[action*="security-check"]','[id*="captcha" i]','[class*="captcha" i]','[id*="challenge" i]','[class*="challenge" i]','[id*="access-check" i]','[class*="access-check" i]','[id*="security-check" i]','[class*="security-check" i]','[id*="verify-code" i]','[class*="verify-code" i]'].join(","),Ms=[".sc_content",".result",".result-item","[data-paperlens-baidu-result]",".sc_title","h3",".result-title"].join(","),Bs=[".sc_title a","h3 a",".result-title a",'a[data-click*="title"]'].join(","),oh=["#completesearch-publs","#completesearch-publs .body","#main","ul.publ-list","li.entry","#infinitescroll-status","#infinitescroll-pagination","#completesearch-info-skipping","a.next"].join(","),sh=[".search-results",".search__results",".search-result__item","li.search__item",".search-result__body",".search-result",".issue-item",".search-result__meta",".journal-title"].join(",");function JS(a){return!!a.closest('[class^="paperlens-"], [class*=" paperlens-"]')}function lh(a){return a instanceof Element?a:a.parentElement}function VS(a){return/(?:百度安全验证|安全验证|安全校验|滑块验证|拖动滑块|请完成以下验证|请输入验证码|系统检测到您的请求存在异常|Access check|Continue after check)/i.test(a)}function WS(a){return a.matches(ih)||!!a.querySelector(ih)||VS(a.textContent??"")}function ch(a,e,t){if(JS(e))return!1;if(a.id==="baidu-scholar")return WS(e)?!0:e.matches(Ms)||!!e.querySelector(Ms)||e.matches(Bs)||!!e.querySelector(Bs)||t&&e.matches("main, #bdxs_result_lists, #bdxs_result_list, #container, [data-paperlens-baidu-results]");if(a.id==="dblp")return e.matches(oh)||!!e.querySelector(oh)||t&&e.matches("body");if(a.id==="science-org")return e.matches(sh)||t&&!!e.querySelector(sh)||t&&e.matches("main, body, section, [aria-label], [aria-labelledby]");const n=a.getResultsContainer();return n?n.contains(e)||e.matches(ah)||!!e.querySelector(ah)||t&&e.contains(n):!0}function uh(a,e){return e.some(t=>{if(a.id==="baidu-scholar"&&t.type!=="childList")return!1;if(t.type==="childList")return Array.from(t.addedNodes).some(r=>{const i=lh(r);return i?ch(a,i,!0):!1});if(t.type==="attributes"&&t.attributeName?.startsWith("data-paperlens-"))return!1;const n=lh(t.target);return!!(n&&ch(a,n,!1))})}function GS(a){if(!document.body)return;js();let e=null,t=!1,n=!1,r=!1;const i=()=>{r||(e&&clearTimeout(e),e=setTimeout(()=>{e=null,o()},300))},o=async()=>{if(!r){if(t){n=!0;return}t=!0;try{await Is(a),await Uo(a)}finally{t=!1,!r&&n&&(n=!1,i())}}},s=new MutationObserver(c=>{r||uh(a,c)&&i()});s.observe(document.body,{childList:!0,subtree:!0});const l=()=>{if(!r){if(document.hidden){s.disconnect();return}s.observe(document.body,{childList:!0,subtree:!0})}};document.addEventListener("visibilitychange",l),oa=()=>{r=!0,s.disconnect(),e&&clearTimeout(e),document.removeEventListener("visibilitychange",l)}}let oa=null;function js(){oa&&(oa(),oa=null)}function K(a){if(!document.body)return;js();let e=null,t=!1,n=!1,r=location.href,i=!1;const o=async()=>{if(!i){if(t){n=!0;return}t=!0;try{a.isArticlePage()?(await Q(a),await Z(a)):a.isSearchPage()&&(await Is(a),await Uo(a))}finally{t=!1,!i&&n&&(n=!1,s())}}},s=()=>{i||(e&&clearTimeout(e),e=setTimeout(()=>{e=null,o()},300))},l=a.id==="baidu-scholar"?{childList:!0,subtree:!0}:{childList:!0,subtree:!0,attributes:!0,characterData:!0},c=a.id==="baidu-scholar"?a.getResultsContainer()??document.body:document.body,d=!!c?new MutationObserver(y=>{i||uh(a,y)&&s()}):null;d?.observe(c,l);const p=setInterval(()=>{i||location.href!==r&&(r=location.href,s())},500),m=()=>{if(!(i||a.id==="baidu-scholar")){if(document.hidden){d?.disconnect();return}d?.observe(c,l),s()}},h=()=>js();a.id!=="baidu-scholar"&&document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",h,{once:!0}),s(),oa=()=>{i=!0,d?.disconnect(),clearInterval(p),e&&clearTimeout(e),a.id!=="baidu-scholar"&&document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",h)}}function YS(){console.log("[PaperLens] Content script loaded on:",window.location.href),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{nh()}):nh()}const ZS={matches:["*://pubmed.ncbi.nlm.nih.gov/*","*://scholar.google.com/*","*://scholar.google.com.hk/*","*://scholar.google.co.jp/*","*://scholar.google.com.tw/*","*://www.webofscience.com/*","*://www.semanticscholar.org/*","*://www.wanfangdata.com.cn/*","*://med.wanfangdata.com.cn/*","*://s.wanfangdata.com.cn/*","*://d.wanfangdata.com.cn/*","*://xueshu.baidu.com/*","*://dblp.org/*","*://dblp.uni-trier.de/*","*://ieeexplore.ieee.org/*","*://www.sciencedirect.com/*","*://link.springer.com/*","*://onlinelibrary.wiley.com/*","*://*.onlinelibrary.wiley.com/*","*://www.tandfonline.com/*","*://academic.oup.com/*","*://www.cambridge.org/*","*://journals.sagepub.com/*","*://www.nature.com/*","*://www.science.org/*","*://www.biorxiv.org/*","*://biorxiv.org/*","*://www.medrxiv.org/*","*://medrxiv.org/*","*://arxiv.org/*","*://journals.plos.org/*","*://openreview.net/*","*://www.cell.com/*","*://dl.acm.org/*","*://www.jstor.org/*","*://jstor.org/*","*://www.mdpi.com/*","*://www.thelancet.com/*","*://thelancet.com/*","*://www.lancet.com/*","*://lancet.com/*","*://www.bmj.com/content/*","*://www.bmj.com/search*","*://*.bmj.com/content/*","*://*.bmj.com/search*","*://www.nejm.org/*","*://nejm.org/*","*://jamanetwork.com/*","*://www.jamanetwork.com/*","*://journals.lww.com/*","*://*.ovid.com/*","*://www.frontiersin.org/*","*://frontiersin.org/*","*://pubs.acs.org/*","*://pubs.rsc.org/*","*://journals.aps.org/*","*://link.aps.org/*","*://pubs.aip.org/*","*://iopscience.iop.org/*","*://karger.com/*","*://www.karger.com/*","*://www.thieme-connect.de/*","*://thieme-connect.de/*","*://www.thieme-connect.com/*","*://thieme-connect.com/*","*://www.jmir.org/*","*://jmir.org/*","*://*.jmir.org/*","*://www.annualreviews.org/*","*://annualreviews.org/*","*://elifesciences.org/*","*://pnas.org/*","*://www.pnas.org/*","*://rupress.org/*","*://www.rupress.org/*","*://*.rupress.org/*","*://cshperspectives.cshlp.org/*","*://genesdev.cshlp.org/*","*://kns.cnki.net/*","*://www.cnki.net/*","*://navi.cnki.net/*"],main(){YS()}};function di(a,...e){}const QS={debug:(...a)=>di(console.debug,...a),log:(...a)=>di(console.log,...a),warn:(...a)=>di(console.warn,...a),error:(...a)=>di(console.error,...a)};var dh=class ph extends Event{static EVENT_NAME=qs("wxt:locationchange");constructor(e,t){super(ph.EVENT_NAME,{}),this.newUrl=e,this.oldUrl=t}};function qs(a){return`${$?.runtime?.id}:content:${a}`}const KS=typeof globalThis.navigation?.addEventListener=="function";function XS(a){let e,t=!1;return{run(){t||(t=!0,e=new URL(location.href),KS?globalThis.navigation.addEventListener("navigate",n=>{const r=new URL(n.destination.url);r.href!==e.href&&(window.dispatchEvent(new dh(r,e)),e=r)},{signal:a.signal}):a.setInterval(()=>{const n=new URL(location.href);n.href!==e.href&&(window.dispatchEvent(new dh(n,e)),e=n)},1e3))}}}var eT=class la{static SCRIPT_STARTED_MESSAGE_TYPE=qs("wxt:content-script-started");id;abortController;locationWatcher=XS(this);constructor(e,t){this.contentScriptName=e,this.options=t,this.id=Math.random().toString(36).slice(2),this.abortController=new AbortController,this.stopOldScripts(),this.listenForNewerScripts()}get signal(){return this.abortController.signal}abort(e){return this.abortController.abort(e)}get isInvalid(){return $.runtime?.id==null&&this.notifyInvalidated(),this.signal.aborted}get isValid(){return!this.isInvalid}onInvalidated(e){return this.signal.addEventListener("abort",e),()=>this.signal.removeEventListener("abort",e)}block(){return new Promise(()=>{})}setInterval(e,t){const n=setInterval(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearInterval(n)),n}setTimeout(e,t){const n=setTimeout(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearTimeout(n)),n}requestAnimationFrame(e){const t=requestAnimationFrame((...n)=>{this.isValid&&e(...n)});return this.onInvalidated(()=>cancelAnimationFrame(t)),t}requestIdleCallback(e,t){const n=requestIdleCallback((...r)=>{this.signal.aborted||e(...r)},t);return this.onInvalidated(()=>cancelIdleCallback(n)),n}addEventListener(e,t,n,r){t==="wxt:locationchange"&&this.isValid&&this.locationWatcher.run(),e.addEventListener?.(t.startsWith("wxt:")?qs(t):t,n,{...r,signal:this.signal})}notifyInvalidated(){this.abort("Content script context invalidated"),QS.debug(`Content script "${this.contentScriptName}" context invalidated`)}stopOldScripts(){document.dispatchEvent(new CustomEvent(la.SCRIPT_STARTED_MESSAGE_TYPE,{detail:{contentScriptName:this.contentScriptName,messageId:this.id}})),window.postMessage({type:la.SCRIPT_STARTED_MESSAGE_TYPE,contentScriptName:this.contentScriptName,messageId:this.id},"*")}verifyScriptStartedEvent(e){const t=e.detail?.contentScriptName===this.contentScriptName,n=e.detail?.messageId===this.id;return t&&!n}listenForNewerScripts(){const e=t=>{!(t instanceof CustomEvent)||!this.verifyScriptStartedEvent(t)||this.notifyInvalidated()};document.addEventListener(la.SCRIPT_STARTED_MESSAGE_TYPE,e),this.onInvalidated(()=>document.removeEventListener(la.SCRIPT_STARTED_MESSAGE_TYPE,e))}};function hT(){}function pi(a,...e){}const tT={debug:(...a)=>pi(console.debug,...a),log:(...a)=>pi(console.log,...a),warn:(...a)=>pi(console.warn,...a),error:(...a)=>pi(console.error,...a)};return(async()=>{try{const{main:a,...e}=ZS;return await a(new eT("content",e))}catch(a){throw tT.error('The content script "content" crashed on startup!',a),a}})()})();

content;