1import{n as i,d as m,E as p,c as l,a as y,ag as f,t as _,f as S,ev as h,aY as I}from"./index-W6DN-I6u.js";import{e as g}from"./SurveyFieldsViewer-nN-syHeD.js";import{s as x,a as b}from"./survey-instances-BgUO5Wub.js";import"./vuedraggable.umd-DG91PSvN.js";import"./BaseEmpty-CWs5JZK-.js";import"./VChip-CU1Nryyb.js";import"./VTextField-C_kgLppf.js";import"./VTextarea-JiOTGE1e.js";import"./VSlider-Q9Lx-Ep9.js";import"./VDatePicker-DEeQxCTT.js";import"./geo-DfLetQdV.js";import"./pillars-C23X7kce.js";import"./BasePickerUser-C3oePzkv.js";import"./VAutocomplete-CSIoeBua.js";import"./VSelect-C2DBKR82.js";import"./VForm-BlDBFi5G.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"20260924.1"};var e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="57551939-c9d7-447e-b3ec-0a6a8b17d1a0",s._sentryDebugIdIdentifier="sentry-dbid-57551939-c9d7-447e-b3ec-0a6a8b17d1a0")}catch{}})();const w={name:"SurveyViewerStepperWelcome",props:{survey:{type:Object,default:()=>null},isLoading:{type:Boolean,default:!1}}};var V=function(){var n,r;var e=this,t=e._self._c;return t("div",{staticClass:"h-full flex items-center justify-center px-4 py-16 bg-gray-50"},[t("div",{staticClass:"w-full max-w-md p-4 flex flex-col items-center space-y-8 bg-white rounded-md shadow-lg"},[t("div",{staticClass:"flex flex-col items-center space-y-6 text-center"},[t(m,[e.survey?t(p,{staticClass:"mx-auto",attrs:{src:(n=e.survey)==null?void 0:n.logoUrl,"max-width":"200","max-height":"200",contain:""}}):e._e()],1),e._m(0),t(m,[e.survey?t("p",{staticClass:"text-base text-gray-700 max-w-sm mx-auto leading-relaxed"},[e._v(" Click the button to complete the "),t("span",{staticClass:"font-semibold text-gray-900"},[e._v(e._s((r=e.survey)==null?void 0:r.name))])]):e._e()])],1),t(l,{staticClass:"w-full text-base font-medium",attrs:{color:"primary",large:"",loading:e.isLoading},on:{click:function(a){return e.$emit("next")}}},[e._v(" Start Survey ")])],1)])},C=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"space-y-2"},[e("h1",{staticClass:"text-2xl font-bold text-gray-900"},[s._v("Survey")])])}],L=i(w,V,C,!1,null,null);const $=L.exports,E={name:"SurveyViewerStepperFormHeader",props:{survey:{type:Object,required:!0}}};var P=function(){var e=this,t=e._self._c;return t("div",{staticClass:"w-full p-4 sm:p-8 gap-8 flex flex-initial flex-col bg-gray-200 rounded-none border-b border-gray-300"},[t(p,{attrs:{src:e.survey.logoUrl,"max-width":"256","max-height":"256",contain:""}}),t("h1",{staticClass:"text-2xl sm:text-4xl font-bold"},[e._v(e._s(e.survey.name))]),t("span",{domProps:{innerHTML:e._s(e.survey.prologueHtml)}})],1)},F=[],T=i(E,P,F,!1,null,null);const O=T.exports,R={name:"SurveyViewerStepper",components:{SurveyFieldsViewer:g,SurveyViewerStepperFormHeader:O},props:{survey:{type:Object,required:!0},cloneSourceSurveyInstanceId:{type:Number,default:null}},data:()=>({isLoading:!1,surveyItems:[]}),computed:{...y("user",["user"]),answers(){return this.surveyItems.map(s=>({surveyItemId:s.id,customValues:s.customValues||void 0,surveyValueListItemIdList:s.surveyValueListItemIdList||void 0}))}},created(){this.surveyItems=structuredClone(this.survey.surveyItems),this.prePopulateFromClonedTalentRequest()},methods:{async prePopulateFromClonedTalentRequest(){if(!this.cloneSourceSurveyInstanceId)return;const s=await this.fetchPrePopulatedAnswers();!s||s.length===0||this.applyPrePopulatedAnswers(s)},async fetchPrePopulatedAnswers(){const s=await b(this.cloneSourceSurveyInstanceId);return this.normalizeSourceInstanceAnswers(s==null?void 0:s.content)},normalizeSourceInstanceAnswers(s){return((s==null?void 0:s.answers)||[]).map(t=>{var n,r,a,o,c,d;return{surveyItemId:((r=(n=t==null?void 0:t.surveyItemInstance)==null?void 0:n.surveyItem)==null?void 0:r.id)||null,surveyItemName:((o=(a=t==null?void 0:t.surveyItemInstance)==null?void 0:a.surveyItem)==null?void 0:o.name)||null,surveyItemSlug:((d=(c=t==null?void 0:t.surveyItemInstance)==null?void 0:c.surveyItem)==null?void 0:d.slug)||null,customValues:((t==null?void 0:t.answerSurveyCustomValues)||[]).map(u=>u.value),surveyValueListItemIdList:((t==null?void 0:t.answerSurveyValueListItems)||[]).map(u=>u.id)}})},applyPrePopulatedAnswers(s=[]){const e=new Map(s.filter(r=>Number(r==null?void 0:r.surveyItemId)).map(r=>[Number(r.surveyItemId),r])),t=new Map(s.filter(r=>r==null?void 0:r.surveyItemName).map(r=>[String(r.surveyItemName).toLowerCase(),r])),n=new Map(s.filter(r=>r==null?void 0:r.surveyItemSlug).map(r=>[String(r.surveyItemSlug).toLowerCase(),r]));this.surveyItems=this.surveyItems.map(r=>{const a=e.get(r.id)||t.get(String(r.name||"").toLowerCase())||n.get(String(r.slug||"").toLowerCase());return a?{...r,customValues:a.customValues||r.customValues,surveyValueListItemIdList:a.surveyValueListItemIdList||r.surveyValueListItemIdList}:r})},async handleSubmit(){if(!this.defineIsValid())return;const e=this.definePayload();this.isLoading=!0;const t=await x(e);this.isLoading=!1;const{isSuccess:n}=t;n&&this.$emit("next")},defineIsValid(){const s=this.$refs["survey-fields-viewer"].$refs.form.validate();return s||_({title:"Please fill in all required fields"}),s},definePayload(){return{surveyId:this.survey.id,userId:this.user.id,answers:this.answers}},updateItem({field:s,toUpdate:e}){this.surveyItems=this.surveyItems.map(t=>
1t.id===s.id?{...t,...e}:t)}}};var N=function(){var e=this,t=e._self._c;return t(f,{staticClass:"w-full flex flex-col flex-initial overflow-hidden rounded shadow-xl !bg-gray-50",attrs:{outlined:""}},[t("SurveyViewerStepperFormHeader",{attrs:{survey:e.survey}}),t("div",{staticClass:"p-4 sm:p-8 gap-4 flex flex-col flex-initial"},[t("SurveyFieldsViewer",{ref:"survey-fields-viewer",attrs:{list:e.surveyItems},on:{"update-item":e.updateItem}}),t("span",{domProps:{innerHTML:e._s(e.survey.afterwordHtml)}}),t(l,{staticClass:"w-full mt-8",attrs:{color:"primary",large:"",loading:e.isLoading},on:{click:e.handleSubmit}},[e._v("Save & Finish")])],1)],1)},M=[],q=i(R,N,M,!1,null,null);const A=q.exports,k={name:"SurveyViewerStepperWelcome",props:{survey:{type:Object,default:()=>null},isLoading:{type:Boolean,default:!1}},mounted(){window.scrollTo(0,0)}};var B=function(){var e=this,t=e._self._c;return t("div",{staticClass:"h-full flex items-center justify-center px-4 py-16 bg-gray-50"},[t("div",{staticClass:"w-full max-w-md p-4 flex flex-col items-center space-y-6 bg-white rounded-md shadow-lg"},[t("div",{staticClass:"flex flex-col items-center space-y-4 text-center"},[t(S,{staticClass:"!text-3xl",attrs:{color:"black"}},[e._v("mdi-human-greeting-variant")]),t("h1",{staticClass:"text-2xl font-bold text-gray-900"},[e._v("Thank you!")]),t("p",{staticClass:"text-base text-gray-700",domProps:{innerHTML:e._s(e.survey.completionHtml)}}),t("span",{staticClass:"text-base text-gray-700"},[e._v("You can safely close this window now.")])],1),t(l,{staticClass:"w-full",attrs:{color:"primary",large:"",loading:e.isLoading},on:{click:function(n){return e.$emit("finish")}}},[e._v(" Finish & Exit ")])],1)])},H=[],j=i(k,B,H,!1,null,null);const D=j.exports,v={WELCOME:"welcome",FORM:"form",GOODBYE:"goodbye"},G={name:"SurveyViewerStepper",components:{SurveyViewerStepperWelcome:$,SurveyViewerStepperForm:A,SurveyViewerStepperGoodbye:D},props:{survey:{type:Object,default:()=>null},isLoading:{type:Boolean,default:!1},cloneSourceSurveyInstanceId:{type:Number,default:null}},data:()=>({currentStep:v.WELCOME}),created(){this.STEPS=v},methods:{setCurrentStep(s){this.currentStep=s},handleGoodbyeFinish(){this.$router.push({name:"t.home"})}}};var W=function(){var e=this,t=e._self._c;return t("div",{staticClass:"h-full flex flex-col"},[e.currentStep===e.STEPS.WELCOME?t("SurveyViewerStepperWelcome",{attrs:{survey:e.survey,"is-loading":e.isLoading},on:{next:function(n){return e.setCurrentStep(e.STEPS.FORM)}}}):e.currentStep===e.STEPS.FORM?t("SurveyViewerStepperForm",{attrs:{survey:e.survey,"clone-source-survey-instance-id":e.cloneSourceSurveyInstanceId},on:{next:function(n){return e.setCurrentStep(e.STEPS.GOODBYE)}}}):e.currentStep===e.STEPS.GOODBYE?t("SurveyViewerStepperGoodbye",{attrs:{survey:e.survey},on:{finish:e.handleGoodbyeFinish}}):e._e()],1)},Y=[],z=i(G,W,Y,!1,null,null);const U=z.exports,J={name:"SurveyViewer",components:{SurveyViewerStepper:U},props:{surveyId:{type:Number,required:!0}},data:()=>({survey:null,isLoading:!1,cloneSourceSurveyInstanceId:null}),created(){this.handleRefresh()},methods:{async handleRefresh(){const s=async()=>{const{content:e}=await I(this.surveyId);e.surveyItems=e.surveyItems.map((t,n)=>({...t,rankNumber:t.rankNumber||n+1})),this.survey=e};this.isLoading=!0,await s(),await this.fetchCloneSourceSurveyInstanceId(),this.isLoading=!1},async fetchCloneSourceSurveyInstanceId(){var t,n;const s=Number((n=(t=this.$route)==null?void 0:t.query)==null?void 0:n.cloneTalentRequestId);if(!s)return;const{content:e}=await h(s);this.cloneSourceSurveyInstanceId=(e==null?void 0:e.surveyInstanceId)||null}}};var K=function(){var e=this,t=e._self._c;return t("div",{staticClass:"h-full max-w-screen-lg mx-auto"},[t("SurveyViewerStepper",{attrs:{survey:e.survey,"is-loading":e.isLoading,"clone-source-survey-instance-id":e.cloneSourceSurveyInstanceId}}
1)],1)},Q=[],X=i(J,K,Q,!1,null,null);const Z=X.exports,ee={name:"TenantSurveyPage",components:{SurveyViewer:Z},props:{id:{type:[String,Number],required:!0}}};var te=function(){var e=this,t=e._self._c;return t("div",{staticClass:"h-full p-4 sm:p-8"},[t("SurveyViewer",{attrs:{"survey-id":Number(e.id)}})],1)},se=[],re=i(ee,te,se,!1,null,null);const Ie=re.exports;export{Ie as default}; 2//# sourceMappingURL=TenantSurvey-BjkXWhKW.js.map
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.