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/C9U,MAAK,KACJR,EAAMkV,UACL/U,EAAAA,EAAMkC,MAAMC,UAAUqN,YAAYC,YACpC9I,EAAAA,EAAAA,GAAe,CACdzF,QAAS,GACT0F,kBAAmB/G,EAAMuU,UAAU5N,kBAAkBC,gBAMxD,IAAI6N,EAAiBtU,EAAAA,EAAMkC,MAAMqS,UAAUC,KAAKlB,WAAWmB,GACnDA,EAAMC,UAAY7U,EAAM6U,UAYhC,OAVsB,GAAnBJ,IAEEtU,EAAAA,EAAMkC,MAAMqS,UAAUC,KAAKF,GAAgBK,kBAAkBC,SAAS/U,EAAMwU,cAC/ErU,EAAAA,EAAMC,OAAO,sCAAuC,CACnD4U,WAAYP,EACZD,YAAaxU,EAAMwU,eAKftU,GAAS,GAEf,G","sources":["webpack:///./src/services/paper/toc/addToPaper.js","webpack:///./src/services/paper/ck/wProofreaderDestroy.js","webpack:///./src/services/paper/parseHiddenTags.js","webpack:///./src/services/paper/researchNotes/calcSortValue.js","webpack:///./src/services/paper/appendices/cleanUp.js","webpack:///./src/services/paper/copyDiscussionPostToClipboard.js","webpack:///./src/services/paper/buildHtml.js","webpack:///./src/services/paper/citations/removeById.js","webpack:///./src/services/paper/removeReferenceFromPaper.js","webpack:///./src/services/paper/restoreVersion.js","webpack:///./src/services/paper/ck/wProofreaderInit.js","webpack:///./src/services/paper/ck/onFocus.js","webpack:///./src/services/paper/ck/numberFigureCaptions.js","webpack:///./src/services/paper/updateReferenceObject.js","webpack:///./src/services/paper/outline/saveContent.js","webpack:///./src/services/paper/ck/onChange.js","webpack:///./src/services/paper/ck/numberTableCaptions.js","webpack:///./src/services/paper/ck/wrapCitation.js","webpack:///./src/services/paper/buildReferencesInPaper.js","webpack:///./src/services/paper/toolDrawer/open.js","webpack:///./src/services/paper/appendices/addToPaper.js","webpack:///./src/services/paper/annotations/addUpdate.js","webpack:///./src/services/paper/citations/insertCitation.js","webpack:///./src/services/paper/downloadDocumentVersionV4.js","webpack:///./src/services/paper/injectContent.js","webpack:///./src/services/paper/loadByRoute.js","webpack:///./src/services/paper/saveDocument.js","webpack:///./src/services/paper/addReferenceToPaper.js"],"sourcesContent":["// TOCS_AddToPaper\n\nimport PS_SaveDocument from '@/services/paper/saveDocument';\nimport store from '@/store';\nimport Vue from 'vue';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('TOCS_AddToPaper');\n\n\t\tstore.commit('paperEdit/meta/SET_IncludeTableOfContents', true);\n\n\t\tPS_SaveDocument({\n\t\t\tisMetaDataChanges: true,\n\t\t\tmessage: 'Added Table of Contents',\n\t\t}).then(()=>{\n\n\t\t\tVue.nextTick(()=>{\n\t\t\t\t// scroll new toc page into view\n\t\t\t\tlet $newInstnaceWrp = document.getElementById('instancePaperToc');\n\t\t\t\tif($newInstnaceWrp){\n\t\t\t\t\t$newInstnaceWrp.scrollIntoView('smooth');\n\t\t\t\t}\n\n\t\t\t\treturn resolve();\n\t\t\t});\n\t\t});\n\n\t});//e:Promise\n}\n","\n\n// PCKS_wProofreaderDestroy\nimport config from '@/config';\nimport store from '@/store';\n\nexport default () => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_wProofreaderDestroy');\n\t\t\n\t\tif(config.useWProofreader && typeof WEBSPELLCHECKER != 'undefined'){\n\n\t\t\t// get all wsc instances (should be one on every ckInstance)\n\t\t\tlet wscInstances = WEBSPELLCHECKER.getInstances();\n\t\t\t\t\t\n\t\t\t// loop through instance\n\t\t\twscInstances.forEach((wscInstance)=>{\n\t\t\t\twscInstance.destroy();\n\t\t\t});\n\t\t}\n\n\t\tstore.commit('paperEdit/ck/SET_IS_WPROOF_READER_ACTIVE', false);\n\t\t\n\t\tresolve();\n\t});//e:Promise\n}\n","// PS_ParseHiddenTags\n// runs when PaperEdit.vue is ready to loadPaperData()\n\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport _orderBy from 'lodash/orderBy';\nimport _sortBy from 'lodash/sortBy';\nimport _uniq from 'lodash/uniq';\nimport config from '@/config';\nimport PAnS_AddUpdate from '@/services/paper/annotations/addUpdate';\nimport PApS_CleanUp from '@/services/paper/appendices/cleanUp';\nimport store from '@/store';\nimport Swal from 'sweetalert2';\nimport toBoolean from 'validator/lib/toBoolean';\t//https://www.npmjs.com/package/validator\n\n// let isOverrideActualPaperContent = true;\t// BOOl used to test users content from paper source, this will bypyass what's actualy in the paper source\n\nexport default (content) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_ParseHiddenTags');\n\n\t\tlet parsedHtml = new DOMParser().parseFromString(content, 'text/html');\n\n\t\t// \n\t\tlet metaElements = parsedHtml.getElementsByTagName(\"meta\");\n\n\t\t\n\t\tlet hasUseNewCitationModeTag = false;\t// assume the user does not have this meta tag\n\n\t\t_forEach(metaElements, (element)=>{\n\t\t\tlet attrName = element.getAttribute('name');\n\t\t\ttry{\n\t\t\t\tlet attrContent = decodeURIComponent(element.getAttribute('content'));\n\t\t\t\t// console.log(attrName + ': ' + attrContent);\n\n\t\t\t\t// if the user has this meta tag set in the paper content then i dont have to add a new one\n\t\t\t\tif(attrName === 'UseNewCitationMode'){\n\t\t\t\t\thasUseNewCitationModeTag = true;\n\t\t\t\t}\n\t\t\t\tstore.commit('paperEdit/meta/SET_' + attrName, attrContent);\n\t\t\t} catch(error){\n\t\t\t\tconsole.log('decodeURIComponent content error');\n\t\t\t\tconsole.log(error);\n\t\t\t}\n\t\t});//e:_forEach\n\n\t\t// if the user didn't have the citation meta tag - add one with value false\n\t\tif(!hasUseNewCitationModeTag){\n\t\t\tstore.commit('paperEdit/meta/SET_UseNewCitationMode', false);\n\t\t}\n\n\t\t// separate conversion from PaperType to DocumentType (if it wasn't found in the meta data)\n\t\tswitch(store.state.paperEdit.meta.PaperType){\n\t\t\tcase config.enums.PaperType.APA7_AnnotatedBibliography:\n\t\t\tcase config.enums.PaperType.MLA9_AnnotatedBibliography:\n\t\t\tcase config.enums.PaperType.Turabian9_AnnotatedBibliography:\n\t\t\t\tstore.commit('paperEdit/meta/SET_DocumentType', config.enums.DocumentType.ANNOTATED_BIBLIOGRAPHY);\n\t\t\t\tbreak;\n\t\t\tcase config.enums.PaperType.APA_DiscussionPost:\n\t\t\tcase config.enums.PaperType.APA7_DiscussionPost:\n\t\t\tcase config.enums.PaperType.MLA_DiscussionPost:\n\t\t\tcase config.enums.PaperType.MLA9_DiscussionPost:\n\t\t\tcase config.enums.PaperType.Turabian9_DiscussionPost:\n\t\t\t\tstore.commit('paperEdit/meta/SET_DocumentType', config.enums.DocumentType.DISCUSSION_POST);\n\t\t\t\tbreak;\n\t\t\tcase config.enums.PaperType.APA7_ReferenceList:\n\t\t\tcase config.enums.PaperType.MLA9_ReferenceList:\n\t\t\tcase config.enums.PaperType.Turabian9_ReferenceList:\n\t\t\t\tstore.commit('paperEdit/meta/SET_DocumentType', config.enums.DocumentType.REFERENCE_LIST);\n\t\t\t\tbreak;\n\t\t\tcase config.enums.PaperType.APA_ResearchPaper:\n\t\t\tcase config.enums.PaperType.APA7_ProfessionalPaper:\n\t\t\tcase config.enums.PaperType.APA7_StudentPaper:\n\t\t\tcase config.enums.PaperType.MLA_ResearchPaper:\n\t\t\tcase config.enums.PaperType.MLA9_ResearchPaper:\n\t\t\tcase config.enums.PaperType.Turabian9_ResearchPaper:\n\t\t\t\tstore.commit('paperEdit/meta/SET_DocumentType', config.enums.DocumentType.RESEARCH_PAPER);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// throw a flag here, the PaperType is needed for the editor to load properly, so no defaults\n\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\n\t\t\t\tSwal.fire({\n\t\t\t\t\tallowOutsideClick: false,\n\t\t\t\t\tbuttonsStyling: false,\n\t\t\t\t\ttext: 'PaperType not found',\n\t\t\t\t\ticon: 'error',\n\t\t\t\t\tconfirmButtonText: 'Ok',\n\t\t\t\t\tshowCloseButton: false,\n\t\t\t\t\tshowConfirmButton: true,\n\t\t\t\t\tcustomClass:{\n\t\t\t\t\t\tconfirmButton: 'btn btn-danger me-2',\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn resolve();\n\t\t}//e:switch\n\n\t\tstore.dispatch('paperEdit/config/setPaperProperties').then(()=>{\n\t\t\t// \n\t\t\tif(store.state.paperEdit.meta.IncludeAuthorNote){\n\t\t\t\tlet authorNoteInPaperElement = parsedHtml.getElementsByTagName(\"author-note\");\n\t\t\t\tif(authorNoteInPaperElement[0]){\n\t\t\t\t\tstore.commit('paperEdit/authorsNote/CONTENT', decodeURIComponent(authorNoteInPaperElement[0].getAttribute('content')));\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t\t// \n\t\t\tif(store.state.paperEdit.meta.IncludeAbstract){\n\t\t\t\t// if(isOverrideActualPaperContent){\n\t\t\t\t// \tlet forceAbstractContentFromPaperSource = `\n\t\t\t\t// \t%3Cp%3EDespite%20an%20expanded%20focus%20on%20educating%20students%20in%20STEM%20disciplines%2C%20nearly%20half%20of%20U.S.%20college%20students%20who%20enroll%20in%20these%20degree%20programs%20fail%20to%20graduate%20(Hamm%20et%20al.%2C%202020%2C%20p.%20623).%20Critics%20sometimes%20blame%20pedagogically%20untrained%20faculty%2C%20(e.g.%20Kahn%2C%202022).%20This%20Dissertation%20in%20Practice%20(DiP)%20focused%20on%20STEM%20university%20faculty's%20motivation%20for%20teaching%20and%20whether%20professors%20are%20motivated%20to%20enroll%20in%20pedagogy%20courses.%20Via%20the%20lens%20of%20Self%20Determination%20Theory%20(SDT)%2C%20this%20DiP%20examined%20to%20what%20extent%20STEM%20faculty%20at%20a%20major%20research%20university%20in%20the%20upper%20Midwest%20could%20devote%20additional%20time%20to%20pedagogy%20by%20enrolling%20in%20a%20college%20teaching%20graduate%20certificate%20program.%20This%20DiP%20utilized%20a%20semi-structured%20interview%20to%20address%20the%20primary%20research%20question%20of%20to%20what%20extent%20faculty%20are%20able%20or%20unable%26nbsp%3Bto%20enroll%20in%20a%20college%20teaching%20graduate%20certificate%20program%20to%20address%20critics%20who%20advocate%20for%20pedagogically-trained%20faculty.%20Findings%20indicated%20that%20...%20This%20DiP%20concludes%20that%2C%20as%20the%20results%20showed%20...%20a%20Delphi%20study%20may%20need%20to%20be%20conducted%20to%20determine%20a%20solution%20to%20the%20untrained%20faculty%20issue%20that%20more%20effectively%20balances%20student%20outcomes%20with%20faculties'%20motivation%20for%20teaching.%3C%2Fp%3E\n\t\t\t\t// \t`;\n\n\t\t\t\t// \tlet forceAbstractKeywordsFromPaperSource = `\n\t\t\t\t// \t%3Cp%3EDespite%20an%20expanded%20focus%20on%20educating%20students%20in%20STEM%20disciplines%2C%20nearly%20half%20of%20U.S.%20college%20students%20who%20enroll%20in%20these%20degree%20programs%20fail%20to%20graduate%20(Hamm%20et%20al.%2C%202020%2C%20p.%20623).%20Critics%20sometimes%20blame%20pedagogically%20untrained%20faculty%2C%20(e.g.%20Kahn%2C%202022).%20This%20Dissertation%20in%20Practice%20(DiP)%20focused%20on%20STEM%20university%20faculty's%20motivation%20for%20teaching%20and%20whether%20professors%20are%20motivated%20to%20enroll%20in%20pedagogy%20courses.%20Via%20the%20lens%20of%20Self%20Determination%20Theory%20(SDT)%2C%20this%20DiP%20examined%20to%20what%20extent%20STEM%20faculty%20at%20a%20major%20research%20university%20in%20the%20upper%20Midwest%20could%20devote%20additional%20time%20to%20pedagogy%20by%20enrolling%20in%20a%20college%20teaching%20graduate%20certificate%20program.%20This%20DiP%20utilized%20a%20semi-structured%20interview%20to%20address%20the%20primary%20research%20question%20of%20to%20what%20extent%20faculty%20are%20able%20or%20unable%26nbsp%3Bto%20enroll%20in%20a%20college%20teaching%20graduate%20certificate%20program%20to%20address%20critics%20who%20advocate%20for%20pedagogically-trained%20faculty.%20Findings%20indicated%20that%20...%20This%20DiP%20concludes%20that%2C%20as%20the%20results%20showed%20...%20a%20Delphi%20study%20may%20need%20to%20be%20conducted%20to%20determine%20a%20solution%20to%20the%20untrained%20faculty%20issue%20that%20more%20effectively%20balances%20student%20outcomes%20with%20faculties'%20motivation%20for%20teaching.%3C%2Fp%3E\n\t\t\t\t// \t`;\n\t\t\t\t\t\n\t\t\t\t// \tstore.commit('paperEdit/abstract/CONTENT', decodeURIComponent(forceAbstractContentFromPaperSource));\n\n\t\t\t\t\t\n\t\t\t\t// \tconsole.log('get me to the greek');\n\n\t\t\t\t// } else {\n\t\t\t\t\tlet abstractInPaperElement = parsedHtml.getElementsByTagName(\"abstract\");\n\t\t\t\t\tif(abstractInPaperElement[0]){\n\t\t\t\t\t\tstore.commit('paperEdit/abstract/CONTENT', decodeURIComponent(abstractInPaperElement[0].getAttribute('content')));\n\t\t\t\t\t\tstore.commit('paperEdit/abstract/KEYWORDS', decodeURIComponent(abstractInPaperElement[0].getAttribute('keywords')));\n\n\t\t\t\t\t}\n\n\t\t\t\t// }\n\t\t\t}\n\n\t\t\t// \n\t\t\tlet _appendicesInPaper = [];\n\t\t\tlet appendicesInPaperElements = parsedHtml.getElementsByTagName(\"appendix\");\n\n\t\t\t_forEach(appendicesInPaperElements, (appendix)=>{\n\t\t\t\tlet appendixContent = '';\n\t\t\t\t\n\t\t\t\t// decode the appendix content\n\t\t\t\tlet appendixContentDecoded = decodeURIComponent(appendix.getAttribute('content'));\n\t\t\t\t\n\t\t\t\t// parse it's content as html\n\t\t\t\tlet appendixContentHtml = new DOMParser().parseFromString(appendixContentDecoded, 'text/html');\n\t\t\t\t\n\t\t\t\t// grab all the h1s in here\n\t\t\t\tlet h1sInAppendix = appendixContentHtml.getElementsByTagName(\"h1\");\n\t\t\t\t\n\t\t\t\t// add a default title element if you need to\n\t\t\t\tif(h1sInAppendix.length > 0){\n\t\t\t\t\t// h1s, go deeper\n\t\t\t\t\tlet isAppendixTitleFound = false;\n\n\t\t\t\t\t// loop through all h1s in this appendix\n\t\t\t\t\t_forEach(h1sInAppendix, (h1)=>{\n\t\t\t\t\t\tif(h1.classList.contains('appendix-title')){\n\t\t\t\t\t\t\tisAppendixTitleFound = true;\n\t\t\t\t\t\t\treturn false; // just need to find one\n\t\t\t\t\t\t}\n\t\t\t\t\t});//forEach:h1sInAppendix\n\n\t\t\t\t\tif(!isAppendixTitleFound){\n\t\t\t\t\t\t// an h1 was found, but not a title so make the same default one again\n\t\t\t\t\t\tappendixContent = '

Type the title of your appendix here

';\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// no h1s, make a new one before the content\n\t\t\t\t\tappendixContent = '

Type the title of your appendix here

';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// the title is ready, append the rest of the content\n\t\t\t\tappendixContent += appendixContentDecoded;\n\n\t\t\t\t// push this appendix to the vuex store\n\t\t\t\t_appendicesInPaper.push({\n\t\t\t\t\tcontent: appendixContent,\n\t\t\t\t\t// sort: appendix.getAttribute('sort'), \t// don't carry over, recalculated every time\n\t\t\t\t\t// label: appendix.getAttribute('label'), \t// don't carry over, recalculated every time\n\t\t\t\t\tuid: appendix.getAttribute('uid'), \n\t\t\t\t});\n\t\t\t});\n\t\t\t\n\t\t\t_appendicesInPaper = _orderBy(_appendicesInPaper, ['sort'], ['asc']);\n\t\t\t\n\t\t\tPApS_CleanUp({\n\t\t\t\tarrayOfAppendices: _appendicesInPaper,\n\t\t\t}).then((cleanedAppendicesInPaper)=>{\n\t\t\t\tstore.commit('paperEdit/appendices/IN_PAPER', cleanedAppendicesInPaper);\n\t\t\t});\n\n\t\t\t// \n\t\t\t// 2023.02.22 - commenting this out since RNs are about to live outside of a paper\n\t\t\t// let researchNotesInPaperElement = parsedHtml.getElementsByTagName(\"research-notes\");\n\t\t\t// if(researchNotesInPaperElement[0]){\n\t\t\t// \ttry{\n\t\t\t// \t\twindow.atob(researchNotesInPaperElement[0].getAttribute('data'));\n\t\t\t// \t\tlet parsedResearhNotes = JSON.parse(window.atob(researchNotesInPaperElement[0].getAttribute('data')));\n\t\t\t// \t\t// console.log('parsedResearhNotes');\n\t\t\t// \t\t// console.log(parsedResearhNotes);\n\t\t\t// \t\tstore.commit('paperEdit/researchNotes/FULL_CHECKIN', parsedResearhNotes);\n\t\t\t// \t} catch {\n\t\t\t// \t\tconsole.log(\"Research Notes were using the old format\");\n\t\t\t// \t\tstore.commit('paperEdit/researchNotes/FULL_CHECKIN', {});\n\t\t\t// \t}\n\t\t\t// } else {\n\t\t\t// \t// hidden tag doesnt' exisit - commit an object but loop in references first\n\t\t\t// \tstore.commit('paperEdit/researchNotes/FULL_CHECKIN', {});\n\t\t\t// }\n\t\t\n\t\t\t// \n\t\t\t// do not include annotations to start with\n\t\t\tstore.commit('paperEdit/annotations/IS_INCLUDE', false);\n\n\t\t\tlet _referencesInPaper = [];\n\t\t\t/*\n\t\t\t\tthis is weird bare with me - i need to add this to help bridge people over\n\t\t\t\twhen i removed from the paper HTML, i relyed on the ReferencesInPaper Array from special rules\n\t\t\t\tnow i need to go back to keeping a separate object for all the citations\n\t\t\t\tbut during that change over, customers will loose the connection to citations they had, it just renders as plain text\n\t\t\t*/\n\t\t\tlet _citationsInPaper = [];\t\n\n\t\t\tlet referenceElementsInPaper = parsedHtml.getElementsByTagName(\"reference\");\n\t\t\t\n\t\t\t_forEach(referenceElementsInPaper, (referenceElemenent)=>{\n\t\t\t\tlet referenceData = JSON.parse(decodeURIComponent(referenceElemenent.getAttribute('data')));\n\n\t\t\t\t// console.log('referenceData from parseHiddenTags.js');\n\t\t\t\t// console.log(referenceData.displayValue);\n\t\t\t\t// console.log(referenceData.orderByValue);\n\t\t\t\t// console.log('---')\n\n\t\t\t\t// let valuesObject = JSON.parse(referenceData.values);\n\n\t\t\t\tif(_has(referenceData, 'citations') && referenceData.citations.length > 0){\n\t\t\t\t\treferenceData.citations.forEach((citationObject)=>{\n\t\t\t\t\t\t_citationsInPaper.push(citationObject);\n\t\t\t\t\t});//e:forEach:referenceData.citations\n\t\t\t\t}\n\n\t\t\t\t_referencesInPaper.push({\n\t\t\t\t\torderByValue: referenceData.orderByValue,\n\t\t\t\t\treferenceUniqueID: referenceData.referenceUniqueID.toUpperCase(),\n\t\t\t\t});\n\n\t\t\t\t// if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.APA7 && _has(valuesObject, 'apa7')){\n\t\t\t\t// \tif(_has(referenceData, 'citations') && referenceData.citations.length > 0){\n\t\t\t\t// \t\treferenceData.citations.forEach((citationObject)=>{\n\t\t\t\t// \t\t\t_citationsInPaper.push(citationObject);\n\t\t\t\t// \t\t});//e:forEach:referenceData.citations\n\t\t\t\t// \t}\n\n\t\t\t\t// \t_referencesInPaper.push({\n\t\t\t\t// \t\t// orderByValue: valuesObject.apa7.value,\n\t\t\t\t// \t\torderByValue: referenceData.orderByValue,\n\t\t\t\t// \t\treferenceUniqueID: referenceData.referenceUniqueID.toUpperCase(),\n\t\t\t\t// \t});\n\n\t\t\t\t// } else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.MLA9 && _has(valuesObject, 'mla9')){\n\t\t\t\t// \tif(_has(referenceData, 'citations') && referenceData.citations.length > 0){\n\t\t\t\t// \t\treferenceData.citations.forEach((citationObject)=>{\n\t\t\t\t// \t\t\t_citationsInPaper.push(citationObject);\n\t\t\t\t// \t\t});//e:forEach:referenceData.citations\n\t\t\t\t// \t}\n\n\t\t\t\t// \t_referencesInPaper.push({\n\t\t\t\t// \t\t// orderByValue: valuesObject.mla9.value,\n\t\t\t\t// \t\torderByValue: referenceData.orderByValue,\n\t\t\t\t// \t\treferenceUniqueID: referenceData.referenceUniqueID.toUpperCase(),\n\t\t\t\t// \t});\n\n\t\t\t\t// } else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9 && _has(valuesObject, 'turabian9')){\n\t\t\t\t// \tif(_has(referenceData, 'citations') && referenceData.citations.length > 0){\n\t\t\t\t// \t\treferenceData.citations.forEach((citationObject)=>{\n\t\t\t\t// \t\t\t_citationsInPaper.push(citationObject);\n\t\t\t\t// \t\t});//e:forEach:referenceData.citations\n\t\t\t\t// \t}\n\n\t\t\t\t// \t_referencesInPaper.push({\n\t\t\t\t// \t\t// orderByValue: valuesObject.turabian9.value,\n\t\t\t\t// \t\torderByValue: referenceData.orderByValue,\n\t\t\t\t// \t\treferenceUniqueID: referenceData.referenceUniqueID.toUpperCase(),\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t\t// check for annotation on this reference\n\t\t\t\tif(referenceElemenent.hasAttribute('annotation')){\n\t\t\t\t\tPAnS_AddUpdate({\n\t\t\t\t\t\tcontent: decodeURIComponent(referenceElemenent.getAttribute('annotation')),\n\t\t\t\t\t\treferenceUniqueId: referenceData.referenceUniqueID.toUpperCase(),\t\n\t\t\t\t\t});\n\t\t\t\t}//e:if\n\t\t\n\t\t\t});//e:forEach:referenceElementsInPaper\n\n\t\t\t_referencesInPaper = _sortBy(_referencesInPaper, ['orderByValue']);\n\t\t\t\n\t\t\tlet _referenceUniqueIdsInPaper = [];\n\t\t\t\n\t\t\t_referencesInPaper.forEach((sortedReference)=>{\n\t\t\t\t_referenceUniqueIdsInPaper.push(sortedReference.referenceUniqueID);\n\t\t\t});\n\n\t\t\t// this is where the referenceId gets added to referenceUniqueIdsInPaper - i'd rather this add directly to the ReferenceV2Object\n\t\t\tstore.commit('paperEdit/SET_REFERENCE_UNIQUE_IDS_IN_PAPER', _uniq(_referenceUniqueIdsInPaper));\n\t\t\t\n\t\t\t// console.log('_citationsInPaper');\n\t\t\t// console.log(_citationsInPaper);\n\n\t\t\t// store.commit('paperEdit/citations/SET_IN_PAPER', _citationsInPaper);\n\n\n\t\t\t// \n\t\t\tlet outlineInPaperElement = parsedHtml.getElementsByTagName(\"outline\");\n\t\t\tlet useOultineInPaperElement; // a user had two of these recently somehow, to fix that lets look at what's in there and get only one\n\t\t\t\n\t\t\tif(outlineInPaperElement.length === 1){\n\t\t\t\t// just one - that's what i'll use\n\t\t\t\tuseOultineInPaperElement = outlineInPaperElement[0];\n\n\t\t\t} else if(outlineInPaperElement.length > 1){\n\t\t\t\t// more than one - check them all and use the longest one\n\t\t\t\t_forEach(outlineInPaperElement, (outlineElement)=>{\n\t\t\t\t\t// store.commit('paperEdit/outline/PUSH_TO_DUPLICATE_CONTENT', outlineElement.getAttribute('data'));\n\n\t\t\t\t\t// if there isn't a use set yet - start there\n\t\t\t\t\tif(!useOultineInPaperElement){\n\t\t\t\t\t\tuseOultineInPaperElement = outlineElement;\n\t\t\t\t\t}\n\n\t\t\t\t\t// check this length vs the last one that was set as the longest\n\t\t\t\t\tif(outlineElement.getAttribute('data').length > useOultineInPaperElement.getAttribute('data').length){\n\t\t\t\t\t\tuseOultineInPaperElement = outlineElement;\n\t\t\t\t\t}\n\t\t\t\t});//e:forEach\n\t\t\t}//e:if:else\n\n\t\t\tif(useOultineInPaperElement){\n\t\t\t\tlet outlineDataRaw = window.atob(useOultineInPaperElement.getAttribute('data'))\n\t\t\t\tlet outlineDataEncoded = '';\n\t\t\t\t\n\t\t\t\tlet isOutlineDecoded = false;\n\n\t\t\t\t// try to decode the outline a new way (2023.06.12)\n\t\t\t\ttry {\n\t\t\t\t\toutlineDataEncoded = decodeURIComponent(outlineDataRaw);\n\t\t\t\t\tisOutlineDecoded = true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// console.log(error);\n\t\t\t\t}\n\n\t\t\t\t// if the outline wasn't decoded as URI then it was in the old format\n\t\t\t\tif(!isOutlineDecoded){\n\t\t\t\t\toutlineDataEncoded = outlineDataRaw;\n\t\t\t\t}\n\n\t\t\t\tstore.commit('paperEdit/outline/FULL_HTML', outlineDataEncoded);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\tstore.commit('paperEdit/outline/FULL_HTML', config.startContent.outline);\n\t\t\t}\n\t\t\t\n\t\t\t//\n\t\t\t// let outlineDuplicatesInPaperElement = parsedHtml.getElementsByTagName(\"outline-duplicated\");\n\t\t\t// if(outlineDuplicatesInPaperElement.length > 0){\n\t\t\t// \t// loop through each duplicated outline element\n\t\t\t// \t_forEach(outlineDuplicatesInPaperElement, (outlineElement)=>{\n\t\t\t// \t\tstore.commit('paperEdit/outline/PUSH_TO_DUPLICATE_CONTENT', outlineElement.getAttribute('data'));\n\t\t\t// \t});//e:forEach\n\t\t\t// }\n\n\t\t\t// - 2023.09.27 - i put this back in so i can have all the citations indepenedent from the Reference In Paper (this on combines all the citations into one object, so closer to footnotes)\n\t\t\tlet allCitationsElement = parsedHtml.getElementsByTagName(\"citations\");\n\t\t\tlet allCitationsObject = [];\n\t\t\t\n\t\t\tif(allCitationsElement[0]){\n\t\t\t\ttry {\n\t\t\t\t\tallCitationsObject = JSON.parse(decodeURIComponent(window.atob(allCitationsElement[0].getAttribute('data'))));\n\t\t\t\t} catch(error){\n\t\t\t\t\tconsole.log(`error - allCitationsElement[0].getAttribute('data')`);\n\t\t\t\t\tconsole.log(error);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tstore.commit('paperEdit/citations/SET_IN_PAPER', allCitationsObject);\n\t\t\t} else {\n\t\t\t\t// allCitationsElement wasn't found - that's ok it's probably a customer that needs their citations converted and will fix on the next document save\n\t\t\t\tstore.commit('paperEdit/citations/SET_IN_PAPER', _citationsInPaper);\n\n\t\t\t}//e:if:else\n\t\t\t\n\t\t\t// create logic to determine which reference row should be \"open\" - this is last so can process\n\t\t\tif(store.state.paperEdit.openReferenceUID === ''){\n\t\t\t\t// no open id\n\t\t\t\t\n\t\t\t\t// check if there is only one reference in this paper\n\t\t\t\tif(store.state.paperEdit.referenceUniqueIdsInPaper.length === 1){\n\t\t\t\t\t// check if this solitary reference has any citations (they can be active or)\n\t\t\t\t\tif(allCitationsObject.length > 0){\n\t\t\t\t\t\tlet setOpenReferenceId = store.state.paperEdit.referenceUniqueIdsInPaper[0];\n\t\t\t\t\t\t_forEach(allCitationsObject, (citationData)=>{\n\t\t\t\t\t\t\tif(citationData.citationData.referenceUniqueID.toUpperCase() === setOpenReferenceId.toUpperCase()){\n\t\t\t\t\t\t\t\tstore.commit('paperEdit/SET_OPEN_REFERENCE_UID', setOpenReferenceId);\n\t\t\t\t\t\t\t\treturn false;\t// just need to find one match, after that stop looping\n\n\t\t\t\t\t\t\t}//e:if\n\t\t\t\t\t\t});//e:forEach\n\n\t\t\t\t\t}//e:if\n\n\t\t\t\t}//e:if\n\n\t\t\t}//e:if\n\n\n\t\t\t// \n\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\tlet footnotesElement = parsedHtml.getElementsByTagName(\"footnotes\");\n\t\t\t\tif(footnotesElement[0]){\n\t\t\t\t\tlet footnotesContent = JSON.parse(decodeURIComponent(window.atob(footnotesElement[0].getAttribute('data'))));\n\n\t\t\t\t\t// console.log('footnotesContent');\n\t\t\t\t\t// console.log(footnotesContent);\n\t\t\t\t\t\n\t\t\t\t\tif(footnotesContent.length === 0 && allCitationsObject.length >= 1){\n\t\t\t\t\t\tconsole.log('footnotesContent empty');\n\t\t\t\t\t\t// there is a footnote element, but it's content is empty AND there are actual citations in this paper - something went wrong so lets build a fresh collection of footnotes\n\t\t\t\t\t\t// console.log('allCitationsObject');\n\t\t\t\t\t\t// console.log(allCitationsObject);\n\t\t\t\t\t\t\n\t\t\t\t\t\t// loop through all citation objects\n\t\t\t\t\t\tallCitationsObject.forEach((citationObject)=>{\n\t\t\t\t\t\t\t// console.log('citationObject');\n\t\t\t\t\t\t\t// console.log(citationObject);\n\t\t\t\t\t\t\tlet findById = citationObject.citationData.citationUniqueID.toUpperCase();\n\n\t\t\t\t\t\t\tif(_has(citationObject, 'groupUniqueID')){\n\t\t\t\t\t\t\t\tfindById = citationObject.groupUniqueID\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tstore.dispatch('paperEdit/footnotes/addToPaper', {\n\t\t\t\t\t\t\t\tfindById,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t});//e:forEach\n\n\t\t\t\t\t\t// clean up citation in paper\n\t\t\t\t\t\tstore.commit('paperEdit/footnotes/CLEAN_UNIQUE');\n\t\t\t\t\t\t\n\t\t\t\t\t\t// console.log('store.state.paperEdit.footnotes.inPaper');\n\t\t\t\t\t\t// console.log(store.state.paperEdit.footnotes.inPaper);\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log('footnotesContent NOT blank - but still could be empty');\n\n\t\t\t\t\t\tif(footnotesContent.length > 0){\n\t\t\t\t\t\t\tfootnotesContent.forEach((footnoteData)=>{\n\t\t\t\t\t\t\t\t// console.log('footnoteData');\n\t\t\t\t\t\t\t\t// console.log(footnoteData);\n\t\t\t\t\t\t\t\t// add this to the list of footnotes in this paper\n\t\t\t\t\t\t\t\tstore.dispatch('paperEdit/footnotes/addToPaper', {\n\t\t\t\t\t\t\t\t\tcontent: footnoteData.content,\n\t\t\t\t\t\t\t\t\tfindById: footnoteData.findById,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});//:forEach\n\n\t\t\t\t\t\t\t// clean up citation in paper\n\t\t\t\t\t\t\tstore.commit('paperEdit/footnotes/CLEAN_UNIQUE');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// console.log('store.state.paperEdit.footnotes.inPaper');\n\t\t\t\t\t\t\t// console.log(store.state.paperEdit.footnotes.inPaper);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t}//e:if:footnotesContent.length\n\n\t\t\t\t}//e:if:footnotesElement\n\t\t\t}//e:if:renderCitationsAsFootnotes\n\n\n\t\t\t// (comes here becasue i need references and citations parsed first)\n\t\t\tlet reviewElements = parsedHtml.getElementsByTagName(\"review\");\n\n\t\t\t_forEach(reviewElements, (element)=>{\n\t\t\t\tstore.commit('paperEdit/review/SET_STATE', {\n\t\t\t\t\tkey: element.getAttribute('name'),\n\t\t\t\t\tvalue: toBoolean(element.getAttribute('content')),\n\t\t\t\t});\n\t\t\t});//e:_forEach\n\n\t\t\treturn resolve();\n\t\t});//e:paperEdit/config/setPaperProperties\n\t});//e:Promise\n}","/*\n- RNS_CalcSortValue\n-- When sorting by citation location - a score is calculated and returned\n*/\nimport config from '@/config';\n\nexport default ($opts) =>{\n\t// console.log('RNS_CalcSortValue');\n\t\n\tlet sortByScore = 0;\n\tlet parsedLocationValue = 0;\n\n\tif($opts.sortByEnum === config.enums.ResearchNotesSortBy.CITATION_FIRST_TO_LAST){\n\t\tsortByScore = 0;\n\n\t\t// inc sort based on type (location)\n\t\tswitch($opts.citationData.type){\n\t\t\tcase 'n.d.':\n\t\t\t\tsortByScore += 1000000;\n\t\t\t\tbreak;\n\t\t\tcase 'page':\n\t\t\t\tsortByScore += 100000;\n\t\t\t\tbreak;\n\t\t\tcase 'paragraph':\n\t\t\t\tsortByScore += 10000;\n\t\t\t\tbreak;\n\t\t\tcase 'section':\n\t\t\t\tsortByScore += 1000;\n\t\t\t\tbreak;\n\t\t\tcase 'table':\n\t\t\t\tsortByScore += 100;\n\t\t\t\tbreak;\n\t\t\tcase 'figure':\n\t\t\t\tsortByScore += 10;\n\t\t\t\tbreak;\n\t\t\t// default:\n\t\t\t\t// don't add anything - it can stay 0\n\t\t}\n\t\t\n\t\tparsedLocationValue = parseInt($opts.citationData.value)\n\t\t\n\t\t// anything but numbers will comeback as NaN\n\t\tif (isNaN(parsedLocationValue)) {\n\t\t\tparsedLocationValue = 0;\n\t\t} else {\n\t\t\tparsedLocationValue = 100000 - parsedLocationValue;\n\t\t}\n\n\t\t// inc sort base on value\n\t\tsortByScore += parsedLocationValue;\n\n\t} else if($opts.sortByEnum === config.enums.ResearchNotesSortBy.CITATION_LAST_TO_FIRST){\n\t\tsortByScore = 1000000;\n\n\t\t// inc sort based on type (location)\n\t\tswitch($opts.citationData.type){\n\t\t\tcase 'n.d.':\n\t\t\t\tsortByScore += 10;\n\t\t\t\tbreak;\n\t\t\tcase 'page':\n\t\t\t\tsortByScore += 100;\n\t\t\t\tbreak;\n\t\t\tcase 'paragraph':\n\t\t\t\tsortByScore += 1000;\n\t\t\t\tbreak;\n\t\t\tcase 'section':\n\t\t\t\tsortByScore += 10000;\n\t\t\t\tbreak;\n\t\t\tcase 'table':\n\t\t\t\tsortByScore += 100000;\n\t\t\t\tbreak;\n\t\t\tcase 'figure':\n\t\t\t\tsortByScore += 1000000;\n\t\t\t\tbreak;\n\t\t\t// default:\n\t\t\t\t// don't add anything - it can stay 0\n\t\t}\n\n\t\tparsedLocationValue = parseInt($opts.citationData.value)\n\t\t\n\t\t// anything but numbers will comeback as NaN\n\t\tif (isNaN(parsedLocationValue)) {\n\t\t\tparsedLocationValue = 0;\n\t\t}\n\n\t\t// inc sort base on value\n\t\tsortByScore += parsedLocationValue;\n\t\t\n\t}\n\t\n\n\treturn sortByScore;\n\t\t\n\t\n}\n","// PApS_CleanUp\n// fired when an appendix is added or removed\n// mainly it acts as a reset so titles are accurate\n\nimport _cloneDeep from 'lodash/cloneDeep'\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport _uniqBy from 'lodash/uniqBy';\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PApS_CleanUp');\n\n\treturn new Promise((resolve) => {\n\n\t\t// title calculations\n\t\tconst ordA = 'a'.charCodeAt(0); //97\n\t\tconst ordZ = 'z'.charCodeAt(0); //122\n\t\tconst ordAordZlen = ordZ - ordA + 1;\n\n\t\tconst _$opts = $opts || {};\n\n\t\t// use what's inPaper if there isn't an array passed\n\t\tlet _arrayOfAppendices = (_has(_$opts, 'arrayOfAppendices')) ? _$opts.arrayOfAppendices : _cloneDeep(store.state.paperEdit.appendices.inPaper);\n\t\t_arrayOfAppendices = _uniqBy(_arrayOfAppendices, 'uid');\n\n\t\tif(_arrayOfAppendices.length === 1){\n\t\t\t_arrayOfAppendices[0].sort = 0;\n\t\t\t_arrayOfAppendices[0].label = 'Appendix';\n\n\t\t} else if(_arrayOfAppendices.length > 1){\n\t\t\t_forEach(_arrayOfAppendices, (appendix, indexCounter)=>{\n\t\t\t\t// force update sort\n\t\t\t\tappendix.sort = indexCounter;\n\t\t\t\n\t\t\t\tlet _indexCounter = indexCounter;\n\t\t\t\t\n\t\t\t\t// https://stackoverflow.com/questions/8240637/convert-numbers-to-letters-beyond-the-26-character-alphabet\n\t\t\t\tlet labelAppend = \"\";\n\t\t\t\twhile(_indexCounter >= 0) {\n\t\t\t\t\tlabelAppend = String.fromCharCode(_indexCounter % ordAordZlen + ordA) + labelAppend;\n\t\t\t\t\t_indexCounter = Math.floor(_indexCounter / ordAordZlen) - 1;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// force update a new label\n\t\t\t\tappendix.label = 'Appendix ' + labelAppend.toUpperCase();\n\t\t\t});//e:forEach\n\t\t}\n\t\tresolve(_arrayOfAppendices);\n\t});//e:Promise\n\n}\n\n","/*\n- PS_CopyDiscussionPostToClipboard\n-- https://stackoverflow.com/questions/34191780/javascript-copy-string-to-clipboard-as-text-html\n-- top answer here works for Safari where the other one didnt \n-- i commented out disabling the style sheets since i don't think that does anything useful for Copy\n*/\n// import _forEach from 'lodash/forEach';\nimport _forEachRight from 'lodash/forEachRight';\n\nimport config from '@/config';\nimport HelperGetReferenceFormatId from '@/helpers/get-reference-format-id';\nimport store from '@/store';\n\nexport default () => {\n\treturn new Promise((resolve, reject) => {\n\t\t// console.log('PS_CopyDiscussionPostToClipboard');\n\t\t\n\t\tlet _referenceFormatTypeId = HelperGetReferenceFormatId();\n\n\t\t// built the html you are going to copy\n\t\tlet contentToClipBoard = '';\n\t\t\n\t\t// discution post title\n\t\t// APA7 Heading 1:

Heading 1

\n\t\t// MLA9 Heading 1:

Heading 1

\n\t\t// Turabian9 Heading 1:

Heading 1

\n\t\tswitch(_referenceFormatTypeId){\n\t\t\tcase config.enums.Format.APA7:\n\t\t\tcase config.enums.Format.Turabian9:\n\t\t\t\tcontentToClipBoard += '

' + store.state.paperEdit.meta.Title + '

';\n\t\t\t\tbreak;\n\t\t\tcase config.enums.Format.MLA9:\n\t\t\t\tcontentToClipBoard += '

' + store.state.paperEdit.meta.Title + '

';\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// discution post content\n\t\tif(CKEDITOR.instances.ckPaperBody){\n\t\t\t// there is a ck instance use it's data\n\t\t\tcontentToClipBoard += CKEDITOR.instances.ckPaperBody.getData();\n\n\t\t} else {\n\t\t\tif(window.$vm.$route.name === 'PaperTabExport'){\n\t\t\t\tcontentToClipBoard += store.state.paperEdit.paperDataBody;\n\t\t\t} else {\n\t\t\t\treturn reject();\t// should handle this better - but i don't have a ck instnace and not on the Export tab so this is worst case\n\t\t\t}\n\t\t}\n\n\t\t// discution post reference section > title\n\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t// check for single or multiple references\n\t\t\tif(store.state.paperEdit.referencesInPaper.length === 1){\n\t\t\t\tcontentToClipBoard += '

Work Cited

';\n\t\t\t} else {\n\t\t\t\tcontentToClipBoard += '

Works Cited

';\n\t\t\t}\n\t\t} else {\n\t\t\tcontentToClipBoard += '

References

';\n\t\t}\n\n\t\t// discution post reference section > references\n\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\tcontentToClipBoard += '

' + referenceObject.displayValue + '

'\n\t\t});\n\t\t\n\t\t// replace any PERRLA Headings with code that fits better on something like Blackboard\n\t\tlet parsedHtml = new DOMParser().parseFromString(contentToClipBoard, 'text/html');\n\t\t\n\t\t// APA7 Heading 1:

Heading 1

\n\t\t// MLA9 Heading 1:

Heading 1

\n\t\t// Turabian9 Heading 1:

Heading 1

\n\t\tlet h1Elements = parsedHtml.getElementsByTagName(\"h1\");\n\t\t_forEachRight(h1Elements, (h1Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7 || _referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.style['text-align'] = 'center';\n\t\t\t}\n\t\t\tnewElement.innerHTML = '' + h1Element.innerText + '';\n\t\t\th1Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 Heading 2:

Heading 2

\n\t\t// MLA9 Heading 2:

Heading 2

\n\t\t// Turabian9 Heading 2:

Heading 2

\n\t\tlet h2Elements = parsedHtml.getElementsByTagName(\"h2\");\n\t\t_forEachRight(h2Elements, (h2Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\tnewElement.innerHTML = '' + h2Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h2Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.style['text-align'] = 'center';\n\t\t\t\tnewElement.innerHTML = h2Element.innerText;\n\t\t\t}\n\t\t\t\n\t\t\th2Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 Heading 3:

Heading 3

\n\t\t// MLA9 Heading 3:

Heading 3

\n\t\t// Turabian9 Heading 3:

Heading 3

\n\t\tlet h3Elements = parsedHtml.getElementsByTagName(\"h3\");\n\t\t_forEachRight(h3Elements, (h3Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\tnewElement.innerHTML = '' + h3Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = h3Element.innerText;\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.innerHTML = '' + h3Element.innerText + '';\n\t\t\t}\n\t\t\th3Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// MLA9 Heading 4:

Heading 4.

\n\t\t// Turabian9 Heading 4:

Heading 4.

\n\t\tlet h4Elements = parsedHtml.getElementsByTagName(\"h4\");\n\t\t_forEachRight(h4Elements, (h4Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h4Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.innerHTML = h4Element.innerText;\n\t\t\t}\n\t\t\th4Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// MLA9 Heading 5:

Heading 5.

\n\t\tlet h5Elements = parsedHtml.getElementsByTagName(\"h5\");\n\t\t_forEachRight(h5Elements, (h5Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h5Element.innerText + '';\n\t\t\t// } else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t// \tnewElement.innerHTML = h4Element.innerText;\n\t\t\t}\n\t\t\th5Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 inline headings that render in the editor as SPAN tags\n\t\tlet spanElements = parsedHtml.getElementsByTagName(\"span\");\n\t\t_forEachRight(spanElements, (spanElement)=>{\n\t\t\tif(spanElement.classList.contains('h4')){\n\t\t\t\t// APA7 Heading 4:

Heading 4. Sentence

\n\t\t\t\tlet newElement = document.createElement('strong');\n\t\t\t\tnewElement.innerHTML = spanElement.innerText;\n\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t} else if(spanElement.classList.contains('h5')){\n\t\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\t\t// APA7 Heading 5:

Heading 5. Sentence

\n\t\t\t\t\tlet newElement = document.createElement('em');\n\t\t\t\t\tnewElement.innerHTML = '' + spanElement.innerText + '';\n\t\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\t\t// Turabian9 Heading 5:

Heading 5. Sentence.

\n\t\t\t\t\tlet newElement = document.createElement('strong');\n\t\t\t\t\t\tnewElement.innerHTML = spanElement.innerText;\n\t\t\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t\t}\n\t\t\t}\n\t\t});//e:forEach\n\n\t\n\t\tlet bodyInnerHtml = parsedHtml.getElementsByTagName(\"body\")[0].innerHTML\n\n\t\t// Create container for the HTML\n\t\tlet container = document.createElement('div');\n\t\tcontainer.innerHTML = bodyInnerHtml;\n\n\t\t// Hide element\n\t\tcontainer.style.position = 'fixed';\n\t\tcontainer.style.pointerEvents = 'none';\n\t\tcontainer.style.opacity = 0;\n\n\t\t// Detect all style sheets of the page\n\t\t// var activeSheets = Array.prototype.slice.call(document.styleSheets).filter(function (sheet) {\n\t\t// \treturn !sheet.disabled\n\t\t// });\n\n\t\t// Mount the container to the DOM to make `contentWindow` available\n\t\tdocument.body.appendChild(container);\n\n\t\t// Copy to clipboard\n\t\twindow.getSelection().removeAllRanges();\n\n\t\tlet range = document.createRange();\n\t\trange.selectNode(container);\n\t\twindow.getSelection().addRange(range);\n\n\t\tdocument.execCommand('copy');\n\n\t\t// for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true\n\n\t\t// document.execCommand('copy');\n\n\t\t// for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false;\n\n\t\t// Remove the container\n\t\tdocument.body.removeChild(container);\n\n\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\ttextContent: 'Copied to clipboard',\n\t\t});\n\t\t\n\t\treturn resolve();\n\n\t});//e:Promise\n\t\n}","// PS_BuildHtml\n// paper edit level - converts all paper parts into complete html \n\nimport _cloneDeep from 'lodash/cloneDeep';\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport _isEmpty from 'lodash/isEmpty';\nimport _sortBy from 'lodash/sortBy';\nimport _uniqBy from 'lodash/uniqBy';\nimport config from '@/config';\nimport PCKS_NumberFigureCaptions from '@/services/paper/ck/numberFigureCaptions'\nimport PCKS_NumberTableCaptions from '@/services/paper/ck/numberTableCaptions'\nimport router from '@/router';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst errorSourceName = 'PS_BuildHtml';\n\t\t// console.log(errorSourceName);\n\n\t\t// set defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _updateMetaTags = _has(_$opts, 'updateMetaTags') ? _$opts.updateMetaTags : null;\n\t\t\n\t\tlet returnHtml = '';\n\t\tlet paperId = 0;\n\n\t\t// meta\n\t\t_forEach(config.metaDataKeys, (metaDataKey)=>{\n\t\t\t// if(metaDataKey !== 'UseNewCitationMode'){\n\t\t\t\tlet isMetaChange = false;\n\t\t\t\tif(_updateMetaTags){\n\t\t\t\t\t_forEach(_updateMetaTags, (updatedTagValue)=>{\n\t\t\t\t\t\tif(updatedTagValue[metaDataKey]){\n\t\t\t\t\t\t\tisMetaChange = true;\n\t\t\t\t\t\t\treturnHtml += '';\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(metaDataKey === 'PaperID'){\n\t\t\t\t\tpaperId = store.state.paperEdit.meta[metaDataKey] || 0;\n\t\t\t\t}\n\t\t\t\tif(!isMetaChange){\n\t\t\t\t\treturnHtml += '';\n\t\t\t\t}\n\n\t\t\t// }\n\t\t});\n\n\t\treturnHtml += '\\r\\r';\n\t\t\n\t\t// review\n\t\t_forEach(store.state.paperEdit.review, (value, key)=>{\n\t\t\treturnHtml += '';\n\t\t});//e:_forEach\n\n\t\treturnHtml += '\\r\\r';\n\t\t\t\t\n\t\t// authorsNote\n\t\tif(store.state.paperEdit.meta.IncludeAuthorNote){\n\t\t\tlet authorsNoteContent = '';\n\n\t\t\t// Check for the ckEditor Instance of the Abstract\n\t\t\tif(CKEDITOR.instances.ckPaperAuthorNote){\n\t\t\t\tauthorsNoteContent = CKEDITOR.instances.ckPaperAuthorNote.getData();\n\t\t\t\tstore.commit('paperEdit/authorsNote/CONTENT', authorsNoteContent);\n\t\t\t} else if(store.state.paperEdit.authorsNote.content){\n\t\t\t\tauthorsNoteContent = store.state.paperEdit.authorsNote.content;\n\t\t\t} else {\n\t\t\t\tauthorsNoteContent = `\n\t\t\t\t\t

ORCID iD's

\n\t\t\t\t\t

Changes of Affiliation

\n\t\t\t\t\t

Disclosures & Acknowledgements

\n\t\t\t\t\t

Contact Information

\n\t\t\t\t`;\n\t\t\t}\n\t\t\treturnHtml += '';\n\t\t\treturnHtml += '\\r\\r';\n\t\t}\n\t\n\t\t// abstract\n\t\tif(store.state.paperEdit.meta.IncludeAbstract){\n\t\t\tlet abstractContent = null;\n\n\t\t\tif(CKEDITOR.instances.ckPaperAbstract){\n\t\t\t\t// instance exisits, has to be on the Editor Tab\n\t\t\t\tabstractContent = CKEDITOR.instances.ckPaperAbstract.getData();\n\t\t\t} else {\n\t\t\t\t// instance does not exisits, prob the Organize Tab\n\t\t\t\tabstractContent = store.state.paperEdit.abstract.content;\n\t\t\t}\n\n\t\t\tlet abstractKeywords = '';\n\n\t\t\t// Check for Abstract Keywords\n\t\t\tlet $elmTxtPaperAbstractKeywords = document.getElementById('txtPaperAbstractKeywords');\n\t\t\tif($elmTxtPaperAbstractKeywords){\n\t\t\t\tabstractKeywords = $elmTxtPaperAbstractKeywords.value;\n\t\t\t} else if(store.state.paperEdit.abstract.keywords){\n\t\t\t\tabstractKeywords = store.state.paperEdit.abstract.keywords;\n\t\t\t}\n\n\t\t\treturnHtml += '';\n\t\t\treturnHtml += '\\r\\r';\n\t\t}//e:IncludeAbstract\n\t\t\n\t\tPCKS_NumberTableCaptions({\n\t\t\tckEditor: 'all'\n\t\t}).then(()=>{\n\n\t\t\tPCKS_NumberFigureCaptions({\n\t\t\t\tckEditor: 'all'\n\t\t\t}).then(()=>{\n\t\t\n\t\t\t\t// append paper body\n\t\t\t\tif(CKEDITOR.instances.ckPaperBody){\n\t\t\t\t\treturnHtml += CKEDITOR.instances.ckPaperBody.getData();\n\t\t\t\t} else if(store.state.paperEdit.paperDataBody){\n\t\t\t\t\treturnHtml += store.state.paperEdit.paperDataBody;\n\t\t\t\t}\n\n\t\t\t\treturnHtml += '\\r\\r';\n\n\t\t\t\t// add references in paper\n\t\t\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\t\t\t// console.log(referenceObject);\n\t\t\t\t\treturnHtml += '
';\n\t\t\t\t\treturnHtml += '\\r\\r';\t\n\t\t\t\t}\n\n\t\t\t\t// check for duplicate outline tags\n\t\t\t\t// if(!_isEmpty(store.state.paperEdit.outline.duplicateContent)){\n\t\t\t\t// \tstore.state.paperEdit.outline.duplicateContent.forEach((duplicateContentObject)=>{\n\t\t\t\t// \t\treturnHtml += '';\n\t\t\t\t// \t\treturnHtml += '\\r\\r';\t\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t\t// appendices\n\t\t\t\tstore.state.paperEdit.appendices.inPaper.forEach((appendixData)=>{\n\t\t\t\t\tlet appendixContent = null;\n\n\t\t\t\t\t// Check for the ckEditor Instance of this looped appendix\n\t\t\t\t\tif(CKEDITOR.instances['ck_appendix_' + appendixData.uid]){\n\t\t\t\t\t\t// instance exisits, has to be on the Editor Tab\n\t\t\t\t\t\tappendixContent = CKEDITOR.instances['ck_appendix_' + appendixData.uid].getData();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// instance does not exisits, prob the Export Tab\n\t\t\t\t\t\tappendixContent = appendixData.content;\n\t\t\t\t\t}\n\t\t\t\t\treturnHtml += '';\n\t\t\t\t\treturnHtml += '\\r';\n\t\t\t\t});//e:forEach\n\t\t\t\t\n\t\t\t\treturnHtml += '\\r';\n\t\t\t\t\n\n\t\t\t\t// citations\n\t\t\t\tlet citationHtmlToCheckIn = '';\n\t\t\t\tlet arrayOfCitationsInThisDocument = [];\n\n\n\t\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// console.log('store.state.paperEdit.citations.inPaper');\n\t\t\t\t\t\t// console.log(store.state.paperEdit.citations.inPaper);\n\t\n\t\t\t\t\t\t// this actaully checks each citation in the vuex store, and makes sure the element is actually in the paper before it saves again (user could have 20 citations and none of them in the paper yet)\n\t\t\t\t\t\tstore.state.paperEdit.citations.inPaper.forEach((citationObject)=>{\n\t\t\t\t\t\t\tlet _thisCitation = _cloneDeep(citationObject);\n\t\t\t\t\t\t\t// console.log('_thisCitation');\n\t\t\t\t\t\t\t// console.log(_thisCitation);\n\t\n\t\t\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\t\t\tif(ckInstance.document){\n\t\t\t\t\t\t\t\t\t// i need the actual citation widget node so i can add it's position in the document\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t// start by looking for the group uid\n\t\t\t\t\t\t\t\t\tlet $citationNode = ckInstance.document.findOne('span[data-group-unique-id=\"' + _thisCitation.groupUniqueID + '\"]');\n\t\n\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\t// group citation\n\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-citation-unique-id');\n\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-reference-unique-id');\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// no group citation - look for a single\n\t\t\t\t\t\t\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-citation-unique-id=\"' + _thisCitation.citationData.citationUniqueID + '\"]');\n\t\n\t\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\t\t// single citation found\n\t\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-group-unique-id');\n\t\t\t\t\t\t\t\t\t\t\t$citationNode.setAttribute('data-reference-unique-id', _thisCitation.citationData.referenceUniqueID.toUpperCase());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t}//e:else:$citationNode\n\t\n\t\t\t\t\t\t\t\t\t// console.log('$citationNode');\n\t\t\t\t\t\t\t\t\t// console.log($citationNode);\n\t\n\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\tlet weightForEditor = 0;\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t// i need to weight the document position based on what ckInstance it's in\n\t\t\t\t\t\t\t\t\t\tswitch(ckInstance.$ckEditorType){\n\t\t\t\t\t\t\t\t\t\t\tcase config.enums.CkEditorType.ABSTRACT:\n\t\t\t\t\t\t\t\t\t\t\t\tweightForEditor = 1;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\tcase config.enums.CkEditorType.BODY:\n\t\t\t\t\t\t\t\t\t\t\t\tweightForEditor = 100;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\tcase config.enums.CkEditorType.APPENDIX:\n\t\t\t\t\t\t\t\t\t\t\t\tweightForEditor = 10000;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t_thisCitation.documentPosition = Math.round($citationNode.getDocumentPosition().y) + (Math.round($citationNode.getDocumentPosition().x) / 1000) + weightForEditor;\n\t\t\t\t\t\t\t\t\t\tarrayOfCitationsInThisDocument.push(_thisCitation);\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}//e:if\n\t\n\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t\n\t\t\t\t\t\tarrayOfCitationsInThisDocument = _sortBy(arrayOfCitationsInThisDocument, 'documentPosition');\n\t\t\t\t\t\n\t\t\t\t\t\tcitationHtmlToCheckIn = window.btoa(encodeURIComponent(JSON.stringify(arrayOfCitationsInThisDocument)));\n\t\t\t\t\t} catch (error){\n\t\t\t\t\t\tconsole.log(error);\n\t\t\t\t\t\t\n\t\t\t\t\t\treturn reject({\n\t\t\t\t\t\t\tenum: config.enums.Error.PAPER_SAVE,\n\t\t\t\t\t\t\tsrc: errorSourceName,\n\t\t\t\t\t\t});\n\t\t\t\t\t}//e:try:catch\n\n\t\t\t\t} else {\n\t\t\t\t\t// paper body citations won't have a document position since i'm saving from the outline\n\t\t\t\t\tcitationHtmlToCheckIn = window.btoa(encodeURIComponent(JSON.stringify(store.state.paperEdit.citations.inPaper)));\n\n\t\t\t\t}//e:if:Tab\n\n\t\t\t\treturnHtml += '';\n\n\t\t\t\t// footnotes - i'm probably over looping here but it's working so don't freak out too much\n\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\treturnHtml += '\\r';\n\t\t\t\t\treturnHtml += '\\r';\n\t\t\t\t\t\n\t\t\t\t\tlet footnotesInDocument = []; // array of Footnote objects \n\n\t\t\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\t\t\t// paper body citations won't have a document position since i'm saving from the outline\n\t\t\t\t\t\treturnHtml += '';\n\t\t\t\t\t\t\n\t\t\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\t\t\tlet arrayToMakeFootnotes = [];\t// an array of footnote objects (doing it this way to handle group citations)\n\n\t\t\t\t\t\t// loop through citations actually in this document (this was collected above for ) - i need to make an array just for footnote citations\n\t\t\t\t\t\tarrayOfCitationsInThisDocument.forEach((citationObject)=>{\n\t\t\t\t\t\t\tlet _citationObject = _cloneDeep(citationObject);\n\n\t\t\t\t\t\t\tif(_has(_citationObject, 'groupUniqueID')){\n\t\t\t\t\t\t\t\t// group id\n\n\t\t\t\t\t\t\t\t// check if this has already been added to the object\n\t\t\t\t\t\t\t\tlet findFootnote = arrayToMakeFootnotes.find((footnoteData)=>{\n\t\t\t\t\t\t\t\t\treturn footnoteData.groupUniqueID === _citationObject.groupUniqueID\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif(!findFootnote){\n\t\t\t\t\t\t\t\t\tarrayToMakeFootnotes.push(_citationObject);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// no group id - just a normal push\n\t\t\t\t\t\t\t\t_citationObject.groupUniqueID = '';\n\t\t\t\t\t\t\t\tarrayToMakeFootnotes.push(_citationObject);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});//e:forEach\n\n\t\t\t\t\t\t// console.log('arrayToMakeFootnotes');\n\t\t\t\t\t\t// console.log(arrayToMakeFootnotes);\n\n\t\t\t\t\t\tarrayToMakeFootnotes.forEach((citationObject)=>{\n\t\t\t\t\t\t\t// console.log('citationObject');\n\t\t\t\t\t\t\t// console.log(citationObject);\n\n\t\t\t\t\t\t\tlet findFootnote = null;\n\n\t\t\t\t\t\t\tif(citationObject.groupUniqueID === ''){\n\t\t\t\t\t\t\t\t// single citation\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tfindFootnote = store.state.paperEdit.footnotes.inPaper.find((footnoteData)=>{\n\t\t\t\t\t\t\t\t\t\treturn footnoteData.findById.toUpperCase() === citationObject.citationData.citationUniqueID.toUpperCase();\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch(error) {\n\t\t\t\t\t\t\t\t\treturn reject({\n\t\t\t\t\t\t\t\t\t\tenum: config.enums.Error.PAPER_SAVE,\n\t\t\t\t\t\t\t\t\t\tsrc: errorSourceName,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// merged citation - look for the group uid\n\t\t\t\t\t\t\t\tif(_has(citationObject, 'groupUniqueID')){\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tfindFootnote = store.state.paperEdit.footnotes.inPaper.find((footnoteData)=>{\n\t\t\t\t\t\t\t\t\t\t\treturn footnoteData.findById.toUpperCase() === citationObject.groupUniqueID.toUpperCase();\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} catch(error) {\n\t\t\t\t\t\t\t\t\t\treturn reject({\n\t\t\t\t\t\t\t\t\t\t\tenum: config.enums.Error.PAPER_SAVE,\n\t\t\t\t\t\t\t\t\t\t\tsrc: errorSourceName,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif(findFootnote){\n\t\t\t\t\t\t\t\tfootnotesInDocument.push({\n\t\t\t\t\t\t\t\t\tfindById: findFootnote.findById,\n\t\t\t\t\t\t\t\t\tcontent: findFootnote.content,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(!config.isLive){\n\t\t\t\t\t\t\t\t\talert('findFootnote is null');\n\t\t\t\t\t\t\t\t\tconsole.log(citationObject);\n\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t }//e:if:findFootnote\n\n\t\t\t\t\t\t});//e:forEach\n\t\n\t\t\t\t\t}//e::else:Tab\n\n\t\t\t\t\tstore.commit('paperEdit/footnotes/SET_FULL_IN_PAPER', footnotesInDocument);\n\t\t\t\t\n\t\t\t\t\t// can i use footnotesInDocument to build an export friendly array\n\t\t\t\t\tlet footnoteExportArray = [];\n\t\t\t\t\t\n\t\t\t\t\t// console.log('footnotesInDocument');\n\t\t\t\t\t// console.log(footnotesInDocument);\n\n\t\t\t\t\t// loop through references in this paper again (yes i know again but it's ok)\n\t\t\t\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\t\t\t\tif(_has(referenceObject, 'citations') && referenceObject.citations.length > 0){\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// loop through each citation in this reference\n\t\t\t\t\t\t\treferenceObject.citations.forEach((citationObject)=>{\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t// start by looking for a single citation\n\t\t\t\t\t\t\t\tlet foundCitation = footnotesInDocument.find((footnoteObject)=>{\n\t\t\t\t\t\t\t\t\treturn footnoteObject.findById.toUpperCase() === citationObject.citationData.citationUniqueID.toUpperCase()\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t// if still not found then try looking for it's group id\n\t\t\t\t\t\t\t\tif(!foundCitation){\n\t\t\t\t\t\t\t\t\tif(_has(citationObject, 'groupUniqueID')){\n\t\t\t\t\t\t\t\t\t\tfoundCitation = footnotesInDocument.find((footnoteObject)=>{\n\t\t\t\t\t\t\t\t\t\t\treturn footnoteObject.findById.toUpperCase() === citationObject.groupUniqueID.toUpperCase()\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// at this point if the citation has been found it's good to write the export \n\t\t\t\t\t\t\t\tif(foundCitation){\n\t\t\t\t\t\t\t\t\tlet preContent = '

';\n\t\t\t\t\t\t\t\t\tlet postContent = '

';\n\n\t\t\t\t\t\t\t\t\tif(foundCitation.content !== '

@@@

'){\n\t\t\t\t\t\t\t\t\t\t// there are pre and post content we need to extract\n\n\t\t\t\t\t\t\t\t\t\tlet splitAtCitationPlaceholderArray = foundCitation.content.split('@@@');\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t// if theres any variation here, figure out the use case and add code to check them\n\t\t\t\t\t\t\t\t\t\tif(splitAtCitationPlaceholderArray.length === 2){\n\t\t\t\t\t\t\t\t\t\t\t// replace html tags in the pre content\n\t\t\t\t\t\t\t\t\t\t\tpreContent = splitAtCitationPlaceholderArray[0]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/strong>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/u>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/em>/gi, '');\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t// replace html tags in the post content\n\t\t\t\t\t\t\t\t\t\t\tpostContent = splitAtCitationPlaceholderArray[1]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/strong>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/u>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/em>/gi, '');\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tfootnoteExportArray.push({\n\t\t\t\t\t\t\t\t\t\tcitationDisplayValue: citationObject.displayValue,\n\t\t\t\t\t\t\t\t\t\tpre: preContent,\n\t\t\t\t\t\t\t\t\t\tpost: postContent,\n\t\t\t\t\t\t\t\t\t\tfindById: foundCitation.findById.toUpperCase()\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t}//e:if:foundCitation\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t}\n\n\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\n\t\t\t\t\t// since group citations will list here twice, just remove any duplicated ids\n\t\t\t\t\tfootnoteExportArray = _uniqBy(footnoteExportArray, 'findById');\n\t\t\t\t\t\n\t\t\t\t\t/*\n\t\t\t\t\t// using this to check what's happening with Footnoes in Discusion posts\n\t\t\t\t\tlet exportTextToCheck = `JTVCJTdCJTIyY2l0YXRpb25EaXNwbGF5VmFsdWUlMjIlM0ElMjJTdGFubGV5JT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MjIlM0ElMjJQb3J0ZXIlMkMlMjAlM0NlbSUzRVRoZSUyMEFwb3N0bGUlMjBQYXVsJTNDJTJGZW0lM0UuJTIyJTJDJTIycHJlJTIyJTNBJTIyJTNDcCUzRSUyMiUyQyUyMnBvc3QlMjIlM0ElMjIlM0MlMkZwJTNFJTIyJTJDJTIyZmluZEJ5SWQlMjIlM0ElMjJBOUZEMTIwOS03RjdGLTQ3NkYtODRGMy05QzQyMTIyOTA2MDAlMjIlN0QlNUQ`;\n\t\t\t\t\tlet decodedTextToCheck = decodeURIComponent(window.atob(exportTextToCheck));\n\t\t\t\t\tlet jsonPaseExportTextToCheck = JSON.parse(decodedTextToCheck);\n\n\t\t\t\t\tconsole.log('jsonPaseExportTextToCheck');\n\t\t\t\t\tconsole.log(jsonPaseExportTextToCheck);\n\t\t\t\t\t\n\t\t\t\t\t// jsonPaseExportTextToCheck = \n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Stanley E. Porter, The Apostle Paul: His Life, Thought, and Letters (Grand Rapids, MI: William B. Eerdmans, 2016).\",\n\t\t\t\t\t\t\t\"pre\": \"

\",\n\t\t\t\t\t\t\t\"post\": \"

\",\n\t\t\t\t\t\t\t\"findById\": \"786C067F-8812-437D-B58A-D68A85848CB4\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul, 304.\",\n\t\t\t\t\t\t\t\"pre\": \"

\",\n\t\t\t\t\t\t\t\"post\": \"

\",\n\t\t\t\t\t\t\t\"findById\": \"B158661D-C30D-40AF-98E0-726E6D8B59F9\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul.\",\n\t\t\t\t\t\t\t\"pre\": \"

\",\n\t\t\t\t\t\t\t\"post\": \"

\",\n\t\t\t\t\t\t\t\"findById\": \"1EB5DCC9-C61A-4169-903A-81007F4B322C\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul.\",\n\t\t\t\t\t\t\t\"pre\": \"

\",\n\t\t\t\t\t\t\t\"post\": \"

\",\n\t\t\t\t\t\t\t\"findById\": \"A9FD1209-7F7F-476F-84F3-9C4212290600\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t*/\n\n\t\t\t\t\treturnHtml += '';\n\t\t\t\t}//e:if:store.state.paperEdit.config.renderCitationsAsFootnotes\n\n\t\t\t\t// remove non breaking spaces (but i need this for pagebreaks)\n\t\t\t\t// returnHtml = returnHtml.replace(/ /g, ' ');\n\n\t\t\t\tresolve({\n\t\t\t\t\tpaperId,\n\t\t\t\t\treturnHtml\n\t\t\t\t});\n\n\t\t\t});//e:PCKS_NumberFigureCaptions\n\t\t});//e:PCKS_NumberTableCaptions\n\n\t});//e:Promise\n}","\n// PCS_RemoveById\n// removes a citation (single or grouped) - it loops after removing a reference from this paper\n\nimport _has from 'lodash/has';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCS_RemoveById');\n\n\t\tlet saveMessage = '';\t// resolves back so SaveDocument has a message of what was deleted\n\n\t\tlet isGroupCitation = false;\n\n\t\tif($opts.citationElementInPaper){\n\t\t\tisGroupCitation = $opts.citationElementInPaper.hasAttribute('data-group-unique-id');\n\t\t}\n\n\t\tif(isGroupCitation){\n\t\t\t// Group\n\t\t\tlet groupUniqueId = $opts.citationElementInPaper.getAttribute('data-group-unique-id');\n\t\t\t// console.log('groupUniqueId');\n\t\t\t// console.log(groupUniqueId);\n\n\t\t\tlet remainingCitationObject;\n\n\t\t\t// get a list of single citations inside this group id\n\t\t\tlet listOfCitationsInGroup = store.state.paperEdit.citations.inPaper.filter((citationData)=>{\n\t\t\t\treturn (citationData.groupUniqueID) && (citationData.groupUniqueID.toUpperCase() === groupUniqueId.toUpperCase());\n\t\t\t});\n\t\t\t// console.log('listOfCitationsInGroup');\n\t\t\t// console.log(listOfCitationsInGroup);\n\n\t\t\t// loop through single citations in this group\n\t\t\tlistOfCitationsInGroup.forEach((citationObject)=>{\n\t\t\t\tif(\n\t\t\t\t\t_has(citationObject,'citationData') && \n\t\t\t\t\t_has(citationObject.citationData, 'referenceUniqueID')\n\t\t\t\t){\n\t\t\t\t\tif(citationObject.citationData.referenceUniqueID === $opts.referenceIdRemoved){\n\t\t\t\t\t\t// remove citation NOT from the matching reference from vuex store citationInPaperObject\n\t\t\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === citationObject.citationData.citationUniqueID.toUpperCase();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\t\t\tstore.commit('paperEdit/citations/REMOVE_AT_INDEX', findCitationIndex);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tremainingCitationObject = citationObject;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t});//e:forEach\n\t\t\t\n\t\t\t// update citation widget in paper body\n\t\t\tif (remainingCitationObject && $opts.citationElementInPaper && $opts.citationElementInPaper.getParent()) {\n\t\t\t\tsaveMessage = $opts.citationElementInPaper.getHtml();\n\t\t\t\t// console.log(saveMessage);\n\n\t\t\t\tdelete remainingCitationObject.groupUniqueID;\n\t\t\t\t// console.log('remainingCitationObject');\n\t\t\t\t// console.log(remainingCitationObject);\n\n\t\t\t\t$opts.citationElementInPaper.removeAttribute('data-group-unique-id');\n\t\t\t\t$opts.citationElementInPaper.setAttribute('data-citation-unique-id', remainingCitationObject.citationData.citationUniqueID.toUpperCase());\n\t\t\t\t$opts.citationElementInPaper.setAttribute('data-reference-unique-id', remainingCitationObject.citationData.referenceUniqueID.toUpperCase());\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t// prob should check here if apa7 or mla9 when i have all this working \n\t\t\t\t$opts.citationElementInPaper.setHtml(remainingCitationObject.apa7.first);\n\n\t\t\t} else {\n\t\t\t\tconsole.log('There was a problem removing the citation from this paper');\n\t\t\t}\n\n\n\t\t} else {\n\t\t\t// Single\n\t\t\tlet citationUniqueId = $opts.citationElementInPaper.getAttribute('data-citation-unique-id');\n\t\t\t// console.log(citationUniqueId);\n\n\t\t\t// remove citation from vuex store citationInPaperObject\n\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === citationUniqueId.toUpperCase();\n\t\t\t});\n\t\t\tif(findCitationIndex !== -1){\n\t\t\t\tstore.commit('paperEdit/citations/REMOVE_AT_INDEX', findCitationIndex);\n\t\t\t}\n\n\t\t\t// remove citation widget from paper body\n\t\t\tif ($opts.citationElementInPaper && $opts.citationElementInPaper.getParent()) {\n\t\t\t\tsaveMessage = $opts.citationElementInPaper.getHtml();\n\t\t\t\t// console.log(saveMessage);\n\t\t\t\t\n\t\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t\tlet $elToInsert = new CKEDITOR.dom.element('sup');\n\t\t\t\t\t$elToInsert.setText('CITATION DELETED');\n\t\t\t\t\t$elToInsert.replace($opts.citationElementInPaper.getParent());\n\n\t\t\t\t} else {\n\t\t\t\t\tlet $elToInsert = new CKEDITOR.dom.element('span');\n\t\t\t\t\t\n\t\t\t\t\tif(store.state.paperEdit.meta.UseNewCitationMode){\n\t\t\t\t\t\t$elToInsert.setText('CITATION DELETED');\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$elToInsert.setText('(CITATION DELETED)');\n\t\t\t\t\t}\n\t\t\t\t\t$elToInsert.replace($opts.citationElementInPaper.getParent());\n\n\t\t\t\t}\n\t\t\t\t\n\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\tconsole.log('There was a problem removing the citation from this paper');\n\t\t\t}\n\n\t\t}\n\n\t\tresolve(saveMessage);\n\t\t\n\t});//e:Promise\n}\n","// PS_RemoveReferenceFromPaper\nimport _has from 'lodash/has';\nimport _forEach from 'lodash/forEach';\nimport PCS_RemoveById from '@/services/paper/citations/removeById';\nimport PS_UpdateReferenceObject from '@/services/paper/updateReferenceObject';\nimport RS_GetValueOutput from '@/services/reference/getValueOutput';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\tlet _reference;\n\n\t\t// do i have this reference included in options?\n\t\tif(_has($opts, 'reference')){\n\t\t\t_reference = $opts.reference;\n\t\t} else {\n\t\t\t// look this reference up\n\t\t\t_reference = store.state.paperEdit.referencesInPaper.find((reference)=>{\n\t\t\t\treturn reference.referenceID === $opts.referenceID;\n\t\t\t});\n\t\t}\n\t\t\n\t\t// remove this reference from the Reference List\n\t\tif(_has($opts, 'paperID')){\n\t\t\tlet findPaperIndex = store.state.paperList.list.findIndex((paper) =>{\n\t\t\t\treturn paper.paperID === $opts.paperID;\n\t\t\t});\n\t\t\tif(findPaperIndex != -1){\n\t\t\t\t// paper found, is this reference already in the list (assume APA7 / Genesis)\n\t\t\t\tif(store.state.paperList.list[findPaperIndex].genesisReferences.includes($opts.referenceID)){\n\t\t\t\t\tstore.commit('paperList/REMOVE_REFERENCE_ID_FROM_PAPER', {\n\t\t\t\t\t\tpaperIndex: findPaperIndex,\n\t\t\t\t\t\treferenceID: $opts.referenceID\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// force remove active citations from the abstract and body of the paper (user has already confirmed this is ok)\t\t\t\n\t\tif($opts.hasActiveCitations && $opts.isDrawer){\n\t\t\t// console.log('removeReferenceFromPaper - active citations & in drawer');\n\n\t\t\t// loop through all citations for this reference\n\t\t\t_reference.citations.forEach((citation)=>{\n\t\t\t\t// group\n\t\t\t\tif(_has(citation, 'groupUniqueID')){\n\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\tlet $citationNodeList = ckInstance.document.find('span[data-group-unique-id=\"' + citation.groupUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\tif($citationNodeList){\n\t\t\t\t\t\t\t// a nodelist was created - convert it toArray\n\t\t\t\t\t\t\tlet $citationNodeListArray = $citationNodeList.toArray();\n\t\t\t\t\t\t\tif($citationNodeListArray.length > 0){\n\t\t\t\t\t\t\t\t_forEach($citationNodeList.toArray(), ($citationNode) => {\n\t\t\t\t\t\t\t\t\tPCS_RemoveById({\n\t\t\t\t\t\t\t\t\t\tcitationElementInPaper: $citationNode,\n\t\t\t\t\t\t\t\t\t\treferenceIdRemoved: _reference.referenceUniqueID.toUpperCase()\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t\t}//e:if:$citationNodeListArray\n\t\t\t\t\t\t}\n\t\t\t\t\t});//e:forEach\n\t\t\t\t}\n\t\t\t\n\t\t\t\t// single\n\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\tlet $citationNodeList = ckInstance.document.find('span[data-reference-unique-id=\"' + _reference.referenceUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\tif($citationNodeList){\n\t\t\t\t\t\t// a nodelist was created - convert it toArray\n\t\t\t\t\t\tlet $citationNodeListArray = $citationNodeList.toArray();\n\t\t\t\t\t\tif($citationNodeListArray.length > 0){\n\t\t\t\t\t\t\t_forEach($citationNodeList.toArray(), ($citationNode) => {\n\t\t\t\t\t\t\t\tPCS_RemoveById({\n\t\t\t\t\t\t\t\t\tcitationElementInPaper: $citationNode,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t}//e:if:$citationNodeListArray\n\t\t\t\t\t}\n\t\t\t\t});//e:forEach\n\t\t\t});\n\n\t\t}//e:hasActiveCitations\n\n\t\t// remove any left over citations\n\t\t// to trigger this:\n\t\t// - add a reference, a citation, insert that citation into the paper\n\t\t// - now in the organize tab remove this reference from the paper\n\t\tstore.state.paperEdit.citations.inPaper.forEach((citation)=>{\n\t\t\tif(citation.citationData.referenceUniqueID.toUpperCase() === _reference.referenceUniqueID.toUpperCase()){\n\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === citation.citationData.citationUniqueID.toUpperCase();\n\t\t\t\t});\n\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\tstore.commit('paperEdit/citations/REMOVE_AT_INDEX', findCitationIndex);\n\t\t\t\t}\n\n\t\t\t\t// remove footnote from vuex store\n\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\tstore.commit('paperEdit/footnotes/REMOVE_AT_CITATION_UID', citation.citationData.citationUniqueID.toUpperCase());\n\t\t\t\t}\n\t\t\t}\n\t\t});//e:forEach\n\n\t\t// remove reference from this paper\n\t\tstore.commit('paperEdit/REFERENCE_REMOVE_FROM_PAPER', _reference.referenceUniqueID.toUpperCase());\n\n\t\tlet referenceDisplayValue = RS_GetValueOutput({\n\t\t\tdisplayFormatVersionId: store.state.customer.preferredFormatVersionID,\n\t\t\treferenceData: _reference,\n\t\t});\n\n\t\tPS_UpdateReferenceObject({\n\t\t\tsaveMessage: 'Removed reference - ' + referenceDisplayValue,\n\t\t}).then(()=>{\n\t\t\treturn resolve();\n\t\t});\n\n\t});//e:Promise\n\n}","/*\n- PS_RestoreVersion\n-- 2023.02.07\n*/\n \n\nimport _has from 'lodash/has';\nimport ApiS_MakeCall from '@/services/app/api/makeCall';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_RestoreVersion');\n\n\t\t// set opt defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _paperId = (_has(_$opts, 'paperId')) ? _$opts.paperId : '';\n\t\tconst _versionId = (_has(_$opts, 'versionId')) ? _$opts.versionId : '';\n\n\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t\n\t\tApiS_MakeCall({\n\t\t\turl: 'v4/Paper/Restore',\n\t\t\tparams:{\n\t\t\t\tpaperId: _paperId,\n\t\t\t\tversionId: _versionId,\n\t\t\t},\n\t\t\tmethod: 'PUT',\n\t\t\tresponseType: 'none',\n\t\t}).then(()=>{\n\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\tresolve();\n\t\t});//e:ApiS_MakeCall\n\t});//e:Promise\n}\n","// PCKS_wProofreaderInit\n\nimport _forEach from 'lodash/forEach';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_wProofreaderInit');\n\t\t\n\t\tstore.commit('paperEdit/ck/SET_IS_WPROOF_READER_ACTIVE', true);\n\n\t\tif(config.useWProofreader && typeof WEBSPELLCHECKER != 'undefined'){\n\t\t\t// WproofReader init\n\t\t\tif($opts.container === 'all'){\n\t\t\t\t// Find and init all\n\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\tWEBSPELLCHECKER.init({\n\t\t\t\t\t\tcontainer: ckInstance.window.getFrame().$,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Init single (called in instanceReady)\n\t\t\t\tWEBSPELLCHECKER.init({\n\t\t\t\t\tcontainer: $opts.container,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn resolve();\n\t\t\t\n\t\t} else {\n\t\t\t// WproofReader should not turn on\n\t\t\treturn resolve();\n\t\t}\n\n\t});//e:Promise\n}","// PCKS_OnFocus\n// fires when the user focuses on any of the Paper Editor ckInstances\n\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PCKS_OnFocus');\n\n\tif(window.$vm && window.$vm.emitter){\n\t\twindow.$vm.emitter.emit('closeAllDropdowns');\n\t\twindow.$vm.emitter.emit('closeAllFootnoteContextMenus')\n\t\tstore.commit('paperEdit/footnotes/SET_CONTEXT_MENU_SELECT_ON_CITATION_FIND_BY_ID', '');\n\t}\n\tstore.commit('paperEdit/ck/SET_EDITOR_LAST_FOCUSED', $opts.editorName);\n\t\n\tif (store.state.paperEdit.isPaperFooterOn) {\n\t\twindow.$vm.emitter.emit('footerUpdateWordCount', {\n\t\t\teditorName: $opts.editorName\n\t\t});\n\t}\n}\n","// PCKS_NumberFigureCaptions\n// Updates the numbers of all figure captions\n\nimport _forEach from 'lodash/forEach';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_NumberFigureCaptions');\n\t\t\n\t\tif($opts.ckEditor === 'all'){\n\t\t\t// check all instances - this is probably from a document save\n\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\tnumberFiguresForSingleInstance(ckInstance);\n\t\t\t});\n\t\t\t\n\t\t} else {\n\t\t\t// single instance\n\t\t\tnumberFiguresForSingleInstance($opts.ckEditor);\n\n\t\t}//e:if\n\n\t\treturn resolve();\n\n\t});//e:Promise\n\n\tfunction numberFiguresForSingleInstance(ckEditor){\n\t\tlet figureCount = 0;\n\n\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.ABSTRACT){\n\t\t\t// abstract - start the table count at 0\n\t\t\tfigureCount = 0;\n\t\t\t\n\t\t} else if(ckEditor.$ckEditorType === config.enums.CkEditorType.BODY){\n\t\t\t// body - i need to know how many tables were in the abstract\n\t\t\tif(CKEDITOR.instances['ckPaperAbstract'] && CKEDITOR.instances['ckPaperAbstract'].document){\n\t\t\t\tlet figuresInAbstract = CKEDITOR.instances['ckPaperAbstract'].document.find('figure');\n\t\t\t\tfigureCount = figuresInAbstract.toArray().length;\n\t\t\t}\n\n\t\t}\n\t\t\n\t\tif(ckEditor.document){\n\t\t\t// find all table elements in this instance\n\t\t\tlet figuresInInstance = ckEditor.document.find('figure');\n\n\t\t\t// loop through the elements found\n\t\t\t_forEach(figuresInInstance.toArray(), (figureElement)=>{\n\t\t\t\t// console.log(figureElement);\n\n\t\t\t\tfigureCount++;\n\n\t\t\t\t// find the
in this figure\n\t\t\t\tlet thisCaptionEl = figureElement.findOne('figcaption');\n\n\t\t\t\t// console.log(thisCaptionEl);\n\t\t\t\tif(thisCaptionEl){\n\t\t\t\t\t//
found\n\t\t\t\t\tlet thisCaptionText = '';\n\n\t\t\t\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.APPENDIX){\n\t\t\t\t\t\tthisCaptionText = thisCaptionEl.getText().trim();\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.APA7 || store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t\t\t\tthisCaptionText = 'Figure ' + figureCount;\n\n\t\t\t\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.MLA9){\n\t\t\t\t\t\t\tthisCaptionText = 'Fig. ' + figureCount + '. ';\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tlet $figureTitleEl = thisCaptionEl.findOne('figure-title');\n\t\t\t\t\tif(!$figureTitleEl){\n\t\t\t\t\t\t// figure element wasn't found using custom tag, maybe it's the old span way\n\t\t\t\t\t\t$figureTitleEl = thisCaptionEl.findOne('span.figure-title');\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet figureTitle = 'Figure Title';\t// default title if the proper element wasn't found\n\t\t\t\t\tif($figureTitleEl){\n\t\t\t\t\t\tfigureTitle = $figureTitleEl.getHtml();\n\n\t\t\t\t\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.APPENDIX){\n\t\t\t\t\t\t\t// remove the length of the label from the caption\n\t\t\t\t\t\t\tfigureTitle = figureTitle.slice(0, -figureTitle.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.APA7){\n\t\t\t\t\t\tthisCaptionEl.setHtml(`\n\t\t\t\t\t\t\t` + thisCaptionText + `

\n\t\t\t\t\t\t\t` + figureTitle + `\n\t\t\t\t\t\t`);\n\n\t\t\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.MLA9){\n\t\t\t\t\t\tthisCaptionEl.setHtml(`\n\t\t\t\t\t\t\t` + thisCaptionText + `\n\t\t\t\t\t\t\t` + figureTitle + `\n\t\t\t\t\t\t`);\n\n\t\t\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t\t\tthisCaptionEl.setHtml(`\n\t\t\t\t\t\t\t` + thisCaptionText + `.\n\t\t\t\t\t\t\t` + figureTitle + `\n\t\t\t\t\t\t`);\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t}//e:if:thisCaptionEl\n\n\t\t\t});//e:forEach.figuresInInstance\n\t\t}\n\t\t\n\t\treturn;\n\n\t}//e:numberFiguresForSingleInstance\n}","// PS_UpdateReferenceObject\n// called after a reference is added or removed\n\nimport _has from 'lodash/has';\nimport config from '@/config';\nimport PS_BuildReferencesInPaper from '@/services/paper/buildReferencesInPaper';\nimport PS_SaveDocument from '@/services/paper/saveDocument';\nimport router from '@/router';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_UpdateReferenceObject');\n\n\t\t// set defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _saveMessage = _has(_$opts, 'saveMessage') ? _$opts.saveMessage : '';\n\n\t\tPS_BuildReferencesInPaper().then(()=>{\n\t\t\tlet isMatchFound = false;\n\n\t\t\tif(router.currentRoute.meta.module === config.enums.Module.PAPER_EDIT){\n\t\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\t\tisMatchFound = true;\n\t\t\t\t\twindow.$vm.emitter.emit('generateReferencePage', {\n\t\t\t\t\t\tisSaveAfter: true,\n\t\t\t\t\t\tsaveMessage: _saveMessage\n\t\t\t\t\t});\n\t\t\t\t\treturn resolve();\n\t\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE || router.currentRoute.meta.tab === config.enums.Tab.RESEARCH){\n\t\t\t\t\tisMatchFound = true;\n\t\t\t\t\tPS_SaveDocument({\n\t\t\t\t\t\tisMetaDataChanges: true,\n\t\t\t\t\t\tmessage: _saveMessage\n\t\t\t\t\t}).then(()=>{\n\t\t\t\t\t\treturn resolve();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if(router.currentRoute.meta.module === config.enums.Module.REFERENCE_LIST){\n\t\t\t\tisMatchFound = true;\n\t\t\t\treturn resolve();\n\t\t\t}\n\t\t\t\n\t\t\tif(!isMatchFound){\n\t\t\t\tconsole.log('router.currentRoute.name could not find a match');\n\t\t\t\tconsole.log(router.currentRoute.name);\n\t\t\t}\n\t\t});//e:PS_BuildReferencesInPaper\n\n\t});//e:Promise\n}","// OS_SaveContent\n// Saves outline content in the Paper Organize Tab\n\nimport _forEach from 'lodash/forEach';\nimport PS_BuildReferencesInPaper from '@/services/paper/buildReferencesInPaper';\nimport PS_SaveDocument from '@/services/paper/saveDocument';\nimport store from '@/store';\n\nexport default () => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('OS_SaveContent');\n\n\t\t// before saving the paper document, update the Vuex store object\n\t\tif(window.$ckPaperOutline) {\n\t\t\tPS_BuildReferencesInPaper().then(()=>{\n\t\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\n\t\t\t\tlet outlineHtml = window.$ckPaperOutline.getData();\n\t\t\t\t// console.log('outlineHtml');\n\t\t\t\t// console.log(outlineHtml);\n\n\t\t\t\t// experimental, remove raw p tags\n\t\t\t\t// outlineHtml = outlineHtml.replaceAll('

', '');\n\t\t\t\t// outlineHtml = outlineHtml.replaceAll('

', '');\n\n\t\t\t\tstore.commit('paperEdit/outline/FULL_HTML', outlineHtml);\n\n\t\t\t\tPS_SaveDocument({\n\t\t\t\t\tisStealthSave: true,\n\t\t\t\t\tmessage: 'Saved Organize tab',\n\t\t\t\t}).then(()=>{\n\t\t\t\t\tstore.commit('paperEdit/outline/SET_IS_UNSAVED', false);\n\t\t\t\t\t\n\t\t\t\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\t\t\t\ttextContent: 'Outline changes saved',\n\t\t\t\t\t});\n\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\treturn resolve();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\n\t\t\t});//e:PS_BuildReferencesInPaper\n\t\t} else {\n\t\t\treturn resolve();\n\t\t}\n\t});//e:Promise\n}","// PCKS_OnChange\n\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PCKS_OnChange');\n\n\treturn new Promise((resolve) => {\n\t\tif(store.state.paperEdit.isPaperFooterOn) {\n\t\t\t// set a stop type timer with every change event\n\t\t\tstore.commit('paperEdit/ck/USER_TYPE_FOOTER_TIMER_START', $opts.editorName);\n\t\t}\n\t\tstore.commit('paperEdit/localVersion/USER_TYPE_LOCAL_TIMER_START');\n\t\tstore.commit('paperEdit/localVersion/SET_IS_LOCAL_STORAGE_FRESH', false);\n\t\tstore.commit('paperEdit/SET_IS_DOCUMENT_SAVED', false);\n\n\t\tstore.dispatch('paperEdit/inactivityAlert/startTimer');\n\t\t\n\t\treturn resolve();\n\t});//e:Promise\t\t\t\n\n}\n","// PCKS_NumberTableCaptions\n\nimport _forEach from 'lodash/forEach';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_NumberTableCaptions');\n\t\t\n\t\tif($opts.ckEditor === 'all'){\n\t\t\t// check all instances - this is probably from a document save\n\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\tnumberTablesForSingleInstance(ckInstance);\n\t\t\t});\n\t\t\t\n\t\t} else {\n\t\t\t// single instance\n\t\t\tnumberTablesForSingleInstance($opts.ckEditor);\n\n\t\t}//e:if\n\t\t\n\t\treturn resolve();\n\n\t});//e:Promise\n\n\tfunction numberTablesForSingleInstance(ckEditor){\n\t\tlet tableCount = 0;\n\n\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.ABSTRACT){\n\t\t\t// abstract - start the table count at 0\n\t\t\ttableCount = 0;\n\t\t\t\n\t\t} else if(ckEditor.$ckEditorType === config.enums.CkEditorType.BODY){\n\t\t\t// body - i need to know how many tables were in the abstract\n\t\t\tif(CKEDITOR.instances['ckPaperAbstract'] && CKEDITOR.instances['ckPaperAbstract'].document){\n\t\t\t\tlet tablesInAbstract = CKEDITOR.instances['ckPaperAbstract'].document.find('table');\n\t\t\t\ttableCount = tablesInAbstract.toArray().length;\n\t\t\t}\n\n\t\t}\n\n\t\t// find all table elements in this instance\n\t\tif(ckEditor.document){\n\t\t\tlet tablesInInstance = ckEditor.document.find('table');\n\n\t\t\t// loop through the elements found\n\t\t\t_forEach(tablesInInstance.toArray(), (tableElement)=>{\n\t\t\t\ttableElement.$.style.width = \"100%\";\n\t\t\t\ttableCount++;\n\n\t\t\t\t// find the in this table\n\t\t\t\tlet thisCaptionEl = tableElement.findOne('caption');\n\n\t\t\t\tif(thisCaptionEl){\n\t\t\t\t\t// found\n\t\t\t\t\tlet thisCaptionText = '';\n\n\t\t\t\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.APPENDIX){\n\t\t\t\t\t\tthisCaptionText = thisCaptionEl.getText().trim();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthisCaptionText = 'Table ' + tableCount;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet $tableTitleEl = thisCaptionEl.findOne('table-title');\n\t\t\t\t\tif(!$tableTitleEl){\n\t\t\t\t\t\t// table title element wasn't found using custom tag, maybe it's the old span way\n\t\t\t\t\t\t$tableTitleEl = thisCaptionEl.findOne('span.table-title');\n\t\t\t\t\t}\n\n\t\t\t\t\tlet tableTitle = 'Table Title';\t// default title if the proper element wasn't found\n\t\t\t\t\tif($tableTitleEl){\n\t\t\t\t\t\ttableTitle = $tableTitleEl.getHtml();\n\n\t\t\t\t\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.APPENDIX){\n\t\t\t\t\t\t\t// remove the length of the label from the caption\n\t\t\t\t\t\t\ttableTitle = tableTitle.slice(0, -tableTitle.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t\t\tthisCaptionEl.setHtml(`\n\t\t\t\t\t\t\t` + thisCaptionText + `.\n\t\t\t\t\t\t\t` + tableTitle + `\n\t\t\t\t\t\t`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthisCaptionEl.setHtml(`\n\t\t\t\t\t\t\t` + thisCaptionText + `

\n\t\t\t\t\t\t\t` + tableTitle + `\n\t\t\t\t\t\t`);\n\t\t\t\t\t}\n\t\t\t\t}//e:if:thisCaptionEl\n\n\t\t\t\t// https://trello.com/c/aa1Wc0xN/201-tfoot-element-causing-save-error\n\t\t\t\t// check this tables footer \n\t\t\t\tlet tFootElements = tableElement.$.getElementsByTagName(\"tfoot\");\n\t\t\t\tif (tFootElements.length > 0) {\n\t\t\t\t\t// now you have a tfoot, look for any td in side\n\t\t\t\t\tlet tFootTdElement = tFootElements[0].getElementsByTagName(\"td\");\n\t\t\t\t\tif(tFootTdElement.length === 0){\n\t\t\t\t\t\t// there is a tfoot without a td, remove the whole tfoot\n\t\t\t\t\t\ttFootElements[0].remove();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});//e:forEach.tableElement\n\t\t}//e:if\n\n\t\treturn;\n\t}//e:numberTablesForSingleInstance\n\n}","/*\n- PCKS_WrapCitation\n-- https://perrla.monday.com/boards/1892814374/pulses/3040814893\n-- checks the character before and after the citation widget for parentiesis \n-- add them if they have been removed, outside the widget\n*/\n\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_WrapCitation');\n\t\t\n\t\t// wrap the citation you just inserted with ( )\n\t\tlet $citationNode = null;\n\n\t\t// loop through ckeditor instance\n\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t// look for a group citation first - do i need this here?\n\t\t\tif(_has($opts, 'groupUniqueID') && $opts.groupUniqueID){\n\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-group-unique-id=\"' + $opts.groupUniqueID.toUpperCase() + '\"]');\n\t\t\t}\n\t\t\tif($citationNode){\n\t\t\t\treturn false;\t// stop looking when found\n\t\t\t} else {\n\t\t\t\t// look for regular citations second\n\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-citation-unique-id=\"' + $opts.citationUniqueID + '\"]');\n\t\t\t\tif($citationNode){\n\t\t\t\t\treturn false;\t// stop looking when found\n\t\t\t\t}\n\t\t\t}\n\t\t});//e:forEach:ckInstance\n\n\t\t// if the citation element was not found, resolve now\n\t\tif(!$citationNode){\n\t\t\treturn resolve();\n\t\t}\n\n\t\t// grab some generic properties that you can use after the format split\n\t\tlet beforeText = '';\n\t\tlet citationPrevious;\n\t\tlet citationParent = $citationNode.getParent();\n\t\tif(citationParent){\n\t\t\tcitationPrevious = citationParent.getPrevious();\n\t\t\t\n\t\t\tif(citationPrevious && citationPrevious.type === CKEDITOR.NODE_TEXT){\n\t\t\t\tbeforeText = citationPrevious.getText() || '';\n\n\t\t\t}//e:if\n\t\t}//e:if:citationParent\n\n\t\t// the citation node should have been identified by now\n\t\tif($citationNode){\n\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t// turabian 9 doesnt have any citation wrapping\n\n\t\t\t\t// there is a chance this was created using the new citation create context menu, if so there will be a # before this citation\n\t\t\t\tif(beforeText && beforeText.charAt(beforeText.length - 1) === '#'){\n\t\t\t\t\tlet $elToInsert = new CKEDITOR.dom.element('span');\n\t\t\t\t\t$elToInsert.setText(beforeText.slice(0, -1));\n\t\t\t\t\t$elToInsert.replace(citationPrevious);\n\t\t\t\t}\n\n\t\t\t\treturn resolve();\n\n\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.APA7 || store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.MLA9){\n\t\t\t\t// apa7 or mla9 - citations wrap\n\t\t\t\t\n\t\t\t\t// this feature will come from a tag in the paper content\n\t\t\t\tif(store.state.paperEdit.meta.UseNewCitationMode){\n\t\t\t\t\tif(!_has($opts, 'citationUniqueID')){\n\t\t\t\t\t\treturn resolve();\n\t\t\t\t\t}\n\n\t\t\t\t\tif(citationParent){\n\t\t\t\t\t\tif(\n\t\t\t\t\t\t\tbeforeText === '' ||\n\t\t\t\t\t\t\t(beforeText && beforeText.charAt(beforeText.length - 1) !== '(')\n\t\t\t\t\t\t){\n\t\t\t\t\t\t\t// i need to add an open bracket before the citation\n\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.text('(');\n\t\t\t\t\t\t\tbracketElement.insertBefore(citationParent);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// now check after this citation\n\t\t\t\t\t\tlet citationNext = citationParent.getNext();\n\t\t\t\t\t\tif(citationNext && citationNext.type === CKEDITOR.NODE_TEXT){\n\t\t\t\t\t\t\tlet afterText = citationNext.getText() || '';\n\t\t\t\t\t\t\tif(afterText === '' || (afterText && afterText.charAt(0) !== ')')){\n\t\t\t\t\t\t\t\t// i need to add an close bracket after the citation\n\t\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.text(')');\n\t\t\t\t\t\t\t\tbracketElement.insertAfter( citationParent );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.text(')');\n\t\t\t\t\t\t\tbracketElement.insertAfter( citationParent );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn resolve();\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\treturn resolve();\n\n\t\t\t\t}//e:if:isCitationOutputV2\n\t\t\t\t\n\t\t\t}//e:if:else:turabian9\n\n\t\t}//e:if:$citationNode\n\n\t});//e:Promise\n}","/*\n- PS_BuildReferencesInPaper\n-- looks at the unique reference ids inside a paper and builds a local reference object\n-- also cleans the citation objects (collapsed function at end)\n*/\n\nimport _cloneDeep from 'lodash/cloneDeep';\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport _orderBy from 'lodash/orderBy';\nimport _sortBy from 'lodash/sortBy';\nimport config from '@/config';\nimport Engine from '@/services/reference/Engine';\nimport router from '@/router';\nimport RS_CalcCitationDisplayValueFromReferenceData from '@/services/reference/calcCitationDisplayValueFromReferenceData';\nimport RS_ExtractPrimaryTitleFromReferenceData from '@/services/reference/extractPrimaryTitleFromReferenceData';\nimport store from '@/store';\n\nexport default () => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_BuildReferencesInPaper');\n\t\t\n\t\tlet _referencesInPaper = [];\n\n\t\t// console.log('store.state.paperEdit.referenceUniqueIdsInPaper');\n\t\t// console.log(store.state.paperEdit.referenceUniqueIdsInPaper);\n\n\t\tif(store.state.paperEdit.referenceUniqueIdsInPaper.length === 0){\n\t\t\t// no references\n\t\t\tstore.commit('paperEdit/SET_REFERENCES_IN_PAPER', []);\n\n\t\t\twindow.$vm.emitter.emit('referencesInPaperReady');\n\n\t\t\treturn resolve();\n\t\t\t\n\t\t} else {\n\n\t\t\t// loop through 'references' (value will be a Unique ID)\n\t\t\tstore.state.paperEdit.referenceUniqueIdsInPaper.forEach((referenceUID)=>{\n\t\t\t\t// look up a fresh copy of the reference by using the UID from the paper content\n\t\t\t\tlet thisReference = store.state.referenceLibraryGenesis.find((reference)=>{\n\t\t\t\t\treturn reference.referenceUniqueID.toUpperCase() === referenceUID.toUpperCase();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tif(thisReference){\n\t\t\t\t\t// console.log('thisReference');\n\t\t\t\t\t// console.log(thisReference);\n\t\t\t\t\n\t\t\t\t\tlet _citationsForThisReference = [];\n\n\t\t\t\t\tstore.state.paperEdit.citations.inPaper.forEach((citation)=>{\n\n\t\t\t\t\t\tif(citation.citationData.referenceUniqueID.toUpperCase() === referenceUID.toUpperCase()){\n\t\t\t\t\t\t\tlet _thisCitation = _cloneDeep(citation);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// console.log('_thisCitation');\n\t\t\t\t\t\t\t// console.log(_thisCitation);\n\n\t\t\t\t\t\t\t// loop through each CkEditor Instance\n\t\t\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\t\t\tif(ckInstance.document){\n\t\t\t\t\t\t\t\t\t// i need the actual citation widget node so i can add it's position in the document\n\n\t\t\t\t\t\t\t\t\tlet $citationNode = ckInstance.document.findOne('span[data-group-unique-id=\"' + _thisCitation.groupUniqueID + '\"]');\n\n\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\t// group citation\n\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-citation-unique-id');\n\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-reference-unique-id');\n\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// no group citation - look for a single\n\t\t\t\t\t\t\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-citation-unique-id=\"' + _thisCitation.citationData.citationUniqueID + '\"]');\n\n\t\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\t\t// single citation found\n\t\t\t\t\t\t\t\t\t\t\t$citationNode.removeAttribute('data-group-unique-id');\n\t\t\t\t\t\t\t\t\t\t\t$citationNode.setAttribute('data-reference-unique-id', _thisCitation.citationData.referenceUniqueID.toUpperCase());\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\t// console.log('$citationNode');\n\t\t\t\t\t\t\t\t\t\t// console.log($citationNode);\n\n\t\t\t\t\t\t\t\t\t\tlet weightForEditor = 0;\n\n\t\t\t\t\t\t\t\t\t\t// i need to weight the document position based on what ckInstance it's in\n\t\t\t\t\t\t\t\t\t\t// if(ckInstance.name === 'ckPaperBody'){\n\t\t\t\t\t\t\t\t\t\t// \tweightForEditor = 100;\n\t\t\t\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t_thisCitation.documentPosition = Math.round($citationNode.getDocumentPosition().y) + (Math.round($citationNode.getDocumentPosition().x) / 1000) + weightForEditor;\n\n\t\t\t\t\t\t\t\t\t\treturn false;\t// stop looping through ck instances i found what i needed\n\n\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t_thisCitation.documentPosition = 0;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}//e:ckInstance.document\n\n\t\t\t\t\t\t\t});//e:forEach\n\n\t\t\t\t\t\t\t// console.log('_thisCitation.documentPosition');\n\t\t\t\t\t\t\t// console.log(_thisCitation.documentPosition);\n\n\t\t\t\t\t\t\t_citationsForThisReference.push(_thisCitation);\n\n\t\t\t\t\t\t}//e:if\n\t\t\t\t\t});//e:_forEach:paperEdit.citations.inPaper\n\n\t\t\t\t\t_citationsForThisReference = _sortBy(_citationsForThisReference, 'documentPosition');\n\t\t\t\t\t\n\t\t\t\t\t// console.log('_citationsForThisReference');\n\t\t\t\t\t// console.log(_citationsForThisReference);\n\n\t\t\t\t\t// prepare the new modified reference\n\t\t\t\t\tlet thisReferenceModified = _cloneDeep(thisReference); // clone the array so the Engine can modify it\n\t\t\t\t\t\n\t\t\t\t\t// console.log('thisReferenceModified');\n\t\t\t\t\t// console.log(thisReferenceModified);\n\n\t\t\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\t\t\tthisReferenceModified.citations = _citationsForThisReference;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(store.state.customer.citationAutoInsert){\n\t\t\t\t\t\t\tthisReferenceModified.citationDisplayValue = RS_CalcCitationDisplayValueFromReferenceData(thisReference) || '';\n\t\t\t\t\t\t\tthisReferenceModified.primaryTitle = RS_ExtractPrimaryTitleFromReferenceData(thisReference.data) || '';\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\n\t\t\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\t\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\t\t\t\t\tif(thisReferenceModified.referenceUniqueID.toUpperCase() === referenceObject.referenceUniqueID.toUpperCase()){\n\t\t\t\t\t\t\t\tif(_has(referenceObject, 'citations') && referenceObject.citations.length > 0){\n\t\t\t\t\t\t\t\t\tthisReferenceModified.citations = referenceObject.citations;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif(store.state.customer.citationAutoInsert){\n\t\t\t\t\t\t\t\t\tthisReferenceModified.citationDisplayValue = RS_CalcCitationDisplayValueFromReferenceData(thisReference) || '';\n\t\t\t\t\t\t\t\t\tthisReferenceModified.primaryTitle = RS_ExtractPrimaryTitleFromReferenceData(thisReference.data) || '';\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});//forEach:paperEdit.referencesInPaper\n\n\t\t\t\t\t}//e:if:else:Tab.OUTLINE\n\t\t\t\t\t\n\t\t\t\t\t_referencesInPaper.push(thisReferenceModified);\n\n\t\t\t\t}//e:if:thisReference\n\t\t\t\t\n\t\t\t});//e:forEach:paperEdit.referenceUniqueIdsInPaper\n\t\t\t\n\t\t\t// console.log(_referencesInPaper);\n\t\t\t\n\t\t\t// run the special rules Engine (this will check in a full complete List of Reference Objects in this paper)\n\t\t\t// try it first an stop if there is an error\n\t\t\tlet EngineAfterSpecialRules;\n\t\t\ttry {\n\t\t\t\tEngineAfterSpecialRules = Engine.specialRules(store.state.paperEdit.meta.PaperFormatVersionID, _referencesInPaper);\n\t\t\t\t// EngineAfterSpecialRules = Engine.specialRules(store.state.paperEdit.meta.PaperFormatVersionID); // this will cause an error\n\t\t\t\t// console.log('Special Rules were a success');\n\t\t\t\t// console.log(EngineAfterSpecialRules);\n\t\t\t} catch (error){\n\t\t\t\tconsole.log('Special Rules had an error');\n\t\t\t\t\n\t\t\t\tconsole.log(error);\n\t\t\t\treturn;\t// since there was an error stop here, the blue spinner is still up - this is a chance to communicate to them something is wrong, or support can see more details if they are impersonating \n\t\t\t}\n\n\t\t\tstore.commit('paperEdit/SET_REFERENCES_IN_PAPER', EngineAfterSpecialRules);\n\n\t\t\twindow.$vm.emitter.emit('referencesInPaperReady');\n\n\n\t\t\t/*\n\t\t\t*** PCKS_CleanCitationOutput\n\t\t\t*/\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t// footnotes\n\t\t\t\t\tlet footnoteCounter = 1;\n\n\t\t\t\t\t// loop through each CkEditor Instance\n\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\tif(ckInstance.document){\n\t\t\t\t\t\t\tlet citationElementsInThisInstance = ckInstance.document.find('span.perrla_citation');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// loop through any citations element found in this instance\n\t\t\t\t\t\t\t_forEach(citationElementsInThisInstance.toArray(), (citationElement)=>{\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tlet citationElementParent = citationElement.getParent();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t// Add a space after this footnote so the cursor can grab something\n\t\t\t\t\t\t\t\tif(citationElementParent){\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tcitationElement.setHtml('' + footnoteCounter + '');\n\t\t\t\t\t\t\t\t\tfootnoteCounter++;\n\n\t\t\t\t\t\t\t\t\tlet citationAfter = citationElementParent.getNext();\n\n\t\t\t\t\t\t\t\t\tif(!citationAfter){\n\t\t\t\t\t\t\t\t\t\t// there is nothing after this citation\n\t\t\t\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.element('span');\n\t\t\t\t\t\t\t\t\t\tbracketElement.setHtml(' ');\n\t\t\t\t\t\t\t\t\t\tbracketElement.insertAfter(citationElementParent);\n\t\t\t\t\t\t\t\t\t}//e:if:!citationAfter\n\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t}//e:if:citationElementParent\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t}//e:ckInstance.document\n\t\t\t\t\t}); //e:forEach\n\t\t\t\t\t\n\t\t\t\t\twindow.$vm.emitter.emit('calculateFootnoteDisplay');\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t// regular citations\n\t\t\t\t\tlet citationsWithDocumentPosition = []; // list of all the citations with a document position that isn't 0\n\t\n\t\t\t\t\t// loop through references in this paper\n\t\t\t\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\t\t\t\tif(_has(referenceObject, 'citations') && referenceObject.citations.length > 0){\n\t\t\t\t\t\t\treferenceObject.citations.forEach((citationObject)=>{\n\t\t\t\t\t\t\t\tif(_has(citationObject, 'documentPosition') && citationObject.documentPosition !== 0){\n\t\t\t\t\t\t\t\t\tcitationsWithDocumentPosition.push(citationObject);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});//e:forEach:referenceObject.citations\n\t\t\t\t\t\t}//e:if\n\t\t\t\t\t});//forEach:paperEdit.referencesInPaper\n\t\n\t\t\t\t\t// citationsWithDocumentPosition should be built now\n\t\t\t\t\tif(citationsWithDocumentPosition.length > 0){\n\t\t\t\t\t\tcitationsWithDocumentPosition = _sortBy(citationsWithDocumentPosition, ['documentPosition']);\n\t\n\t\t\t\t\t\tcitationsWithDocumentPosition.forEach((citationObject)=>{\n\t\t\t\t\t\t\t// find the citation node in the ckEditor instances and force it's content to come from the Engine\n\t\t\t\t\t\t\tlet $citationNode = null;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\t\t\t// look for a group citation first\n\t\t\t\t\t\t\t\tif(citationObject.groupUniqueID){\n\t\t\t\t\t\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-group-unique-id=\"' + citationObject.groupUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\treturn false;\t// stop looking when found\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// look for regular citations second\n\t\t\t\t\t\t\t\t\t$citationNode = ckInstance.document.findOne('span[data-citation-unique-id=\"' + citationObject.citationData.citationUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t\t\treturn false;\t// stop looking when found\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});//e:forEach:ckInstance\n\t\n\t\t\t\t\t\t\tif($citationNode){\n\t\t\t\t\t\t\t\t// Not a footnote - treat like a regular citation\n\t\t\t\t\t\t\t\t// check if using new citation mode\n\t\t\t\t\t\t\t\tif(store.state.paperEdit.meta.UseNewCitationMode){\n\t\t\t\t\t\t\t\t\t// console.log('citationObject');\n\t\t\t\t\t\t\t\t\t// console.log(citationObject);\n\t\t\t\t\t\t\t\t\t$citationNode.setHtml(citationObject.displayValue.slice(1, -1));\n\t\t\t\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t$citationNode.setHtml(citationObject.displayValue);\n\t\t\t\n\t\t\t\t\t\t\t\t}//e:if:UseNewCitationMode\n\t\t\t\t\t\t\t}//e:if:$citationNode\n\t\n\t\t\t\t\t\t});//e:forEach:citationsWithDocumentPosition\n\t\n\t\t\t\t\t}//e:if:citationsWithDocumentPosition.length\n\t\n\t\t\t\t}//e:if:else:renderCitationsAsFootnotes\n\t\t\t\t\n\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\tlet citationsInThisOutline;\n\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\tcitationsInThisOutline = [];\n\t\n\t\t\t\t} else {\n\t\t\t\t\tcitationsInThisOutline = {};\n\t\t\t\t}\n\t\n\t\t\t\t// loop trough all ck instances on this page\n\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t// find any citations in this ck instance\n\t\t\t\t\tlet citationsNodeList = ckInstance.document.find('span.perrla_citation');\n\t\t\t\t\t// console.log(citationsNodeList);\n\t\n\t\t\t\t\t// loop through all citation elements - i'm going to group them by reference unique id\n\t\t\t\t\t_forEach(citationsNodeList.toArray(), (citationElement, index)=>{\n\t\t\t\t\t\t// console.log('citationElement');\n\t\t\t\t\t\t// console.log(citationElement);\n\t\n\t\t\t\t\t\t// parse the data object (this only works this way when coming from the outline - if you make this broader you will have to accomodate)\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet citationDataObject = JSON.parse(window.atob(citationElement.getAttribute('citation-data')));\n\t\t\t\t\t\t\t// console.log('citationDataObject');\n\t\t\t\t\t\t\t// console.log(citationDataObject);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// add this reference uid \n\t\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\t\t// console.log('make an array of all citations');\n\t\t\t\t\t\t\t\tcitationsInThisOutline.push({\n\t\t\t\t\t\t\t\t\tcitationDataObject: citationDataObject,\n\t\t\t\t\t\t\t\t\tcitationElement: citationElement,\n\t\t\t\t\t\t\t\t\tfootnoteIndex: index,\n\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(!_has(citationsInThisOutline, citationDataObject.citationData.referenceUniqueID)){\n\t\t\t\t\t\t\t\t\tcitationsInThisOutline[citationDataObject.citationData.referenceUniqueID] = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\t\t\t\t// push citation data here\n\t\t\t\t\t\t\t\tcitationsInThisOutline[citationDataObject.citationData.referenceUniqueID].push({\n\t\t\t\t\t\t\t\t\tcitationDataObject: citationDataObject,\n\t\t\t\t\t\t\t\t\tcitationElement: citationElement,\n\t\t\t\t\t\t\t\t\tfootnoteIndex: index,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch(error){\n\t\t\t\t\t\t\tconsole.log('error JSON.parse(window.atob');\n\t\t\t\t\t\t\tconsole.log(error);\n\t\t\t\t\t\t}//e:try:catch\n\t\t\t\t\t\n\t\t\t\t\t});//e:forEach:citationsNodeList.toArray() \n\t\n\t\t\t\t});//e:forEach:CKEDITOR.instances\n\t\n\t\t\t\t// all ck instances have been looped through - a super array of citations on this page is now ready\n\t\n\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\n\t\t\t\t\tlet _citationsInThisOutline = _orderBy(citationsInThisOutline, ['footnoteIndex'], ['asc']);\n\t\n\t\t\t\t\t_forEach(_citationsInThisOutline, (citationDataChild, index)=>{\n\t\t\t\t\t\t// console.log('citationDataChild');\n\t\t\t\t\t\t// console.log(citationDataChild);\n\t\n\t\t\t\t\t\t// Footnote content\n\t\t\t\t\t\tcitationDataChild.citationElement.setHtml('' + (index + 1) + '');\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add a space after this footnote so the cursor can grab something\n\t\t\t\t\t\tif(citationDataChild.citationElement.getParent()){\n\t\t\t\t\t\t\tlet citationAfter = citationDataChild.citationElement.getParent().getNext();\n\t\t\t\t\t\t\tif(!citationAfter){\n\t\t\t\t\t\t\t\t// there is nothing after this citation\n\t\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.element('span');\n\t\t\t\t\t\t\t\tbracketElement.setHtml(' ');\n\t\t\t\t\t\t\t\tbracketElement.insertAfter( citationDataChild.citationElement.getParent() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\n\t\t\t\t\t});//e:forEach:citationDataChidren\n\t\n\t\t\t\t\tstore.commit('paperEdit/outline/SET_FULL_CITATION_OBJECTS', _citationsInThisOutline);\n\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t// console.log('citationsInThisOutline');\n\t\t\t\t\t// console.log(citationsInThisOutline);\n\n\t\t\t\t\t// loop through each citation in the super array\n\t\t\t\t\t_forEach(citationsInThisOutline, (citationsForThisReference, referenceUniqueId)=>{\n\t\t\t\t\t\t// sort these citations by their position\n\t\t\t\t\t\tlet _citationsForThisReference = _orderBy(citationsForThisReference, ['footnoteIndex'], ['asc']);\n\t\t\t\t\t\t\n\t\t\t\t\t\t// loop through each citation object found under this reference uid\n\t\t\t\t\t\t_forEach(_citationsForThisReference, (citationDataChild, index)=>{\n\t\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\t\t// Footnote content\n\t\t\t\t\t\t\t\tcitationDataChild.citationElement.setHtml('' + (index + 1) + '');\n\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Not a footnote - treat like a regular citation\n\n\t\t\t\t\t\t\t\t// use this referenceUniqueId to look up the full reference in the library - i want real ref data\n\t\t\t\t\t\t\t\tlet thisReference = store.state.referenceLibraryGenesis.find((ref) => {\n\t\t\t\t\t\t\t\t\treturn ref.referenceUniqueID.toUpperCase() == referenceUniqueId.toUpperCase();\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif(thisReference){\n\t\t\t\t\t\t\t\t\tlet modeLevel = 'available';\n\t\t\t\t\t\t\t\t\tif(config.isDev){\n\t\t\t\t\t\t\t\t\t\tmodeLevel = 'dev';\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t} else if(config.isTest){\n\t\t\t\t\t\t\t\t\t\tmodeLevel = 'test';\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tlet citationEngineResult = Engine.getCitation(thisReference.referenceTypeID, JSON.parse(thisReference.data), citationDataChild.citationDataObject.citationData, modeLevel);\n\n\t\t\t\t\t\t\t\t\tlet setValue = '';\n\t\t\n\t\t\t\t\t\t\t\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.APA7){\n\t\t\t\t\t\t\t\t\t\t// APA7\n\t\t\t\t\t\t\t\t\t\tif(index === 0){\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.apa7.first;\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.apa7.subsequent;\n\t\t\t\t\t\t\t\t\t\t\tif(setValue === ''){\n\t\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.apa7.first;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.MLA9){\n\t\t\t\t\t\t\t\t\t\t// MLA9\n\t\t\t\t\t\t\t\t\t\tif(index === 0){\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.mla9.first;\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.mla9.subsequent;\n\t\t\t\t\t\t\t\t\t\t\tif(setValue === ''){\n\t\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.mla9.first;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t\t} else if(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\t\t\t\t\t\t\t\t// Turabian9\n\t\t\t\t\t\t\t\t\t\tif(index === 0){\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.turabian9.first;\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.turabian9.subsequent;\n\t\t\t\t\t\t\t\t\t\t\tif(setValue === ''){\n\t\t\t\t\t\t\t\t\t\t\t\tsetValue = citationEngineResult.turabian9.first;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t\t}//e:if\n\n\t\t\t\t\t\t\t\t\tif(store.state.paperEdit.meta.UseNewCitationMode){\n\t\t\t\t\t\t\t\t\t\tcitationDataChild.citationElement.setHtml(setValue.slice(1, -1));\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tcitationDataChild.citationElement.setHtml(setValue);\n\t\t\t\t\t\t\t\t\t}//e:if:UseNewCitationMode\n\n\t\t\t\t\t\t\t\t}//e:if:thisReference\n\n\t\t\t\t\t\t\t}//e:if:store.state.paperEdit.config.renderCitationsAsFootnotes\n\t\n\t\t\t\t\t\t});//e:forEach:citationDataChidren\n\t\n\t\t\t\t\t});//e:forEach:citationsInThisOutline\n\t\n\t\t\t\t}//e:store.state.paperEdit.config.renderCitationsAsFootnotes\n\t\t\t\t\n\t\t\t}//e:if:OUTLINE\n\t\t\t\n\t\t\treturn resolve();\n\t\t\t\t\n\t\t}//e:if:else\n\t\t\n\t});//e:Promise\n}","// TDS_Open\n\nimport store from '@/store';\n\nexport default () => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('TDS_Open');\n\t\t\n\t\tstore.commit('paperEdit/toolDrawer/IS_OPEN', true);\n\t\tstore.commit('paperEdit/toolDrawer/IS_SIDEMENU_OPEN', false);\n\n\t\tif(window.$vm && window.$vm.emitter){\n\t\t\twindow.$vm.emitter.emit('closeAllDropdowns');\n\t\t}\n\n\t\tresolve();\n\t})//e:Promise\n}\n","// PApS_AddToPaper\nimport config from '@/config';\nimport PApS_CleanUp from '@/services/paper/appendices/cleanUp';\nimport store from '@/store';\nimport { v1 as uuidv1 } from 'uuid';\n\nexport default () => {\n\t// console.log('PApS_AddToPaper');\n\n\treturn new Promise((resolve) => {\n\t\t// generate a uid for this appendix you are adding\n\t\tlet newUUID = uuidv1().toUpperCase();\n\t\t\n\t\tlet appendixTitleDefaultContent = '

Type the title of your appendix here

';\n\t\t\n\t\tif(store.state.paperEdit.meta.PaperFormatVersionID === config.enums.Format.Turabian9){\n\t\t\tappendixTitleDefaultContent = '

Optional descriptive title for the appendix


Type your appendix content here...

';\n\t\t}\n\n\t\tstore.commit('paperEdit/appendices/ADD_TO_PAPER', {\n\t\t\tcontent: appendixTitleDefaultContent,\t// this is the Title the user can change, don't confuse it with the Label like \"Appendix A\"\n\t\t\tuid: newUUID, \n\t\t});\n\n\t\t// after adding just reclean them (to sync sort and title)\n\t\tPApS_CleanUp().then((cleanedAppendicesInPaper)=>{\n\t\t\tstore.commit('paperEdit/appendices/IN_PAPER', cleanedAppendicesInPaper);\n\t\t\t\n\t\t\tstore.dispatch('paperEdit/toc/generateContent').then(()=>{\n\t\t\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\t\t\ttextContent: 'Appendix added',\n\t\t\t\t});\n\n\t\t\t\tresolve(newUUID);\n\t\t\t});//e:dispatch:paperEdit/toc/generateContent\n\t\t\t\n\t\t});\n\t});//e:Promise\n}","// PAnS_AddUpdate\n// Adds an empty annotation instnace\n// Updates exisiting annotation content\n\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PAnS_AddUpdate');\n\n\treturn new Promise((resolve) => {\n\t\tstore.commit('paperEdit/annotations/IS_INCLUDE', true);\n\t\t\t\t\n\t\tlet thisAnnotationFindIndex = store.state.paperEdit.annotations.inPaper.findIndex((annotationData)=>{\n\t\t\treturn annotationData.referenceUniqueId.toUpperCase() === $opts.referenceUniqueId.toUpperCase();\n\t\t});\n\t\tif(thisAnnotationFindIndex > -1){\n\t\t\tstore.commit('paperEdit/annotations/UPDATE_AT_INDEX', {\n\t\t\t\tcontent: $opts.content,\n\t\t\t\tindex: thisAnnotationFindIndex,\n\t\t\t});\n\t\t} else {\n\t\t\t// Add\n\t\t\tstore.commit('paperEdit/annotations/ADD_TO_PAPER', $opts);\n\t\t}\n\n\t\treturn resolve();\n\t});//e:Promise\t\t\t\n\n}\n","/*\n- PCS_InsertCitation\n-- Inserts a single citation\n-- Renders a citation (APA7 / MLA9) or a Footnote (Turabian)\n-- Fires from CitationAdd or the CitationRow to Insert an Orphan Citation\n*/\n\nimport _has from 'lodash/has';\nimport config from '@/config';\nimport PCKS_WrapCitation from '@/services/paper/ck/wrapCitation';\nimport router from '@/router';\nimport store from '@/store';\nimport Swal from 'sweetalert2';\nimport { v4 as uuidv4 } from 'uuid';\nimport Vue from 'vue';\n\nexport default ($opts) => {\n\treturn new Promise((resolve, reject) => {\n\t\t// console.log('PCS_InsertCitation');\n\n\t\tif(!CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused]){\n\t\t\treturn reject();\n\t\t}\n\n\t\tlet $findFocusedCitation; \n\n\t\tif(store.state.paperEdit.footnotes.contextMenuSelectedOnFindById === ''){\n\t\t\t// user was already on a citation element in the paper\n\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span.cke_widget_wrapper_perrla_citation.cke_widget_selected');\n\n\t\t} else {\n\t\t\t// user had a Footnote Citation selected, find it's matching citation in the paper\n\t\t\t\t\t\t\n\t\t\t// start by looking for the group uid\n\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span[data-group-unique-id=\"' + store.state.paperEdit.footnotes.contextMenuSelectedOnFindById + '\"]');\n\n\t\t\tif(!$findFocusedCitation){\n\t\t\t\t// not found, try to find a single\n\t\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span[data-citation-unique-id=\"' + store.state.paperEdit.footnotes.contextMenuSelectedOnFindById + '\"]');\n\t\t\t}\n\n\t\t\tif($findFocusedCitation){\n\t\t\t\t$findFocusedCitation = $findFocusedCitation.getParent();\n\t\t\t}\n\t\t}//e:if:else\n\n\n\n\t\tif($findFocusedCitation) {\n\t\t\t// Focus was inside a citation widget while inserting one - combine them\n\n\t\t\t// %Rh Temp Fix - Group Citations are not wired up in the Outline, stop them from being added for now so you can come back and fix them properly soon\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\tSwal.fire({\n\t\t\t\t\tallowOutsideClick: false,\n\t\t\t\t\tbuttonsStyling: false,\n\t\t\t\t\ttext: 'There was a problem adding this citation to your outline',\n\t\t\t\t\ticon: 'error',\n\t\t\t\t\tconfirmButtonText: 'Ok',\n\t\t\t\t\tshowCloseButton: false,\n\t\t\t\t\tshowConfirmButton: true,\n\t\t\t\t\tcustomClass:{\n\t\t\t\t\t\tconfirmButton: 'btn btn-danger',\n\t\t\t\t\t},\n\t\t\t\t}).then((result) => {\n\t\t\t\t\tif (result.value) {\n\t\t\t\t\t\treturn reject();\n\t\t\t\t\t}\n\t\t\t\t});//e:Swal\n\n\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\n\t\t\t\t// this is the actual ckElement that is focused\n\t\t\t\tlet $findCitationNode = $findFocusedCitation.findOne('span.perrla_citation');\n\t\t\t\t\n\t\t\t\t// console.log('$findCitationNode1');\n\t\t\t\t// console.log($findCitationNode);\n\n\t\t\t\t// https://app.raygun.com/crashreporting/mb3tr7/errors/82499371374\n\t\t\t\tif(!$findCitationNode) {\n\t\t\t\t\treturn reject();\n\t\t\t\t}\n\n\t\t\t\tlet currentCitationNodeUid = $findCitationNode.getAttribute('data-citation-unique-id');\n\t\t\t\t// console.log('currentCitationNodeUid');\n\t\t\t\t// console.log(currentCitationNodeUid);\n\n\t\t\t\t// is this citation already part of a group?\n\t\t\t\tlet isGroupCitation = $findCitationNode.hasAttribute('data-group-unique-id');\n\t\t\t\t\n\t\t\t\tlet newGroupUniqueID = '';\n\t\t\t\t\n\t\t\t\tlet createOrder = 0;\n\n\t\t\t\tif(isGroupCitation) {\n\t\t\t\t\t// Already a group citation - add to it\n\t\t\t\t\tnewGroupUniqueID = $findCitationNode.getAttribute('data-group-unique-id')\n\t\t\t\t\t\n\t\t\t\t\tlet citationsWithThisGroupUid = [];\n\n\t\t\t\t\t// loop through current citations in paper\n\t\t\t\t\tstore.state.paperEdit.citations.inPaper.forEach((citationObject)=>{\n\t\t\t\t\t\tif(_has(citationObject, 'groupUniqueID') && citationObject.groupUniqueID.toUpperCase() === newGroupUniqueID.toUpperCase()){\n\t\t\t\t\t\t\tcitationsWithThisGroupUid.push(citationObject);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// console.log('citationsWithThisGroupUid');\n\t\t\t\t\t// console.log(citationsWithThisGroupUid);\n\n\t\t\t\t\tcreateOrder += citationsWithThisGroupUid.length;\n\n\t\t\t\t} else {\n\t\t\t\t\t// Single citation, create a group\n\t\t\t\t\tcreateOrder++;\n\n\t\t\t\t\t// generate a group uid to link these two inPaper\n\t\t\t\t\tnewGroupUniqueID = uuidv4().toUpperCase();\n\t\t\t\t\t\n\t\t\t\t\t// console.log('newGroupUniqueID');\n\t\t\t\t\t// console.log(newGroupUniqueID);\n\t\t\t\t\t\n\t\t\t\t\t$findCitationNode.setAttribute('data-group-unique-id', newGroupUniqueID);\n\t\t\t\t\t$findCitationNode.removeAttribute('data-citation-unique-id');\n\n\t\t\t\t\t// console.log('$findCitationNode2');\n\t\t\t\t\t// console.log($findCitationNode);\n\n\t\t\t\t\t// add the currently focused citation to the group\n\t\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === currentCitationNodeUid.toUpperCase();\n\t\t\t\t\t});\n\t\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\t\tstore.commit('paperEdit/citations/ADD_GROUP_UID_AT_INDEX', {\n\t\t\t\t\t\t\tcreateOrder: createOrder,\n\t\t\t\t\t\t\tfindIndex: findCitationIndex,\n\t\t\t\t\t\t\tgroupUniqueID: newGroupUniqueID,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tstore.commit('paperEdit/footnotes/REMOVE_AT_CITATION_UID', currentCitationNodeUid.toUpperCase());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}//e:if:else:isGroupCitation\n\n\t\t\t\t// add the citation that was just created (or trying to insert as orphan) also to the group\n\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === $opts.citationUniqueID.toUpperCase();\n\t\t\t\t});\n\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\tcreateOrder++;\n\t\t\t\t\tstore.commit('paperEdit/citations/ADD_GROUP_UID_AT_INDEX', {\n\t\t\t\t\t\tcreateOrder: createOrder,\n\t\t\t\t\t\tfindIndex: findCitationIndex,\n\t\t\t\t\t\tgroupUniqueID: newGroupUniqueID,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// add a group unique id\n\t\t\t\t$opts.groupUniqueID = newGroupUniqueID;\n\t\t\t\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\treturn resolve(newGroupUniqueID);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t}//e:if:else:Tab.EDITOR\n\n\t\t} else {\n\t\t\t// Focus was in a normal document, insert as usual\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\tCKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].execCommand('perrlaReferences', {\n\t\t\t\t\tstartupData: $opts\n\t\t\t\t});\n\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\t// if it's a footnote, force space after it so the cursor can grab something \n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tlet $citationNode = CKEDITOR.instances.ckPaperBody.document.findOne('span[data-citation-unique-id=\"' + $opts.citationUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\tif($citationNode && $citationNode.getParent()){\n\t\t\t\t\t\t\t\tlet textItem = new CKEDITOR.dom.text(' ');\n\t\t\t\t\t\t\t\ttextItem.insertAfter( $citationNode.getParent() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twindow.$vm.emitter.emit('calculateFootnoteDisplay');\n\t\t\t\t\t\treturn resolve($opts.citationUniqueID.toUpperCase());\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\t// console.log('$opts');\n\t\t\t\t// console.log($opts);\n\t\t\t\n\t\t\t\tCKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].execCommand('outlineCitation', {\n\t\t\t\t\tstartupData: $opts\n\t\t\t\t});\n\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tstore.commit('paperEdit/outline/ADD_CITATION_OBJECT', {\n\t\t\t\t\t\tcitationUniqueId: $opts.citationUniqueID,\n\t\t\t\t\t\tdataBase64: $opts.citationDataBase64,\n\t\t\t\t\t});\n\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\t// if it's a footnote, force space after it so the cursor can grab something \n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tlet $citationNode = CKEDITOR.instances.ckPaperOutline.document.findOne('span[data-citation-unique-id=\"' + $opts.citationUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif($citationNode && $citationNode.getParent()){\n\t\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.element('span');\n\t\t\t\t\t\t\t\tbracketElement.setHtml(' ');\n\t\t\t\t\t\t\t\tbracketElement.insertAfter( $citationNode.getParent() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn resolve();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});//e:Promise\n}","/*\n- PS_DownloadDocumentVersion\n-- 2023.03.14\n*/\n\nimport _has from 'lodash/has';\nimport _isEmpty from 'lodash/isEmpty';\nimport ApiS_MakeCall from '@/services/app/api/makeCall';\nimport config from '@/config';\nimport dateToLongString from '@/helpers/date-to-long-string';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_DownloadDocumentVersionV4');\n\n\t\t// set opt defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _versionId = (_has(_$opts, 'versionId')) ? _$opts.versionId : '';\n\t\tconst _isOpenAfter = (_has(_$opts, 'isOpenAfter')) ? _$opts.isOpenAfter : false;\n\t\tconst _isPrint = (_has(_$opts, 'isPrint')) ? _$opts.isPrint : false;\n\t\tconst _isStealth = (_has(_$opts, 'isStealth')) ? _$opts.isStealth : false;\n\t\t\n\t\tconst _paperId = (_has(_$opts, 'paperId')) ? _$opts.paperId : store.state.paperEdit.meta.PaperID;\n\t\tconst _paperTitle = (_has(_$opts, 'paperId')) ? _$opts.paperTitle : store.state.paperEdit.meta.Title;\n\t\tlet _versionDateOuput = (_has(_$opts, 'versionDateOuput')) ? _$opts.versionDateOuput : null;\n\n\t\tif(!_versionDateOuput){\n\t\t\t_versionDateOuput = dateToLongString({\n\t\t\t\tdateValue: new Date(),\n\t\t\t\tshowTime: true,\n\t\t\t});\n\t\t}\n\t\t\n\t\tlet paramPass = {\n\t\t\tpaperId: _paperId,\n\t\t\tplatform: $opts.platform,\n\t\t\tcontentType: $opts.contentType\n\t\t};\n\t\tif(_versionId != '') {\n\t\t\tparamPass.versionId = _versionId;\n\t\t}\n\t\t\n\t\tif(!_isStealth){\n\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t}\n\n\t\tApiS_MakeCall({\n\t\t\tmethod: 'GET',\n\t\t\tparams: paramPass,\n\t\t\tresponseType: 'arraybuffer',\n\t\t\turl: 'v4/Paper',\n\t\t}).then((responseData)=>{\n\t\t\tlet paperTitle = '';\n\n\t\t\tif(config.platformId === config.enums.Platform.CHROME_EXT){\n\t\t\t\tif(_isEmpty(store.state.users.papers.openData)){\n\t\t\t\t\tpaperTitle = _paperTitle || 'Document';\n\t\t\t\t} else {\n\t\t\t\t\tpaperTitle = store.state.users.papers.openData.name || 'Document';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpaperTitle = _paperTitle || 'Document';\n\t\t\t}\n\n\t\t\tpaperTitle = paperTitle.replace(/[/\\\\?%*:|\"<>]/g, '-');\n\t\t\t\n\t\t\tlet fileBlobType = '';\n\t\t\tlet fileSaveExtension = '';\n\n\t\t\tswitch($opts.contentType){\n\t\t\t\tcase config.enums.DownloadPaperContentType.COMPRESSED:\n\t\t\t\t\tfileBlobType = 'text/plain';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.PDF:\n\t\t\t\t\tfileBlobType = 'application/pdf';\n\t\t\t\t\tfileSaveExtension = 'pdf';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.HTML:\n\t\t\t\t\tfileBlobType = 'text/html';\n\t\t\t\t\tfileSaveExtension = 'html';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.WORD:\n\t\t\t\tcase config.enums.DownloadPaperContentType.WORD_SIMPLE:\n\t\t\t\t\tfileBlobType = 'application/msword';\n\t\t\t\t\tfileSaveExtension = 'docx';\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tlet file = new Blob([responseData], {\n\t\t\t\ttype: fileBlobType\n\t\t\t});\n\n\t\t\tif (window.navigator && window.navigator.msSaveOrOpenBlob) {\n\t\t\t\twindow.navigator.msSaveOrOpenBlob(file, paperTitle + ' - ' + _versionDateOuput + '.' + fileSaveExtension);\n\t\t\t} else {\n\t\t\t\tlet fileURL = window.URL.createObjectURL(file);\n\n\t\t\t\tlet fileLink = document.createElement('a');\n\t\t\t\tfileLink.href = fileURL;\n\n\t\t\t\tif(_isOpenAfter){\n\t\t\t\t\tfileLink.target = '_blank';\n\t\t\t\t\twindow.open(fileLink);\n\n\t\t\t\t} else if(_isPrint){\n\t\t\t\t\tconst iframe = document.createElement('iframe');\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\tiframe.style.display = 'none';\n\t\t\t\t\tiframe.src = fileURL;\n\t\t\t\t\tiframe.onload = ()=>{\n\t\t\t\t\t\tsetTimeout(()=>{\n\t\t\t\t\t\t\tiframe.focus();\n\t\t\t\t\t\t\tiframe.contentWindow.print();\n\t\t\t\t\t\t}, 33);\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\tif($opts.contentType === config.enums.DownloadPaperContentType.COMPRESSED){\n\t\t\t\t\t\tfileLink.download = 'PaperContent.txt';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfileLink.download = paperTitle + ' - ' + _versionDateOuput + '.' + fileSaveExtension;\n\t\t\t\t\t}\n\t\t\t\t\tdocument.body.appendChild(fileLink);\n\t\t\t\t\tfileLink.click();\n\n\t\t\t\t\tsetTimeout(()=>{\n\t\t\t\t\t\t// For Firefox it is necessary to delay revoking the ObjectURL\n\t\t\t\t\t\twindow.URL.revokeObjectURL(fileURL);\n\t\t\t\t\t}, 100);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\n\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\n\t\t\tresolve();\n\n\t\t});//e:ApiS_MakeCall\n\t});//e:Promise\n}","// PS_InjectContent\nimport config from '@/config';\nimport LzString from 'lz-string';\nimport PS_ParseHiddenTags from '@/services/paper/parseHiddenTags';\nimport RS_UpdateAfterSync from '@/services/reference/updateAfterSync';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_InjectContent');\n\n\t\tstore.commit('paperEdit/SET_ENCRYPTED_PAPER_LZ_STRING', $opts.compressedPaperData);\n\n\t\tlet decompressedPaperData = LzString.decompressFromUTF16($opts.compressedPaperData);\n\n\t\tPS_ParseHiddenTags(decompressedPaperData).then(()=>{\n\t\t\tswitch(store.state.paperEdit.meta.DocumentType){\n\t\t\t\tcase config.enums.DocumentType.ANNOTATED_BIBLIOGRAPHY:\n\t\t\t\tcase config.enums.DocumentType.REFERENCE_LIST:\n\t\t\t\t\t// no ckEditor Body\n\t\t\t\t\tRS_UpdateAfterSync().then(()=>{\n\t\t\t\t\t\twindow.$vm.emitter.emit('loadCkReferencePage');\n\t\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DocumentType.DISCUSSION_POST:\n\t\t\t\t\t// no Title Page\n\t\t\t\t\twindow.$vm.emitter.emit('loadCkBody');\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DocumentType.RESEARCH_PAPER:\n\t\t\t\t\twindow.$vm.emitter.emit('loadCkTitlePage');\n\t\t\t\t\twindow.$vm.emitter.emit('loadTitlePageDrawer');\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tstore.commit('paperEdit/ck/SET_IS_EDITOR_LOADED_ONCE');\n\n\t\t\tresolve();\n\n\t\t});//e:paperEdit/parseHiddenTags\n\n\t});//e:Promise\n\n}","// PS_LoadByRoute\nimport _isEmpty from 'lodash/isEmpty';\nimport AS_SyncData from '@/services/app/syncData';\nimport store from '@/store';\n\nexport default () =>{\n\treturn new Promise((resolve, reject) => {\n\t\t// console.log('PS_LoadByRoute');\n\n\t\tif(_isEmpty(store.state.openObject)){\n\t\t\t// console.log('need to look this paper up');\n\n\t\t\tAS_SyncData().then(()=>{\n\t\t\t\t// look paper up by the encryptedId param\n\t\t\t\tlet findPaper = store.state.paperList.list.find((paperData)=>{\n\t\t\t\t\treturn paperData.encryptedID === window.$vm.$route.params.encryptedId\n\t\t\t\t});\n\n\t\t\t\tif(findPaper){\n\t\t\t\t\tstore.commit('paperEdit/SET_OPEN_OBJECT', findPaper)\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject('Could not find paper');\n\t\t\t\t}\n\t\t\t});//e:syncData\n\n\t\t} else {\n\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\n\t\t\tresolve();\n\t\t}\n\n\t});//e:Promise\n\n}","// PS_SaveDocument\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport ApiS_MakeCall from '@/services/app/api/makeCall';\nimport config from '@/config';\nimport ErrS_GenericAlert from '@/services/app/error/generic-alert.js';\nimport LzString from 'lz-string';\nimport PS_BuildHtml from '@/services/paper/buildHtml';\nimport router from '@/router';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_SaveDocument');\n\t\n\t\t// set defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _isAutoSave = (_has(_$opts, 'isAutoSave')) ? _$opts.isAutoSave : false;\n\t\tconst _isMetaDataChanges = (_has(_$opts, 'isMetaDataChanges')) ? _$opts.isMetaDataChanges : false;\n\n\t\t// 2024.09.23 Updated to remove the blue spinner - Document Saves will be processed without any problems\n\t\t// let _isStealthSave = (_has(_$opts, 'isStealthSave')) ? _$opts.isStealthSave : false;\n\t\tlet _isStealthSave = true;\n\t\t\n\t\tlet verifyLogId;\n\n\t\tconst _updateMetaTags = (_has(_$opts, 'updateMetaTags')) ? _$opts.updateMetaTags : [];\n\t\tconst _message = (_has(_$opts, 'message')) ? _$opts.message : '';\n\n\t\t// write the initial request local logs\n\t\tstore.dispatch('logs/write', {\n\t\t\tmessage: _message,\n\t\t}).then((newLogId)=>{\n\t\t\tverifyLogId = newLogId;\n\t\t});\n\n\t\t// stop the inactivy timer\n\t\tstore.dispatch('paperEdit/inactivityAlert/endTimer');\n\n\t\t// cancel the local version check in\n\t\tstore.commit('paperEdit/localVersion/USER_TYPE_LOCAL_TIMER_CANCEL');\n\n\t\tif(!_isAutoSave && !_isStealthSave){\n\t\t\t// show loading if not Auto or Stealth\n\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t}\n\n\t\t// prepare the document and try to save it\n\t\tPS_BuildHtml({\n\t\t\tupdateMetaTags: _updateMetaTags,\n\t\t}).then((buildHtmlResponseObj)=>{\n\t\t\t// console.log('buildHtmlResponseObj.returnHtml');\n\t\t\t// console.log(buildHtmlResponseObj.returnHtml);\n\n\t\t\tlet compressedPaperContent = LzString.compressToUTF16(buildHtmlResponseObj.returnHtml)\n\t\t\tlet encryptedPaper = encodeURIComponent(compressedPaperContent);\n\n\t\t\tlet params = {};\n\t\t\t\n\t\t\tif(_isMetaDataChanges){\n\t\t\t\tparams['metaDataChanges'] = true;\n\t\t\t}\n\n\t\t\t// MESSAGES API - https://trello.com/c/3A5FYXAY/305-action-descriptions-for-paper-saves-in-online-add-in\n\t\t\tif(_message != ''){\n\t\t\t\tparams['message'] = _message;\n\t\t\t}\n\n\t\t\t// start the inactivityAlert timer back up (but not in Outline)\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\tstore.dispatch('paperEdit/inactivityAlert/startTimer');\n\t\t\t}\n\n\t\t\tif(!_isAutoSave && !_isStealthSave){\n\t\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t\t}\n\n\t\t\t/*\n\t\t\tto simulate vairious error responses replace one of these with one of the parameters in the api call:\n\t\t\t\t?\t\t\t\t\t\t400\n\t\t\t\turl: 'v3/PaperX',\t\t404\n\t\t\t\turl: 'v3/Paper/%',\t\t?\n\t\t\t\tbody: 'content=XXX',\t?\n\t\t\t*/\n\t\t\t\n\t\t\tApiS_MakeCall({\n\t\t\t\tcontentType: 'application/x-www-form-urlencoded',\n\t\t\t\tbody: 'content=' + encryptedPaper,\n\t\t\t\tmethod: 'PUT',\n\t\t\t\tparams,\n\t\t\t\tresponseType: 'json',\n\t\t\t\turl: 'v3/Paper',\n\t\t\t}).then((responseData)=>{\n\t\t\t\t// console.log('responseData');\n\t\t\t\t// console.log(responseData);\n\t\t\t\n\t\t\t\tstore.commit('paperEdit/SET_IS_DOCUMENT_SAVED', true);\n\n\t\t\t\tstore.dispatch('paperEdit/toc/generateContent').then(()=>{\n\n\t\t\t\t\t// reset all ck instances so they are clean\n\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\tckInstance.resetDirty();\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t// if(!_isAutoSave && !_isStealthSave){\n\t\t\t\t\t\t// hide loading if not Auto or Stealth\n\t\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\t// }\n\n\t\t\t\t\tif(responseData && _has(responseData, 's3VersionID')){\n\t\t\t\t\t\t// save was successful at this point, i can update the proper indexedDb item\n\t\t\t\t\t\tconst openRequest = indexedDB.open('po_papers', 2);\n\n\t\t\t\t\t\topenRequest.onupgradeneeded = () => {\n\t\t\t\t\t\t\t// console.log('indb:onupgradeneeded po_papers 2');\n\n\t\t\t\t\t\t\tlet db = openRequest.result;\n\n\t\t\t\t\t\t\tif(!db.objectStoreNames.contains('papers')){\n\t\t\t\t\t\t\t\tdb.createObjectStore('papers', {\n\t\t\t\t\t\t\t\t\tautoIncrement: true,\t// people online says this will fix an error i'm seeing in rollbar - i can't replicate to error to verify, changing this doesn't seem to matter locally\n\t\t\t\t\t\t\t\t\tkeyPath: 'paperId',\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};//e:onupgradeneeded\n\n\t\t\t\t\t\topenRequest.onsuccess = () => {\n\t\t\t\t\t\t\tlet db = openRequest.result;\n\n\t\t\t\t\t\t\tif(db.objectStoreNames.contains('papers')){\n\n\t\t\t\t\t\t\t\tconst txn = db.transaction([\"papers\"], 'readwrite');\n\t\t\t\t\t\t\t\tconst store = txn.objectStore('papers');\n\n\t\t\t\t\t\t\t\tlet request = store.openCursor(buildHtmlResponseObj.paperId);\n\n\t\t\t\t\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\t\t\t\t\tlet requestResult = request.result;\n\t\t\t\t\t\t\t\t\tif (requestResult) {\n\t\t\t\t\t\t\t\t\t\t// this item should now be fresh since the save went through\n\t\t\t\t\t\t\t\t\t\tlet item = requestResult.value;\n\t\t\t\t\t\t\t\t\t\titem.content = compressedPaperContent;\n\t\t\t\t\t\t\t\t\t\titem.isFresh = true;\n\t\t\t\t\t\t\t\t\t\tstore.put(item);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};//e:onsuccess\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\ttxn.oncomplete = () => {\n\t\t\t\t\t\t\t\t\tdb.close();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t};//e:onsuccess\n\t\t\t\t\t\t\n\t\t\t\t\t\t// verify the last request in the log, it was successfull\n\t\t\t\t\t\tstore.dispatch('logs/verify', {\n\t\t\t\t\t\t\ts3Link: responseData.s3VersionID,\n\t\t\t\t\t\t\tverifyLogId: verifyLogId\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\twindow.$vm.emitter.emit('referencesInPaperReady');\t// emit to ReferenceCitation.vue (if that drawer isn't open then nothing will happen)\n\n\t\t\t\t\t\tstore.commit('paperEdit/localVersion/SET_IS_FORCE_SAVE_AFTER_LOADING', false);\t// resets to false, only should be true if the user is restoring from local storage\n\n\t\t\t\t\t\treturn resolve({\n\t\t\t\t\t\t\t'contentUrl': (_has(responseData, 'contentUrl')) ? responseData.contentUrl : '',\n\t\t\t\t\t\t\t'pageCount': (_has(responseData, 'pageCount')) ? responseData.pageCount : '',\n\t\t\t\t\t\t});\n\n\t\t\t\t\t}//e:if:responseData\n\n\t\t\t\t});//e:dispatch:paperEdit/toc/generateContent\n\n\t\t\t});//e:ApiS_MakeCall\n\t\t\t\n\t\t}).catch((errorObj)=>{\n\t\t\tErrS_GenericAlert({\n\t\t\t\tenum: errorObj.enum,\n\t\t\t\tsrc: errorObj.src\n\t\t\t});\n\t\t});//e:PS_BuildHtml\n\t\t\n\t});//e:Promise\n}","// PS_AddReferenceToPaper\n// happens when adding a reference from the library, or when creating a new reference in a paper\n\nimport PAnS_AddUpdate from '@/services/paper/annotations/addUpdate';\nimport PS_UpdateReferenceObject from '@/services/paper/updateReferenceObject';\nimport RS_GetValueOutput from '@/services/reference/getValueOutput';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\tstore.commit('paperEdit/REFERENCE_ADD_TO_PAPER', $opts.reference.referenceUniqueID.toUpperCase());\n\t\t\t\t\t\t\n\t\t// craft a message that will eventually make it's way to saveDocument\n\t\tlet referenceDisplayValue = RS_GetValueOutput({\n\t\t\tdisplayFormatVersionId: store.state.customer.preferredFormatVersionID,\n\t\t\treferenceData: $opts.reference,\n\t\t});\n\n\t\tPS_UpdateReferenceObject({\n\t\t\tsaveMessage: 'Added reference from library - ' + referenceDisplayValue,\n\t\t}).then(()=>{\n\t\t\tif($opts.isDrawer){\n\t\t\t\tif(store.state.paperEdit.annotations.isInclude){\n\t\t\t\t\tPAnS_AddUpdate({\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\treferenceUniqueId: $opts.reference.referenceUniqueID.toUpperCase(),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// add reference to list of all customer papers\n\t\t\tlet findPaperIndex = store.state.paperList.list.findIndex((paper) =>{\n\t\t\t\treturn paper.paperID === $opts.paperID;\n\t\t\t});\n\t\t\tif(findPaperIndex != -1){\n\t\t\t\t// paper found, is this reference already in the list (assume APA7 / Genesis)\n\t\t\t\tif(!store.state.paperList.list[findPaperIndex].genesisReferences.includes($opts.referenceID)){\n\t\t\t\t\tstore.commit('paperList/ADD_REFERENCE_ID_TO_PAPER', {\n\t\t\t\t\t\tpaperIndex: findPaperIndex,\n\t\t\t\t\t\treferenceID: $opts.referenceID\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn resolve();\n\t\t\t\n\t\t});//e:PS_UpdateReferenceObject\n\n\t});//e:Promise\n}\n"],"names":["$opts","Promise","resolve","store","commit","PS_SaveDocument","isMetaDataChanges","message","then","Vue","$newInstnaceWrp","document","getElementById","scrollIntoView","config","useWProofreader","WEBSPELLCHECKER","getInstances","forEach","wscInstance","destroy","content","parsedHtml","DOMParser","parseFromString","metaElements","getElementsByTagName","hasUseNewCitationModeTag","_forEach","element","attrName","getAttribute","attrContent","decodeURIComponent","error","console","log","state","paperEdit","meta","PaperType","enums","APA7_AnnotatedBibliography","MLA9_AnnotatedBibliography","Turabian9_AnnotatedBibliography","DocumentType","ANNOTATED_BIBLIOGRAPHY","APA_DiscussionPost","APA7_DiscussionPost","MLA_DiscussionPost","MLA9_DiscussionPost","Turabian9_DiscussionPost","DISCUSSION_POST","APA7_ReferenceList","MLA9_ReferenceList","Turabian9_ReferenceList","REFERENCE_LIST","APA_ResearchPaper","APA7_ProfessionalPaper","APA7_StudentPaper","MLA_ResearchPaper","MLA9_ResearchPaper","Turabian9_ResearchPaper","RESEARCH_PAPER","Swal","allowOutsideClick","buttonsStyling","text","icon","confirmButtonText","showCloseButton","showConfirmButton","customClass","confirmButton","dispatch","IncludeAuthorNote","authorNoteInPaperElement","IncludeAbstract","abstractInPaperElement","_appendicesInPaper","appendicesInPaperElements","appendix","appendixContent","appendixContentDecoded","h1sInAppendix","length","isAppendixTitleFound","h1","classList","contains","push","uid","_orderBy","PApS_CleanUp","arrayOfAppendices","cleanedAppendicesInPaper","_referencesInPaper","_citationsInPaper","referenceElementsInPaper","referenceElemenent","referenceData","JSON","parse","_has","citations","citationObject","orderByValue","referenceUniqueID","toUpperCase","hasAttribute","PAnS_AddUpdate","referenceUniqueId","_sortBy","_referenceUniqueIdsInPaper","sortedReference","_uniq","useOultineInPaperElement","outlineInPaperElement","outlineElement","outlineDataRaw","window","atob","outlineDataEncoded","isOutlineDecoded","startContent","outline","allCitationsElement","allCitationsObject","openReferenceUID","referenceUniqueIdsInPaper","setOpenReferenceId","citationData","renderCitationsAsFootnotes","footnotesElement","footnotesContent","findById","citationUniqueID","groupUniqueID","footnoteData","reviewElements","key","value","toBoolean","sortByScore","parsedLocationValue","sortByEnum","ResearchNotesSortBy","CITATION_FIRST_TO_LAST","type","parseInt","isNaN","CITATION_LAST_TO_FIRST","ordA","charCodeAt","ordAordZlen","_$opts","_arrayOfAppendices","_cloneDeep","appendices","inPaper","_uniqBy","sort","label","indexCounter","_indexCounter","labelAppend","String","fromCharCode","Math","floor","reject","_referenceFormatTypeId","HelperGetReferenceFormatId","contentToClipBoard","Format","APA7","Turabian9","Title","MLA9","CKEDITOR","instances","ckPaperBody","getData","$vm","$route","name","paperDataBody","referencesInPaper","referenceObject","displayValue","h1Elements","_forEachRight","h1Element","newElement","createElement","style","innerHTML","innerText","replaceWith","h2Elements","h2Element","h3Elements","h3Element","h4Elements","h4Element","h5Elements","h5Element","spanElements","spanElement","bodyInnerHtml","container","position","pointerEvents","opacity","body","appendChild","getSelection","removeAllRanges","range","createRange","selectNode","addRange","execCommand","removeChild","emitter","emit","textContent","errorSourceName","_updateMetaTags","updateMetaTags","returnHtml","paperId","metaDataKeys","metaDataKey","isMetaChange","updatedTagValue","encodeURIComponent","review","authorsNoteContent","ckPaperAuthorNote","authorsNote","abstractContent","ckPaperAbstract","abstract","abstractKeywords","$elmTxtPaperAbstractKeywords","keywords","PCKS_NumberTableCaptions","ckEditor","PCKS_NumberFigureCaptions","stringify","annotations","isInclude","_isEmpty","fullHtml","btoa","appendixData","citationHtmlToCheckIn","arrayOfCitationsInThisDocument","router","currentRoute","tab","Tab","EDITOR","_thisCitation","ckInstance","$citationNode","findOne","removeAttribute","setAttribute","weightForEditor","$ckEditorType","CkEditorType","ABSTRACT","BODY","APPENDIX","documentPosition","round","getDocumentPosition","y","x","enum","Error","PAPER_SAVE","src","footnotesInDocument","OUTLINE","footnotes","arrayToMakeFootnotes","_citationObject","find","findFootnote","isLive","alert","footnoteExportArray","foundCitation","footnoteObject","preContent","postContent","splitAtCitationPlaceholderArray","split","replace","citationDisplayValue","pre","post","saveMessage","isGroupCitation","citationElementInPaper","remainingCitationObject","groupUniqueId","filter","referenceIdRemoved","findCitationIndex","findIndex","citation","getParent","getHtml","setHtml","apa7","first","citationUniqueId","PaperFormatVersionID","$elToInsert","dom","setText","UseNewCitationMode","_reference","reference","referenceID","findPaperIndex","paperList","list","paper","paperID","genesisReferences","includes","paperIndex","hasActiveCitations","isDrawer","$citationNodeList","toArray","PCS_RemoveById","referenceDisplayValue","RS_GetValueOutput","displayFormatVersionId","customer","preferredFormatVersionID","PS_UpdateReferenceObject","_paperId","_versionId","versionId","ApiS_MakeCall","url","params","method","responseType","init","getFrame","$","editorName","isPaperFooterOn","numberFiguresForSingleInstance","figureCount","figuresInAbstract","figuresInInstance","figureElement","thisCaptionEl","thisCaptionText","getText","trim","$figureTitleEl","figureTitle","slice","_saveMessage","PS_BuildReferencesInPaper","isMatchFound","module","Module","PAPER_EDIT","isSaveAfter","RESEARCH","$ckPaperOutline","outlineHtml","isStealthSave","numberTablesForSingleInstance","tableCount","tablesInAbstract","tablesInInstance","tableElement","width","$tableTitleEl","tableTitle","tFootElements","remove","citationPrevious","beforeText","citationParent","getPrevious","NODE_TEXT","charAt","insertBefore","citationNext","getNext","afterText","insertAfter","EngineAfterSpecialRules","referenceUID","thisReference","referenceLibraryGenesis","_citationsForThisReference","thisReferenceModified","citationAutoInsert","RS_CalcCitationDisplayValueFromReferenceData","primaryTitle","RS_ExtractPrimaryTitleFromReferenceData","data","Engine","footnoteCounter","citationElementsInThisInstance","citationElement","citationElementParent","bracketElement","citationsWithDocumentPosition","citationsInThisOutline","citationsNodeList","index","citationDataObject","footnoteIndex","_citationsInThisOutline","citationDataChild","citationsForThisReference","ref","modeLevel","isDev","isTest","citationEngineResult","referenceTypeID","setValue","subsequent","mla9","turabian9","newUUID","uuidv1","appendixTitleDefaultContent","thisAnnotationFindIndex","annotationData","ck","editorLastFocused","$findFocusedCitation","contextMenuSelectedOnFindById","result","$findCitationNode","currentCitationNodeUid","newGroupUniqueID","createOrder","citationsWithThisGroupUid","uuidv4","PCKS_WrapCitation","startupData","dataBase64","citationDataBase64","ckPaperOutline","_isOpenAfter","isOpenAfter","_isPrint","isPrint","_isStealth","isStealth","PaperID","_paperTitle","paperTitle","_versionDateOuput","versionDateOuput","dateToLongString","dateValue","Date","showTime","paramPass","platform","contentType","responseData","platformId","Platform","CHROME_EXT","users","papers","openData","fileBlobType","fileSaveExtension","DownloadPaperContentType","COMPRESSED","PDF","HTML","WORD","WORD_SIMPLE","file","Blob","navigator","msSaveOrOpenBlob","fileURL","URL","createObjectURL","fileLink","href","target","open","iframe","display","onload","setTimeout","focus","contentWindow","print","download","click","revokeObjectURL","compressedPaperData","decompressedPaperData","LzString","PS_ParseHiddenTags","RS_UpdateAfterSync","openObject","AS_SyncData","findPaper","paperData","encryptedID","encryptedId","_isMetaDataChanges","isAutoSave","verifyLogId","_message","newLogId","PS_BuildHtml","buildHtmlResponseObj","compressedPaperContent","encryptedPaper","resetDirty","openRequest","indexedDB","onupgradeneeded","db","objectStoreNames","createObjectStore","autoIncrement","keyPath","onsuccess","txn","transaction","objectStore","request","openCursor","requestResult","item","isFresh","put","oncomplete","close","s3Link","s3VersionID","contentUrl","pageCount","catch","errorObj","ErrS_GenericAlert"],"sourceRoot":""}