1import{h as We,c as F,f as w,w as ue,_ as A,$ as l,n as a,a1 as h,u as d,a0 as s,ac as Ra,M as n,g as me,a as Da,W as ft,K as C,L as p,a4 as $,F as J,a6 as re,U as It,a7 as Ae,O as ke,Y as za,q as dt,ah as Ga,ai as Ma,r as Dt,v as ja,G as Na,R as Ba,p as qe}from"./vue-datepicker-CpIdsRIT.js";import{_ as Xt}from"./CardContainer.vue_vue_type_script_setup_true_lang-BKfUFWAw.js";import{_ as Ka}from"./EntityCountKpis.vue_vue_type_script_setup_true_lang-Dw5_nmPl.js";import{_ as Ha,a as Ja,b as Xa,c as Yt}from"./CatalogListItem.vue_vue_type_script_setup_true_lang-0g4AYtGe.js";import{a as Ue,b as Oe,aR as Re,aS as De,n as le,aY as zt,C as we,aT as ze,aU as de,V as D,D as Ge,aZ as Ya,v as Ye,a_ as Za,a$ as eo,b0 as ct,K as Vt,Q as Wt,t as Ze,b1 as to,b2 as Gt,b3 as ao,b4 as da,b5 as Zt,b6 as ca,aL as Ve,aI as pa,aK as pt,aJ as _t,b7 as ga,L as Ut,b8 as oo,b9 as lo,ba as Te,aV as nt,bb as it,q as ma,bc as Et,bd as no,w as fe,be as so,bf as io,bg as Xe,l as ea,ab as ta,Z as Qt,bh as Ot,bi as fa,ae as ro,P as uo,_ as va,W as ya,bj as co,y as po,bk as go,bl as lt,d as aa,O as mo,bm as oa,ak as xt,bn as fo,bo as la}from"./index-o4dhNVJj.js";import{u as Pe}from"./catalogStore-C1C8k41I.js";import{r as se}from"./ResolveErrorCode-uRcKEtjn.js";import{V as et}from"./VTextField-DmCcBAfM.js";import{u as Ca}from"./InfiniteListComposable-D1mDhAIs.js";import{V as ha,a as vo,b as yo,c as Co}from"./VExpansionPanels-Bor2I0Ze.js";import{V as Ie}from"./VSkeletonLoader-A2vQBjLT.js";import{_ as na}from"./SelectInput.vue_vue_type_script_setup_true_lang-ph5j1wp3.js";import{_ as he}from"./SwitchInput.vue_vue_type_script_setup_true_lang-CrQyeYt2.js";import{u as Mt}from"./RiskLevelComposable-Bgkjfx0u.js";import{V as rt}from"./VCheckbox-nrSLyQgk.js";import{V as gt}from"./filter-t-MjLniW.js";import{V as Fe}from"./VAutocomplete-CR3sph-Q.js";import{V as be}from"./VChip-0TTkSTXl.js";import{V as st}from"./VSelect-BUMCLhrk.js";import{V as sa}from"./VSwitch-DIBNbKCn.js";import{g as ut,_ as wt}from"./LocalizedTextInput.vue_vue_type_script_setup_true_lang-Br2SojUX.js";import{c as ho,_ as bo}from"./ConfigurationWarnings-kdKdLjaA.js";import{V as ba,r as ko,a as At}from"./VForm-DE7HWpqe.js";import{V as wo,a as ia}from"./VTabs-DW0CRFNf.js";import"./datefns-BAflKSlV.js";import"./KpiHint.vue_vue_type_script_setup_true_lang-BCVNHQox.js";import"./userStore-DfNIKqll.js";import"./workItemStore-Bmx9fXJv.js";import"./lmraStore-CBhiIKz0.js";import"./plotly-DsqdWQfm.js";import"./Debounce-Y5hT8a-T.js";import"./LocalizedTextComposable-DaZErAPF.js";import"./VCheckboxBtn-gsiJdvrK.js";import"./VTextarea-BIBMhQgy.js";const ka=We({__name:"CatalogFolderDialog",props:{modelValue:{type:Boolean,required:!0},folder:{type:Object,default:null}},emits:["update:modelValue"],setup(W,{emit:u}){const m=W,v=u,L=Pe(),{notifyError:f,notifySuccess:R}=Ue(),{t:G}=Oe(),E=F({get:()=>m.modelValue,set:V=>v("update:modelValue",V)}),P=F(()=>!!m.folder?.id),z=w("");ue(E,V=>{V&&(z.value=m.folder?.name??"")});const q=w(!1),j=async()=>{if(!(!z.value.trim()||q.value)){q.value=!0;try{P.value?await L.updateFolder({...m.folder,name:z.value}):await L.createFolder(z.value),R(G("App.Catalog.Folders.saveSuccess")),E.value=!1}catch(V){f(G(se(V,"App.Catalog.Folders.genericSaveError")))}q.value=!1}};return(V,c)=>(n(),A(Re,{modelValue:E.value,"onUpdate:modelValue":c[2]||(c[2]=t=>E.value=t),"max-width":"420"},{default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h6 px-6 pt-5 pb-2 flex items-center gap-2"},{default:l(()=>[a(le,{icon:d(zt),size:"22",class:"mr-1"},null,8,["icon"]),h(" "+s(V.$t(P.value?"App.Catalog.Folders.rename":"App.Catalog.Folders.new")),1)]),_:1}),a(we,{class:"px-6 py-3"},{default:l(()=>[a(et,{modelValue:z.value,"onUpdate:modelValue":c[0]||(c[0]=t=>z.value=t),label:V.$t("General.name"),color:"secondary",variant:"outlined",density:"compact","hide-details":"auto",autofocus:"",onKeyup:Ra(j,["enter"])},null,8,["modelValue","label"])]),_:1}),a(ze,{class:"px-6 pb-4"},{default:l(()=>[a(de),a(D,{variant:"text",onClick:c[1]||(c[1]=t=>E.value=!1)},{default:l(()=>[h(s(V.$t("General.cancel")),1)]),_:1}),a(D,{color:"success",loading:q.value,disabled:!z.value.trim(),onClick:j},{default:l(()=>[h(s(V.$t("General.save")),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),Ao=["onClick"],$o={class:"flex items-center gap-1.5 text-sm font-semibold text-light-text"},xo={class:"text-xs text-secondary"},Io={class:"flex items-center"},Vo={key:1,class:"px-2 py-1 text-xs text-gray-400"},Wo={key:1,class:"flex flex-col"},_o={key:2,class:"flex justify-center py-3"},Lo={key:3,class:"text-center py-2 text-xs text-gray-400"},So=We({__name:"CatalogList",setup(W){const u={chosenClass:"chosen",animation:150,easing:"cubic-bezier(1, 0, 0, 1)"},m=Pe(),{notifyError:v}=Ue(),{t:L}=Oe(),f=me("catalogSearch",w("")),{items:R,loading:G,isLoadingMore:E,hasMore:P,sentinel:z,reset:q}=Ca(_=>m.fetchCatalogsPage(_),{search:f}),j=me("canEditCatalog",w(!1)),V=F(()=>m.folders??[]),c=F(()=>V.value.length>0),t=F(()=>!!f.value?.trim()),N=F(()=>{const _=V.value.map(O=>({key:O.id,folder:O,catalogs:R.value.filter(X=>X.folderId===O.id)}));return _.push({key:"unassigned",folder:null,catalogs:R.value.filter(O=>!O.folderId)}),_.filter(O=>O.catalogs.length>0||!t.value&&O.folder!==null)}),Z=w(new Set(Ya()??[])),Q=_=>!t.value&&Z.value.has(_),Y=_=>{const O=new Set(Z.value),X=!O.has(_);if(X?O.add(_):O.delete(_),Z.value=O,to([...O]),X&&ie.value){const ne=R.value.find(H=>H.id===ie.value),S=_==="unassigned"?!ne?.folderId:ne?.folderId===_;ne&&S&&(ie.value=void 0)}},T=w(!1),M=w(null),oe=_=>{M.value=_,T.value=!0},ae=w(!1),U=w(null),I=w(!1),x=_=>{U.value=_,ae.value=!0},B=async()=>
1{if(U.value){I.value=!0;try{await m.deleteFolder(U.value),R.value.forEach(_=>{_.folderId===U.value.id&&(_.folderId=null)}),ae.value=!1,U.value=null}catch(_){v(L(se(_,"App.Catalog.Folders.genericDeleteError")))}I.value=!1}},ce=me("selectedQuestion"),ee=me("selectedCatalog"),ie=w(),ve=new Set,ye=w(new Set);Da(()=>{ee&&(ie.value?ee.value=R.value.find(_=>_.id===ie.value):ee.value=null),ce&&(ce.value=null)});let ge=!1;const _e=async _=>{if(!ge){ge=!0;try{await q(),ve.clear();const O=ie.value===(_??void 0);ie.value=_??void 0,O&&_&&$e(_)}catch(O){v(L(se(O,"App.Catalog.tableGenericLoadingError")))}finally{ge=!1}}};ue(()=>ee?.value,_=>{ge||(_&&_.id&&!R.value.some(O=>O===_)?_e(_.id):!_&&ie.value&&_e(void 0))});async function $e(_){if(!_||ve.has(_))return;const O=R.value.find(X=>X.id===_);if(O){ve.add(_),ye.value.add(_);try{await m.fetchQuestions(O)}catch(X){ve.delete(_),v(L(se(X,"App.Catalog.tableGenericLoadingError")))}finally{ye.value.delete(_)}}}return ue(ie,$e),ft(async()=>{try{await Promise.all([q(),m.fetchFolders(),m.assertQuestionTypes()])}catch(_){v(L(se(_,"App.Catalog.tableGenericLoadingError")))}}),(_,O)=>(n(),C("div",null,[d(G)?(n(),C("div",Wo,[a(Ie,{type:"list-item-avatar"}),a(Ie,{type:"list-item-avatar"}),a(Ie,{type:"list-item-avatar"}),a(Ie,{type:"list-item-avatar"}),a(Ie,{type:"list-item-avatar"})])):(n(!0),C(J,{key:0},re(N.value,X=>(n(),C("div",{key:X.key,class:"mb-4"},[c.value?It((n(),C("div",{key:0,class:"flex items-center justify-between px-2 py-2 rounded cursor-pointer select-none hover:bg-background",onClick:ne=>Y(X.key)},[p("span",$o,[a(Ye,{"svg-path":X.folder?d(zt):d(Za),class:"h-4 w-4"},null,8,["svg-path"]),h(" "+s(X.folder?X.folder.name:_.$t("App.Catalog.Folders.unassignedTitle"))+" ",1),p("span",xo,s(X.catalogs.length),1)]),p("div",Io,[X.folder&&d(j)?(n(),C(J,{key:0},[a(D,{variant:"text",size:"x-small",icon:"",onClick:Ae(ne=>oe(X.folder),["stop"])},{default:l(()=>[a(Ye,{"svg-path":d(eo),class:"h-4 w-4 text-light-text"},null,8,["svg-path"])]),_:2},1032,["onClick"]),a(D,{variant:"text",size:"x-small",icon:"",onClick:Ae(ne=>x(X.folder),["stop"])},{default:l(()=>[a(Ye,{"svg-path":d(ct),class:"h-4 w-4 text-error"},null,8,["svg-path"])]),_:2},1032,["onClick"])],64)):$("",!0),a(Ye,{"svg-path":d(Vt),class:ke(["h-5 w-5 ml-1 text-light-text transition-transform duration-200",{"-rotate-90":Q(X.key)}])},null,8,["svg-path","class"])])],8,Ao)),[[Gt]]):$("",!0),a(Wt,null,{default:l(()=>[It(p("div",null,[X.catalogs.length?(n(),A(ha,{key:0,modelValue:ie.value,"onUpdate:modelValue":O[0]||(O[0]=ne=>ie.value=ne)},{default:l(()=>[(n(!0),C(J,null,re(X.catalogs,ne=>(n(),A(Ha,{catalog:ne,questions:ne.questions,"questions-loading":ye.value.has(ne.id),options:u,key:ne.id},null,8,["catalog","questions","questions-loading"]))),128))]),_:2},1032,["modelValue"])):(n(),C("div",Vo,s(_.$t("App.Catalog.Folders.emptyHint")),1))],512),[[za,!Q(X.key)]])]),_:2},1024)]))),128)),p("div",{ref_key:"sentinel",ref:z,class:"h-1"},null,512),d(E)?(n(),C("div",_o,[a(Ze,{indeterminate:"",size:"24",color:"primary"})])):!d(G)&&!d(P)&&d(R).length>0?(n(),C("div",Lo,s(_.$t("General.allLoaded")),1)):$("",!0),a(ka,{modelValue:T.value,"onUpdate:modelValue":O[1]||(O[1]=X=>T.value=X),folder:M.value},null,8,["modelValue","folder"]),a(Re,{modelValue:ae.value,"onUpdate:modelValue":O[3]||(O[3]=X=>ae.value=X),"max-width":"500px"},{default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h5 text-wrap"},{default:l(()=>[h(s(_.$t("App.Catalog.Folders.deleteConfirmText")),1)]),_:1}),a(ze,null,{default:l(()=>[a(de),a(D,{variant:"text",onClick:O[2]||(O[2]=X=>ae.value=!1)},{default:l(()=>[h(s(_.$t("General.cancel")),1)]),_:1}),a(D,{color:"error",loading:I.value,onClick:B},{default:l(()=>[h(s(_.$t("General.confirm")),1)]),_:1},8,["loading"]),a(de)]),_:1})]),_:1})]),_:1},8,["modelValue"])]))}}),qo={class:"flex flex-col gap-3"},Fo={class:"flex flex-wrap items-center gap-3 px-2"},Po={key:0,class:"flex flex-wrap items-center gap-2 px-2 py-2 rounded bg-background"},Eo={class:"text-sm font-semibold mr-2"},Qo={key:1,class:"flex items-center gap-2 px-2 text-xs text-light-text"},To={class:"flex flex-col gap-2 px-2"},Uo={key:0,class:"text-sm text-light-text py-8 text-center"},Oo={key:2,class:"flex justify-center py-3"},Ro={key:3,class:"text-center py-2 text-xs text-gray-400"},Do=We({__name:"QuestionPool",setup(W){const u=Pe(),{notifyError:m,notifySuccess:v}=Ue(),{t:L,te:f}=Oe(),R=me("questionSearch",w("")),G=me("selectedQuestion"),E=me("questionPoolVersion",w(0)),P=me("canDeleteCatalog",w(!1)),z=w([]),q=w([]),j=w(!1),V=w(!1),c=w([]),t=w(!1),N=w("assign"),Z=w(!1),Q=w(!1),{items:Y,total:T,loading:M,isLoadingMore:oe,hasMore:ae,sentinel:U,reset:I}=Ca(S=>u.fetchQuestionPoolPage({...S,typeIds:z.value,catalogIds:j.value?[]:q.value,unassigned:j.value,aiGenerated:V.value}),{search:R}),{ensureLevels:x}=Mt(),B=S=>{const H=`General.QuestionTypes.${S.name}`;return f(H)?L(H):S.name},ce=F(()=>(u.questionTypes??[]).map(S=>({value:S.id,title:B(S)}))),ee=F(()=>(u.assignableCatalogs??[]).map(S=>({value:S.id,title:S.name}))),ie=F(()=>{const S=new Set;for(const H of Y.value)c.value.includes(H.id)&&H.catalogIds?.forEach(te=>S.add(te));return[...S]}),ve=S=>{c.value=c.value.includes(S)?c.value.filter(H=>H!==S):[...c.value,S]},ye=()=>{c.value=Y.value.map(S=>
1S.id).filter(Boolean)},ge=()=>{c.value=[]},_e=S=>{G&&(G.value=G.value?.id===S.id?null:{...S,catalogId:void 0})},$e=()=>{N.value="assign",t.value=!0},_=()=>{N.value="detach",t.value=!0},O=async()=>{try{await I()}catch(S){m(L(se(S,"App.Catalog.tableGenericLoadingError")))}},X=async()=>{ge(),await O()},ne=async()=>{Q.value=!0;try{const S=await u.deleteQuestions(c.value);v(S.archived?L("App.Catalog.Pool.deleteSuccessWithArchived",{deleted:S.deleted,archived:S.archived}):L("App.Catalog.Pool.deleteSuccess",{count:S.deleted})),G?.value?.id&&c.value.includes(G.value.id)&&(G.value=null),Z.value=!1,ge(),await O()}catch(S){m(L(se(S,"App.Catalog.CatalogForm.genericDeleteError")))}Q.value=!1};return ue([z,q,j,V],()=>{O()}),ue(E,()=>{O()}),ft(async()=>{await Promise.all([u.assertQuestionTypes().catch(()=>{}),u.fetchAssignableCatalogs().catch(()=>{}),x().catch(()=>{})]),await O()}),(S,H)=>(n(),C("div",qo,[p("div",Fo,[a(na,{modelValue:z.value,"onUpdate:modelValue":H[0]||(H[0]=te=>z.value=te),items:ce.value,label:S.$t("App.Catalog.QuestionForm.typeLabel"),multiple:"",chips:"",clearable:"",style:{"min-width":"200px"},class:"grow"},null,8,["modelValue","items","label"]),a(na,{modelValue:q.value,"onUpdate:modelValue":H[1]||(H[1]=te=>q.value=te),items:ee.value,label:S.$t("App.Catalog.Pool.catalogFilterLabel"),multiple:"",chips:"",clearable:"",disabled:j.value,style:{"min-width":"200px"},class:"grow"},null,8,["modelValue","items","label","disabled"]),a(he,{modelValue:j.value,"onUpdate:modelValue":H[2]||(H[2]=te=>j.value=te),label:S.$t("App.Catalog.Pool.unassignedFilterLabel"),"hide-details":""},null,8,["modelValue","label"]),a(he,{modelValue:V.value,"onUpdate:modelValue":H[3]||(H[3]=te=>V.value=te),label:S.$t("App.Catalog.Ai.poolFilterLabel"),"hide-details":""},null,8,["modelValue","label"])]),c.value.length?(n(),C("div",Po,[p("span",Eo,s(S.$t("App.Catalog.Pool.selectedCount",{count:c.value.length})),1),a(D,{size:"small",variant:"tonal",color:"secondary","prepend-icon":d(ao),onClick:$e},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.assignAction")),1)]),_:1},8,["prepend-icon"]),a(D,{size:"small",variant:"tonal","prepend-icon":d(da),disabled:!ie.value.length,onClick:_},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.detachAction")),1)]),_:1},8,["prepend-icon","disabled"]),d(P)?(n(),A(D,{key:0,size:"small",variant:"tonal",color:"error","prepend-icon":d(ct),onClick:H[4]||(H[4]=te=>Z.value=!0)},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.deleteAction")),1)]),_:1},8,["prepend-icon"])):$("",!0),a(de),a(D,{size:"small",variant:"text",onClick:ge},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.clearSelection")),1)]),_:1})])):(n(),C("div",Qo,[d(Y).length?(n(),A(D,{key:0,size:"x-small",variant:"text",onClick:ye},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.selectAllOnPage")),1)]),_:1})):$("",!0),p("span",null,s(S.$t("App.Catalog.Pool.totalCount",{count:d(T)})),1)])),p("div",To,[d(M)?(n(),C(J,{key:1},[a(Ie,{type:"list-item-two-line"}),a(Ie,{type:"list-item-two-line"}),a(Ie,{type:"list-item-two-line"}),a(Ie,{type:"list-item-two-line"})],64)):(n(),C(J,{key:0},[(n(!0),C(J,null,re(d(Y),te=>(n(),A(Ja,{key:te.id,question:te,selected:c.value.includes(te.id),highlighted:d(G)?.id===te.id,"onUpdate:selected":Me=>ve(te.id),onOpen:Me=>_e(te)},null,8,["question","selected","highlighted","onUpdate:selected","onOpen"]))),128)),d(Y).length?$("",!0):(n(),C("div",Uo,s(S.$t("App.Catalog.Pool.empty")),1))],64))]),p("div",{ref_key:"sentinel",ref:U,class:"h-1"},null,512),d(oe)?(n(),C("div",Oo,[a(Ze,{indeterminate:"",size:"24",color:"primary"})])):!d(M)&&!d(ae)&&d(Y).length>0?(n(),C("div",Ro,s(S.$t("General.allLoaded")),1)):$("",!0),a(Xa,{modelValue:t.value,"onUpdate:modelValue":H[5]||(H[5]=te=>t.value=te),"question-ids":c.value,"assigned-catalog-ids":ie.value,mode:N.value,onDone:X},null,8,["modelValue","question-ids","assigned-catalog-ids","mode"]),a(Re,{modelValue:Z.value,"onUpdate:modelValue":H[7]||(H[7]=te=>Z.value=te),"max-width":"520px"},{default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h6 text-wrap"},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.deleteConfirmTitle",{count:c.value.length})),1)]),_:1}),a(we,{class:"text-sm"},{default:l(()=>[h(s(S.$t("App.Catalog.Pool.deleteConfirmText")),1)]),_:1}),a(ze,null,{default:l(()=>[a(de),a(D,{variant:"text",onClick:H[6]||(H[6]=te=>Z.value=!1)},{default:l(()=>[h(s(S.$t("General.cancel")),1)]),_:1}),a(D,{color:"error",loading:Q.value,onClick:ne},{default:l(()=>[h(s(S.$t("General.confirm")),1)]),_:1},8,["loading"]),a(de)]),_:1})]),_:1})]),_:1},8,["modelValue"])]))}}),zo={class:"flex items-center justify-between px-2 py-1 mb-2"},Go={class:"text-xs text-medium-emphasis"},Mo={key:0,class:"ml-8 mb-1"},jo={key:0,class:"ml-1 opacity-70"},No=We({__name:"CatalogExportDialog",setup(W){const u=Pe(),m=w(!1),v=w(new Set),L=w(new Set),f=F(()=>u.catalogs??[]);ue(m,V=>{V&&(v.value=new Set(f.value.map(c=>c.id)),L.value=new Set)});const R=F(()=>v.value.size===f.value.length&&f.value.length>0),G=F(()=>v.value.size>0);function E(){R.value?v.value=new Set:v.value=new Set(f.value.map(V=>V.id))}function P(V){const c=new Set(v.value);c.has(V)?c.delete(V):c.add(V),v.value=c}function z(V){const c=new Set(L.value);c.has(V)?c.delete(V):c.add(V),L.value=c}function q(V){const c=V.data?.request;if(!c)return"â";const t=Object.keys(c).find(N=>c[N]);return t&&c[t]||"â"}async function j(){const V=u.questionTypes??[],c=f.value.filter(T=>v.value.has(T.id));await Promise.all(c.filter(T=>T.questions===void 0).map(T=>u.fetchQuestions(T).catch(()=>{T.questions=[]})));const t=c.map(T=>({name:T.name,languages:T.languages,questions:(T.questions??[]).map(M=>({typeName:V.find(ae=>ae.id===M.typeId)?.name??null,data:M.data,order:M.order??0}))})),N={version:1,exportedAt:new Date().toISOString(),catalogs:t},Z=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),Q=URL.createObjectURL(Z),Y=document.createElement("a");Y.href=Q,Y.download=`kataloge-export-${new Date().toISOString().slice(0,10)}.json`,Y.click(),URL.revokeObjectURL(Q),m.value=!1}return(V,c)=>(n(),A(Re,{modelValue:m.value,"onUpdate:modelValue":c[2]||(c[2]=t=>m.value=t),"max-width":"680",scrollable:""},{activator:l(({props:t})=>[a(D,dt({variant:"text"},t,{size:"small",icon:""}),{default:l(()=>[a(le,{icon:d(Zt)},null,8,["icon"]),a(gt,{activator:"parent",location:"top"},{default:l(()=>
1[h(s(V.$t("App.Catalog.Export.button")),1)]),_:1})]),_:2},1040)]),default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h6 px-6 pt-5 pb-2 flex items-center gap-2"},{default:l(()=>[a(le,{icon:d(Zt),size:"22",class:"mr-1"},null,8,["icon"]),h(" "+s(V.$t("App.Catalog.Export.title")),1)]),_:1}),a(ca,{class:"px-6 pb-3"},{default:l(()=>[h(s(V.$t("App.Catalog.Export.subtitle")),1)]),_:1}),a(Ve),a(we,{class:"px-4 py-3",style:{"max-height":"460px"}},{default:l(()=>[p("div",zo,[a(rt,{modelValue:R.value,"onUpdate:modelValue":c[0]||(c[0]=t=>R.value=t),indeterminate:G.value&&!R.value,label:V.$t("App.Catalog.Export.selectAll"),"hide-details":"",density:"compact",color:"secondary",onChange:E},null,8,["modelValue","indeterminate","label"]),p("span",Go,s(v.value.size)+" / "+s(f.value.length)+" "+s(V.$t("App.Catalog.Export.catalogsSelected")),1)]),a(Ve,{class:"mb-2"}),a(pa,{density:"compact",class:"pa-0"},{default:l(()=>[(n(!0),C(J,null,re(f.value,t=>(n(),C(J,{key:t.id},[a(pt,{class:ke(["rounded pr-2 pl-1 mb-1",{"bg-surface-variant":v.value.has(t.id)}])},{prepend:l(()=>[a(rt,{"model-value":v.value.has(t.id),"hide-details":"",density:"compact",color:"secondary",onChange:N=>P(t.id)},null,8,["model-value","onChange"])]),append:l(()=>[a(D,{variant:"text",size:"x-small",icon:L.value.has(t.id)?d(Ut):d(Vt),disabled:!t.questions?.length,onClick:Ae(N=>z(t.id),["stop"])},null,8,["icon","disabled","onClick"])]),default:l(()=>[a(_t,{class:"font-semibold text-sm"},{default:l(()=>[h(s(t.name),1)]),_:2},1024),a(ga,{class:"text-xs"},{default:l(()=>[h(s(t.questions?.length??t.questionCount??0)+" "+s(V.$t("App.Catalog.Export.questions"))+"  · "+s(t.languages.join(", ").toUpperCase()),1)]),_:2},1024)]),_:2},1032,["class"]),a(Wt,null,{default:l(()=>[L.value.has(t.id)&&t.questions?.length?(n(),C("div",Mo,[(n(!0),C(J,null,re(t.questions,N=>(n(),A(pt,{key:N.id,density:"compact",class:"rounded text-xs"},{prepend:l(()=>[a(le,{icon:d(oo),size:"14",class:"mr-2 text-medium-emphasis"},null,8,["icon"])]),default:l(()=>[a(_t,{class:"text-xs"},{default:l(()=>[h(s(q(N)),1)]),_:2},1024)]),_:2},1024))),128))])):$("",!0)]),_:2},1024)],64))),128))]),_:1})]),_:1}),a(Ve),a(ze,{class:"px-6 py-4 gap-2"},{default:l(()=>[a(de),a(D,{variant:"text",onClick:c[1]||(c[1]=t=>m.value=!1)},{default:l(()=>[h(s(V.$t("General.cancel")),1)]),_:1}),a(D,{color:"secondary",variant:"flat",disabled:v.value.size===0,"prepend-icon":d(lo),onClick:j},{default:l(()=>[h(s(V.$t("App.Catalog.Export.export"))+" ",1),v.value.size>0?(n(),C("span",jo,"("+s(v.value.size)+")",1)):$("",!0)]),_:1},8,["disabled","prepend-icon"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),Bo={class:"items-start"},wa=We({__name:"CatalogLanguageSelect",props:Ga({label:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(W){const u=Ma(W,"modelValue"),m=F(()=>
1Object.values(Te).map(v=>({title:v.toUpperCase(),value:v})).sort((v,L)=>v.title.localeCompare(L.title)));return(v,L)=>(n(),A(Fe,{modelValue:u.value,"onUpdate:modelValue":L[0]||(L[0]=f=>u.value=f),items:m.value,multiple:"",label:v.label??v.$t("General.languageSettings"),color:"secondary","prepend-inner-icon":d(nt),variant:"outlined","hide-details":"auto"},{chip:l(({item:f})=>[a(it,{"lang-code":f.raw.value,class:"mr-2"},null,8,["lang-code"]),h(" "+s(f.raw.title)+", ",1)]),item:l(({props:f,item:R})=>[a(pt,dt(f,{title:R.raw.title}),{prepend:l(()=>[a(it,{"lang-code":R.raw.value,class:"mr-2"},null,8,["lang-code"])]),append:l(()=>[p("span",Bo,s(v.$t(`Languages.${R.raw.value}`)),1)]),_:2},1040,["title"])]),_:1},8,["modelValue","items","label","prepend-inner-icon"]))}}),Ko="none",Ho=()=>({workStop:"never",followUpQuestions:!1,questionTypeId:null,riskLevel:null,suggestReactions:!0}),Jo=new Set(Object.values(Te)),Xo=["request","info"],Yo=10,Zo=100,el=2e4,$t=W=>typeof W=="string"&&W.trim()!=="",Aa=W=>typeof W=="string"&&Jo.has(W),Rt=W=>[...new Set((W.languages??[]).filter(Aa))];function $a(W,u,m){return{keep:u.filter(v=>W.includes(v)),translate:u.filter(v=>!W.includes(v)),remove:W.filter(v=>!u.includes(v)),source:m&&W.includes(m)?m:W[0]??null}}function tl(W){const u=[];let m=W;for(let v=0;m&&typeof m=="object"&&v<Yo;v++){for(const L of Xo)m[L]&&typeof m[L]=="object"&&u.push(m[L]);m=m.onWrong}return u}function al(W,u){const m=[];let v=[],L=0;for(const f of W){const R=f.length*u;v.length&&(v.length>=Zo||L+R>el)&&(m.push(v),v=[],L=0),v.push(f),L+=R}return v.length&&m.push(v),m}async function ol(W,u,m,v,L){const f=new Map,R=W.map(P=>{const z=Rt(P),q=$a(z,u,m),j=JSON.parse(JSON.stringify(P.questions));for(const V of j)for(const c of tl(V.data)){const t=u.filter(M=>!$t(c[M])),N=[q.source,...z,...Object.keys(c)].find(M=>Aa(M)&&$t(c[M])),Z=N?c[N]:"";if(q.remove.forEach(M=>{delete c[M]}),!t.length)continue;if(!N){t.forEach(M=>{c[M]=c[M]??""});continue}const Q=`${N}>${t.join(",")}`,Y=f.get(Q)??{from:N,to:t,targets:new Map};f.set(Q,Y);const T=Y.targets.get(Z)??[];T.push(c),Y.targets.set(Z,T)}return{...P,languages:[...u],questions:j}}),G=[...f.values()].reduce((P,z)=>P+z.targets.size,0);let E=0;G&&L?.(0,G);for(const P of f.values())for(const z of al([...P.targets.keys()],P.to.length)){const q=await v(P.from,P.to,z);z.forEach((j,V)=>{for(const c of P.targets.get(j)??[])for(const t of P.to){const N=q[t]?.[V];$t(c[t])||(c[t]=$t(N)?N:"")}}),E+=z.length,L?.(E,G)}return R}const ll={class:"text-sm font-medium mb-1"},nl={class:"text-xs text-medium-emphasis text-center"},sl=["accept"],il={key:1,class:"mt-4"},rl={class:"text-xs font-semibold text-medium-emphasis mb-2"},ul={class:"flex flex-col gap-1"},dl={class:"text-sm grow min-w-0 truncate"},cl={class:"text-xs text-medium-emphasis shrink-0"},pl={key:2,class:"mt-5 rounded-lg import-panel px-4 py-3"},gl={class:"flex items-center gap-2"},ml={class:"text-sm font-semibold"},fl={class:"text-xs text-medium-emphasis mt-1 mb-4"},vl={class:"grid grid-cols-1 sm:grid-cols-2 gap-3"},yl={class:"mt-3 flex flex-col gap-2"},Cl={class:"text-xs text-medium-emphasis -mt-1 ml-1"},hl={class:"text-xs text-medium-emphasis -mt-1 ml-1"},bl={key:0,class:"flex items-center gap-3 mb-4"},kl={class:"text-sm font-medium"},wl={class:"text-xs text-medium-emphasis"},Al={class:"flex flex-col gap-2"},$l={class:"w-5 flex justify-center pt-0.5 shrink-0"},xl={class:"grow min-w-0"},Il={class:"text-sm truncate"},Vl={key:0},Wl={key:1},_l={class:"flex items-center justify-between px-2 py-1 mb-2"},Ll={class:"truncate"},Sl={key:0,class:"pl-6 pr-1 pb-2"},ql={key:0,class:"ml-10 mr-2 mb-2 px-3 py-2 rounded-lg import-panel text-xs"},Fl={class:"gap-x-3 gap-y-1",style:{display:"grid","grid-template-columns":"auto 1fr"}},Pl={class:"text-medium-emphasis"},El={class:"text-medium-emphasis"},Ql={class:"text-medium-emphasis"},Tl={class:"text-medium-emphasis"},Ul={class:"text-medium-emphasis"},Ol={class:"text-medium-emphasis"},Rl={key:0,class:"flex gap-1 mt-2"},Dl={class:"text-sm font-semibold mb-1"},zl={class:"text-xs text-medium-emphasis mb-4"},Gl={class:"rounded-lg import-panel px-4 py-3 mb-4"},Ml={class:"text-xs font-semibold text-medium-emphasis mb-2"},jl={key:0,class:"flex flex-wrap gap-2"},Nl={key:0,class:"ml-1 text-medium-emphasis"},Bl={key:1,class:"text-xs text-medium-emphasis"},Kl={class:"flex flex-col gap-4"},Hl={class:"mt-5"},Jl={class:"text-xs font-semibold text-medium-emphasis mb-2"},Xl={class:"flex flex-col gap-1 import-language-summary"},Yl={class:"flex items-center gap-2 min-w-0"},Zl={class:"text-sm truncate"},en={class:"flex flex-wrap gap-1 mt-1"},tn={class:"line-through"},an={class:"flex flex-wrap gap-x-4 gap-y-1 mt-2 text-xs text-medium-emphasis"},on={class:"flex items-center gap-1"},ln={class:"flex items-center gap-1"},nn={key:2,class:"flex items-center gap-3 mt-4"},sn={class:"text-sm"},rn={key:0,class:"ml-1 opacity-70"},un={key:0,class:"ml-1 opacity-70"},Tt=10,ra=8,dn=3,cn=3e3,pn=5,gn=960*1e3,Je="__ai__",mn=5,fn=We({__name:"CatalogImportDialog",setup(W){const u=Pe(),m=ma(),{notifySuccess:v,notifyError:L}=Ue(),{t:f,te:R}=Oe(),{options:G,labelForCode:E,ensureLevels:P}=Mt(),z=["json"],q=["xlsx","csv","pdf","png","jpg","jpeg","webp"],j=[...z,...q].map(e=>`.${e}`).join(","),V=w(!1),c=w("files"),t=w(null),N=w(!1),Z=w([]),Q=w([]),Y=w(!1),T=w(null),M=w(new Map),oe=F(()=>new Set([...M.value.entries()].filter(([,e])=>e.size>0).map(([e])=>e))),ae=w(new Set),U=w(new Set),I=w(!1),x=w(null);let B=0;const ce=()=>({...Ho(),questionTypeId:Je,riskLevel:Je}),ee=Dt(ce()),ie=F(()=>({workStop:ee.workStop,followUpQuestions:ee.followUpQuestions,questionTypeId:ee.questionTypeId===Je?null:ee.questionTypeId,riskLevel:ee.riskLevel===Je?null:ee.riskLevel,suggestReactions:ee.suggestReactions})),ve=F(()=>[{value:"never",title:f("App.Catalog.Import.Settings.workStopNever")},{value:"ai",title:f("App.Catalog.Import.Settings.workStopAi")},{value:"always",title:f("App.Catalog.Import.Settings.workStopAlways")}]),ye=e=>{const i=`General.QuestionTypes.${e}`;return R(i)?f(i):e},ge=F(()=>[{value:Je,title:f("App.Catalog.Import.Settings.aiDecides")},...(u.questionTypes??[]).map(e=>({value:e.id,title:ye(e.name)}
1))]),_e=F(()=>[{value:Je,title:f("App.Catalog.Import.Settings.aiDecides")},{value:Ko,title:f("App.Catalog.Import.Settings.riskLevelNone")},...G.value.map(e=>({value:e.value,title:e.title}))]);ue(ee,()=>{for(const e of Q.value)e.kind==="ai"&&e.status!=="queued"&&H(e)},{deep:!0});const $e=F(()=>Q.value.some(e=>e.kind==="ai")),_=F(()=>Q.value.some(e=>e.kind==="ai"&&e.status!=="done")),O=F(()=>Q.value.filter(e=>e.status==="failed")),X=F(()=>!!T.value?.some(e=>e.aiGenerated)),ne=e=>e.split(".").pop()?.toLowerCase()??"",S=e=>e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`;function H(e){e.status="queued",e.progress=null,e.errorKey=null,e.catalogs=[]}function te(e){if(!e)return;const i=[];for(const o of Array.from(e)){const y=ne(o.name),k=z.includes(y)?"json":q.includes(y)?"ai":null;if(!k){i.push(f("App.Catalog.Import.unsupportedFileNamed",{file:o.name}));continue}if(k==="ai"&&o.size>ra*1024*1024){i.push(f("App.Catalog.Import.aiFileTooLargeNamed",{file:o.name,max:ra}));continue}if(!Q.value.some(K=>K.file.name===o.name&&K.file.size===o.size)){if(Q.value.length>=Tt){i.push(f("App.Catalog.Import.tooManyFiles",{max:Tt}));break}Q.value.push({key:`${o.name}:${o.size}:${o.lastModified}`,file:Na(o),kind:k,status:"queued",progress:null,errorKey:null,catalogs:[]})}}Z.value=i}function Me(e){Q.value=Q.value.filter(i=>i.key!==e),Z.value=[]}function Lt(e){const i=e.target;te(i.files),i.value=""}function St(e){N.value=!1,te(e.dataTransfer?.files)}function r(e){switch(e.status){case"uploading":return f("App.Catalog.Import.statusUploading");case"processing":{const i=e.progress;if(i?.total){const o=i.stage==="ocr"?"aiProgressOcr":"aiProgressStructuring";return f(`App.Catalog.Import.${o}`,{done:i.done,total:i.total})}return f("App.Catalog.Import.statusProcessing")}case"done":return f("App.Catalog.Import.statusDone",{count:e.catalogs.length});case"failed":return f(`App.Catalog.Import.${e.errorKey??"aiConvertError"}`);default:return f("App.Catalog.Import.statusQueued")}}class g extends Error{constructor(i){super(i),this.errorKey=i}}const b=e=>new Promise(i=>setTimeout(i,e));function pe(e){return new Promise((i,o)=>{const y=new FileReader;y.onload=()=>i(y.result),y.onerror=()=>o(y.error),y.readAsText(e)})}function Le(e){return new Promise((i,o)=>{const y=new FileReader;y.onload=()=>{const k=y.result;i(k.substring(k.indexOf(",")+1))},y.onerror=()=>o(y.error),y.readAsDataURL(e)})}async function Ce(e){try{const i=JSON.parse(await pe(e.file));if(!i?.catalogs||!Array.isArray(i.catalogs))throw new g("parseErrorInvalid");const o=i.catalogs.filter(y=>Array.isArray(y?.questions)&&y.questions.length).map(y=>({...y,sourceFileName:e.file.name,aiGenerated:!1}));if(!o.length)throw new g("parseErrorInvalid");e.catalogs=o,e.status="done"}catch(i){e.status="failed",e.errorKey=i instanceof g?i.errorKey:"parseErrorJson"}}const je={PDF_NO_TEXT:"aiPdfNoText",PDF_TOO_MANY_PAGES:"aiPdfTooManyPages",TIMEOUT:"aiTimeout"};async function Ne(e,i,o){const y=Date.now();let k=0;for(;;){if(await b(cn),o!==B)throw new g("cancelled");if(Date.now()-y>gn)throw new g("aiTimeout");let K;try{K=await u.fetchAiImportJob(e)}catch{if(++k>=pn)throw new g("aiConvertError");continue}if(o!==B)throw new g("cancelled");if(k=0,K.progress&&(i.progress=K.progress),K.status==="done")return K.catalogs??[];if(K.status==="failed")throw new g(K.errorCode&&je[K.errorCode]||"aiConvertError")}}async function xa(e,i){e.status="uploading",e.progress=null,e.errorKey=null;try{const o=await Le(e.file);if(i!==B)return;const y=await u.startAiImport({fileName:e.file.name,mimeType:e.file.type||"application/octet-stream",content:o,options:ie.value});if(i!==B)return;e.status="processing";const k=(await Ne(y.id,e,i)).filter(K=>K.questions?.length).map(K=>({...K,sourceFileName:e.file.name,aiGenerated:!0}));if(!k.length)throw new g("aiConvertError");e.catalogs=k,e.status="done"}catch(o){if(i!==B)return;e.status="failed",e.errorKey=o instanceof g?o.errorKey:"aiConvertError"}}async function Ia(){if(!Q.value.length)return;const e=++B;Z.value=[],c.value="processing",Y.value=!0;const i=Q.value.filter(k=>k.status!=="done");
1i.forEach(H);for(const k of i.filter(K=>K.kind==="json"))await Ce(k);const o=i.filter(k=>k.kind==="ai");if(await Promise.all(Array.from({length:Math.min(dn,o.length)},async()=>{for(;o.length&&e===B;)await xa(o.shift(),e)})),e!==B)return;Y.value=!1;const y=Q.value.flatMap(k=>k.status==="done"?k.catalogs:[]);y.length&&(T.value=y,c.value="select")}function jt(){B++,Y.value=!1;for(const e of Q.value)(e.status==="uploading"||e.status==="processing")&&H(e);T.value=null,M.value=new Map,ae.value=new Set,U.value=new Set,x.value=null,Kt(),c.value="files"}function Va(){B++,Y.value=!1,c.value="files",Q.value=[],Z.value=[],T.value=null,M.value=new Map,ae.value=new Set,U.value=new Set,x.value=null,Kt(),N.value=!1,Object.assign(ee,ce()),t.value&&(t.value.value="")}ja(()=>{B++}),ue(V,e=>{if(!e){Va();return}u.assertQuestionTypes().catch(()=>{}),P().catch(()=>{})}),ue(T,async e=>{if(e){x.value=null;try{const i=await m.getLimitDetails("catalog");(i.limit==null||i.limit===-1)&&(i.limit=1/0),x.value=i;const o=x.value.limit===-1||x.value.limit===1/0?1/0:Math.max(0,x.value.limit-x.value.currentCount),y=Math.min(e.length,isFinite(o)?o:e.length);qt(Array.from({length:y},(k,K)=>K))}catch{qt(e.map((i,o)=>o))}}});const Ee=F(()=>oe.value.size),vt=F(()=>{if(!x.value)return!1;const{limit:e,currentCount:i}=x.value;return e===-1?!1:i+Ee.value>e}),yt=F(()=>T.value!==null&&oe.value.size===T.value.length&&T.value.length>0),Wa=F(()=>oe.value.size>0);function Ct(e){if(oe.value.has(e)||!x.value)return!1;const{limit:i,currentCount:o}=x.value;return i===-1?!1:o+oe.value.size>=i}function qt(e){const i=new Map;for(const o of e){const y=T.value?.[o];y&&i.set(o,new Set(y.questions.map((k,K)=>K)))}M.value=i}function ht(e){return M.value.get(e)?.size??0}function bt(e,i){return M.value.get(e)?.has(i)??!1}function _a(e){const i=T.value?.[e]?.questions.length??0;return i>0&&ht(e)===i}function La(e){const i=ht(e);return i>0&&i<(T.value?.[e]?.questions.length??0)}function Sa(){if(T.value)if(yt.value)M.value=new Map;else{const e=x.value&&x.value.limit!==-1?Math.max(0,x.value.limit-x.value.currentCount):T.value.length;qt(Array.from({length:Math.min(T.value.length,e)},(i,o)=>o))}}function qa(e){const i=new Map(M.value);if(ht(e)>0)i.delete(e);else{const o=T.value?.[e];if(!o)return;i.set(e,new Set(o.questions.map((y,k)=>k)))}M.value=i}function Fa(e,i){const o=M.value.get(e)??new Set;if(o.size===0&&Ct(e))return;const y=new Set(o);y.has(i)?y.delete(i):y.add(i);const k=new Map(M.value);y.size?k.set(e,y):k.delete(e),M.value=k}function Nt(e,i){return U.value.has(`${e}:${i}`)}function Pa(e,i){const o=`${e}:${i}`,y=new Set(U.value);y.has(o)?y.delete(o):y.add(o),U.value=y}function Se(e,i){if(!e)return"";for(const o of i.languages){const y=e[o];if(y&&y.trim())return y}return Object.values(e).find(o=>o&&String(o).trim())??""}function Bt(e){const i=e.data;return i?i.onWrong?.request?i.onWrong.workPermission===!1:i.workPermission===!1:!1}function Ea(e){const i=new Set(ae.value);i.has(e)?i.delete(e):i.add(e),ae.value=i}function Qa(e){const i=e.data?.request;if(!i)return"â";const o=Object.keys(i).find(y=>i[y]);return o&&i[o]||"â"}const xe=w([]),Be=w(null),Ke=w(null),tt=w(!1);function Kt(){xe.value=[],Be.value=null,Ke.value=null,tt.value=!1}const at=F(()=>(T.value??[]).map((e,i)=>({...e,questions:e.questions.filter((o,y)=>bt(i,y)).map((o,y)=>({...o,order:y+1}))})).filter(e=>e.questions.length>0)),kt=F(()=>{const e=new Map;for(const i of at.value)for(const o of Rt(i))e.set(o,(e.get(o)??0)+1);return[...e.entries()].map(([i,o])=>({code:i,count:o}))}),Ht=F(()=>kt.value.map(({code:e})=>({value:e,title:`${e.toUpperCase()} â ${f(`Languages.${e}`)}`}))),Jt=F(()=>at.value.map(e=>({catalog:e,plan:$a(Rt(e),xe.value,Be.value)}))),Ft=F(()=>Jt.value.some(e=>e.plan.translate.length>0));function Ta(){const e=kt.value.map(i=>i.code);xe.value=e.length?e:[Te.DE],Be.value=e.includes(Te.DE)?Te.DE:e[0]??null,Ke.value=null,tt.value=!1,c.value="languages"}async function Ua(e){const i=u.questionTypes??[];if(!e)return i[0]?.id;const o=i.find(y=>y.name===e);if(o)return o.id;try{return(await u.createQuestionType(e)).id}catch{return}}async function Oa(){if(!T.value||I.value||!xe.value.length)return;I.value=!0,tt.value=!1;let e=0,i=0,o=0,y;try{y=await ol(at.value,xe.value,Be.value,(k,K,Qe)=>u.translateTexts(k,K,Qe),(k,K)=>{Ke.value={done:k,total:K}})}catch{tt.value=!0,I.value=!1;return}finally{Ke.value=null}await u.assertQuestionTypes().catch(()=>{});for(const k of y)try{const K=await u.createCatalog({name:k.name,languages:k.languages}),Qe=new Map;for(const He of k.questions){const ot=He.typeName??"";Qe.has(ot)||Qe.set(ot,await Ua(He.typeName))}const Pt=[...k.questions];await Promise.all(Array.from({length:Math.min(mn,Pt.length)},async()=>{for(;Pt.length;){const He=Pt.shift(),ot=Qe.get(He.typeName??"");if(!ot){o++;continue}
1try{await u.createQuestion(K,{typeId:ot,data:He.data,order:He.order,aiGenerated:k.aiGenerated===!0})}catch{o++}}})),e++}catch{i++}I.value=!1,e>0&&v(f("App.Catalog.Import.importSuccess",{count:e})),i>0&&L(f("App.Catalog.Import.importPartialError",{count:i})),o>0&&L(f("App.Catalog.Import.importQuestionErrors",{count:o})),V.value=!1}return(e,i)=>(n(),A(Re,{modelValue:V.value,"onUpdate:modelValue":i[13]||(i[13]=o=>V.value=o),"max-width":c.value==="select"?1100:760,scrollable:"",persistent:""},{activator:l(({props:o})=>[a(D,dt({variant:"text"},o,{size:"small",icon:""}),{default:l(()=>[a(le,{icon:d(Et)},null,8,["icon"]),a(gt,{activator:"parent",location:"top"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.button")),1)]),_:1})]),_:2},1040)]),default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h6 px-6 pt-5 pb-2 flex items-center gap-2"},{default:l(()=>[a(le,{icon:d(Et),size:"22",class:"mr-1"},null,8,["icon"]),h(" "+s(e.$t("App.Catalog.Import.title")),1)]),_:1}),a(ca,{class:"px-6 pb-3 text-wrap"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.subtitle")),1)]),_:1}),a(Ve),c.value==="files"?(n(),A(we,{key:0,class:"px-6 py-5"},{default:l(()=>[p("div",{class:ke(["border-2 border-dashed rounded-lg flex flex-col items-center justify-center px-4 cursor-pointer transition-colors",[N.value?"border-secondary bg-surface-variant":"border-divider hover:border-secondary",Q.value.length?"py-4":"py-10"]]),onDragover:i[0]||(i[0]=Ae(o=>N.value=!0,["prevent"])),onDragleave:i[1]||(i[1]=o=>N.value=!1),onDrop:Ae(St,["prevent"]),onClick:i[2]||(i[2]=o=>t.value?.click())},[a(le,{icon:d(no),size:Q.value.length?28:48,class:"mb-2 text-medium-emphasis"},null,8,["icon","size"]),p("p",ll,s(Q.value.length?e.$t("App.Catalog.Import.addMoreFiles"):e.$t("App.Catalog.Import.dropHint")),1),p("p",nl,s(e.$t("App.Catalog.Import.dropHintSub",{max:Tt})),1),p("input",{ref_key:"fileInputRef",ref:t,type:"file",multiple:"",accept:d(j),class:"hidden",onChange:Lt},null,40,sl)],34),Z.value.length?(n(),A(fe,{key:0,type:"error",class:"mt-4",density:"compact"},{default:l(()=>[(n(!0),C(J,null,re(Z.value,(o,y)=>(n(),C("div",{key:y},s(o),1))),128))]),_:1})):$("",!0),Q.value.length?(n(),C("div",il,[p("p",rl,s(e.$t("App.Catalog.Import.filesTitle",{count:Q.value.length})),1),p("div",ul,[(n(!0),C(J,null,re(Q.value,o=>(n(),C("div",{key:o.key,class:"flex items-center gap-2 rounded-lg import-panel px-2 py-1.5"},[a(le,{icon:o.kind==="json"?d(so):d(io),size:"18",class:"text-medium-emphasis shrink-0"},null,8,["icon"]),p("span",dl,s(o.file.name),1),a(be,{size:"x-small",variant:"tonal",color:o.kind==="ai"?"secondary":void 0,class:"shrink-0"},{default:l(()=>[o.kind==="ai"?(n(),A(le,{key:0,icon:d(Xe),size:"x-small",start:""},null,8,["icon"])):$("",!0),h(" "+s(o.kind==="ai"?e.$t("App.Catalog.Import.fileKindAi"):e.$t("App.Catalog.Import.fileKindJson")),1)]),_:2},1032,["color"]),o.status==="done"?(n(),A(le,{key:0,icon:d(ea),color:"success",size:"16",class:"shrink-0"},null,8,["icon"])):o.status==="failed"?(n(),A(le,{key:1,icon:d(ta),color:"error",size:"16",class:"shrink-0"},null,8,["icon"])):$("",!0),p("span",cl,s(S(o.file.size)),1),a(D,{variant:"text",size:"x-small",icon:"",class:"shrink-0",onClick:Ae(y=>Me(o.key),["stop"])},{default:l(()=>[a(le,{icon:d(Qt),size:"16"},null,8,["icon"]),a(gt,{activator:"parent",location:"top"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.removeFile")),1)]),_:1})]),_:2},1032,["onClick"])]))),128))])])):$("",!0),$e.value?(n(),C("div",pl,[p("div",gl,[a(le,{icon:d(Xe),size:"18",color:"secondary"},null,8,["icon"]),p("span",ml,s(e.$t("App.Catalog.Import.Settings.title")),1)]),p("p",fl,s(e.$t("App.Catalog.Import.Settings.hint")),1),p("div",vl,[a(st,{modelValue:ee.workStop,"onUpdate:modelValue":i[3]||(i[3]=o=>ee.workStop=o),items:ve.value,label:e.$t("App.Catalog.Import.Settings.workStopLabel"),"prepend-inner-icon":d(Ot),variant:"outlined",density:"compact",color:"secondary","hide-details":"",class:"sm:col-span-2"},null,8,["modelValue","items","label","prepend-inner-icon"]),a(st,{modelValue:ee.questionTypeId,"onUpdate:modelValue":i[4]||(i[4]=o=>ee.questionTypeId=o),items:ge.value,label:e.$t("App.Catalog.Import.Settings.questionTypeLabel"),variant:"outlined",density:"compact",color:"secondary","hide-details":""},null,8,["modelValue","items","label"]),a(st,{modelValue:ee.riskLevel,"onUpdate:modelValue":i[5]||(i[5]=o=>ee.riskLevel=o),items:_e.value,label:e.$t("App.Catalog.Import.Settings.riskLevelLabel"),"prepend-inner-icon":d(fa),variant:"outlined",density:"compact",color:"secondary","hide-details":""},null,8,["modelValue","items","label","prepend-inner-icon"])]),p("div",yl,[p("div",null,[a(sa,{modelValue:ee.followUpQuestions,"onUpdate:modelValue":i[6]||(i[6]=o=>ee.followUpQuestions=o),label:e.$t("App.Catalog.Import.Settings.followUpLabel"),color:"secondary",density:"compact",inset:"","hide-details":""},null,8,["modelValue","label"]),p("p",Cl,s(e.$t("App.Catalog.Import.Settings.followUpHint")),1)]),p("div",null,[a(sa,{modelValue:ee.suggestReactions,"onUpdate:modelValue":i[7]||(i[7]=o=>ee.suggestReactions=o),label:e.$t("App.Catalog.Import.Settings.suggestReactionsLabel"),color:"secondary",density:"compact",inset:"","hide-details":""},null,8,["modelValue","label"]),p("p",hl,s(e.$t("App.Catalog.Import.Settings.suggestReactionsHint")),1)])])])):$("",!0),$e.value?(n(),A(fe,{key:3,type:"warning",variant:"tonal",density:"compact",class:"mt-4",icon:d(Xe)},{default:l(()=>[h(s(e.$t("App.Catalog.Import.aiMistakesHint")),1)]),_:1},8,["icon"])):$("",!0)]),_:1})):c.value==="processing"?(n(),A(we,{key:1,class:"px-6 py-5"},{default:l(()=>[Y.value?(n(),C("div",bl,[a(Ze,{indeterminate:"",color:"secondary",size:"28",width:"3"}),p("div",null,[p("p",kl,s(e.$t("App.Catalog.Import.aiConverting")),1),p("p",wl,s(e.$t("App.Catalog.Import.aiConvertingHint")),1)])])):(n(),A(fe,{key:1,type:"error",variant:"tonal",density:"compact",class:"mb-4"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.allFailed")),1)]),_:1})),p("div",Al,[(n(!0),C(J,null,re(Q.value,o=>(n(),C("div",{key:o.key,class:"flex items-start gap-3 rounded-lg import-panel px-3 py-2"},[p("div",$l,[o.status==="uploading"||o.status==="processing"?(n(),A(Ze,{key:0,indeterminate:"",size:"16",width:"2",color:"secondary"})):o.status==="done"?(n(),A(le,{key:1,icon:d(ea),color:"success",size:"18"},null,8,["icon"])):o.status==="failed"?(n(),A(le,{key:2,icon:d(ta),color:"error",size:"18"},null,8,["icon"])):(n(),A(le,{key:3,icon:d(ro),size:"18",class:"text-medium-emphasis"},null,8,["icon"]))]),p("div",xl,[p("p",Il,s(o.file.name),1),p("p",{class:ke(["text-xs",o.status==="failed"?"text-error":"text-medium-emphasis"])},s(r(o)),3)])]))),128))])]),_:1})):c.value==="select"?(n(),C(J,{key:2},[X.value?(n(),A(we,{key:0,class:"px-6 py-3 pb-0"},{default:l(()=>[a(fe,{type:"warning",density:"compact",variant:"tonal",class:"mb-0",icon:d(Xe)},{default:l(()=>[h(s(e.$t("App.Catalog.Import.aiReviewHint")),1)]),_:1},8,["icon"])]),_:1})):$("",!0),O.value.length?(n(),A(we,{key:1,class:"px-6 py-3 pb-0"},{default:l(()=>[a(fe,{type:"error",density:"compact",variant:"tonal",class:"mb-0"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.failedFilesHint",{count:O.value.length,files:O.value.map(o=>o.file.name).join(", ")})),1)]),_:1})]),_:1})):$("",!0),a(we,{class:"px-6 py-3 pb-0"},{default:l(()=>[a(fe,{type:vt.value?"error":"info",density:"compact",variant:"tonal",class:"mb-0"},{default:l(()=>[x.value?(n(),C(J,{key:0},[x.value.limit===-1||x.value.limit===1/0?(n(),C("span",Vl,s(e.$t("App.Catalog.Import.licenseUnlimited")),1)):(n(),C("span",Wl,s(e.$t("App.Catalog.Import.licenseInfo",{current:x.value.currentCount,max:x.value.limit,remaining:Math.max(0,x.value.limit-x.value.currentCount)}
1)),1))],64)):(n(),A(Ze,{key:1,indeterminate:"",size:"14",width:"2",class:"mr-1"}))]),_:1},8,["type"])]),_:1}),a(we,{class:"px-4 py-3 import-select-list"},{default:l(()=>[p("div",_l,[a(rt,{modelValue:yt.value,"onUpdate:modelValue":i[8]||(i[8]=o=>yt.value=o),indeterminate:Wa.value&&!yt.value,label:e.$t("App.Catalog.Import.selectAll"),"hide-details":"",density:"compact",color:"secondary",onChange:Sa},null,8,["modelValue","indeterminate","label"]),p("span",{class:ke(["text-xs",vt.value?"text-error":"text-medium-emphasis"])},[h(s(Ee.value)+" / "+s(T.value.length)+" "+s(e.$t("App.Catalog.Import.catalogsSelected"))+" ",1),x.value&&x.value.limit!==-1&&x.value.limit!==1/0?(n(),C(J,{key:0},[h("  · "),p("span",{class:ke(vt.value?"font-bold text-error":"")},s(e.$t("App.Catalog.Import.remainingSlots",{remaining:Math.max(0,x.value.limit-x.value.currentCount)})),3)],64)):$("",!0)],2)]),a(Ve,{class:"mb-2"}),a(pa,{density:"compact",class:"pa-0 bg-transparent flex flex-col gap-2"},{default:l(()=>[(n(!0),C(J,null,re(T.value,(o,y)=>(n(),C("div",{key:y,class:ke(["import-catalog",{"import-catalog--selected":oe.value.has(y)}])},[a(pt,{class:ke(["pr-2 pl-2 py-2",{"opacity-60":Ct(y)}])},{prepend:l(()=>[a(rt,{"model-value":_a(y),indeterminate:La(y),disabled:Ct(y),"hide-details":"",density:"compact",color:"secondary",onChange:k=>qa(y)},null,8,["model-value","indeterminate","disabled","onChange"])]),append:l(()=>[a(D,{variant:"text",size:"x-small",icon:ae.value.has(y)?d(Ut):d(Vt),disabled:!o.questions.length,onClick:Ae(k=>Ea(y),["stop"])},null,8,["icon","disabled","onClick"])]),default:l(()=>[a(_t,{class:"font-semibold text-sm flex items-center gap-2"},{default:l(()=>[p("span",Ll,s(o.name),1),o.aiGenerated?(n(),A(Yt,{key:0})):$("",!0)]),_:2},1024),a(ga,{class:"text-xs"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.questionsSelectedOf",{selected:ht(y),total:o.questions.length}))+"  · "+s(o.languages.join(", ").toUpperCase())+" ",1),Q.value.length>1&&o.sourceFileName?(n(),C(J,{key:0},[h("  · "+s(e.$t("App.Catalog.Import.sourceFile",{file:o.sourceFileName})),1)],64)):$("",!0)]),_:2},1024)]),_:2},1032,["class"]),a(Wt,null,{default:l(()=>[ae.value.has(y)&&o.questions.length?(n(),C("div",Sl,[(n(!0),C(J,null,re(o.questions,(k,K)=>(n(),C(J,{key:K},[a(pt,{density:"compact",class:ke(["import-question text-xs pl-1 pr-2",{"opacity-50":!bt(y,K)}])},{prepend:l(()=>[a(rt,{"model-value":bt(y,K),disabled:!bt(y,K)&&Ct(y),"hide-details":"",density:"compact",color:"secondary",onChange:Qe=>Fa(y,K)},null,8,["model-value","disabled","onChange"])]),append:l(()=>[k.typeName?(n(),A(be,{key:0,size:"x-small",variant:"tonal",class:"ml-2"},{default:l(()=>[h(s(ye(k.typeName)),1)]),_:2},1024)):$("",!0),a(D,{variant:"text",size:"x-small",icon:Nt(y,K)?d(Ut):d(Vt),onClick:Ae(Qe=>Pa(y,K),["stop"])},null,8,["icon","onClick"])]),default:l(()=>[a(_t,{class:"text-xs",style:{"white-space":"normal"}},{default:l(()=>[h(s(Qa(k)),1)]),_:2},1024)]),_:2},1032,["class"]),a(Wt,null,{default:l(()=>[Nt(y,K)?(n(),C("div",ql,[p("div",Fl,[p("span",Pl,s(e.$t("App.Catalog.QuestionForm.expectedLabel")),1),p("span",null,s(k.data?.expected===!1?e.$t("General.no"):e.$t("General.yes")),1),p("span",El,s(e.$t("App.Catalog.QuestionForm.riskLevelLabel")),1),p("span",null,s(d(E)(k.data?.riskLevel)||"â"),1),Se(k.data?.info,o)?(n(),C(J,{key:0},[p("span",Ql,s(e.$t("App.Catalog.QuestionForm.infoLabel")),1),p("span",null,s(Se(k.data?.info,o)),1)],64)):$("",!0),Se(k.data?.onWrong?.info,o)?(n(),C(J,{key:1},[p("span",Tl,s(e.$t("App.Catalog.QuestionForm.onWrongResponse")),1),p("span",null,s(Se(k.data?.onWrong?.info,o)),1)],64)):$("",!0),Se(k.data?.onWrong?.request,o)?(n(),C(J,{key:2},[p("span",Ul,s(e.$t("App.Catalog.newFollowUpQuestion")),1),p("span",null,s(Se(k.data?.onWrong?.request,o)),1)],64)):$("",!0),Se(k.data?.onWrong?.onWrong?.info,o)?(n(),C(J,{key:3},[p("span",Ol,s(e.$t("App.Catalog.Import.followUpReaction")),1),p("span",null,s(Se(k.data?.onWrong?.onWrong?.info,o)),1)],64)):$("",!0)]),k.data?.noteRequired||Bt(k)?(n(),C("div",Rl,[k.data?.noteRequired?(n(),A(be,{key:0,size:"x-small",variant:"tonal"},{default:l(()=>[h(s(e.$t("App.Catalog.QuestionForm.notesLabel")),1)]),_:1})):$("",!0),Bt(k)?(n(),A(be,{key:1,size:"x-small",variant:"tonal",color:"error"},{default:l(()=>[h(s(e.$t("App.Catalog.QuestionForm.workPermissionLabel")),1)]),_:1})):$("",!0)])):$("",!0)])):$("",!0)]),_:2},1024)],64))),128))])):$("",!0)]),_:2},1024)],2))),128))]),_:1})]),_:1})],64)):(n(),A(we,{key:3,class:"px-6 py-5"},{default:l(()=>[p("p",Dl,s(e.$t("App.Catalog.Import.Languages.title")),1),p("p",zl,s(e.$t("App.Catalog.Import.Languages.hint")),1),p("div",Gl,[p("p",Ml,s(e.$t("App.Catalog.Import.Languages.existingLabel")),1),kt.value.length?(n(),C("div",jl,[(n(!0),C(J,null,re(kt.value,o=>
1(n(),A(be,{key:o.code,size:"small",variant:"tonal"},{default:l(()=>[a(it,{"lang-code":o.code,class:"mr-2"},null,8,["lang-code"]),h(" "+s(e.$t(`Languages.${o.code}`))+" ",1),o.count<at.value.length?(n(),C("span",Nl," ("+s(e.$t("App.Catalog.Import.Languages.catalogCount",{count:o.count,total:at.value.length}))+") ",1)):$("",!0)]),_:2},1024))),128))])):(n(),C("p",Bl,s(e.$t("App.Catalog.Import.Languages.noneDetected")),1))]),p("div",Kl,[a(wa,{modelValue:xe.value,"onUpdate:modelValue":i[9]||(i[9]=o=>xe.value=o),label:e.$t("App.Catalog.Import.Languages.targetLabel"),disabled:I.value,"error-messages":xe.value.length?[]:[e.$t("App.Catalog.Import.Languages.targetRequired")]},null,8,["modelValue","label","disabled","error-messages"]),Ht.value.length>1?(n(),A(st,{key:0,modelValue:Be.value,"onUpdate:modelValue":i[10]||(i[10]=o=>Be.value=o),items:Ht.value,label:e.$t("App.Catalog.Import.Languages.sourceLabel"),hint:e.$t("App.Catalog.Import.Languages.sourceHint"),"persistent-hint":"",variant:"outlined",density:"compact",color:"secondary",disabled:I.value},null,8,["modelValue","items","label","hint","disabled"])):$("",!0)]),p("div",Hl,[p("p",Jl,s(e.$t("App.Catalog.Import.Languages.summaryTitle")),1),p("div",Xl,[(n(!0),C(J,null,re(Jt.value,(o,y)=>(n(),C("div",{key:y,class:"rounded-lg import-panel px-3 py-2"},[p("div",Yl,[p("span",Zl,s(o.catalog.name),1),o.catalog.aiGenerated?(n(),A(Yt,{key:0})):$("",!0)]),p("div",en,[(n(!0),C(J,null,re(o.plan.keep,k=>(n(),A(be,{key:`keep-${k}`,size:"x-small",variant:"tonal"},{default:l(()=>[a(it,{"lang-code":k,class:"mr-1"},null,8,["lang-code"]),h(" "+s(k.toUpperCase()),1)]),_:2},1024))),128)),(n(!0),C(J,null,re(o.plan.translate,k=>(n(),A(be,{key:`translate-${k}`,size:"x-small",variant:"tonal",color:"secondary"},{default:l(()=>[a(le,{icon:d(nt),start:"",size:"x-small"},null,8,["icon"]),a(it,{"lang-code":k,class:"mr-1"},null,8,["lang-code"]),h(" "+s(k.toUpperCase()),1)]),_:2},1024))),128)),(n(!0),C(J,null,re(o.plan.remove,k=>(n(),A(be,{key:`remove-${k}`,size:"x-small",variant:"outlined",color:"error"},{default:l(()=>[a(le,{icon:d(Qt),start:"",size:"x-small"},null,8,["icon"]),p("span",tn,s(k.toUpperCase()),1)]),_:2},1024))),128))])]))),128))]),p("div",an,[p("span",on,[a(le,{icon:d(nt),size:"14",color:"secondary"},null,8,["icon"]),h(" "+s(e.$t("App.Catalog.Import.Languages.legendTranslate")),1)]),p("span",ln,[a(le,{icon:d(Qt),size:"14",color:"error"},null,8,["icon"]),h(" "+s(e.$t("App.Catalog.Import.Languages.legendRemove")),1)])])]),Ft.value?(n(),A(fe,{key:0,type:"info",variant:"tonal",density:"compact",class:"mt-4",icon:d(nt)},{default:l(()=>[h(s(e.$t("App.Catalog.Import.Languages.machineTranslationHint")),1)]),_:1},8,["icon"])):$("",!0),tt.value?(n(),A(fe,{key:1,type:"error",variant:"tonal",density:"compact",class:"mt-4"},{default:l(()=>[h(s(e.$t("App.Catalog.Import.Languages.translateError")),1)]),_:1})):$("",!0),I.value?(n(),C("div",nn,[a(Ze,{indeterminate:"",color:"secondary",size:"22",width:"3"}),p("span",sn,s(Ke.value?e.$t("App.Catalog.Import.Languages.translating",Ke.value):e.$t("App.Catalog.Import.Languages.creating")),1)])):$("",!0)]),_:1})),a(Ve),a(ze,{class:"px-6 py-4 gap-2"},{default:l(()=>[c.value==="files"?(n(),C(J,{key:0},[a(D,{variant:"text",onClick:i[11]||(i[11]=o=>V.value=!1)},{default:l(()=>[h(s(e.$t("General.cancel")),1)]),_:1}),a(de),a(D,{color:"secondary",variant:"flat",disabled:!Q.value.length,"prepend-icon":_.value?d(Xe):void 0,onClick:Ia},{default:l(()=>[h(s(_.value?e.$t("App.Catalog.Import.startAi"):e.$t("App.Catalog.Import.start")),1)]),_:1},8,["disabled","prepend-icon"])],64)):c.value==="processing"?(n(),C(J,{key:1},[a(D,{variant:"text",onClick:jt},{default:l(()=>[h(s(Y.value?e.$t("General.cancel"):e.$t("App.Catalog.Import.back")),1)]),_:1}),a(de)],64)):c.value==="select"?(n(),C(J,{key:2},[a(D,{variant:"text",onClick:jt},{default:l(()=>[h(s(e.$t("App.Catalog.Import.back")),1)]),_:1}),a(de),a(D,{color:"secondary",variant:"flat",disabled:Ee.value===0||vt.value,"append-icon":d(uo),onClick:Ta},{default:l(()=>[h(s(e.$t("App.Catalog.Import.Languages.next"))+" ",1),Ee.value>0?(n(),C("span",rn,"("+s(Ee.value)+")",1)):$("",!0)]),_:1},8,["disabled","append-icon"])],64)):(n(),C(J,{key:3},[a(D,{variant:"text",disabled:I.value,onClick:i[12]||(i[12]=o=>c.value="select")},{default:l(()=>[h(s(e.$t("App.Catalog.Import.back")),1)]),_:1},8,["disabled"]),a(de),a(D,{color:"secondary",variant:"flat",disabled:!xe.value.length||I.value,loading:I.value,"prepe
1nd-icon":Ft.value?d(nt):d(Et),onClick:Oa},{default:l(()=>[h(s(Ft.value?e.$t("App.Catalog.Import.Languages.translateAndImport"):e.$t("App.Catalog.Import.import"))+" ",1),Ee.value>0?(n(),C("span",un,"("+s(Ee.value)+")",1)):$("",!0)]),_:1},8,["disabled","loading","prepend-icon"])],64))]),_:1})]),_:1})]),_:1},8,["modelValue","max-width"]))}}),vn=va(fn,[["__scopeId","data-v-37ea2bd7"]]),ua=[30,60,90,120,180,360],mt=(W,u=!1)=>{const m={info:ut(W),infoPhone:"",noteRequired:!1,imageRequired:!1,workPermission:!1,expected:!0,autoInstruction:!1,autoInstructionOnCorrect:!1};return u&&(m.request=ut(W),m.expected=!0,m.alwaysLast=!1,m.onWrong=mt(W)),m},yn=(W,u)=>({typeId:u?.id??"",catalogId:W.id,data:mt(W.languages,!0),order:W.questions?W.questions.length+1:0}),Cn=(W,u)=>({typeId:u?.id??"",data:mt(W,!0),catalogIds:[],catalogs:[],catalogCount:0}),hn={class:"flex items-center justify-between border-b px-2 py-3 mb-5"},bn={class:"flex items-center gap-5"},kn={class:"flex items-center"},wn=We({__name:"CatalogForm",props:{catalog:{type:Object,required:!0},canEditCatalog:{type:Boolean,default:!0},canDeleteCatalog:{type:Boolean,default:!0}},setup(W){const u=W,m=Dt({name:u.catalog?.name??"",languages:u.catalog?.languages??[],folderId:u.catalog?.folderId??null}),v=Pe(),{notifyError:L,notifySuccess:f}=Ue(),{t:R}=Oe(),G=F(()=>[{title:R("App.Catalog.Folders.none"),value:null},...(v.folders??[]).map(U=>({title:U.name,value:U.id}))]);ft(()=>{v.folders===null&&v.fetchFolders().catch(()=>{})});const E=F(()=>!u.catalog?.id),P=F(()=>ho(u.catalog,u.catalog?.questions?.length)),z=w(!1),q=w(!1),j=w(!1),V=F(()=>u.catalog?.active===!1),c=w(!1),t=async()=>{if(u.catalog?.id){c.value=!0;try{const U=V.value;await v.setCatalogActive(u.catalog,U),f(R(U?"App.Catalog.CatalogForm.enableSuccess":"App.Catalog.CatalogForm.disableSuccess"))}catch(U){L(R(se(U,"App.Catalog.CatalogForm.genericToggleError")))}c.value=!1}},N=async()=>{try{let U;u.catalog?.id?U=await v.updateCatalog({...u.catalog,name:m.name,languages:m.languages,folderId:m.folderId}):U=await v.createCatalog(m),f(R("App.Catalog.CatalogForm.saveSuccess")),Q&&(Q.value=U)}catch(U){L(R(se(U,"App.Catalog.CatalogForm.genericSaveError")))}},Z=async()=>{q.value=!0,await N(),q.value=!1},Q=me("selectedCatalog"),Y=()=>{Q&&(Q.value=null)},T=w(!1),M=()=>T.value=!0,oe=()=>T.value=!1,ae=async()=>{j.value=!0;try{await v.deleteCatalog(u.catalog),f(R("App.Catalog.CatalogForm.deleteSuccess")),Q&&(Q.value=null)}catch(U){L(R(se(U,"App.Catalog.CatalogForm.genericDeleteError")))}j.value=!1,oe()};return(U,I)=>(n(),A(ba,{modelValue:z.value,"onUpdate:modelValue":I[4]||(I[4]=x=>z.value=x),class:"flex flex-col gap-3",onSubmit:Ae(Z,["prevent"])},{default:l(()=>[p("div",hn,[It((n(),C("i",{onClick:Y,class:"p-1 rounded-full cursor-pointer"},[a(Ye,{"svg-path":d(ya),class:"text-error"},null,8,["svg-path"])])),[[Gt]]),p("div",bn,[E.value?$("",!0):(n(),A(Re,{key:0,modelValue:T.value,"onUpdate:modelValue":I[0]||(I[0]=x=>T.value=x),"max-width":"500px"},{activator:l(({props:x})=>[a(D,{loading:j.value,variant:"text",onClick:M,disabled:!W.canDeleteCatalog},{default:l(()=>[a(le,{icon:d(ct),color:"error"},null,8,["icon"])]),_:1},8,["loading","disabled"])]),default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h5 text-wrap"},{default:l(()=>[h(s(U.$t("App.Catalog.deleteConfirmText")),1)]),_:1}),a(ze,null,{default:l(()=>[a(de),a(D,{variant:"text",onClick:oe},{default:l(()=>[h(s(U.$t("General.cancel")),1)]),_:1}),a(D,{color:"error",onClick:ae},{default:l(()=>[h(s(U.$t("General.confirm")),1)]),_:1}),a(de)]),_:1})]),_:1})]),_:1},8,["modelValue"])),E.value?$("",!0):(n(),A(D,{key:1,color:V.value?"info":"error",loading:c.value,disabled:!W.canEditCatalog||q.value,onClick:t},{default:l(()=>[h(s(U.$t(V.value?"App.Catalog.CatalogForm.enable":"App.Catalog.CatalogForm.disable")),1)]),_:1},8,["color","loading","disabled"])),a(D,{color:"success",loading:q.value,type:"submit",disabled:!W.canEditCatalog},{default:l(()=>[h(s(U.$t(E.value?"General.create":"General.save")),1)]),_:1},8,["loading","disabled"])])]),!E.value&&V.value?(n(),A(fe,{key:0,type:"warning",variant:"tonal",density:"compact",class:"mb-1"},{default:l(()=>[h(s(U.$t("App.Catalog.CatalogForm.inactiveHint")),1)]),_:1})):$("",!0),p("div",kn,[a(et,{modelValue:m.name,"onUpdate:modelValue":I[1]||(I[
11]=x=>m.name=x),label:U.$t("General.name"),"prepend-inner-icon":d(co),color:"secondary",variant:"outlined","hide-details":"auto",class:"grow"},null,8,["modelValue","label","prepend-inner-icon"]),E.value?$("",!0):(n(),A(bo,{key:0,warnings:P.value},null,8,["warnings"]))]),a(st,{modelValue:m.folderId,"onUpdate:modelValue":I[2]||(I[2]=x=>m.folderId=x),items:G.value,label:U.$t("App.Catalog.Folders.label"),color:"secondary","prepend-inner-icon":d(zt),variant:"outlined","hide-details":"auto"},null,8,["modelValue","items","label","prepend-inner-icon"]),a(wa,{modelValue:m.languages,"onUpdate:modelValue":I[3]||(I[3]=x=>m.languages=x),"bg-color":"white"},null,8,["modelValue"])]),_:1},8,["modelValue"]))}}),An=new Set(["bg","hr","cs","da","nl","en","et","fi","fr","de","el","hu","ga","it","lv","lt","mt","pl","pt","ro","sk","sl","es","sv"]),$n={typeId:"App.Catalog.QuestionForm.typeLabel",request:"App.Catalog.QuestionForm.requestLabel",info:"App.Catalog.QuestionForm.infoLabel",infoPhone:"App.Catalog.QuestionForm.infoPhoneLabel",expected:"App.Catalog.QuestionForm.expectedLabel",noteRequired:"App.Catalog.QuestionForm.notesLabel",imageRequired:"App.Catalog.QuestionForm.imageRequiredLabel",workPermission:"App.Catalog.QuestionForm.workPermissionLabel",autoInstruction:"App.Catalog.QuestionForm.autoInstructionLabel",onWrong:"App.Catalog.QuestionForm.onWrongResponse"},xn=W=>W.match(/"([^"]+)"/)?.[1]??null,In=W=>/is required/i.test(W)?"validationFieldRequired":/is not allowed to be empty/i.test(W)?"validationFieldEmpty":/must have at least \d+ key/i.test(W)?"validationFieldMinKeys":"validationFieldInvalid",Vn=(W,u)=>{const v=W.replace(/\[(\d+)]/g,".$1").split(".").filter(Boolean),L=v[v.length-1]?.toLowerCase();let f;L&&An.has(L)&&(f=L,v.pop());const R=v.filter(z=>z==="onWrong").length,G=v[v.length-1]??W,E=$n[G];let P=E?u(E):W;return R>0&&G!=="onWrong"&&(P=`${u(G==="request"?"App.Catalog.newFollowUpQuestion":"App.Catalog.QuestionForm.onWrongResponse")}: ${P}`),f&&(P=`${P} (${u(`Languages.${f}`)})`),P};function Wn(W,u){if(!po(W))return null;const m=W.response?.data?.code,v=String(W.response?.data?.message??"").trim();if(m!=="ValidationException")return null;if(!v)return u("App.Catalog.QuestionForm.validationGeneric");const L=xn(v);if(!L)return v;const f=Vn(L,u),R=In(v);return u(`App.Catalog.QuestionForm.${R}`,{field:f})}const _n={class:"flex justify-between items-center border-b px-2 py-3 mb-5"},Ln={class:"flex items-center gap-5"},Sn={key:0,class:"flex flex-col gap-2 px-2 -mt-3 mb-3"},qn={class:"flex items-center gap-1.5 flex-wrap"},Fn={class:"text-xs text-light-text"},Pn={class:"flex flex-wrap items-center gap-2"},En={class:"flex flex-col gap-8"},Qn={class:"text-lg font-semibold"},Tn={key:1,class:"flex flex-col gap-1"},Un={key:0,class:"text-xs text-light-text pl-1"},On={class:"text-lg font-semibold"},Rn={key:3,class:"px-4 py-6 bg-background rounded-xl flex flex-col gap-8"},Dn={class:"text-lg font-semibold"},zn={key:2,class:"flex justify-end"},Gn={class:"w-full flex justify-between items-center"},Mn={class:"flex items-center gap-3"},jn={class:"text-lg font-semibold"},Nn={key:0,class:"text-xs text-light-text"},Bn={class:"flex flex-col gap-8"},Kn={class:"text-lg font-semibold"},Hn={key:2,class:"px-4 py-6 bg-background rounded-xl flex flex-col gap-3"},Jn={class:"flex justify-between items-center"},Xn={class:"text-lg font-semibold"},Yn=We({__name:"QuestionFormLimited",props:{question:{type:Object,required:!0}},setup(W){const u=W,m=Pe(),{notifyError:v,notifySuccess:L}=Ue(),{t:f,te:R}=Oe(),G=me("selectedQuestion"),E=me("selectedCatalog"),P=me("questionPoolVersion",w(0)),z=F(()=>!u.question.catalogId),q=F(()=>{if(u.question.catalogId)return E?.value?.id===u.question.catalogId?E.value:m.getCatalogById(u.question.catalogId)??m.assignableCatalogs?.find(r=>r.id===u.question.catalogId)}),j=F(()=>u.question.catalogs??[]),V=F(()=>u.question.catalogCount??j.value.length),c=F(()=>{if(q.value?.languages?.length)return q.value.languages;const r=new Set;if(j.value.forEach(pe=>pe.languages?.forEach(Le=>r.add(Le))),r.size)return[...r];const g=new Set;if(m.assignableCatalogs?.forEach(pe=>pe.languages?.forEach(Le=>g.add(Le))),g.size)return[...g];const b=Object.keys(u.question.data?.request??{});return b.length?b:[Te.DE]}),t=Dt({typeId:u.question?.typeId??m.questionTypes?.[0]?.id??"",request:u.question?.data?.request??void 0,infoPhone:u.question?.data?.infoPhone??"",expected:u.question?.data?.expected??void 0,noteRequired:u.question?.data?.noteRequired??!1,workPermission:u.question?.data?.workPermission??!1,riskLevel:u.question?.data?.riskLevel??void 0,alwaysLast:u.question?.data?.alwaysLast??!1,onWrong:u.question?.data?.onWrong??mt(c.value)}),N=F(()=>[{value:!0,title:f("General.yes")},{value:!1,title:f("General.no")}]),Z=F(()=>[{value:!1,title:f("General.yes")},{value:!0,title:f("General.no")}]),{options:Q,ensureLevels:Y}=Mt(),T=F(()=>ua.map(r=>({value:r,title:f("App.Catalog.QuestionForm.autoInstructionIntervalDays",{days:r})}))),M=F(()=>!!t.onWrong?.request),oe=F(()=>M.value||!!t.alwaysLast),ae=F(()=>t.alwaysLast?f("App.Catalog.QuestionForm.alwaysLastForcesWorkStopHint"):f("App.Catalog.QuestionForm.workPermissionFollowUpTooltip")),U=w(M.value?0:void 0),I=F(()=>!u.question?.id),x=w(!1),B=w(!1),ce=w(!1),ee=r=>{const g=`General.QuestionTypes.${r.name}`;return R(g)?f(g):r.name},ie=F(()=>m.questionTypes?.map(r=>
1({value:r.id,title:ee(r)})));ue(()=>m.questionTypes,r=>{!t.typeId&&r&&r.length&&(t.typeId=r[0].id)});const ve=()=>{t.onWrong&&(t.onWrong.request=ut(c.value),t.onWrong.expected=!0,ge())},ye=()=>{t.onWrong&&(t.onWrong.request=void 0,t.onWrong.expected=void 0,t.onWrong.onWrong=void 0,t.onWrong.workPermission=!1)},ge=()=>{t.onWrong&&!t.onWrong.onWrong&&(t.onWrong.onWrong=mt(c.value))};ue([M,()=>t.alwaysLast],([r])=>{t.alwaysLast?(t.workPermission!==!1&&(t.workPermission=!1),t.onWrong&&t.onWrong.workPermission!==!1&&(t.onWrong.workPermission=!1)):r&&t.workPermission!==!0&&(t.workPermission=!0),U.value=r?0:void 0},{immediate:!0}),ue(()=>t.onWrong?.autoInstructionOnCorrect,r=>{r&&t.onWrong&&!t.onWrong.autoInstructionInterval&&(t.onWrong.autoInstructionInterval=ua[0])}),ue(()=>t.onWrong?.autoInstruction,r=>{!r&&t.onWrong&&(t.onWrong.autoInstructionOnCorrect=!1)});const _e=()=>{G&&(G.value=null)},$e=()=>{const r=u.question?.id?{...u.question}:{typeId:t.typeId,data:{}};if(r.typeId=t.typeId,t.request&&!Object.keys(t.request).every(g=>t.request?.[g]==="")&&(r.data.request=t.request),t.infoPhone&&t.infoPhone!==""&&(r.data.infoPhone=t.infoPhone),t.expected!==void 0&&(r.data.expected=t.expected),t.noteRequired!==void 0&&(r.data.noteRequired=t.noteRequired),t.workPermission!==void 0&&(r.data.workPermission=t.workPermission),t.riskLevel&&(r.data.riskLevel=t.riskLevel),t.alwaysLast!==void 0&&(r.data.alwaysLast=t.alwaysLast),t.onWrong&&(t.onWrong.request||t.onWrong.info)){r.data.onWrong={},t.onWrong?.info&&!Object.keys(t.onWrong.info).every(b=>t.onWrong?.info?.[b]==="")&&(r.data.onWrong.info=t.onWrong?.info);const g=!!t.onWrong.request&&!Object.keys(t.onWrong.request).every(b=>t.onWrong?.request?.[b]==="");g&&(r.data.onWrong.request=t.onWrong?.request),t.onWrong?.infoPhone&&t.onWrong?.infoPhone!==""&&(r.data.onWrong.infoPhone=t.onWrong.infoPhone),g&&t.onWrong.expected!==void 0&&(r.data.onWrong.expected=t.onWrong.expected),t.onWrong.noteRequired!==void 0&&(r.data.onWrong.noteRequired=t.onWrong.noteRequired),t.onWrong.imageRequired!==void 0&&(r.data.onWrong.imageRequired=t.onWrong.imageRequired),t.onWrong.autoInstruction!==void 0&&(r.data.onWrong.autoInstruction=t.onWrong.autoInstruction),t.onWrong.autoInstructionOnCorrect!==void 0&&(r.data.onWrong.autoInstructionOnCorrect=t.onWrong.autoInstructionOnCorrect),t.onWrong.autoInstructionOnCorrect&&t.onWrong.autoInstructionInterval&&(r.data.onWrong.autoInstructionInterval=t.onWrong.autoInstructionInterval),g&&t.onWrong.workPermission!==void 0&&(r.data.onWrong.workPermission=t.onWrong.workPermission),g&&t.onWrong.onWrong&&(t.onWrong.onWrong.request||t.onWrong.onWrong.info)&&(r.data.onWrong.onWrong={},t.onWrong&&t.onWrong.onWrong?.info&&!Object.keys(t.onWrong.onWrong?.info).every(b=>t.onWrong.onWrong.info?.[b]==="")&&(r.data.onWrong.onWrong.info=t.onWrong.onWrong.info),t.onWrong.onWrong?.infoPhone&&t.onWrong.onWrong.infoPhone!==""&&(r.data.onWrong.onWrong.infoPhone=t.onWrong.onWrong.infoPhone),t.onWrong.onWrong?.noteRequired!==void 0&&(r.data.onWrong.onWrong.noteRequired=t.onWrong.onWrong.noteRequired),t.onWrong.onWrong?.imageRequired!==void 0&&(r.data.onWrong.onWrong.imageRequired=t.onWrong.onWrong.imageRequired),t.onWrong.onWrong?.autoInstruction!==void 0&&(r.data.onWrong.onWrong.autoInstruction=t.onWrong.onWrong.autoInstruction))}return r},_=async()=>{if(!(!z.value&&!q.value)){B.value=!0;try{let r;await St();const g=$e();u.question?.aiGenerated&&(g.aiGenerated=!1),z.value?r=u.question?.id?await m.updatePoolQuestion({...u.question,...g}):await m.createPoolQuestion(g):u.question?.id?r=await m.updateQuestion(q.value,g):r=await m.createQuestion(q.value,g),L(f("App.Catalog.CatalogForm.saveSuccess")),P.value++,G&&(G.value=r)}catch(r){const g=Wn(r,f);v(g??f(se(r,"App.Catalog.CatalogForm.genericSaveError")))}B.value=!1}},O=w(!1),X=async()=>{if(q.value){O.value=!0;try{await m.removeQuestionsFromCatalog(q.value,[u.question.id]),L(f("App.Catalog.Pool.removeFromCatalogSuccess",{count:1})),P.value++,G&&(G.value=null)}catch(r){v(f(se(r,"App.Catalog.Pool.assignGenericError")))}O.value=!1}},ne=w(!1),S=async()=>{ne.value=!0;try{const r=q.value?.id?[q.value.id]:[],g=await m.duplicateQuestion(u.question,r);q.value?.id&&(await m.removeQuestionsFromCatalog(q.value,[u.question.id]),await m.fetchQuestions(q.value)),L(f("App.Catalog.Pool.duplicateSuccess")),P.value++,G&&(G.value=q.value?.id?{...g,catalogId:q.value.id}:g)}catch(r){v(f(se(r,"App.Catalog.Pool.duplicateGenericError")))}ne.value=!1},H=w(!1),te=()=>H.value=!0,Me=()=>H.value=!1,Lt=async()=>
1{if(!(!z.value&&!q.value)){ce.value=!0;try{z.value?await m.deleteQuestions([u.question.id]):await m.deleteQuestion(q.value,u.question),L(f("App.Catalog.CatalogForm.deleteSuccess")),P.value++,G&&(G.value=null)}catch(r){v(f(se(r,"App.Catalog.CatalogForm.genericDeleteError")))}ce.value=!1,Me()}};ft(()=>{t.onWrong?.info||(t.onWrong.info=ut(c.value)),t.onWrong?.onWrong&&!t.onWrong.onWrong?.info&&(t.onWrong.onWrong.info=ut(c.value)),Y().catch(()=>{})});async function St(){const r=c.value,g=async b=>{if(!b)return b;const pe=r.find(Ce=>!!b[Ce]&&String(b[Ce]).trim()!=="");if(!pe)return b;const Le=r.filter(Ce=>!b[Ce]||String(b[Ce]).trim()==="");if(Le.length===0)return b;try{const Ce=await m.translateText(pe,Le,b[pe]),je={...b};return Ce.translations.forEach(Ne=>{(!je[Ne.to]||String(je[Ne.to]).trim()==="")&&(je[Ne.to]=Ne.text)}),je}catch{return b}};t.request&&(t.request=await g(t.request)),t.onWrong&&(t.onWrong.info&&(t.onWrong.info=await g(t.onWrong.info)),t.onWrong.request&&(t.onWrong.request=await g(t.onWrong.request)),t.onWrong.onWrong&&t.onWrong.onWrong.info&&(t.onWrong.onWrong.info=await g(t.onWrong.onWrong.info)))}return(r,g)=>(n(),A(ba,{modelValue:x.value,"onUpdate:modelValue":g[23]||(g[23]=b=>x.value=b),class:"flex flex-col gap-3 pb-6",onSubmit:Ae(_,["prevent"])},{default:l(()=>[p("div",_n,[It((n(),C("i",{onClick:_e,class:"p-1 rounded-full cursor-pointer"},[a(Ye,{"svg-path":d(ya),class:"text-error"},null,8,["svg-path"])])),[[Gt]]),p("div",Ln,[I.value?$("",!0):(n(),A(Re,{key:0,modelValue:H.value,"onUpdate:modelValue":g[0]||(g[0]=b=>H.value=b),"max-width":"500px"},{activator:l(({props:b})=>[a(D,{loading:ce.value,variant:"text"},{default:l(()=>[a(le,{icon:d(ct),color:"error",onClick:te},null,8,["icon"])]),_:1},8,["loading"])]),default:l(()=>[a(Ge,null,{default:l(()=>[a(De,{class:"text-h5 text-wrap"},{default:l(()=>[h(s(r.$t("App.Catalog.deleteQuestionConfirmText")),1)]),_:1}),a(ze,null,{default:l(()=>[a(de),a(D,{variant:"text",onClick:Me},{default:l(()=>[h(s(r.$t("General.cancel")),1)]),_:1}),a(D,{color:"error",onClick:Lt},{default:l(()=>[h(s(r.$t("General.confirm")),1)]),_:1}),a(de)]),_:1})]),_:1})]),_:1},8,["modelValue"])),a(D,{color:"success",loading:B.value,disabled:B.value,type:"submit"},{default:l(()=>[h(s(r.$t(I.value?"General.create":"App.Catalog.QuestionForm.save")),1)]),_:1},8,["loading","disabled"])])]),I.value?$("",!0):(n(),C("div",Sn,[W.question.aiGenerated?(n(),A(fe,{key:0,type:"warning",variant:"tonal",density:"compact",class:"text-sm",icon:d(Xe)},{default:l(()=>[h(s(r.$t("App.Catalog.Ai.formHint")),1)]),_:1},8,["icon"])):$("",!0),p("div",qn,[p("span",Fn,s(r.$t("App.Catalog.Pool.assignedCatalogsLabel")),1),(n(!0),C(J,null,re(j.value,b=>(n(),A(be,{key:b.id,size:"x-small",variant:"tonal",color:"blue-grey"},{default:l(()=>[h(s(b.name),1)]),_:2},1024))),128)),j.value.length?$("",!0):(n(),A(be,{key:0,size:"x-small",variant:"tonal",color:"warning"},{default:l(()=>[h(s(r.$t("App.Catalog.Pool.unassignedChip")),1)]),_:1}))]),V.value>1?(n(),A(fe,{key:1,type:"info",variant:"tonal",density:"compact",class:"text-sm"},{default:l(()=>[h(s(r.$t("App.Catalog.Pool.sharedEditHint",{count:V.value})),1)]),_:1})):$("",!0),p("div",Pn,[a(D,{size:"x-small",variant:"text","prepend-icon":d(go),loading:ne.value,onClick:S},{default:l(()=>[h(s(q.value?r.$t("App.Catalog.Pool.duplicateForCatalogAction"):r.$t("App.Catalog.Pool.duplicateAction")),1)]),_:1},8,["prepend-icon","loading"]),q.value?(n(),A(D,{key:0,size:"x-small",variant:"text","prepend-icon":d(da),loading:O.value,onClick:X},{default:l(()=>[h(s(r.$t("App.Catalog.Pool.removeFromCatalogAction")),1)]),_:1},8,["prepend-icon","loading"])):$("",!0)])])),p("div",En,[p("span",Qn,s(r.$t("App.Catalog.newQuestion")),1),a(Fe,{modelValue:t.typeId,"onUpdate:modelValue":g[1]||(g[1]=b=>t.typeId=b),items:ie.value,label:r.$t("App.Catalog.QuestionForm.typeLabel"),color:"secondary","prepend-inner-icon":d(lt),rules:[d(ko)],variant:"outlined","hide-details":"auto",required:""},null,8,["modelValue","items","label","prepend-inner-icon","rules"]),a(Fe,{modelValue:t.riskLevel,"onUpdate:modelValue":g[2]||(g[2]=b=>t.riskLevel=b),items:d(Q),label:r.$t("App.Catalog.QuestionForm.riskLevelLabel"),color:"secondary","prepe
1nd-inner-icon":d(fa),variant:"outlined","hide-details":"auto",clearable:""},null,8,["modelValue","items","label","prepend-inner-icon"]),t.request?(n(),A(wt,{key:0,modelValue:t.request,"onUpdate:modelValue":g[3]||(g[3]=b=>t.request=b),languages:c.value,rules:[d(At)(c.value,t.request)],label:r.$t("App.Catalog.QuestionForm.requestLabel"),icon:d(lt),color:"secondary",variant:"outlined","hide-details":"auto"},null,8,["modelValue","languages","rules","label","icon"])):$("",!0),t.request?(n(),C("div",Tn,[a(he,{modelValue:t.alwaysLast,"onUpdate:modelValue":g[4]||(g[4]=b=>t.alwaysLast=b),label:r.$t("App.Catalog.QuestionForm.alwaysLastLabel")},null,8,["modelValue","label"]),t.alwaysLast?(n(),C("span",Un,s(r.$t("App.Catalog.QuestionForm.alwaysLastForcesWorkStopHint")),1)):$("",!0)])):$("",!0),t.request?(n(),A(Fe,{key:2,modelValue:t.expected,"onUpdate:modelValue":g[5]||(g[5]=b=>t.expected=b),items:N.value,label:r.$t("App.Catalog.QuestionForm.expectedLabel"),color:"secondary","prepend-inner-icon":d(lt),variant:"outlined","hide-details":"auto"},null,8,["modelValue","items","label","prepend-inner-icon"])):$("",!0),a(Ve,{class:"question-form-divider",thickness:"1"}),p("span",On,s(r.$t("App.Catalog.QuestionForm.onWrongResponse")),1),a(gt,{disabled:!oe.value,text:ae.value},{activator:l(({props:b})=>[p("div",dt(b,{class:"w-full"}),[a(Fe,{modelValue:t.workPermission,"onUpdate:modelValue":g[6]||(g[6]=pe=>t.workPermission=pe),languages:c.value,items:Z.value,label:r.$t("App.Catalog.QuestionForm.workPermissionLabel"),color:"secondary","prepend-inner-icon":d(Ot),variant:"outlined","hide-details":"auto",disabled:oe.value},null,8,["modelValue","languages","items","label","prepend-inner-icon","disabled"])],16)]),_:1},8,["disabled","text"]),t.onWrong?(n(),C("div",Rn,[p("span",Dn,s(r.$t("App.Catalog.QuestionForm.reaction")),1),a(et,{modelValue:t.onWrong.infoPhone,"onUpdate:modelValue":g[7]||(g[7]=b=>t.onWrong.infoPhone=b),label:r.$t("App.Catalog.QuestionForm.infoPhoneLabel"),type:"text",color:"secondary","prepend-inner-icon":d(aa),variant:"outlined","hide-details":"auto","bg-color":"white"},null,8,["modelValue","label","prepend-inner-icon"]),a(he,{modelValue:t.onWrong.noteRequired,"onUpdate:modelValue":g[8]||(g[8]=b=>t.onWrong.noteRequired=b),label:r.$t("App.Catalog.QuestionForm.notesLabel")},null,8,["modelValue","label"]),a(he,{modelValue:t.onWrong.imageRequired,"onUpdate:modelValue":g[9]||(g[9]=b=>t.onWrong.imageRequired=b),label:r.$t("App.Catalog.QuestionForm.imageRequiredLabel")},null,8,["modelValue","label"]),a(he,{modelValue:t.onWrong.autoInstruction,"onUpdate:modelValue":g[10]||(g[10]=b=>t.onWrong.autoInstruction=b),label:r.$t("App.Catalog.QuestionForm.autoInstructionLabel")},null,8,["modelValue","label"]),a(he,{modelValue:t.onWrong.autoInstructionOnCorrect,"onUpdate:modelValue":g[11]||(g[11]=b=>t.onWrong.autoInstructionOnCorrect=b),label:r.$t("App.Catalog.QuestionForm.autoInstructionOnCorrectLabel"),disabled:!t.onWrong.autoInstruction},null,8,["modelValue","label","disabled"]),t.onWrong.autoInstructionOnCorrect?(n(),A(Fe,{key:0,modelValue:t.onWrong.autoInstructionInterval,"onUpdate:modelValue":g[12]||(g[12]=b=>t.onWrong.autoInstructionInterval=b),items:T.value,label:r.$t("App.Catalog.QuestionForm.autoInstructionIntervalLabel"),color:"secondary","prepend-inner-icon":d(mo),variant:"outlined","hide-details":"auto","bg-color":"white"},null,8,["modelValue","items","label","prepend-inner-icon"])):$("",!0),t.onWrong.info?(n(),A(wt,{key:1,modelValue:t.onWrong.info,"onUpdate:modelValue":g[13]||(g[13]=b=>t.onWrong.info=b),languages:c.value,rules:[d(At)(c.value,t.onWrong.info)],label:r.$t("App.Catalog.QuestionForm.infoLabel"),icon:d(oa),color:"secondary",variant:"outlined","hide-details":"auto","input-class":"bg-white"},null,8,["modelValue","languages","rules","label","icon"])):$("",!0),a(Ve,{class:"question-form-divider",thickness:"1"}),t.onWrong.request?$("",!0):(n(),C("div",zn,[a(D,{onClick:ve,color:"secondary",variant:"elevated",style:{"background-image":"linear-gradient(45deg,#d73625,#F78361)!important"}},{default:l(()=>[a(le,{icon:d(xt)},null,8,["icon"]),h(" "+s(r.$t("App.Catalog.QuestionForm.addFollowUpQuestion")),1)]),_:1})])),t.onWrong.request?(n(),A(ha,{key:3,modelValue:U.value,"onUpdate:modelValue":g[22]||(g[22]=b=>U.value=b)},{default:l(()=>[a(vo,{class:"expansion-no-shadow"},{default:l(()=>[a(yo,null,{default:l(({expanded:b})=>[p("div",Gn,[p("div",Mn,[p("span",jn,s(r.$t("App.Catalog.newFollowUpQuestion")),1),b?$("",!0):(n(),C("span",Nn,s(r.$t("App.Catalog.QuestionForm.followUpQuestionCollapsedHint")),1))]),a(le,{icon:d(ct),color:"error",onClick:ye},null,8,["icon"])])]),_:1}),a(Co,null,{default:l(()=>[p("div",Bn,[t.onWrong.request?(n(),A(wt,{key:0,modelValue:t.onWrong.request,"onUpdate:modelValue":g[14]||(g[14]=b=>t.onWrong.request=b),languages:c.value,rules:[d(At)(c.value,t.onWrong.request)],label:r.$t("App.Catalog.QuestionForm.requestLabel"),icon:d(lt),color:"secondary",variant:"outlined","hide-details":"auto","input-class":"bg-white"},null,8,["modelValue","languages","rules","label","icon"])):$("",!0),t.onWrong.request?(n(),A(Fe,{key:1,modelValue:t.onWrong.expected,"onUpdate:modelValue":g[15]||(g[15]=b=>t.onWrong.expected=b),items:N.value,label:r.$t("App.Catalog.QuestionForm.expectedLabel"),color:"secondary","prepe
1nd-inner-icon":d(lt),variant:"outlined","hide-details":"auto","bg-color":"white"},null,8,["modelValue","items","label","prepend-inner-icon"])):$("",!0),a(Ve,{class:"question-form-divider",thickness:"1"}),p("span",Kn,s(r.$t("App.Catalog.QuestionForm.onWrongResponse")),1),a(gt,{disabled:!t.alwaysLast,text:r.$t("App.Catalog.QuestionForm.alwaysLastForcesWorkStopHint")},{activator:l(({props:b})=>[p("div",dt(b,{class:"w-full"}),[t.onWrong.request?(n(),A(Fe,{key:0,modelValue:t.onWrong.workPermission,"onUpdate:modelValue":g[16]||(g[16]=pe=>t.onWrong.workPermission=pe),items:Z.value,label:r.$t("App.Catalog.QuestionForm.workPermissionLabel"),color:"secondary","prepend-inner-icon":d(Ot),variant:"outlined","hide-details":"auto","bg-color":"white",disabled:!!t.alwaysLast},null,8,["modelValue","items","label","prepend-inner-icon","disabled"])):$("",!0)],16)]),_:1},8,["disabled","text"]),t.onWrong.onWrong?(n(),C("div",Hn,[p("div",Jn,[p("span",Xn,s(r.$t("App.Catalog.QuestionForm.reaction")),1)]),a(et,{modelValue:t.onWrong.onWrong.infoPhone,"onUpdate:modelValue":g[17]||(g[17]=b=>t.onWrong.onWrong.infoPhone=b),label:r.$t("App.Catalog.QuestionForm.infoPhoneLabel"),type:"text",color:"secondary","prepend-inner-icon":d(aa),variant:"outlined","hide-details":"auto","bg-color":"white"},null,8,["modelValue","label","prepend-inner-icon"]),a(he,{modelValue:t.onWrong.onWrong.noteRequired,"onUpdate:modelValue":g[18]||(g[18]=b=>t.onWrong.onWrong.noteRequired=b),label:r.$t("App.Catalog.QuestionForm.notesLabel")},null,8,["modelValue","label"]),a(he,{modelValue:t.onWrong.onWrong.imageRequired,"onUpdate:modelValue":g[19]||(g[19]=b=>t.onWrong.onWrong.imageRequired=b),label:r.$t("App.Catalog.QuestionForm.imageRequiredLabel")},null,8,["modelValue","label"]),a(he,{modelValue:t.onWrong.onWrong.autoInstruction,"onUpdate:modelValue":g[20]||(g[20]=b=>t.onWrong.onWrong.autoInstruction=b),label:r.$t("App.Catalog.QuestionForm.autoInstructionLabel")},null,8,["modelValue","label"]),t.onWrong.onWrong.info?(n(),A(wt,{key:0,modelValue:t.onWrong.onWrong.info,"onUpdate:modelValue":g[21]||(g[21]=b=>t.onWrong.onWrong.info=b),languages:c.value,rules:[d(At)(c.value,t.onWrong.onWrong.info)],label:r.$t("App.Catalog.QuestionForm.infoLabel"),icon:d(oa),color:"secondary",variant:"outlined","hide-details":"auto","input-class":"bg-white"},null,8,["modelValue","languages","rules","label","icon"])):$("",!0)])):$("",!0)])]),_:1})]),_:1})]),_:1},8,["modelValue"])):$("",!0)])):$("",!0)])]),_:1},8,["modelValue"]))}}),Zn={class:"flex flex-col gap-4"},es={class:"flex items-center justify-between border-b px-2 py-3 mb-2"},ts={class:"flex justify-between w-full"},as={class:"flex items-center gap-3"},os={class:"text-xs text-light-text"},ls=We({__name:"Catalog",setup(W){const u=ma(),m=Pe(),{notifyError:v,notifySuccess:L}=Ue(),{t:f}=Oe(),R=w(!0),G=w(!1),E=w(null);qe("selectedCatalog",E);const P=w(null);qe("selectedQuestion",P);const z=w("");qe("catalogSearch",z);const q=w("");qe("questionSearch",q);const j=w("catalogs"),V=w(0);qe("questionPoolVersion",V),ue(j,()=>{P.value=null,E.value=null});const c=w(!1);ue([P,E],([I,x],[B,ce])=>setTimeout(()=>G.value=!!(I??x),I??x?0:300));const t=()=>{E.value={name:""}},N=F(()=>m.questionTypes?.[0]),Z=I=>P.value=yn(I,N.value),Q=F(()=>{const I=new Set;return m.assignableCatalogs?.forEach(x=>x.languages?.forEach(B=>I.add(B))),I.size?[...I]:[Te.DE]}),Y=async()=>{try{await m.fetchAssignableCatalogs()}catch(I){v(f(se(I,"App.Catalog.tableGenericLoadingError")))}P.value=Cn(Q.value,N.value)};qe("saveQuestionOrder",async()=>{if(!(!E.value||!E.value.id))try{const I=E.value.questions?E.value:m.getCatalogById(E.value.id);if(!I||!I.questions)return;const x=[...I.questions].sort((B,ce)=>(B.data?.alwaysLast?1:0)-(ce.data?.alwaysLast?1:0));I.questions=x,await m.saveQuestionOrder(I,x.map(B=>B.id)),L(f("App.Catalog.questionChangeOrderSuccess"))}catch(I){v(f(se(I,"App.Catalog.questionChangeOrderGenericError")))}}),ft(async()=>{R.value=!0;try{oe.value=await u.hasPermission("professional","can_create_catalogs","operational supervisor"),oe.value&&(M.value=await u.isLimitReached("catalog"))}catch(I){v(f(se(I,"App.rolesRights.permissionCheckError")))}try{ae.value=await u.hasPermission("basic_plus","can_edit_catalogs","operational supervisor")}catch(I){v(f(se(I,"App.rolesRights.permissionCheckError")))}try{U.value=await u.hasPermission("professional","can_delete_catalogs","operational supervisor")}catch(I){v(f(se(I,"App.rolesRights.permissionCheckError")))}R.value=!1});const M=w(!1),oe=w(!1),ae=w(!1),U=w(!1);return qe("canEditCatalog",ae),qe("canDeleteCatalog",U),(I,x)=>(n(),C("div",Zn,[a(Ka),p("div",{class:ke(["grid grid-cols-1 gap-4",{"md:grid-cols-2":G.value}])},[a(Xt,null,{default:l(()=>[a(wo,{modelValue:j.value,"onUpdate:modelValue":x[0]||(x[0]=B=>j.value=B),color:"secondary",density:"compact",class:"border-b"},{default:l(()=>[a(ia,{value:"catalogs"},{default:l(()=>
1[h(s(I.$t("App.Catalog.Tabs.catalogs")),1)]),_:1}),a(ia,{value:"questions"},{default:l(()=>[h(s(I.$t("App.Catalog.Tabs.questions")),1)]),_:1})]),_:1},8,["modelValue"]),p("div",es,[p("div",ts,[p("div",as,[j.value==="catalogs"?(n(),C(J,{key:0},[a(D,{color:"secondary",style:{"background-image":"linear-gradient(64deg,#d73625,#F78361)!important"},disabled:!oe.value||!!M.value||!!E.value,prependIcon:d(xt),"data-tour":"catalog-new",onClick:t},{default:l(()=>[h(s(I.$t("App.Catalog.newCatalog")),1)]),_:1},8,["disabled","prependIcon"]),a(D,{color:"secondary",style:{"background-image":"linear-gradient(64deg,#d73625,#F78361)!important"},disabled:!E.value||!E.value?.id||!!P.value,prependIcon:d(xt),onClick:x[1]||(x[1]=B=>Z(E.value))},{default:l(()=>[h(s(I.$t("App.Catalog.newQuestion")),1)]),_:1},8,["disabled","prependIcon"]),ae.value?(n(),A(D,{key:0,variant:"text",size:"small","prepend-icon":d(fo),"data-tour":"catalog-folder-new",onClick:x[2]||(x[2]=B=>c.value=!0)},{default:l(()=>[h(s(I.$t("App.Catalog.Folders.new")),1)]),_:1},8,["prepend-icon"])):$("",!0),oe.value?(n(),A(No,{key:1})):$("",!0),oe.value?(n(),A(vn,{key:2})):$("",!0)],64)):(n(),C(J,{key:1},[a(D,{color:"secondary",style:{"background-image":"linear-gradient(64deg,#d73625,#F78361)!important"},disabled:!oe.value||!!P.value,prependIcon:d(xt),onClick:Y},{default:l(()=>[h(s(I.$t("App.Catalog.Pool.newQuestion")),1)]),_:1},8,["disabled","prependIcon"]),p("span",os,s(I.$t("App.Catalog.Pool.tabHint")),1)],64))]),j.value==="catalogs"&&!E.value&&!P.value?(n(),A(et,{key:0,modelValue:z.value,"onUpdate:modelValue":x[3]||(x[3]=B=>z.value=B),label:I.$t("General.search"),"prepend-inner-icon":d(la),variant:"outlined",density:"compact",color:"secondary",flat:"","hide-details":"",style:{"max-width":"320px"}},null,8,["modelValue","label","prepend-inner-icon"])):j.value==="questions"?(n(),A(et,{key:1,modelValue:q.value,"onUpdate:modelValue":x[4]||(x[4]=B=>q.value=B),label:I.$t("General.search"),"prepend-inner-icon":d(la),variant:"outlined",density:"compact",color:"secondary",flat:"","hide-details":"",style:{"max-width":"320px"}},null,8,["modelValue","label","prepend-inner-icon"])):$("",!0)])]),j.value==="catalogs"?(n(),A(So,{key:0,class:"max-h-64 md:max-h-max overflow-auto","data-tour":"catalog-list"})):(n(),A(Do,{key:1,class:"max-h-64 md:max-h-max overflow-auto"}))]),_:1}),a(Ba,{"enter-from-class":"opacity-0 transform translate-x-10","enter-active-class":"transition-all duration-300 ease-in","enter-to-class":"opacity-100","leave-active-class":"transition-all translate-x-10 duration-300 ease-out","leave-to-class":"opacity-0"},{default:l(()=>[P.value||E.value?(n(),A(Xt,{key:0,class:"catalog-detail-panel sticky top-16 self-start"},{default:l(()=>[P.value?(n(),A(Yn,{question:P.value,key:P.value?.id},null,8,["question"])):E.value?(n(),A(wn,{catalog:E.value,key:E.value?.id,"can-edit-catalog":ae.value,"can-delete-catalog":U.value},null,8,["catalog","can-edit-catalog","can-delete-catalog"])):$("",!0)]),_:1})):$("",!0)]),_:1}),a(ka,{modelValue:c.value,"onUpdate:modelValue":x[5]||(x[5]=B=>c.value=B)},null,8,["modelValue"])],2)]))}}),Os=va(ls,[["__scopeId","data-v-dea58240"]]);export{Os as default};
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.