1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[10636],{10636:(e,t,s)=>{s.r(t),s.d(t,{default:()=>H});var r=s(95155),n=s(12115),a=s(27784),i=s(97003),l=s(16110),o=s(33789),d=s(90235),u=s(67001),c=s(33534),h=s(69869),p=s(78355),m=s(2102),f=s(74394),g=s(8736);let x={bracket:"square brackets, like [3] or [3,5-7]",paren:"round brackets, like (3) or (3,5-7)",superscript:"superscript digits, like \xb3","sup-tag":"a sup element pasted out of a word processor",key:"named markers, like [@smith2002]"},b="[â°\xb9\xb2\xb3â´-â¹]";function y(e){return e.split("").map(e=>{let t="â°\xb9\xb2\xb3â´âµâ¶â·â¸â¹".indexOf(e);return t>=0?String(t):"â»"===e?"-":e}).join("")}let v=new Set(["cm","mm","km","dm","nm","um","\xb5m","pm","fm","ft","in","yd","mi","mil","sq","chi","sd"]);function w(e){let t=[],s=[],r=0,n=(n,a,i)=>{let l="key"===a?[]:function(e){let t=[];for(let s of e.split(/\s*[,;]\s*/)){let e=s.trim();if(!e)continue;let r=/^(\d{1,4})\s*[-ââ]\s*(\d{1,4})$/.exec(e);if(r){let e=Number(r[1]),s=Number(r[2]);if(!Number.isFinite(e)||!Number.isFinite(s)||s<e)continue;let n=Math.max(1,e),a=Math.min(s,n+200);for(let e=n;e<=a;e++)t.push(e);continue}/^\d{1,4}$/.test(e)&&Number(e)>=1&&t.push(Number(e))}return t}(i),o="key"===a?i.split(/\s*[,;]\s*/).map(e=>e.trim().replace(/^@/,"")).filter(Boolean):[];if(l.length||o.length){if(("superscript"===a||"sup-tag"===a)&&function(e,t,s){let r=e.slice(0,t);if(/[0-9â»]$/.test(r))return!0;if(!/^[234]$/.test(s))return!1;let n=/(\p{L}+)$/u.exec(r)?.[1];return void 0!==n&&(1===n.length||v.has(n.toLowerCase()))}(e,n.index,i)){let t=/(\S{0,6})$/.exec(e.slice(0,n.index))?.[1]??"";r++,s.length<5e3&&s.push(t+n[0]);return}t.push({start:n.index,end:n.index+n[0].length,raw:n[0],shape:a,numbers:l,keys:o})}},a=(s,r,a,i)=>{let l,o=t.length;for(;null!==(l=s.exec(e));){if(""===l[0]){s.lastIndex++;continue}let e=l[1]??l[0];n(l,r,i?i(e):e)}a!==t&&a.push(...t.splice(o))};a(/\[\s*@([A-Za-z0-9_.\-]{1,40}(?:\s*,\s*@?[A-Za-z0-9_.\-]{1,40})*)\s*\]/g,"key",t),a(/<sup[^>]*>([\s\S]{1,80}?)<\/sup>/gi,"sup-tag",t,e=>y(e.replace(/<[^>]*>/g,""))),a(RegExp(`${b}+(?:\\s*[,â»-]\\s*${b}+)*`,"g"),"superscript",t,y),a(/\[\s*(\d{1,3}(?:\s*[,;\-â]\s*\d{1,3})*)\s*\]/g,"bracket",t);let i=[];a(/\(\s*(\d{1,3}(?:\s*[,;\-â]\s*\d{1,3})*)\s*\)/g,"paren",i),t.length||t.push(...i),t.sort((e,t)=>e.start-t.start||t.end-e.end);let l=[],o=-1;for(let e of t)e.start<o||(l.push(e),o=e.end);return l.length>5e3?{markers:l.slice(0,5e3),skipped:l.length-5e3,exponents:s,exponentCount:r}:{markers:l,skipped:0,exponents:s,exponentCount:r}}function j(e,t,s){return"bracket"===t.style?`[${e}]`:"paren"===t.style?`(${e})`:s?`<sup>${(0,f.X)(e)}</sup>`:(0,m.om)(e)}var k=s(3362),N=s(95205),$=s(81322),A=s(63483);let T={fieldKeys:p.Kw,onPublisherCity:(e,t)=>(t.place=e,`The place of publication came in as "${e}". Vancouver keeps it, unlike AMA.`)};function C(e,t){return(0,A.Ar)(e,p.Kw,t)}let S=/([12]\d{3})(?:\s+[A-Za-z]{3,9}(?:\s+\d{1,2})?(?:\s*-\s*[A-Za-z]{0,9}\s*\d{0,2})?)?\s*;\s*(\d{1,4})(?:\s*\(\s*([^)]{1,14})\s*\))?\s*:\s*([A-Za-z]?\d+(?:\s*[-â]\s*[A-Za-z]?\d+)?)/,D=/\bdoi:\s*(10\.\d{4,9}\/[^\s]+)/i,I=/\bPMID:?\s*(\d{4,9})/i,M=/^(?:https?:\/\/(?:dx\.)?doi\.org\/|doi:\s*)?(10\.\d{4,9}\/\S+)$/i;function P(e){let t=e.trim();if(!t)return{refs:[],recordsFound:0,notices:[]};if(/^TY\s{2}-/m.test(t))return(0,A.EA)(t,T);if(/^[A-Z][A-Z0-9]{1,3}\s*-\s/m.test(t)&&/^(PMID|TI|AU|FAU|TA|JT)\s*-\s/m.test(t))return(0,A.w3)(t,T);if(/^\s*@[A-Za-z]+\s*\{/.test(t))return{refs:[],recordsFound:0,notices:["That looks like BibTeX. This page does not read BibTeX, because a half-working brace parser produces references that look right and are not. Export the same records as .ris or .nbib instead and drop them in."]};let s=M.exec(t);if(s&&s[1]){let e=(0,p.pl)();return e.doi=s[1].replace(/[.,;]$/,""),{refs:[{id:(0,g.xO)(),type:"journal",fields:e,provenance:{doi:"imported"},importNotes:["A DOI on its own is all that arrived. Nothing here can look it up, because nothing here talks to a server, so the rest of this reference has to be filled in or pasted from PubMed."]}],recordsFound:1,notices:[]}}let r=t.split(/\n\s*\n+/).map(e=>
1e.trim()).filter(Boolean),n=[],a=[];for(let e of r){let t=function(e){let t=e.trim(),s=S.exec(t);if(!s||void 0===s.index)return null;let r=t.slice(0,s.index).trim().split(/\.\s+/).map(e=>e.trim().replace(/\.$/,"")).filter(Boolean);if(r.length<3)return null;let n=r[0]??"",a=r[r.length-1]??"",i=r.slice(1,-1).join(". ");if(!i||!a)return null;let l=(0,p.pl)();l.authors=n.split(/\s*,\s*/).map(e=>e.trim()).filter(e=>e&&!/^et al\.?$/i.test(e)).slice(0,A.WY).join("\n"),l.title=i,l.journal=a,l.year=s[1]??"",l.volume=s[2]??"",l.issue=s[3]??"",l.pages=(s[4]??"").replace(/\s*[-â]\s*/,"-");let o=D.exec(t);o&&o[1]&&(l.doi=o[1].replace(/[.,;]$/,""));let d=I.exec(t);d&&d[1]&&(l.pmid=d[1]);let u=["Read as a PubMed Cite line, so the fields came out in their published order."];/\bet al\b/i.test(n)&&u.push("The line already said et al, so the authors it did not print are not here either.");let c={};for(let[e,t]of Object.entries(l))t.trim()&&(c[e]="imported");return{id:(0,g.xO)(),type:"journal",fields:l,provenance:c,importNotes:u}}(e.replace(/^\s*\d{1,3}[.)]\s+/,""));t?n.push(t):a.push(e)}if(n.length&&!a.length)return{refs:n,recordsFound:n.length,notices:[]};if(n.length){let e=(0,A.GY)(a.join("\n\n"),T);return{refs:[...n,...e.refs],recordsFound:n.length+e.recordsFound,notices:[`${n.length} of these read cleanly as PubMed Cite lines. The other ${e.recordsFound} did not, so only the parts that could be defended were pulled out of them.`,...e.notices]}}return(0,A.GY)(t,T)}let L="tb.vancouver-citation-generator.v1",R={...p.eK,mode:"import",output:"bracket",collapse:!0},O={list:[],draft:""};function E(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`v${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}function J(e){return e.map((e,t)=>e.italic?(0,r.jsx)("em",{children:e.text},t):(0,r.jsx)(n.Fragment,{children:e.text},t))}function z(e){let t=new TextEncoder().encode(e),s="";for(let e of t)s+=String.fromCharCode(e);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}let F=new Set(p.m7.map(e=>e.value));function U(e){let t=(0,p.pl)();if(e&&"object"==typeof e)for(let[s,r]of Object.entries(e))"string"==typeof r&&p.Kw.includes(s)&&(t[s]=r);return t}function Z(e){return"string"==typeof e&&F.has(e)?e:"journal"}function W(e){try{let t=JSON.parse(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(s.length);for(let e=0;e<s.length;e++)r[e]=s.charCodeAt(e);return new TextDecoder().decode(r)}(e));if(!t||"object"!=typeof t)return null;let s=Array.isArray(t.r)?t.r:[],r=[];for(let e of s.slice(0,200))e&&"object"==typeof e&&r.push({id:E(),type:Z(e.t),fields:U(e.f),provenance:{}});let n="string"==typeof t.d?t.d.slice(0,2e5):"";return{doc:{list:r,draft:n},settings:B(t.s)}}catch{return null}}function B(e){if(!e||"object"!=typeof e)return R;let t=new Set(p.OD.map(e=>e.id)),s="paren"===e.output?"paren":"superscript"===e.output?"superscript":"bracket",r="authoring"===e.mode?"authoring":"import";return{authorRuleId:"string"==typeof e.authorRuleId&&t.has(e.authorRuleId)?e.authorRuleId:R.authorRuleId,elidePages:"boolean"==typeof e.elidePages?e.elidePages:R.elidePages,mode:r,output:s,collapse:"boolean"==typeof e.collapse?e.collapse:R.collapse}}function K(e){if(!e||"object"!=typeof e)return null;let t=Array.isArray(e.list)?e.list:[],s=[];for(let e of t.slice(0,200)){if(!e||"object"!=typeof e)continue;let t={id:"string"==typeof e.id&&e.id?e.id:E(),type:Z(e.type),fields:U(e.fields),provenance:{}};"string"==typeof e.raw&&(t.raw=e.raw),Array.isArray(e.importNotes)&&(t.importNotes=e.importNotes.filter(e=>"string"==typeof e)),s.push(t)}return{list:s,draft:"string"==typeof e.draft?e.draft.slice(0,2e5):""}}function Y(){let e=e=>{let t=C("journal");for(let[s,r]of Object.entries(e))"string"==typeof r&&(t.fields[s]=r);return t};return{list:[e({authors:"Nguyen TL\nOkafor B\nSilva MR",title:"Example reference one, edit it or delete it",journal:"J Example Med",year:"2021",volume:"384",issue:"7",pages:"1121-1134",doi:"10.0000/example.001",key:"nguyen2021"}),e({authors:"Haddad R\nPetrov IK",title:"Example reference two, edit it or delete it",j
1ournal:"Ann Example Surg",year:"2020",volume:"12",pages:"284-287",key:"haddad2020"}),e({authors:"Osei K",title:"Example reference three, edit it or delete it",journal:"Example Nurs Res",year:"2019",volume:"58",issue:"2",pages:"77-84",key:"osei2019"})],draft:"Paste your own draft over this one and watch what happens to the numbers.\n\nThe second source in the list is the one this paragraph cites first [2]. A later\nparagraph brings in the third [3], and only then does the first one appear [1]. A\nsentence leaning on all three at once reads [1,2,3]."}}function H(){let[e,t]=(0,n.useState)({present:O,past:[],future:[],mergeKey:null}),s=e.present,[o,b]=(0,n.useState)(R),[y,v]=(0,n.useState)(!1),[S,D]=(0,n.useState)("fresh"),[I,M]=(0,n.useState)(null),[F,U]=(0,n.useState)(!1),[Z,H]=(0,n.useState)(null),[G,q]=(0,n.useState)(null),[_,X]=(0,n.useState)(null),[Q,ee]=(0,n.useState)("journal"),[et,es]=(0,n.useState)(""),[er,en]=(0,n.useState)(null),[ea,ei]=(0,n.useState)(!1),[el,eo]=(0,n.useState)(null),ed=(0,n.useRef)(null),eu=(0,n.useRef)(null),ec="embed"===S,eh=(0,n.useCallback)(e=>
1{t({present:e,past:[],future:[],mergeKey:null})},[]);(0,n.useEffect)(()=>{let e="1"===new URLSearchParams(window.location.search).get("embed")||window.location.pathname.startsWith("/embed"),t=(0,h.qA)(window.location.search,window.location.hash),s=t.get("state"),r=t.get("cfg");if(e){D("embed");let e=s?W(s):null,t=!e&&r?W(r):null;eh(e?e.doc:Y()),e?b(e.settings):t&&b(t.settings),v(!0);return}let n=null,a=null,i=null;try{let e=localStorage.getItem(L);if(e){let t=JSON.parse(e),s=t.doc?K(t.doc):null;s&&(s.list.length||s.draft.trim())&&(n=s,a="string"==typeof t.at?t.at:null,i=B(t.settings))}}catch{}if(s){let e=W(s);if(e){eh(e.doc),b(e.settings),n?(D("shared"),U(!0),M(a)):D("link"),v(!0);return}}let l=r?W(r):null;if(n){eh(n);let e=l?l.settings:i;e&&b(e),D("restored"),M(a)}else l&&b(l.settings),eh(Y()),D("fresh");v(!0)},[eh]);let ep=(0,n.useCallback)((e,t)=>{try{localStorage.setItem(L,JSON.stringify({doc:e,settings:t,at:new Date().toISOString()}))}catch{}},[]),em=(0,a.y1)(JSON.stringify({doc:s,settings:o}));(0,n.useEffect)(()=>{if(!em||ec||F)return;let e=setTimeout(()=>ep(s,o),400);return()=>clearTimeout(e)},[em,ec,F,s,o,ep]);let ef=(0,n.useCallback)((e,s)=>{t(t=>{let r=e(t.present);return r===t.present?t:{present:r,past:void 0!==s&&s===t.mergeKey&&t.past.length>
10?t.past:[...t.past,t.present].slice(-50),future:[],mergeKey:s??null}})},[]);function eg(e){if(e.length>2e5)return void eo(`Your draft is ${e.length.toLocaleString()} characters and this page reads up to ${2e5.toLocaleString()}, so that paste was not taken. Nothing was cut down, because a draft scanned only part of the way through would renumber wrongly and look fine. Split it into two documents and do them one at a time.`);eo(null),ef(t=>({...t,draft:e}),"draft")}function ex(e,t){if((0,p.Jt)(e.fields,p.Ey))return e;let s=(0,p.Ax)(e,function(e,t){let s=new Set;for(let r of e){if(r.id===t)continue;let e=(0,p.Jt)(r.fields,p.Ey).toLowerCase();e&&s.add(e)}return s}(t,e.id));return{...e,fields:{...e.fields,[p.Ey]:s}}}function eb(e,t,s){ef(s=>({...s,list:s.list.map(s=>s.id===e?t(s):s)}),s)}function ey(e,t){ef(s=>{if(e===t)return s;let r=[...s.list],n=Math.max(0,Math.min(e,r.length-1)),a=Math.max(0,Math.min(t,r.length-1)),i=r[n];return i?(r.splice(n,1),r.splice(a,0,i),{...s,list:r}):s})}function ev(e,t){if(!e.recordsFound)return void en(e.notices.length?e.notices.join(" "):"Nothing readable was found in that text, so the list was left alone.");if(e.recordsFound>500)return void en(`${t} holds ${e.recordsFound} records and the limit here is 500, so nothing was added.`);if(e.refs.length>200-s.list.length)return void en(`${t} holds ${e.refs.length} references, your list already has ${s.list.length}, and the cap is 200. Take a few out first and nothing will be lost.`);let r=e.refs;ef(e=>{let t=[...e.list];for(let e of r)t.push(ex(e,t));return{...e,list:t}});let n=e.notices.length?` ${e.notices.join(" ")}`:"";en(`Added ${r.length} reference${1===r.length?"":"s"} from ${t}.${n} Read each one, because an import is only ever as good as the record it came out of.`)}function ew(e){let t=Array.from(e);t.length&&Promise.all(t.map(e=>(0,$.G)(e).then(t=>({name:e.name,text:t.text,note:t.note})).catch(()=>null))).then(e=>{let t=e.filter(e=>null!==e),s=e.length-t.length;if(!t.length)return void en("None of those files could be read.");let r=t.find(e=>e.text.length>2e5);if(r)return void en(`${r.name} is ${r.text.length.toLocaleString()} characters and the limit here is ${2e5.toLocaleString()}, so nothing was added.`);let n=[],a=s?[`${s} file${1===s?"":"s"} could not be read and ${1===s?"was":"were"} skipped.`]:[];for(let e of t)""!==e.note&&a.push(`${e.name}: ${e.note}`);let i=0;for(let e of t){let t=function(e,t){let s=t.toLowerCase();if(s.endsWith(".ris")||s.endsWith(".nbib")||s.endsWith(".medline"))return(0,A.jE)(e,t,T);return s.endsWith(".bib")?{refs:[],recordsFound:0,notices:["This page does not read BibTeX. Export the same records as .ris or .nbib from your reference manager and they will come straight in."]}:P(e)}(e.text,e.name);n.push(...t.refs),i+=t.recordsFound,a.push(...t.notices)}ev({refs:n,recordsFound:i,notices:a},1===t.length?t[0]?.name??"your file":`${t.length} files`)})}(0,n.useEffect)(()=>{function e(e){let t=e.target;if(t&&"function"==typeof t.closest&&t.closest('input, textarea, [contenteditable="true"]'))return;let s=e.clipboardData?.files;if(s&&s.length>0){e.preventDefault(),ew(s);return}let r=e.clipboardData?.getData("text/plain")??"";r&&(e.preventDefault(),ev(P(r),"the pasted record"))}return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[ev,ew]);let ej=(0,n.useMemo)(()=>({authorRuleId:o.authorRuleId,elidePages:o.elidePages}),[o.authorRuleId,o.elidePages]),ek=(0,n.useDeferredValue)(s.draft),eN=(0,n.useMemo)(()=>(function(e,t,s,r){let{markers:n,skipped:a,exponents:i,exponentCount:l}=w(e),o=new Map;for(let e of t){let t=(0,g.Jt)(e.fields,p.Ey).toLowerCase();t&&!o.has(t)&&o.set(t,e)}let d=new Map,u=[],c=[],h=n.map(r=>{let n="authoring"===s?r.keys.map(e=>({ref:o.get(e.toLowerCase())??null,token:`@${e}`})):r.numbers.map(e=>({ref:t[e-1]??null,token:String(e)}));for(let a of n)if(a.ref)d.has(a.ref.id)||(u.push(a.ref),d.set(a.ref.id,u.length));else{let n=function(e,t){let s=1,r=0;for(let n=0;n<t&&n<e.length;n++)"\n"===e[n]&&(s++,r=n+1);return{line:s,column:t-r+1}}(e,r.start);c.push({start:r.start,line:n.line,column:n.column,raw:r.raw,detail:"authoring"===s?`${a.token} does not match the citation key on any reference in your list.`:`${a.token} points past the end of your list, which holds ${t.length} reference${1===t.length?"":"s"}.`})}return{marker:r,entries:n}}),x="",b="",y=0;for(let{marker:t,entries:s}of h){let n=e.slice(y,t.start);x+=n,b+=(0,f.X)(n);let a=[],i=0;for(let e of s){let t=e.ref?d.get(e.ref.id):void 0;void 0===t?i++:a.push(t)}let l=[r.collapse?(0,m.Oc)(a):(0,m.v)(a),...Array.from({length:i},()=>
1"?")].filter(Boolean).join(",");x+=j(l,r,!1),b+=j(l,r,!0),y=t.end}let v=e.slice(y);x+=v,b+=(0,f.X)(v);let k=t.filter(e=>!d.has(e.id)),N=Array.from(new Set(n.map(e=>e.shape)));return{mode:s,markers:n,shapesFound:N,ordered:u,numberOf:d,orphans:k,unresolved:c,text:x,html:b.replace(/\n/g,"<br>"),empty:0===n.length,skipped:a,exponents:i,exponentCount:l}})(ek,s.list,o.mode,{style:o.output,collapse:o.collapse}),[ek,s.list,o.mode,o.output,o.collapse]),e$=eN.empty?s.list:eN.ordered,eA=(0,n.useMemo)(()=>{let e=new Map;for(let t of s.list)e.set(t.id,function(e,t){let s=[],r=e.fields;!function(e,t,s){let r=(0,p.Jt)(e.fields,"authors"),n=(0,p.Nq)(r),a=(0,p.BD)(t.authorRuleId);for(let e of(n.length?n.length>a.limit&&a.limit<1e3&&s.push({field:"authors",rule:`more than ${a.limit} authors, so the first ${a.keep} print and the rest become et al`,message:`You supplied ${n.length} authors. That is the rule you picked above, not a limit here, and you can switch it if your journal counts differently.`,level:"note"}):s.push({field:"authors",rule:"a work with no author starts with its title",message:"No author. That is allowed, and NLM then opens the reference with the title, which is what will print here. If the source does have an author, add it, because a missing one changes where this reference sorts in an alphabetized list elsewhere.",level:"note"}),n))if((0,N.yw)(e)){s.push({field:"authors",rule:"surname first, then initials",message:`"${e}" is a single name with nothing to split on, so which part is the family name cannot be worked out here. It prints exactly as typed. Write it surname first if that is not already what you meant.`,level:"note"});break}let i=n.filter(e=>!(0,N.DG)(e)&&(0,N.Hq)(e));for(let e of i){let t=e.trim();s.push({field:"authors",rule:"NLM writes a corporate author out in full",message:`"${t}" reads as the name of a body, and the surname-then-initials rule is about to print it as "${(0,p.zH)(t)}". Wrap it in braces and it prints whole.`,level:"warn",fix:{field:"authors",value:n.map(e=>i.includes(e)?`{${e.trim()}}`:e.trim()).join("\n"),label:"Wrap it in braces"}})}let l=n.map(p.zH).filter(Boolean),o=n.map(e=>e.trim()).join("\n"),d=n.map(e=>(0,N.DG)(e)?e.trim():(0,p.zH)(e)).filter(Boolean).join("\n");d&&d!==o&&0===i.length&&(/[A-Z]\.|,/.test(r)||/\b[A-Z][a-z]+\s+[A-Z][a-z]+/.test(r))&&s.push({field:"authors",rule:"no periods after the initials and no ampersand",message:`These will print as ${l.slice(0,2).join(", ")}${l.length>2?", and so on":""}. Rewrite the field to match if you would rather see it that way while you work.`,level:"note",fix:{field:"authors",value:d,label:"Rewrite the names in Vancouver form"}})}(e,t,s),function(e,t){let s=(0,p.Jt)(e.fields,"title");if(!s)return t.push({field:"title",rule:"every reference carries a title",message:"No title yet.",level:"warn"});if(!k.F5.includes(e.type))return;let{capitalized:r,counted:n}=(0,k.Zg)(s);n>=3&&r>=3&&r/n>.6&&t.push({field:"title",rule:"article titles are set in sentence case",message:`${r} of the ${n} words after the first are capitalized, which reads as title case. Sentence case keeps proper nouns capitalized and lowercases the rest, so read the result before you trust it.`,level:"note",fix:{field:"title",value:(0,k.zX)(s),label:"Apply sentence case"}})}(e,s);let n=(0,p.Jt)(r,"year"),a="website"!==e.type&&"online-first"!==e.type&&"preprint"!==e.type;a&&n&&!/^\d{4}$/.test(n)?s.push({field:"year",rule:"a four-digit year",message:`"${n}" is not a four-digit year.`,level:"warn"}):a&&!n&&s.push({field:"year",rule:"a four-digit year",message:"No year yet.",level:"warn"}),("journal"===e.type||"online-first"===e.type||"preprint"===e.type)&&function(e,t){let s=(0,p.Jt)(e.fields,"journal");if(!s)return t.push({field:"journal",rule:"a journal article names its journal",message:"No journal title yet.",level:"warn"});(0,k.ti)(s)||t.push({field:"journal",rule:"NLM wants the abbreviated journal title",message:"This reads as a full journal title rather than an NLM abbreviation. It prints exactly as you typed it, and nothing here will shorten it for you, because an abbreviation invented from a word list looks just as official as a real one and cannot be checked once it is pasted. Look it up in the NLM Catalog and paste the short form in.",level:"warn"})}(e,s);let i=(0,p.Jt)(e.fields,"doi");if(i&&(/^https?:/i.test(i)||/doi\.org/i.test(i))){let e=(0,k.ZF)(i);
1s.push({field:"doi",rule:"a DOI prints as doi:10.x rather than as a link",message:"This DOI is written as a URL.",level:"note",fix:{field:"doi",value:e,label:`Write it as doi:${e}`}})}return!function(e,t,s){let r=(0,p.Jt)(e.fields,"pages");if(!r)return;let n=r.split(/\s*[-ââ]\s*/);if(2!==n.length)return;let a=(n[0]??"").trim(),i=(n[1]??"").trim();if(/^\d+$/.test(a)&&/^\d+$/.test(i)){if(i.length===a.length&&Number(i)<Number(a))return s.push({field:"pages",rule:"a page range runs forward",message:`The last page (${i}) is lower than the first (${a}). One of the two numbers is wrong.`,level:"warn"});if(!t.elidePages){let e=(0,k.JV)(a,i);e&&s.push({field:"pages",rule:"you have turned page elision off, so both numbers print in full",message:`${a}-${i} is already elided, and elision is switched off, so it will print exactly like that. Written out in full it is ${a}-${e}.`,level:"note",fix:{field:"pages",value:`${a}-${e}`,label:`Write it as ${a}-${e}`}})}}}(e,t,s),"journal"===e.type&&(0,p.Jt)(r,"volume")&&!(0,p.Jt)(r,"issue")&&s.push({field:"issue",rule:"the issue number is left out entirely when the journal has none",message:"No issue number, which is fine on its own. Plenty of journals number continuously and have none, and then the brackets are simply not printed. Check the article if you are not sure.",level:"note"}),"website"!==e.type&&"report"!==e.type||(0,p.Jt)(r,"accessed")||s.push({field:"accessed",rule:"an online source carries the date you read it",message:"No date yet. It is a claim about when you read the page, so nothing here fills it in on its own. Press the button on the day you actually read it.",level:"warn"}),"website"!==e.type&&"report"!==e.type||(0,p.Jt)(r,"url")||s.push({field:"url",rule:"an online source ends with its address",message:"No URL yet.",level:"warn"}),"book"!==e.type&&"chapter"!==e.type||(0,p.Jt)(r,"place")||s.push({field:"place",rule:"Vancouver keeps the place of publication",message:"No place of publication. This is one of the spots Vancouver and AMA differ, since AMA 11 dropped the city and NLM did not, so a book reference copied out of an AMA paper will be missing it.",level:"note"}),"book"!==e.type&&"chapter"!==e.type||(0,p.Jt)(r,"publisher")||s.push({field:"publisher",rule:"a book names its publisher",message:"No publisher yet.",level:"note"}),s}(t,ej));return e},[s.list,ej]),eT=(0,n.useMemo)(()=>s.list.filter(e=>(eA.get(e.id)??[]).some(e=>"warn"===e.level)).length,[s.list,eA]),eC=(0,n.useMemo)(()=>(0,k.Ir)(s.list),[s.list]),eS=(0,n.useMemo)(()=>(function(e){let{markers:t}=w(e);if(!t.length)return null;let s=t.filter(e=>"key"===e.shape).length;return s&&s===t.length?"authoring":s?null:"import"})(ek),[ek]),eD=(0,n.useMemo)(()=>(0,p.pb)(e$,ej),[e$,ej]),eI=(0,n.useMemo)(()=>(0,p.dI)(e$,ej),[e$,ej]),eM=(0,n.useMemo)(()=>s.list.length||s.draft.trim()?z(JSON.stringify({v:1,r:s.list.map(e=>{let t={};for(let[s,r]of Object.entries(e.fields))r.trim()&&(t[s]=r);return{t:e.type,f:t}}),d:s.draft,s:o})):"",[s,o]),eP=eM.length>8e3,eL=(0,n.useCallback)(()=>(0,h.CZ)([{key:"cfg",value:z(JSON.stringify({v:1,s:o}))},{key:"state",value:eM&&!eP?eM:null,personal:"your draft and the sources you typed into it"}]),[o,eM,eP]),eR="superscript"===o.output?"with the markers as real superscript":"paren"===o.output?"with the markers in round brackets":"with the markers in square brackets",eO="authoring"===o.mode?"named marker mode":"renumber mode";return y?(0,r.jsxs)("div",{className:"space-y-8",children:["shared"===S&&F&&(0,r.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm print:hidden",children:[(0,r.jsx)("p",{className:"font-medium",children:"You are looking at a shared draft and source list."}),(0,r.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Your own saved work is still here, untouched",I?`, from ${new Date(I).toLocaleString()}`:"",". Nothing is written until you pick one."]}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,r.jsx)(i.$,{size:"sm",onClick:()=>{ep(s,o),U(!1),D("link")},children:"Keep the shared one"}),(0,r.jsx)(i.$,{variant:"outline",size:"sm",onClick:()=>{try{let e=localStorage.getItem(L),t=e?JSON.parse(e):null,s=t?.doc?K(t.doc):null;s&&(eh(s),b(B(t?.settings)))}catch{}U(!1),D("restored")},children:"Discard it and go back to mine"})]})]}),"restored"===S&&!F&&I&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground print:hidden",children:["Restored your saved draft and sources from ",new Date(I).toLocaleStr
1ing(),". They live on this device only and are never uploaded."]}),"link"===S&&!F&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground print:hidden",children:"This came from a shared link. Every number on the page was worked out here from the draft, not carried in the link."}),"fresh"===S&&0===e.past.length&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground print:hidden",children:[(0,r.jsx)("span",{children:"Three example sources and a short draft are loaded. The draft cites them out of order on purpose, so the renumbering is visible before you type anything."}),(0,r.jsx)(i.$,{variant:"outline",size:"sm",onClick:()=>ef(()=>({list:[],draft:""})),children:"Clear the examples"})]}),_&&(0,r.jsx)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm print:hidden",children:_}),(0,r.jsxs)("section",{className:"space-y-3 print:hidden",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)(d.J,{htmlFor:"vc-draft",className:"text-base",children:"Your draft"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:function(){t(e=>{let t=e.past[e.past.length-1];return t?{present:t,past:e.past.slice(0,-1),future:[e.present,...e.future].slice(0,50),mergeKey:null}:e})},disabled:!e.past.length,children:"Undo"}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:function(){t(e=>{let t=e.future[0];return t?{present:t,past:[...e.past,e.present].slice(-50),future:e.future.slice(1),mergeKey:null}:e})},disabled:!e.future.length,children:"Redo"})]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:[{id:"import",label:"Renumber a draft that already has numbers"},{id:"authoring",label:"Write with named markers instead"}].map(e=>(0,r.jsx)(i.$,{size:"sm",variant:o.mode===e.id?"default":"outline",onClick:()=>b(t=>({...t,mode:e.id})),children:e.label},e.id))}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"import"===o.mode?"Marker 3 in this draft means the source sitting third in your list below, which is the assumption your existing numbering was built on. The numbers are then rebuilt from first appearance, so put your list in the order your draft'
1s numbers currently refer to.":"A named marker is bound to the source itself, not to a position, so it survives every insertion. Add a source below and use its Insert button to drop its marker at the caret."}),eS&&eS!==o.mode&&(0,r.jsx)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs",children:"authoring"===eS?"Every marker in this draft is a named one, but the page is set to read numbers. Switch above or nothing will resolve.":"Every marker in this draft is a number, but the page is set to read named markers. Switch above or nothing will resolve."}),(0,r.jsx)(u.T,{id:"vc-draft",ref:eu,value:s.draft,onChange:e=>eg(e.target.value),placeholder:"import"===o.mode?"Paste your draft here. Markers like [1], [2,4], [3-6], round brackets and superscript digits are all read.":"Write here and drop a named marker in with the Insert button on any source below.",className:"min-h-[220px] font-mono text-sm"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[s.draft.length.toLocaleString()," of ",2e5.toLocaleString()," characters"]}),(0,r.jsxs)("span",{children:[eN.markers.length," marker",1===eN.markers.length?"":"s"," found"]}),(0,r.jsxs)("span",{children:["Undo keeps the last ",50," steps."]})]}),el&&(0,r.jsx)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:el}),eN.skipped>0&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:["This draft holds more than ",5e3.toLocaleString()," markers, so"," ",eN.skipped.toLocaleString()," past that point were left alone rather than renumbered. Split the document and run the halves separately."]}),eN.empty&&s.draft.trim().length>0&&(0,r.jsxs)("div",{className:"rounded-md border border-input bg-muted/40 p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium",children:"No citation markers turned up in that draft."}),(0,r.jsx)("p",{className:"mt-1 text-muted-foreground",children:"Here is every shape that gets read, so you can see which one yours is missing."}),(0,r.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs text-muted-foreground",children:Object.keys(x).map(e=>(0,r.jsx)("li",{children:x[e]},e))}),(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Until one of those shows up, the list below stays in the order you added it."})]}),eN.shapesFound.length>0&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Read as ",eN.shapesFound.map(e=>x[e]).join(", and "),"."]}),eN.exponentCount>0&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[eN.exponentCount.toLocaleString()," superscript",1===eN.exponentCount?"":"s"," ","read as a unit or a power rather than a citation, starting with"," ",(0,r.jsx)("span",{className:"font-mono",children:eN.exponents.slice(0,3).join(" ")}),". Those are left exactly as you typed them and take no number."]}),eN.unresolved.length>0&&(0,r.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[(0,r.jsxs)("p",{className:"font-medium",children:[eN.unresolved.length," marker",1===eN.unresolved.length?"":"s"," in the draft point at a source that is not in your list."]}),(0,r.jsx)("ul",{className:"mt-2 space-y-1 text-xs",children:eN.unresolved.slice(0,12).map((e,t)=>(0,r.jsxs)("li",{children:["Line ",e.line,", character ",e.column,", reading"," ",(0,r.jsx)("span",{className:"font-mono",children:e.raw}),". ",e.detail]},`${e.start}-${t}`))}),eN.unresolved.length>12&&(0,r.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[eN.unresolved.length-12," more like that further down."]}),(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"They print as a question mark rather than as a number, because a number that points at nothing is worse than a gap you can see."})]}),!eN.empty&&eN.orphans.length>0&&(0,r.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[(0,r.jsxs)("p",{className:"font-medium",children:[eN.orphans.length," source",1===eN.orphans.length?"":"s"," in your list"," ",1===eN.orphans.length?"is":"are"," never cited in the draft."]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"In a numbered style that is an error rather than a spare, so they are left out of the finished list instead of being given a number at the end."}),(0,r.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs",children:eN.orphans.map(e=>(0,r.jsx)("li",{children:(0,p.OK)(e,ej)||"an empty reference"},e.id))})]})]}),(0,r.jsxs)("section",{className:"space-y-3 print:hidden",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)(d.J,{className:"text-base",children:["Your sources (",s.list.length,")"]}),eT>0&&(0,r.jsxs)("span",{className:"text-xs font-medium text-amber-600 dar
1k:text-amber-400",children:[1===eT?"1 source needs":`${eT} sources need`," a look."]})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The number beside each one is where the draft puts it, not where it sits here. Room for"," ",200," sources. Reordering only matters in the mode that reads numbers, where this order is what the existing numbers in your draft refer to."]}),eC.map(e=>(0,r.jsxs)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Source ",e.a," and source ",e.b," look like the same thing. Nothing was merged, that call is yours."]},`${e.a}-${e.b}`)),0===s.list.length?(0,r.jsx)("div",{className:"rounded-md border border-dashed border-input bg-muted/30 p-4 text-sm text-muted-foreground",children:"No sources yet. Add one below, or drop a PubMed .nbib or a .ris file into the import box further down."}):(0,r.jsx)("ol",{className:"space-y-2",children:s.list.map((e,t)=>(0,r.jsx)(V,{ref_:e,index:t,total:s.list.length,style:ej,mode:o.mode,citedAs:eN.numberOf.get(e.id),open:Z===e.id,findings:eA.get(e.id)??[],dragging:G===e.id,onToggle:()=>H(t=>t===e.id?null:e.id),onField:(t,s)=>{var r;return r=e.id,void eb(r,e=>{let r={...e.provenance};return r[t]="typed",{...e,fields:{...e.fields,[t]:s},provenance:r}},`field:${r}:${t}`)},onType:t=>{var s;return s=e.id,void(ee(t),eb(s,e=>({...e,type:t})))},onFix:(t,s)=>{var r;return r=e.id,void eb(r,e=>{let r={...e.provenance};return r[t]="suggested",{...e,fields:{...e.fields,[t]:s},provenance:r}})},onRemove:()=>{var t;return t=e.id,void(ef(e=>({...e,list:e.list.filter(e=>e.id!==t)})),H(e=>e===t?null:e))},onDuplicate:()=>(function(e){if(s.list.length>=200)return void X(`This page holds 200 references and you are at ${s.list.length}, so nothing was added.`);ef(t=>{let s=t.list.findIndex(t=>t.id===e),r=t.list[s];if(!r)return t;let n={id:E(),type:r.type,fields:{...r.fields,[p.Ey]:""},provenance:{...r.provenance}},a=[...t.list];return a.splice(s+1,0,ex(n,t.list)),{...t,list:a}})})(e.id),onInsert:()=>(function(e){let t=eu.current,r=s.draft;if(!t)return void eg(`${r}${e}`);let n=t.selectionStart??r.length,a=t.selectionEnd??n;eg(`${r.slice(0,n)}${e}${r.slice(a)}`),requestAnimationFrame(()=>{t.focus();let s=n+e.length;t.setSelectionRange(s,s)})})(`[@${(0,p.Jt)(e.fields,p.Ey)||"source"}]`),onMoveUp:()=>ey(t,t-1),onMoveDown:()=>ey(t,t+1),onDragStart:()=>q(e.id),onDragEnd:()=>q(null),onDropOn:()=>{if(!G||G===e.id)return;let r=s.list.findIndex(e=>e.id===G);r>=0&&ey(r,t),q(null)}},e.id))}),(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,r.jsxs)("div",{className:"min-w-[14rem] flex-1 space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:"vc-new-type",children:"Add a source"}),(0,r.jsx)("select",{id:"vc-new-type",value:Q,onChange:e=>ee(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p.m7.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsx)(i.$,{size:"sm",onClick:()=>(function(e){if(s.list.length>=200)return void X(`This page holds 200 references and you are at ${s.list.length}, so nothing was added.`);let t=C(e);ee(e),ef(e=>({...e,list:[...e.list,ex(t,e.list)]})),H(t.id),X(null)})(Q),children:"Add it"})]})]}),(0,r.jsxs)("section",{className:"space-y-3 print:hidden",children:[(0,r.jsx)(d.J,{className:"text-base",children:"How it should print"}),(0,r.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:"vc-author-rule",children:"The et al rule your journal uses"}),(0,r.jsx)("select",{id:"vc-author-rule",value:o.authorRuleId,onChange:e=>b(t=>({...t,authorRuleId:e.target.value})),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p.OD.map(e=>(0,r.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Change this and every source below reformats at once, which is the five-minute version of retargeting a paper at a different journal."})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:"vc-marker-style",children:"How the in-text markers print"}),(0,r.jsxs)("select",{id:"vc-marker-style",value:o.output,onChange:e=>b(t=>({...t,output:e.target.value})),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)("option",{value:"bracket",children:"Square brackets, [1]"}),(0,r.jsx)("option",{value:"paren",children:"Round brackets, (1)"}),(0,r.jsx)("option",{value:"superscript",children:"Superscript"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Universities and journals split on this one, so pick the one your handbook shows rather than trusting a default."})]}),(0,r.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-1",checked:o.elidePages,onChange:e=>b(t=>({...t,elidePages:e.target.checked}))}),(0,r.jsxs)("span",{children:["Elide page ranges, so 284-287 prints as 284-7",(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:"This is the NLM convention and the biggest visible difference from AMA. An e-locator or an article number is never shortened."})]})]}),(0,r.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-1",checked:o.collapse,onChange:e=>b(t=>({...t,collapse:e.target.checked}))}),(0,r.jsxs)("span",{children:["Join three or more consecutive numbers, so 1,2,3 prints as 1-3",(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Two in a row are left alone, which is what most Vancouver guides ask for. Turn it off and every number prints."})]})]})]})]}),(0,r.jsxs)("section",{className:"space-y-3 print:hidden",children:[(0,r.jsx)(d.J,{className:"text-base",children:"Bring sources in without typing them"}),(0,r.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{onDragOver:e=>{e.preventDefault(),ei(!0)},onDragLeave:()=>ei(!1),onDrop:e=>{if(e.preventDefault(),ei(!1),e.dataTransfer.files.length)ew(e.dataTransfer.files);else{let t=e.dataTransfer.getData("text/plain");t&&ev(P(t),"the dropped text")}},onClick:()=>ed.current?.click(),onKeyDown:e=>
1{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),ed.current?.click())},role:"button",tabIndex:0,className:`cursor-pointer rounded-md border-2 border-dashed p-4 text-sm transition-colors ${ea?"border-primary bg-primary/5":"border-input bg-muted/30"}`,children:[(0,r.jsx)("p",{className:"font-medium",children:"PubMed and reference-manager files"}),(0,r.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Click to choose a file, or drag one into this box, or paste a record straight in with Ctrl+V. Reads .nbib and MEDLINE from PubMed Send to, and .ris from Zotero, Mendeley or EndNote. Up to ",500," records per import, counting every file you drop at once."]}),(0,r.jsx)("input",{ref:ed,type:"file",accept:".nbib,.ris,.txt,.medline",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&ew(e.target.files),e.target.value=""}})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"A tag the parser does not know is kept on the row rather than thrown away, and the row says how many it kept."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(d.J,{htmlFor:"vc-paste",children:"Paste a citation or a
1whole bibliography"}),(0,r.jsx)(u.T,{id:"vc-paste",value:et,onChange:e=>es(e.target.value),placeholder:"Paste PubMed's Cite line, or an existing reference list, one entry per paragraph.",className:"min-h-[120px] font-mono text-xs"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(i.$,{size:"sm",variant:"outline",disabled:!et.trim(),onClick:()=>{ev(P(et),"what you pasted"),es("")},children:"Read it"}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[et.length.toLocaleString()," characters"]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"A PubMed Cite line reads properly, because its parts arrive in a fixed order. Anything looser gets only what can be defended, which is the DOI, the year, the volume and pages, a PMID and a URL. The rest stays on the row and is flagged, because guessing where an author list ends is how a bibliography goes quietly wrong."})]})]}),er&&(0,r.jsx)("p",{className:"rounded-md border border-input bg-muted/40 p-3 text-sm",children:er})]}),(0,r.jsxs)("section",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 print:hidden",children:[(0,r.jsx)(d.J,{className:"text-base",children:"Your draft with the numbers fixed"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(l.i,{value:eN.text,html:eN.html,label:"Copy the draft (formatted)",copiedLabel:`Copied ${eR}, ${eO}`,describe:"the renumbered draft with formatting",disabled:!s.draft.trim()}),(0,r.jsx)(l.i,{value:eN.text,label:"Copy the draft (plain text)",copiedLabel:`Copied as plain text, ${eO}`,describe:"the renumbered draft as plain text",disabled:!s.draft.trim()})]})]}),(0,r.jsx)("div",{className:"max-h-72 overflow-y-auto whitespace-pre-wrap rounded-md border border-input bg-background p-4 font-mono text-sm leading-relaxed print:hidden",children:s.draft.trim()?eN.text:(0,r.jsx)("span",{className:"font-sans text-muted-foreground",children:"Your renumbered draft appears here."})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground print:hidden",children:"Copy formatted keeps a superscript marker as a real superscript when you paste into Word or Google Docs. Plain text drops it to ordinary characters, which is the failure people never notice, so both buttons say which one they used."})]}),(0,r.jsxs)("section",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"hidden font-semibold print:block",children:"References"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 print:hidden",children:[(0,r.jsx)(d.J,{className:"text-base",children:"The reference list, in the order your draft cites them"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(l.i,{value:eD,html:eI,label:"Copy list (formatted)",copiedLabel:`Copied with the layout kept, ${eO}`,describe:"the reference list with formatting",disabled:!e$.length}),(0,r.jsx)(l.i,{value:eD,label:"Copy list (plain text)",copiedLabel:`Copied as plain text, ${eO}`,describe:"the reference list as plain text",disabled:!e$.length}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",disabled:!e$.length,onClick:()=>window.print(),children:"Print"})]})]}),eN.empty&&s.list.length>0&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground print:hidden",children:"Nothing in the draft cites anything yet, so this is the order you added them in. Cite them and the order follows the text."}),(0,r.jsx)("div",{className:"rounded-md border border-input bg-background p-4 text-sm leading-relaxed print:border-0 print:p-0",children:0===e$.length?(0,r.jsx)("p",{className:"text-muted-foreground",children:"Your finished list appears here."}):(0,r.jsx)("ol",{className:"space-y-2",children:e$.map((e,t)=>{let s=(0,p.SD)(e);return(0,r.jsxs)("li",{className:"pl-8 -indent-8",children:[(0,r.jsxs)("span",{className:"font-medium",children:[t+1,"."]})," ",(0,p.ov)(e,ej)?J((0,p.R6)(e.type,e.fields,ej)):(0,r.jsx)("span",{className:"text-muted-foreground",children:"this source is still empty"}),s.length>0&&(0,r.jsxs)("span",{className:"ml-1 text-xs text-amber-600 dar
1k:text-amber-400 print:hidden",children:["(still missing ",s.join(", ").toLowerCase(),")"]})]},e.id)})})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground print:hidden",children:"Nothing you type is uploaded, there is no account, and there is no daily cap or export paywall."})]}),!ec&&(0,r.jsxs)("section",{className:"space-y-2 print:hidden",children:[(s.list.length>0||s.draft.trim().length>0)&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:eP?`This encodes to ${eM.length.toLocaleString()} characters and the link limit here is ${8e3.toLocaleString()}, so Share would copy the page address without your work in it. Copy the list instead, or share a shorter draft. Nothing gets truncated.`:`Share copies a link carrying the draft, all ${s.list.length} source${1===s.list.length?"":"s"} and the settings that produced this numbering, so it doubles as your bookmark and as the way to hand a starting list to somebody else. The Embed code carries the settings only, because an embed goes on a page anybody can read.`}),(0,r.jsx)(c.ToolActions,{share:eL,title:"Vancouver Citation Generator",embedCarriesPersonal:!1})]})]}):(0,r.jsx)("div",{className:"rounded-md border border-input bg-muted/30 p-6 text-sm text-muted-foreground",children:"Loading your draft and your sources."})}function V({ref_:e,index:t,total:s,style:n,mode:a,citedAs:l,open:c,findings:h,dragging:m,onToggle:f,onField:g,onType:x,onFix:b,onRemove:y,onDuplicate:v,onInsert:w,onMoveUp:j,onMoveDown:k,onDragStart:N,onDragEnd:$,onDropOn:T}){let C=p.bX[e.type],S=(0,p.OK)(e,n),D=h.filter(e=>"warn"===e.level),I=(0,p.Jt)(e.fields,p.Ey);return(0,r.jsxs)("li",{draggable:!c,onDragStart:N,onDragEnd:$,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),T()},className:`rounded-md border bg-background p-3 ${m?"border-primary opacity-60":"border-input"}`,children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:`mt-0.5 w-16 shrink-0 cursor-grab select-none text-xs font-semibold ${void 0===l?"text-muted-foreground":""}`,children:void 0===l?"not cited":`cited as ${l}`}),(0,r.jsx)("button",{type:"button",onClick:f,className:"min-w-0 flex-1 text-left text-sm leading-relaxed hover:underline","aria-expanded":c,children:S?J((0,p.R6)(e.type,e.fields,n)):(0,r.jsx)("span",{className:"text-muted-foreground",children:"Empty source, open it and fill it in."})})]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:["authoring"===a&&(0,r.jsxs)(i.$,{variant:"outline",size:"sm",onClick:w,children:["Insert [@",I||"source","]"]}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:j,disabled:0===t,"aria-label":"Move this source up",children:"Up"}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:k,disabled:t===s-1,"aria-label":"Move this source down",children:"Down"}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:v,children:"Duplicate"}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:f,children:c?"Close":"Edit"}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:y,children:"Delete"}),D.length>0&&!c&&(0,r.jsxs)("span",{className:"ml-1 text-xs text-amber-600 dark:text-amber-400",children:[D.length," thing",1===D.length?"":"s"," to check"]})]}),c&&(0,r.jsxs)("div",{className:"mt-3 space-y-3 border-t border-input pt-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:`type-${e.id}`,children:"Source type"}),(0,r.jsx)("select",{id:`type-${e.id}`,value:e.type,onChange:e=>x(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p.m7.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:`key-${e.id}`,children:"Citation key, for named markers"}),(0,r.jsx)(o.p,{id:`key-${e.id}`,value:I,placeholder:"smith2002",onChange:e=>g(p.Ey,e.target.value.replace(/[^A-Za-z0-9_.\-]/g,""))}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"This is what a named marker points at, so it is bound to this source rather than to a number. Rename it and any marker still using the old name is reported as unresolved with its position in the draft."})]}),C.map(t=>(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)(d.J,{htmlFor:`${t.key}-${e.id}`,children:t.label}),t.dateHelper&&(0,r.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>g(t.key,(0,p.JC)()),children:"Use today"})]}),t.multiline?(0,r.jsx)(u.T,{id:`${t.key}-${e.id}`,value:(0,p.Jt)(e.fields,t.key),placeholder:t.placeholder,onChange:e=>g(t.key,e.target.value),className:"min-h-[68px] text-sm"}):(0,r.jsx)(o.p,{id:`${t.key}-${e.id}`,value:(0,p.Jt)(e.fields,t.key),placeholder:t.placeholder,onChange:e=>g(t.key,e.target.value)}),t.multiline&&"authors"===t.key&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["One name per line. A body rather than a person goes in braces, so"," ",(0,r.jsx)("span",{className:"font-mono",children:"{World Health Organization}"})," prints as written. Up to ",A.WY," names on an imported record."]})]},t.key)),(0,r.jsxs)("div",{className:"space-y-2 rounded-md border border-input bg-muted/40 p-3",children:[(0,r.jsx)("p",{className:"text-xs font-medium",children:"What the rules say about this one"}),0===h.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Every check on this source passed."}):(0,r.jsx)("ul",{className:"space-y-2",children:h.map((e,t)=>(0,r.jsxs)("li",{className:"text-xs",children:[(0,r.jsx)("span",{className:"warn"===e.level?"font-medium text-amber-600 dar
1k:text-amber-400":"font-medium text-muted-foreground",children:e.field})," ",(0,r.jsxs)("span",{className:"text-muted-foreground",children:["(",e.rule,")"]}),(0,r.jsx)("p",{className:"mt-0.5",children:e.message}),e.fix&&(0,r.jsx)(i.$,{variant:"outline",size:"sm",className:"mt-1",onClick:()=>{let t=e.fix;t&&b(t.field,t.value)},children:e.fix.label})]},`${e.field}-${t}`))})]}),e.importNotes&&e.importNotes.length>0&&(0,r.jsxs)("div",{className:"rounded-md border border-input bg-muted/40 p-3 text-xs",children:[(0,r.jsx)("p",{className:"font-medium",children:"From the import"}),(0,r.jsx)("ul",{className:"mt-1 list-disc space-y-1 pl-4 text-muted-foreground",children:e.importNotes.map((e,t)=>(0,r.jsx)("li",{children:e},t))})]}),e.raw&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.J,{htmlFor:`raw-${e.id}`,children:"Text the importer kept but did not place"}),(0,r.jsx)(u.T,{id:`raw-${e.id}`,value:e.raw,readOnly:!0,className:"min-h-[68px] font-mono text-xs"})]})]})]})}},63483:(e,t,s)=>{s.d(t,{Ar:()=>i,EA:()=>x,GY:()=>$,WY:()=>n,jE:()=>A,w3:()=>m});var r=s(8736);let n=60;function a(e){return(0,r.V6)(e.fieldKeys)}function i(e,t,s){let n=(0,r.V6)(t);if(s)for(let e of t){let t=s[e];"string"==typeof t&&(n[e]=t)}return{id:(0,r.xO)(),type:e,fields:n,provenance:{}}}function l(e,t){let s={};for(let[r,n]of Object.entries(e))n.trim()&&(s[r]=t);return s}let o=/^([A-Z][A-Z0-9]{1,3})\s*-\s?(.*)$/,d=new Set(["PMID","TI","AU","FAU","CN","JT","TA","DP","VI","IP","PG","LID","AID","SO","OWN","STAT","DCOM","LR","IS","DA","JID","PST","PT","LA","EDAT","MHDA","CRDT","PHST","AB","AD","CI","OT","MH","PL","TT","SB","COIS","FIR","IR","GR","RN"]),u=new Set(["TI","AU","FAU","CN","JT","TA","DP","VI","IP","PG","LID","AID"]),c=new Set(["AB","MH","OT","AD","CI","GR","RN","PT","LA","SB","COIS","FIR","IR","OWN","STAT","DCOM","LR","DA","EDAT","MHDA","CRDT","PHST","JID","PST","TT","PL"]);function h(e,t){let s=e.values.get(t);return((s&&s.length?s[0]:void 0)??"").trim()}function p(e,t){return(e.values.get(t)??[]).map(e=>e.trim()).filter(Boolean)}function m(e,t){let s=function(e){let t=[],s=null,r=null,n=()=>({values:new Map,unknownTags:[],rawLines:[]});for(let a of e.split(/\r?\n/)){if(!a.trim()){s&&s.values.size&&t.push(s),s=null,r=null;continue}if(s||(s=n()),/^\s/.test(a)&&r){let e=s.values.get(r);if(e&&e.length){let t=e.length-1,s=e[t];void 0!==s&&(e[t]=`${s} ${a.trim()}`)}continue}let e=o.exec(a);if(!e){s.rawLines.push(a.trim());continue}let i=e[1]??"",l=(e[2]??"").trim();r=i;let h=s.values.get(i);h?h.push(l):s.values.set(i,[l]),d.has(i)?u.has(i)||c.has(i)||s.rawLines.push(`${i}: ${l}`):s.unknownTags.push(i)}return s&&s.values.size&&t.push(s),t}(e),i=[];for(let e of s){let s=[],o=a(t),d=p(e,"FAU").length?p(e,"FAU"):p(e,"AU"),u=[...p(e,"CN").map(e=>`{${e}}`),...d];u.length>n&&(s.push(`This record listed ${u.length} authors and the limit here is ${n}, so the first ${n} were kept.`),u=u.slice(0,n)),o.authors=u.join("\n"),o.title=h(e,"TI");let c=h(e,"TA"),m=h(e,"JT");c?(o.journal=c,s.push(t.abbreviationNote??"The journal abbreviation came from the record itself, not from any rule here.")):m&&(o.journal=m,s.push(t.fullTitleNote??"This record had no NLM abbreviation in it, so the full journal title was used."));let f=h(e,"DP"),g=/\b(1[5-9]\d{2}|20\d{2})\b/.exec(f);o.year=g?g[0]:"",o.volume=h(e,"VI"),o.issue=h(e,"IP"),o.pages=h(e,"PG"),o.doi=function(e){for(let t of["LID","AID"])for(let s of p(e,t))if(/\[doi\]/i.test(s)){let e=/10\.\d{4,9}\/\S+/.exec(s);if(e)return e[0]}return""}(e),t.fieldKeys.includes("pmid")&&(o.pmid=function(e){for(let t of["PMID","AN","ID"]){let s=h(e,t);if(/^\d{4,9}$/.test(s))return s}return""}(e));let x=Array.from(new Set(e.unknownTags));x.length&&s.push(`${x.length} tag${1===x.length?"":"s"} were not recognized and were kept below.`);let b={id:(0,r.xO)(),type:"journal",fields:o,provenance:l(o,"imported"),importNotes:s},y=[...e.rawLines,...x.map(t=>`${t}: ${p(e,t).join(" | ")}`)];y.length&&(b.raw=y.join("\n")),i.push(b)}return{refs:i,recordsFound:s.length,notices:[]}}let f=/^([A-Z][A-Z0-9])\s{2}-\s?(.*)$/,g={JOUR:"journal",EJOUR:"journal",BOOK:"book",EBOOK:"book",CHAP:"chapter",ELEC:"website",ICOMM:"website",WEB:"website",CONF:"conference",CPAPER:"c
1onference",THES:"thesis",RPRT:"report"};function x(e,t){let s=[],i=[],o=0,d=a(t),u=[],c=[],h="",p="",m="journal",x=!1,b=[],y=[],v=0,w=()=>{if(!x)return;o++,u.length>n&&(b.push(`This record listed ${u.length} authors and the limit here is ${n}, so the first ${n} were kept.`),u=u.slice(0,n)),d.authors=u.join("\n"),d.editors=c.join("\n"),h&&p?d.pages=`${h}-${p}`:h&&(d.pages=h);let e={id:(0,r.xO)(),type:m,fields:d,provenance:l(d,"imported"),importNotes:[...b]};y.length&&(e.raw=y.join("\n")),s.push(e),d=a(t),u=[],c=[],h="",p="",m="journal",x=!1,b.length=0,y.length=0};for(let s of e.split(/\r?\n/)){if(!s.trim())continue;let e=f.exec(s);if(!e){v++,x&&y.push(s.trim());continue}let r=e[1]??"",n=(e[2]??"").trim();if("TY"===r){w(),x=!0,m=g[n.toUpperCase()]??"journal",!g[n.toUpperCase()]&&n&&b.push(`The record type "${n}" is not one this page formats, so it was treated as a journal article.`);continue}switch(!x&&(x=!0),r){case"ER":w();break;case"AU":case"A1":n&&u.push(n);break;case"ED":case"A2":n&&c.push(n);break;case"TI":case"T1":d.title=n;break;case"JO":case"JF":case"JA":case"T2":"chapter"===m||"conference"===m?d.container=n:d.journal=n;break;case"VL":d.volume=n;break;case"IS":d.issue=n;break;case"SP":h=n;break;case"EP":p=n;break;case"PY":case"Y1":{let e=/\b(1[5-9]\d{2}|20\d{2})\b/.exec(n);e&&(d.year=e[0]);break}case"DO":d.doi=n;break;case"UR":d.url=n;break;case"PB":d.publisher=n;break;case"ET":d.edition=n;break;case"AN":case"ID":case"M1":t.fieldKeys.includes("pmid")&&/^\d{4,9}$/.test(n)&&!d.pmid?d.pmid=n:n&&y.push(`${r}: ${n}`);break;case"CY":if(n){let e=t.onPublisherCity?t.onPublisherCity(n,d):null;e&&b.push(e)}break;default:y.push(`${r}: ${n}`)}}return w(),v&&i.push(`${v} line${1===v?"":"s"} had no RIS tag on them and were kept as notes rather than read.`),{refs:s,recordsFound:o,notices:i}}let b=/10\.\d{4,9}\/[^\s,;)\]]+/,y=/\b(1[5-9]\d{2}|20\d{2})\b/,v=/https?:\/\/[^\s,)\]]+/,w=/\b(\d{1,4})\s*\(\s*([^)]{1,12}?)\s*\)\s*[:,]\s*([A-Za-z]?\d+(?:\s*[-â]\s*[A-Za-z]?\d+)?)/,j=/;\s*(\d{1,4})\s*:\s*([A-Za-z]?\d+(?:\s*[-â]\s*[A-Za-z]?\d+)?)/,k=/\b([A-Z][A-Za-z.\s]{2,25}),\s*([A-Z]{2})\s*:\s*([^.;]{2,60})/,N=/\bPMID:\s*(\d{4,9})/i;function $(e,t){let s=function(e){let t=e.trim();return t?/\n\s*\n/.test(t)?t.split(/\n\s*\n+/).map(e=>e.trim()).filter(Boolean):/^\s*\d{1,3}[.)]\s+/m.test(t)?t.split(/\n(?=\s*\d{1,3}[.)]\s+)/).map(e=>e.replace(/^\s*\d{1,3}[.)]\s+/,"").trim()).filter(Boolean):t.split(/\n+/).map(e=>e.trim()).filter(Boolean):[]}(e),n=[];for(let e of s){let s=a(t),i=["This came in as loose text, so only the parts below were recognized. Everything else is kept underneath for you to move into the right fields."],o=b.exec(e);o&&(s.doi=o[0].replace(/[.,;]$/,""));let d=y.exec(e);d&&(s.year=d[0]);let u=w.exec(e);if(u)s.volume=u[1]??"",s.issue=u[2]??"",s.pages=(u[3]??"").replace(/\s*[-â]\s*/,"-");else{let t=j.exec(e);t&&(s.volume=t[1]??"",s.pages=(t[2]??"").replace(/\s*[-â]\s*/,"-"))}let c=v.exec(e);if(c&&!/doi\.org/i.test(c[0])&&(s.url=c[0].replace(/[.,;]$/,"")),t.fieldKeys.includes("pmid")){let t=N.exec(e);t&&t[1]&&(s.pmid=t[1])}let h=k.exec(e);if(h){s.publisher=(h[3]??"").trim();let e=`${h[1]??""}, ${h[2]??""}`,r=t.onPublisherCity?t.onPublisherCity(e,s):null;r&&i.push(r)}n.push({id:(0,r.xO)(),type:"journal",fields:s,raw:e,provenance:l(s,"imported"),importNotes:i})}return{refs:n,recordsFound:s.length,notices:[]}}function A(e,t,s){let r=t.toLowerCase();return r.endsWith(".ris")?x(e,s):r.endsWith(".nbib")||r.endsWith(".medline")||r.endsWith(".txt")?/^TY\s{2}-/m.test(e)?x(e,s):m(e,s):/^TY\s{2}-/m.test(e)?x(e,s):(o.test(e.split(/\r?\n/)[0]??""),m(e,s))}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.