"use strict";(this.webpackChunk_tsmesolutions_cubes_initiatives=this.webpackChunk_tsmesolutions_cubes_initiatives||[]).push([[203],{40203:(e,t,o)=>{o.r(t),o.d(t,{default:()=>g});var r=o(24590),n=o(90726),l=o(16464),a=o(91123),i=o(19244);const s={modelValue:Array,excluded:Array,single:Boolean,label:String,placeholder:String,searchPlaceholder:String,dropdownProps:{type:Object,default:{size:"lg",placement:"bottom-end",teleport:!0,fullWidth:!1}},readonly:Boolean};var c=o(36040);function u(e,t,o,r,n,l,a){try{var i=e[l](a),s=i.value}catch(e){return void o(e)}i.done?t(s):Promise.resolve(s).then(r,n)}function d(e){return function(){var t=this,o=arguments;return new Promise(function(r,n){var l=e.apply(t,o);function a(e){u(l,r,n,a,i,"next",e)}function i(e){u(l,r,n,a,i,"throw",e)}a(void 0)})}}const p={key:0,class:"has-clearable mr-n1 py-1"},m={class:"list-group-item-body d-flex justify-content-between"},f={class:"list-group-item-title"},v={class:"align-self-center"},h={key:1},y=(0,r.defineComponent)({__name:"select-interdependencies",props:s,emits:["update:modelValue","ui-state"],setup(e,t){let{emit:o}=t;const s=e,u=o,y=n.IoC.DI().resolve(i.St.InterdependencyService.key),g=n.IoC.DI().resolve(l.Ow.appContext),w=g.services[i.St.AppService.key],k=(0,r.ref)([]),b=g.translation.global,V=(0,r.ref)({uniqueId:"id",searchableKey:`name.${w?.application.state.ui.culture.lang}`}),C=(0,r.toRef)(s,"modelValue"),x=(0,r.toRef)(s,"single"),B=(0,r.toRef)(s,"excluded"),_=function(){var e=d(function*(e){return new Promise(function(){var t=d(function*(t,o){try{const o=(yield y.list({limit:e.limit,offset:e.offset,name:e?.query??""})).data;B.value?t(o.filter(e=>!B.value?.some(t=>e.id==t.id&&e.type==t.type))):t(o)}catch(e){w?.error(b.value.errors.requestError,void 0,"BrowserList::browseObjects"),o(e)}});return function(e,o){return t.apply(this,arguments)}}())});return function(t){return e.apply(this,arguments)}}();return(0,r.watch)(()=>C.value,function(){var e=d(function*(e){if(e&&e.length!=k.value?.length)try{k.value=C.value.map(e=>new c.K(e))}catch(e){w?.error(b.value.errors.requestError,void 0,"BrowserList::objectsList")}});return function(t){return e.apply(this,arguments)}}(),{deep:!0,immediate:!0}),(0,r.watch)(()=>k.value,(e,t)=>{e&&!e.length?u("update:modelValue",e=[]):(0,n.equals)(e,t)||u("update:modelValue",e)},{deep:!0}),(e,t)=>{const o=(0,r.resolveComponent)("v-icon"),n=(0,r.resolveComponent)("v-button"),l=(0,r.resolveComponent)("v-badge"),i=(0,r.resolveComponent)("app-select-picker"),s=(0,r.resolveComponent)("v-literal");return e.readonly?((0,r.openBlock)(),(0,r.createElementBlock)("span",h,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(k.value,(t,o)=>((0,r.openBlock)(),(0,r.createBlock)(s,(0,r.mergeProps)({key:t.id,modelValue:t.name,"onUpdate:modelValue":e=>t.name=e,ref_for:!0},e.$attrs,{tag:"span"}),{default:(0,r.withCtx)(e=>{let{text:t}=e;return[(0,r.createTextVNode)((0,r.toDisplayString)(o+1==k.value?.length?t:`${t} ,  `),1)]}),_:2},1040,["modelValue","onUpdate:modelValue"]))),128))])):((0,r.openBlock)(),(0,r.createBlock)(i,{key:0,modelValue:k.value,"onUpdate:modelValue":t[0]||(t[0]=e=>k.value=e),"tag-props":{placeholder:e.placeholder,noInput:!0,label:e.label},"list-props":{fetchOptions:_,bordered:!0,searchProps:{placeholder:e.searchPlaceholder},maxHeight:"200",initialOffset:0},"dropdown-props":e.dropdownProps,"key-mapper":V.value,single:x.value},{"tag-item-badge":(0,r.withCtx)(t=>{let{tagItem:i,remove:s}=t;return[(0,r.createVNode)(l,{accent:(0,r.unref)(a.AccentEnum).dark,subtle:"",class:"d-flex border m-1"},{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("span",{class:(0,r.normalizeClass)(["no-select text-truncate",{"pr-4":!e.readonly&&!x.value}])},(0,r.toDisplayString)((0,r.unref)(a.useLocalize)((0,r.unref)(w),i.name,!0,"-")),3),e.readonly||x.value?(0,r.createCommentVNode)("v-if",!0):((0,r.openBlock)(),(0,r.createElementBlock)("span",p,[(0,r.createVNode)(n,{class:"close show p-0 h-auto shadow-none",accent:(0,r.unref)(a.AccentEnum).default,onClick:(0,r.withModifiers)(e=>s(i.id),["stop"])},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(o,{name:"times-circle","fixed-width":""})]),_:2},1032,["accent","onClick"])]))]),_:2},1032,["accent"])]}),"list-item-body":(0,r.withCtx)(e=>{let{item:t}=e;return[(0,r.createElementVNode)("div",m,[(0,r.createElementVNode)("h4",f,(0,r.toDisplayString)((0,r.unref)(a.useLocalize)((0,r.unref)(w),t.name,!0,"-")),1),(0,r.createElementVNode)("div",v,[(0,r.createVNode)(l,{pill:"",subtle:"",accent:"info",size:"sm"},{default:(0,r.withCtx)(()=>[(0,r.createTextVNode)((0,r.toDisplayString)(0==t.type?(0,r.unref)(b).program:(0,r.unref)(b).initiative),1)]),_:2},1024)])])]}),_:1},8,["modelValue","tag-props","list-props","dropdown-props","key-mapper","single"]))}}}),g=y}}]);
//# sourceMappingURL=77816f9f8f48329efdd7.js.map