1import{_ as ye}from"./DPoi4Umt.js";import{_ as ge}from"./BOoVkJ3C.js";import{u as be,w as he}from"./Dndb8PY0.js";import{aP as fe,aH as k,aS as $,aK as J,bT as _e,b0 as ve,b9 as xe,az as a,aA as n,aU as l,b6 as F,aC as y,aY as c,aX as ke,aB as o,aD as B,bU as K,aV as U,aW as D,aF as f,b7 as M,bV as we,bW as Fe,bX as Q,aE as Se,b5 as Te,bY as Ce,aZ as R,bZ as j,b_ as Ee}from"./BLR8F0yZ.js";import{a as A}from"./BWSt4F4O.js";(function(){try{var g=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V=new g.Error().stack;V&&(g._sentryDebugIds=g._sentryDebugIds||{},g._sentryDebugIds[V]="411f0a7b-72c9-4210-b96e-d0eeaba0ebd3",g._sentryDebugIdIdentifier="sentry-dbid-411f0a7b-72c9-4210-b96e-d0eeaba0ebd3")}catch{}})();const Ue=["disabled"],De={class:"h-full flex flex-col"},Ve={class:"px-8 py-4 flex justify-between items-center bg-black-50"},qe={class:"w-full p-6 md:p-4 flex justify-center overflow-y-scroll mb-6"},Ie={class:"text-lg my-4 font-medium font-['Noto Sans Georgian'] leading-normal"},ze={key:0},Me={class:"flex flex-col gap-4 mt-4"},Ae=["for"],Le={key:0,class:"required"},Ne=["id","onUpdate:modelValue","type","placeholder","onInput"],Oe={key:1},$e=["id"],Be=["for"],Re={key:0,class:"required"},je=["id","onUpdate:modelValue","value","checked","name"],Pe=["for"],Ye={key:0,class:"required"},He={key:2},Ge={class:"flex flex-col gap-4 mt-4"},Ze=["for"],We={key:0,class:"text-lg"},Xe={key:3},Je={class:"flex flex-col gap-4 mt-4"},Ke=["for"],Qe={key:0,class:"required"},et=["id","onUpdate:modelValue","type","rows","placeholder"],tt={key:0},st={key:4},at={class:"flex flex-col gap-4 mt-4"},ot=["for"],nt={key:0,class:"required"},lt=["id","accept","placeholder","onChange"],it={key:0},rt={key:1},dt={key:5},ct={class:"flex flex-col gap-4 mt-4"},ut={class:"flex"},pt={class:"inline-block mr-2"},mt=["innerHTML"],yt={key:1,class:"inline"},gt={key:2,class:"required"},bt=["id","checked","onChange"],ht={key:6},ft={class:"flex flex-col gap-4 mt-4"},_t=["for"],vt={key:0,class:"required"},xt=["id","onUpdate:modelValue","placeholder"],kt={key:7},wt={class:"flex flex-col gap-4 mt-4"},Ft=["innerHTML"],St={key:0,class:"text-red"},Tt={class:"text-white text-base font-medium font-['Noto Sans Georgian'] leading-normal"},Ct={key:0},Et={key:1},Ut={key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Dt={class:"bg-white p-5 rounded-lg text-center shadow-lg"},Vt={class:"mt-2 text-cyan-800 font-bold"},qt={class:"mt-2 text-cyan-800 font-semibold"},It={key:0,class:"mt-4 max-w-xs text-cyan-800 text-sm"},Ot=fe({__name:"form",props:{item:{type:Object,required:!0},deadline:{type:String,default:null},label:{type:String,default:""},buttonClass:{type:String,default:""},confirmationEmail:{type:Boolean,default:!1},hideAllowedFileTypes:{type:Boolean,default:!1}},emits:["close","open"],setup(g,{emit:V}){const b=g,L=k(!1),u=k(null),C=k(null),q=k(!1),_=k(),ee=(s,t)=>{const i=t.target;u.value[s]=i.checked?"true":""},N=$(()=>Y.loading),te=k({}),se=()=>{const s={};if(Ce(b.item)){const t=R(b.item);for(const i of t.pages)for(const r of i.fieldsets)for(const d of r.columns)for(const p of d.fields)switch(p.type.name){case"Short answer":case"Long answer":case"Data Consent":s[p.alias]="";break;case"Single choice":s[p.alias]=p.preValues[0].value;break;case"File upload":s[p.alias]=[];break}return s}},ae=s=>{var t,i;if(((i=(t=s.fileUploadOptions)==null?void 0:t.allowedUploadExtensions)==null?void 0:i.length)>0)return s.fileUploadOptions.allowedUploadExtensions.map(r=>`.${r}`).join(",")},P=$(()=>{if(b.deadline){const s=new Date(b.deadline),t=new Date;return t.getFullYear()>s.getFullYear()||t.getFullYear()===s.getFullYear()&&(t.getMonth()>s.getMonth()||t.getMonth()===s.getMonth()&&t.getDate()>s.getDate())}return!1}),oe=()=>{var r;const s={};let t=!0;const i=b.item.pages.flatMap(d=>d.fieldsets.flatMap(p=>p.columns.flatMap(h=>h.fields.filter(x=>x.required))));return i.forEach(d=>{(!u.value[d.alias]||Array.isArray(u.value[d.alias])&&u.value[d.alias].length===0)&&(s[d.alias]="This field is required",t=!1)}),v.value=s,{isValid:t,firstErrorField:(r=i.find(d=>s[d.alias]))==null?void 0:r.alias}},ne=$(()=>Object.keys(u.value).filter(i=>b.item.pages.some(r=>r.fieldsets.some(d=>d.columns.some(p=>p.fields.some(h=>h.required&&h.alias===i))))).some(i=>Array.isArray(u.value[i])?u.value[i].length===0:!u.value[i])||N.value);J(()=>
1b.item,s=>{u.value=se()},{deep:!0,immediate:!0});const w=_e(),Y=be(),le=async s=>{s.preventDefault();const{isValid:t,firstErrorField:i}=oe();if(t){if(!u.value||N.value)return;L.value=!0,C.value=null;try{const r=R(u.value);A({category:"form",message:"Submitting form",level:"info"});const d=await Y.submit(b.item.id,r);d.error.value?(w.add({type:"error",text:"Form Submission Failed",zIndex:1e3,duration:1e5,attach:_.value}),C.value=d.error.value,j(new Error("Form Submission Failed"),{extra:{formId:b.item.id,error:d.error.value,data:JSON.stringify(r)}})):(w.add({type:"success",text:"Form Submitted",zIndex:1e3,duration:1e5,attach:_.value}),O())}catch(r){w.add({type:"error",text:"Form Submission Failed",zIndex:1e3,duration:1e5,attach:_.value}),C.value=r.message,j(r,{extra:{formId:b.item.id,formData:R(u.value)}})}finally{L.value=!1}}else{if(S.value=!0,setTimeout(()=>{S.value=!1},820),i){await Ee();const r=document.getElementById(i);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.focus())}w.add({type:"error",text:"Please fill in all required fields",duration:5e3})}},ie=async(s,t,i)=>{var z,e,E;const d=s.target.files;if(!d||d.length===0){A({category:"file",message:"No file selected",level:"warning",data:{fieldAlias:t}});return}const p=d[0],h=((z=i.fileUploadOptions)==null?void 0:z.maxFileSize)||10*1024*1024;if(p.size>h){w.add({type:"error",text:`File size exceeds the maximum limit of ${h/1024/1024}MB`,duration:5e3}),A({category:"file",message:"File size exceeded",level:"warning",data:{fieldAlias:t,fileSize:p.size,maxSize:h}});return}const x=((e=i.fileUploadOptions)==null?void 0:e.allowedUploadExtensions)||[],I=(E=p.name.split(".").pop())==null?void 0:E.toLowerCase();if(x.length>0&&!x.includes(I)){w.add({type:"error",text:`File type not allowed. Allowed types: ${x.join(", ")}`,duration:5e3}),A({category:"file",message:"Invalid file type",level:"warning",data:{fieldAlias:t,fileType:I,allowedTypes:x}});return}try{const T=await re(p);u.value[t]=[{fileContents:T,fileName:p.name,fileSize:p.size,fileType:p.type}]}catch(T){w.add({type:"error",text:"Error reading file. Please try again.",duration:5e3}),j(T,{extra:{fieldAlias:t,fileName:p.name}})}},S=k(!1),re=s=>new Promise((t,i)=>{const r=new FileReader;r.onload=()=>
1t(r.result),r.onerror=i,r.readAsDataURL(s)}),de=V;ve();const ce=xe();J(()=>q.value,s=>{var t;s&&((t=_==null?void 0:_.value)==null||t.showModal())});const v=k({}),ue=s=>{v.value[s]&&(v.value[s]=null)},O=()=>{var s;q.value=!1,de("close"),(s=_==null?void 0:_.value)==null||s.close(),ce.replace({query:{open:null}})};return(s,t)=>{const i=ye,r=ge;return a(),n("div",null,[l(q)?c("",!0):(a(),n("button",{key:0,id:"open-form-btn",disabled:l(P),class:F([l(P)?"opacity-50 cursor-not-allowed":"",g.buttonClass||"h-10 !px-11 py-2 bg-cyan-800 text-white rounded justify-center items-center gap-2.5 inline-flex"]),onClick:t[0]||(t[0]=d=>q.value=!0)},y(g.label||s.$t("Open Form")),11,Ue)),(a(),ke(Te,{to:"body"},[o("dialog",{id:"dialog-form",ref_key:"dialog",ref:_,class:"w-[95%] md:w-[80%] h-[100vh] fixed left-0 right-0 top-0 bottom-0 rounded-lg overflow-hidden",onClose:t[1]||(t[1]=d=>O())},[o("div",De,[o("div",Ve,[B(i,{alt:"NewVision University Logo",src:"/images/university-logo.svg",class:"w-[84px] xl:w-[120px]"}),o("button",{class:"w-6 h-6 shrink-0",onClick:K(O,["stop"])},[B(i,{width:"24",height:"24",src:"icons/x-black.svg",alt:"Close Form Icon"})])]),o("div",qe,[l(u)?(a(),n("form",{key:0,class:"",onSubmit:K(le,["prevent"])},[(a(!0),n(U,null,D(g.item.pages,(d,p)=>(a(),n("div",{key:`page-${p}`},[o("div",null,[(a(!0),n(U,null,D(d.fieldsets,(h,x)=>(a(),n("div",{key:`fieldset-${x}`},[o("h2",Ie,y(h.caption),1),(a(!0),n(U,null,D(h.columns,(I,z)=>(a(),n("div",{key:`fieldColumns-${z}`},[(a(!0),n(U,null,D(I.fields,e=>{var E,T,H,G,Z,W,X;return a(),n("div",{key:e.id},[e.type.name==="Short answer"?(a(),n("div",ze,[o("div",Me,[o("label",{class:"block",for:e.id},[f(y(e.caption)+" ",1),e.required?(a(),n("span",Le,"*")):c("",!0)],8,Ae),M(o("input",{id:e.alias,ref_for:!0,ref:m=>{m&&(l(te)[e.alias]=m)},"onUpdate:modelValue":m=>l(u)[e.alias]=m,type:e.settings.fieldType?e.settings.fieldType:"text",class:F(["border block pl-3 py-2 transition-all duration-300",{shake:l(S)&&l(v)[e.alias]}]),maxlength:"255",placeholder:e.placeholder,onInput:m=>ue(e.id)},null,42,Ne),[[we,l(u)[e.alias]]])])])):c("",!0),e.type.name==="Single choice"?(a(),n("div",Oe,[o("div",{id:e.alias,class:"flex flex-col gap-4 mt-4"},[o("label",{class:"block",for:e.id},[f(y(e.caption)+" ",1),e.required?(a(),n("span",Re,"*")):c("",!0)],8,Be),(a(!0),n(U,null,D(e.preValues,(m,pe)=>(a(),n("div",{key:m.value,class:"flex"},[M(o("input",{id:m.value,"onUpdate:modelValue":me=>l(u)[e.alias]=me,type:"radio",value:m.value,checked:pe===0,class:F(["border block border-gray-100 bg-gray-50 pl-3 py-2 transition-all duration-300",l(v)[e.alias]?"border-red-500 bg-red-50":"border-gray-100 bg-gray-50"]),name:e.id},null,10,je),[[Fe,l(u)[e.alias]]]),o("label",{for:m.value,class:"inline-block ml-2"},[f(y(m.caption)+" ",1),e.required?(a(),n("span",Ye,"*")):c("",!0)],8,Pe)]))),128))],8,$e)])):c("",!0),e.type.name==="Title and description"?(a(),n("div",He,[o("div",Ge,[o("h2",{class:"text-xl my-4 font-medium font-['Noto Sans Georgian'] leading-normal",for:e.id},y((E=e.settings)==null?void 0:E.caption),9,Ze),(T=e.settings)!=null&&T.bodyText?(a(),n("p",We,y((H=e.settings)==null?void 0:H.bodyText),1)):c("",!0)])])):c("",!0),e.type.name==="Long answer"?(a(),n("div",Xe,[o("div",Je,[o("label",{class:"block",for:e.id},[f(y(e.caption)+" ",1),e.required?(a(),n("span",Qe,"*")):c("",!0)],8,Ke),M(o("textarea",{id:e.alias,"onUpdate:modelValue":m=>l(u)[e.alias]=m,type:e.settings.fieldType?e.settings.fieldType:"text",rows:e.numberOfRows?e.numberOfRows:4,class:F([{shake:l(S)&&l(v)[e.alias]},"border block border-gray-100 bg-gray-50 pl-3 py-2"]),placeholder:(G=e.settings)==null?void 0:G.placeholder}," ",10,et),[[Q,l(u)[e.alias]]]),e.helpText?(a(),n("small",tt,y(e.helpText),1)):c("",!0)])])):c("",!0),e.type.name==="File upload"?(a(),n("div",st,[o("div",at,[o("label",{class:"block",for:e.id},[f(y(e.caption)+" ",1),e.required?(a(),n("span",nt,"*")):c("",!0)],8,ot),o("input",{id:e.alias,type:"file",class:F([{shake:l(S)&&l(v)[e.alias]},"border block border-gray-100 bg-gray-50 pl-3 py-2"]),accept:ae(e),placeholder:e.placeholder,onChange:m=>ie(m,e.alias,e)},null,42,lt),(Z=e.fileUploadOptions)!=null&&Z.maxFileSize?(a(),n("small",it," Max file size: "+y(e.fileUploadOptions.maxFileSize/1024/1024)+"MB ",1)):c("",!0),!g.hideAllowedFileTypes&&((X=(W=e.fileUploadOptions)==null?void 0:W.allowedUploadExtensions)!=null&&X.length)?(a(),n("small",rt,y(s.$t("Allowed file types:"))+" "+y(e.fileUploadOptions.allowedUploadExtensions.join(", ")),1)):c("",!0)])])):c("",!0),e.type.name==="Data Consent"?(a(),n("div",dt,[o("div",ct,[o("div",ut,[o("label",pt,[e.settings.acceptCopy?(a(),n("div",{key:0,class:"consent-markup inline",innerHTML:("withNewTabLinks"in s?s.withNewTabLinks:l(he))(e.settings.acceptCopy)},null,8,mt)):(a(),n("div",yt,[t[3]||(t[3]=f(" By submitting this application, I/we acknowledge that I/we have read and understood the ")),B(r,{target:"_blank",to:"page/participation-consent"},{default:Se(()=>t[2]||(t[2]=[o("b",{class:"underline"},"terms and conditions",-1)])),_:1}),t[4]||(t[4]=f(" outlined above and agree to participate in the competition in accordance with these terms. "))])),e.required?(a(),n("span",gt,"*")):c("",!0)]),o("input",{id:e.alias,type:"checkbox",checked:l(u)[e.alias]==="true",class:"border block border-gray-100 bg-gray-50 pl-3 py-2",onCh
1ange:m=>ee(e.alias,m)},null,40,bt)])])])):c("",!0),e.type.name==="Date"?(a(),n("div",ht,[o("div",ft,[o("label",{class:"block",for:e.id},[f(y(e.caption)+" ",1),e.required?(a(),n("span",vt,"*")):c("",!0)],8,_t),M(o("input",{id:e.alias,"onUpdate:modelValue":m=>l(u)[e.alias]=m,type:"date",placeholder:e.placeholder,class:F([{shake:l(S)&&l(v)[e.alias]},"border block border-gray-100 bg-gray-50 pl-3 py-2"])},null,10,xt),[[Q,l(u)[e.alias]]])])])):c("",!0),e.type.name==="Rich text"?(a(),n("div",kt,[o("div",wt,[o("div",{class:"blog-markup",innerHTML:e.settings.html},null,8,Ft)])])):c("",!0)])}),128))]))),128))]))),128))])]))),128)),l(C)?(a(),n("div",St,[t[5]||(t[5]=f(" There was a problem with your submission ")),t[6]||(t[6]=o("br",null,null,-1)),t[7]||(t[7]=f(" Please check the form and try again ")),t[8]||(t[8]=o("br",null,null,-1)),f(" "+y(l(C)),1)])):c("",!0),o("button",{type:"submit",class:F([{"opacity-50 cursor-not-allowed":l(ne)},"w-32 self-end ml-auto mt-4 h-10 px-11 py-2 bg-cyan-800 rounded justify-center items-center gap-2.5 inline-flex"])},[o("div",Tt,[l(N)?(a(),n("span",Ct,"Loading...")):(a(),n("span",Et,"Submit"))])],2)],32)):c("",!0)])]),l(L)?(a(),n("div",Ut,[o("div",Dt,[t[9]||(t[9]=o("div",{class:"animate-spin rounded-full h-10 w-10 border-t-2 border-b-2 border-cyan-800 mx-auto"},null,-1)),o("p",Vt,y(s.$t("formSubmitting")),1),o("p",qt,y(s.$t("formDoNotClose")),1),g.confirmationEmail?(a(),n("p",It,y(s.$t("formConfirmationEmail")),1)):c("",!0)])])):c("",!0)],544)]))])}}});export{Ot as _};
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.