1function nkproGetCohortInfo(){const now=new Date();const month=now.getMonth()+1;const year=now.getFullYear();const quarter=Math.ceil(month/3);const closeMonths={1:2,2:5,3:8,4:11};const lastDay=new Date(year,closeMonths[quarter]+1,0).getDate();const closeDate=new Date(year,closeMonths[quarter],lastDay);const formatted=closeDate.toLocaleDateString('en-US',{month:'long',day:'numeric',year:'numeric',});return{label:`Cohort ${quarter} · ${year}`,closes:formatted,}} 2document.addEventListener('alpine:init',()=>{if(typeof Alpine==='undefined'){return} 3Alpine.data('nkproMembersOnly',()=>({state:'logged_out_signin',initialState:'logged_out_signin',userType:'',history:[],proForm:{fullName:'',email:'',organisation:'',phone:'',useCase:'',message:''},proFullNameLocked:!1,proEmailLocked:!1,proInquiryRef:'',proSubmitError:'',proSubmitting:!1,fellowshipSubmitError:'',fellowshipSubmitting:!1,fellowshipForm:{applicantType:'',fullName:'',institutionalEmail:'',institution:'',country:'',phone:'',enrollmentProof:null,terms:{noPaidDeliverables:!1,eligibilityCitation:!1,annualReverification:!1,accurateInfo:!1,},cvFile:null,nonprofitRegFile:null,topics:[],statement:'',workLink:'',},fellowshipUploadErrors:{enrollment:'',cv:'',nonprofit:'',},fellowshipCohortLabel:nkproGetCohortInfo().label,fellowshipClosesLabel:nkproGetCohortInfo().closes,fellowshipStepLabels:['Eligibility','Documents','Statement','Review'],fellowshipStatementMinWords:150,fellowshipStatementMaxWords:1000,proFlowTitle:'Request professional access',fellowshipFlowTitle:'Research fellowship',get showEntryCards(){return this.state==='logged_out_signin'||this.state==='logged_in_upgrade'},get fellowshipStepNumber(){const stepMap={f1_eligibility:1,f2_documents:2,f3_statement:3,f4_review:4};return stepMap[this.state]||0},get wordCount(){return this.fellowshipForm.statement.trim().split(/\s+/).filter((w)=>w.length>0).length},get fellowshipTermsComplete(){const t=this.fellowshipForm.terms;return t.noPaidDeliverables&&t.eligibilityCitation&&t.annualReverification&&t.accurateInfo},get fellowshipF2Ready(){return this.fellowshipTermsComplete},get fellowshipApplicantLabel(){const labels={graduate:'Graduate student',nonprofit:'Nonprofit researcher'};return labels[this.fellowshipForm.applicantType]||''},get fellowshipTopicsDisplay(){const labels={military_weapons:'Military / weapons',leadership_politics:'Leadership / politics',economy_sanctions:'Economy / sanctions',inter_korean:'Inter-Korean',human_rights:'Human rights',foreign_policy:'Foreign policy',cyber_tech:'Cyber / tech',society_culture:'Society / culture',other:'Other',};return this.fellowshipForm.topics.map((t)=>labels[t]||t).join(', ')||'None selected'},get fellowshipF1Valid(){const f=this.fellowshipForm;return!!(f.applicantType&&f.fullName.trim()&&f.institutionalEmail.trim()&&f.institution.trim()&&f.country.trim()&&f.phone.trim()&&f.enrollmentProof)},get fellowshipF3Valid(){return(this.fellowshipForm.topics.length>0&&this.wordCount>=this.fellowshipStatementMinWords&&this.wordCount<=this.fellowshipStatementMaxWords)},get fellowshipTermsSummary(){return this.fellowshipTermsComplete?'Non-commercial use, re-verification, renewal review, accurate information':'â'},init(){const d=this.$el.dataset;const popupState=(d.nkproPopupState||'').trim();const isLoggedIn=d.nkproLoggedIn==='true';const userName=d.nkproUserName||'';const userEmail=d.nkproUserEmail||'';this.userType=d.nkproUserType||'';if(popupState&&!popupState.includes('{')){this.state=popupState}else{this.state=isLoggedIn?'logged_in_upgrade':'logged_out_signin'} 4this.initialState=this.state;this.proForm.fullName=userName;this.proForm.email=userEmail;this.proFullNameLocked=userName.trim()!=='';this.proEmailLocked=userEmail.trim()!=='';const validStates=['logged_out_signin','logged_in_upgrade','pro_form','pro_confirm','f1_eligibility','f2_documents','f3_statement','f4_review','f_confirm'];if(!validStates.includes(this.state)){this.state=this.userType?'logged_in_upgrade':'logged_out_signin';this.initialState=this.state}},goToState(newState){this.history.push(this.state);this.state=newState;if(newState==='f4_review'){this.$nextTick(()=>
4{const root=document.getElementById('nkpro-members-only');if(root&&typeof window.nkPaywallInitPopupTurnstile==='function'){const form=root.querySelector('#fellowship_submit_form');if(form){form.dataset.nkPaywallTurnstileBound=''} 5window.nkPaywallInitPopupTurnstile(root)}})}},getTurnstileResponse(form){if(!form){return''} 6const field=form.querySelector('[name=cf-turnstile-response]');return field?field.value:''},resetFormTurnstile(form){if(typeof window.nkPaywallResetFormTurnstile==='function'){window.nkPaywallResetFormTurnstile(form)}},handleTurnstileUnavailable(event){const form=event.target;const message=event.detail&&event.detail.message?event.detail.message:'Security check is still loading. Please wait a moment and try again.';if(form&&form.id==='pro_inquiry_form'){this.proSubmitError=message}else if(form&&form.id==='fellowship_submit_form'){this.fellowshipSubmitError=message}},goBack(){if(this.history.length>0){this.state=this.history.pop()}},closeFlow(){window.dispatchEvent(new CustomEvent('nk-paywall-close'))},async submitProInquiry(form){if(this.proSubmitting){return} 7this.proSubmitting=!0;this.proSubmitError='';const turnstileToken=this.getTurnstileResponse(form);this.proInquiryRef='NKPRO-'+Math.random().toString(36).substr(2,6).toUpperCase();const body=new FormData();body.append('action','nk_paywall_submit_pro_inquiry');body.append('reference',this.proInquiryRef);body.append('fullName',this.proForm.fullName);body.append('email',this.proForm.email);body.append('organisation',this.proForm.organisation);body.append('phone',this.proForm.phone);body.append('useCase',this.proForm.useCase);body.append('message',this.proForm.message);if(turnstileToken){body.append('cf-turnstile-response',turnstileToken)} 8const ajaxUrl=typeof nkPaywall!=='undefined'?nkPaywall.ajaxUrl:'';try{const response=await fetch(ajaxUrl,{method:'POST',body});const data=await response.json();if(data&&data.success){this.goToState('pro_confirm');return} 9this.proSubmitError=(data&&data.data&&data.data.message)?data.data.message:'Unable to submit your inquiry right now. Please try again.'}catch(e){this.proSubmitError='Unable to submit your inquiry right now. Please try again.'}finally{this.proSubmitting=!1;this.resetFormTurnstile(form)}},toggleTopic(topic){const index=this.fellowshipForm.topics.indexOf(topic);if(index>-1){this.fellowshipForm.topics.splice(index,1)}else{this.fellowshipForm.topics.push(topic)} 10this.$nextTick(()=>{this.validateFellowshipTopics(this.$refs.fellowshipTopicsRequired)})},truncateFellowshipStatement(text){const trimmed=(text||'').trim();if(!trimmed){return''} 11const words=trimmed.split(/\s+/).filter((w)=>w.length>0);if(words.length<=this.fellowshipStatementMaxWords){return text} 12return words.slice(0,this.fellowshipStatementMaxWords).join(' ')},clampFellowshipStatement(){const limited=this.truncateFellowshipStatement(this.fellowshipForm.statement);if(limited!==this.fellowshipForm.statement){this.fellowshipForm.statement=limited}},validateFellowshipStatement(field){if(!field){return} 13if(!this.fellowshipForm.statement.trim()){field.setCustomValidity('');return} 14if(this.wordCount>this.fellowshipStatementMaxWords){field.setCustomValidity('Please limit your statement to '+this.fellowshipStatementMaxWords+' words.');return} 15if(this.wordCount<this.fellowshipStatementMinWords){field.setCustomValidity('Please enter at least '+this.fellowshipStatementMinWords+' words.');return} 16field.setCustomValidity('')},validateFellowshipTopics(field){if(!field){return} 17if(this.fellowshipForm.topics.length<1){field.setCustomValidity('Please select at least one primary research focus.');return} 18field.setCustomValidity('')},rejectFellowshipFile(kind,message,event){this.clearFellowshipFile(kind,!0);this.fellowshipUploadErrors[kind]=message;if(event&&event.target){event.target.value=''}},setFellowshipFile(kind,event){const file=event.target.files&&event.target.files[0];if(!file){return} 19const validation=this.validateFellowshipFile(kind,file);if(!validation.valid){this.rejectFellowshipFile(kind,validation.message,event);return} 20this.fellowshipUploadErrors[kind]='';if(kind==='enrollment'){this.fellowshipForm.enrollmentProof=file}else if(kind==='cv'){this.fellowshipForm.cvFile=file}else if(kind==='nonprofit'){this.fellowshipForm.nonprofitRegFile=file}},clearFellowshipFile(kind,keepError=!1){if(kind==='enrollment'){this.fellowshipForm.enrollmentProof=null;if(this.$refs.enrollmentInput){this.$refs.enrollmentInput.value=''}}else if(kind==='cv'){this.fellowshipForm.cvFile=null;if(this.$refs.cvInput){this.$refs.cvInput.value=''}}else if(kind==='nonprofit'){this.fellowshipForm.nonprofitRegFile=null;if(this.$refs.nonprofitInput){this.$refs.nonprofitInput.value=''}} 21if(!keepError){this.fellowshipUploadErrors[kind]=''}},fellowshipDrop(kind,event){event.preventDefault();const fileList=event.dataTransfer&&event.dataTransfer.files;const file=fileList&&fileList[0];if(!file){return} 22const validation=this.validateFellowshipFile(kind,file);if(!validation.valid){this.rejectFellowshipFile(kind,validation.message);return} 23this.fellowshipUploadErrors[kind]='';if(kind==='enrollment'){this.fellowshipForm.enrollmentProof=file}else if(kind==='cv'){this.fellowshipForm.cvFile=file}else if(kind==='nonprofit'){this.fellowshipForm.nonprofitRegFile=file}},getFellowshipFileRule(kind){const maxBytes=5*1024*1024;const rules={enrollment:{extensions:['pdf'],mimeTypes:['application/pdf'],label:'PDF',maxBytes,},cv:{extensions:['pdf'],mimeTypes:['application/pdf'],label:'PDF',maxBytes,},nonprofit:{extensions:['pdf'],mimeTypes:['application/pdf'],label:'PDF',maxBytes,},};return rules[kind]||null},validateFellowshipFile(kind,file){const rule=this.getFellowshipFileRule(kind);if(!rule||!file){return{valid:!1,message:'Please upload a valid file.'}} 24const fileName=file.name?file.name.toLowerCase():'';const extension=fileName.includes('.')?fileName.split('.').pop():'';const extensionAllowed=extension&&rule.extensions.includes(extension);const mimeAllowed=!file.type||rule.mimeTypes.includes(file.type);if(!extensionAllowed||!mimeAllowed){return{valid:!1,message:'Invalid file type. Upload '+rule.label+' only.'}} 25if(file.size>rule.maxBytes){return{valid:!1,message:'File must be 5MB or smaller.'}} 26return{valid:!0,message:''}},formatProUseCase(){if(this.proForm.useCase==='Other'&&this.proForm.message.trim()){const m=this.proForm.message.trim();return'Other â '+m.slice(0,72)+(m.length>72?'â¦':'')} 27return this.proForm.useCase},async submitFellowship(form){if(this.fellowshipSubmitting){return} 28this.fellowshipSubmitting=!0;this.fellowshipSubmitError='';const turnstileToken=this.getTurnstileResponse(form);const formData=new FormData();const f=this.fellowshipForm;formData.append('action','nk_paywall_submit_fellowship');formData.append('applicantType',f.applicantType);formData.append('fullName',f.fullName);formData.append('institutionalEmail',f.institutionalEmail);formData.append('institution',f.institution);formData.append('country',f.country);formData.append('phone',f.phone);formData.append('topics',JSON.stringify(f.topics));
28formData.append('statement',this.truncateFellowshipStatement(f.statement));formData.append('workLink',f.workLink);formData.append('terms',JSON.stringify(f.terms));formData.append('cohortLabel',this.fellowshipCohortLabel);formData.append('closesLabel',this.fellowshipClosesLabel);if(turnstileToken){formData.append('cf-turnstile-response',turnstileToken)} 29if(f.enrollmentProof){formData.append('enrollment_proof',f.enrollmentProof)} 30if(f.cvFile){formData.append('cv',f.cvFile)} 31if(f.nonprofitRegFile){formData.append('nonprofit_registration',f.nonprofitRegFile)} 32const ajaxUrl=typeof nkPaywall!=='undefined'?nkPaywall.ajaxUrl:'';try{const response=await fetch(ajaxUrl,{method:'POST',body:formData});const data=await response.json();if(data&&data.success){this.goToState('f_confirm');return} 33this.fellowshipSubmitError=(data&&data.data&&data.data.message)?data.data.message:'Unable to submit your application right now. Please try again.'}catch(e){this.fellowshipSubmitError='Unable to submit your application right now. Please try again.'}finally{this.fellowshipSubmitting=!1;this.resetFormTurnstile(form)}},fellowshipApplicantSummary(){const f=this.fellowshipForm;return f.fullName+' · '+f.institution}}))})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.