(()=>{var e,n={66502:(e,n,r)=>{"use strict";var o=r(85471),i=r(65043),a=r(32073),s=r(88837),l=r(67607),c=r(70995),u=r(40083),d=r(432),p=r.n(d);const f={name:"DragVerticalIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var h=r(14486);const g=(0,h.A)(f,(function(){var t=this,e=t._self._c;return e("span",t._b({staticClass:"material-design-icon drag-vertical-icon",attrs:{"aria-hidden":t.title?null:"true","aria-label":t.title,role:"img"},on:{click:function(e){return t.$emit("click",e)}}},"span",t.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:t.fillColor,width:t.size,height:t.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M9,3H11V5H9V3M13,3H15V5H13V3M9,7H11V9H9V7M13,7H15V9H13V7M9,11H11V13H9V11M13,11H15V13H13V11M9,15H11V17H9V15M13,15H15V17H13V15M9,19H11V21H9V19M13,19H15V21H13V19Z"}},[t.title?e("title",[t._v(t._s(t.title))]):t._e()])])])}),[],!1,null,null,null).exports;var v=r(39017),m=r(68560),b=r(32981),y=r(63814);const x={name:"AdminAI",components:{NcCheckboxRadioSwitch:a.A,NcSettingsSection:s.A,NcSelect:l.A,draggable:p(),DragVerticalIcon:g,ArrowDownIcon:v.A,ArrowUpIcon:m.A,NcButton:c.A,NcNoteCard:u.A},data:()=>({loading:!1,dirty:!1,groups:[],loadingGroups:!1,sttProviders:(0,b.C)("settings","ai-stt-providers"),translationProviders:(0,b.C)("settings","ai-translation-providers"),textProcessingProviders:(0,b.C)("settings","ai-text-processing-providers"),textProcessingTaskTypes:(0,b.C)("settings","ai-text-processing-task-types"),text2imageProviders:(0,b.C)("settings","ai-text2image-providers"),taskProcessingProviders:(0,b.C)("settings","ai-task-processing-providers"),taskProcessingTaskTypes:(0,b.C)("settings","ai-task-processing-task-types"),settings:(0,b.C)("settings","ai-settings")}),computed:{hasTextProcessing(){return Object.keys(this.settings["ai.textprocessing_provider_preferences"]).length>0&&Array.isArray(this.textProcessingTaskTypes)},tpTaskTypes(){const t=["OCP\\TextProcessing\\FreePromptTaskType","OCP\\TextProcessing\\HeadlineTaskType","OCP\\TextProcessing\\SummaryTaskType","OCP\\TextProcessing\\TopicsTaskType"];return Object.keys(this.settings["ai.textprocessing_provider_preferences"]).filter((t=>!!this.getTextProcessingTaskType(t))).filter((e=>!t.includes(e)))},hasText2ImageProviders(){return this.text2imageProviders.length>0},hasTaskProcessing(){return Object.keys(this.settings["ai.taskprocessing_provider_preferences"]).length>0&&Array.isArray(this.taskProcessingTaskTypes)}},methods:{moveUp(t){this.settings["ai.translation_provider_preferences"].splice(Math.min(t-1,0),0,...this.settings["ai.translation_provider_preferences"].splice(t,1)),this.saveChanges()},moveDown(t){this.settings["ai.translation_provider_preferences"].splice(t+1,0,...this.settings["ai.translation_provider_preferences"].splice(t,1)),this.saveChanges()},async saveChanges(){this.loading=!0,await(0,o.dY)();const t={settings:this.settings};try{await i.Ay.put((0,y.Jv)("/settings/api/admin/ai"),t)}catch(t){console.error("could not save changes",t)}this.loading=!1},getTextProcessingTaskType(t){return Array.isArray(this.textProcessingTaskTypes)?this.textProcessingTaskTypes.find((e=>e.class===t)):null}}};var _=r(85072),w=r.n(_),S=r(97825),T=r.n(S),C=r(77659),A=r.n(C),E=r(55056),k=r.n(E),D=r(10540),O=r.n(D),P=r(41113),N=r.n(P),M=r(3290),I={};I.styleTagTransform=N(),I.setAttributes=k(),I.insert=A().bind(null,"head"),I.domAPI=T(),I.insertStyleElement=O(),w()(M.A,I),M.A&&M.A.locals&&M.A.locals;const j=(0,h.A)(x,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"ai-settings"},[e("NcSettingsSection",{attrs:{name:t.t("settings","Unified task processing"),description:t.t("settings","AI tasks can be implemented by different apps. Here you can set which app should be used for which task.")}},[t._l(t.taskProcessingTaskTypes,(function(n){return[e("div",{key:n},[e("h3",[t._v(t._s(t.t("settings","Task:"))+" "+t._s(n.name))]),t._v(" "),e("p",[t._v(t._s(n.description))]),t._v(" "),e("p",[t._v(" ")]),t._v(" "),e("NcSelect",{staticClass:"provider-select",attrs:{clearable:!1,options:t.taskProcessingProviders.filter((t=>t.taskType===n.id)).map((t=>t.id))},on:{input:t.saveChanges},scopedSlots:t._u([{key:"option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t\t\t"+t._s(t.taskProcessingProviders.find((t=>t.id===n))?.name)+"\n\t\t\t\t\t")]}},{key:"selected-option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t\t\t"+t._s(t.taskProcessingProviders.find((t=>t.id===n))?.name)+"\n\t\t\t\t\t")]}}],null,!0),model:{value:t.settings["ai.taskprocessing_provider_preferences"][n.id],callback:function(e){t.$set(t.settings["ai.taskprocessing_provider_preferences"],n.id,e)},expression:"settings['ai.taskprocessing_provider_preferences'][type.id]"}}),t._v(" "),e("p",[t._v(" ")])],1)]})),t._v(" "),t.hasTaskProcessing?t._e():[e("NcNoteCard",{attrs:{type:"info"}},[t._v("\n\t\t\t\t"+t._s(t.t("settings","None of your currently installed apps provide Task processing functionality"))+"\n\t\t\t")])]],2),t._v(" "),e("NcSettingsSection",{attrs:{name:t.t("settings","Machine translation"),description:t.t("settings","Machine translation can be implemented by different apps. Here you can define the precedence of the machine translation apps you have installed at the moment.")}},[e("draggable",{on:{change:t.saveChanges},model:{value:t.settings["ai.translation_provider_preferences"],callback:function(e){t.$set(t.settings,"ai.translation_provider_preferences",e)},expression:"settings['ai.translation_provider_preferences']"}},t._l(t.settings["ai.translation_provider_preferences"],(function(n,r){return e("div",{key:n,staticClass:"draggable__item"},[e("DragVerticalIcon"),t._v(" "),e("span",{staticClass:"draggable__number"},[t._v(t._s(r+1))]),t._v(" "+t._s(t.translationProviders.find((t=>t.class===n))?.name)+"\n\t\t\t\t"),e("NcButton",{attrs:{"aria-label":"Move up",type:"tertiary"},on:{click:function(e){return t.moveUp(r)}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("ArrowUpIcon")]},proxy:!0}],null,!0)}),t._v(" "),e("NcButton",{attrs:{"aria-label":"Move down",type:"tertiary"},on:{click:function(e){return t.moveDown(r)}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("ArrowDownIcon")]},proxy:!0}],null,!0)})],1)})),0)],1),t._v(" "),e("NcSettingsSection",{attrs:{name:t.t("settings","Image generation"),description:t.t("settings","Image generation can be implemented by different apps. Here you can set which app should be used.")}},[t._l(t.text2imageProviders,(function(n){return[e("NcCheckboxRadioSwitch",{key:n.id,attrs:{checked:t.settings["ai.text2image_provider"],value:n.id,name:"text2image_provider",type:"radio"},on:{"update:checked":[function(e){return t.$set(t.settings,"ai.text2image_provider",e)},t.saveChanges]}},[t._v("\n\t\t\t\t"+t._s(n.name)+"\n\t\t\t")])]})),t._v(" "),t.hasText2ImageProviders?t._e():[e("NcNoteCard",{attrs:{type:"info"}},[t._v("\n\t\t\t\t"+t._s(t.t("settings","None of your currently installed apps provide image generation functionality"))+"\n\t\t\t")])]],2),t._v(" "),e("NcSettingsSection",{attrs:{name:t.t("settings","Text processing"),description:t.t("settings","Text processing tasks can be implemented by different apps. Here you can set which app should be used for which task.")}},[t._l(t.tpTaskTypes,(function(n){return[e("div",{key:n},[e("h3",[t._v(t._s(t.t("settings","Task:"))+" "+t._s(t.getTextProcessingTaskType(n).name))]),t._v(" "),e("p",[t._v(t._s(t.getTextProcessingTaskType(n).description))]),t._v(" "),e("p",[t._v(" ")]),t._v(" "),e("NcSelect",{staticClass:"provider-select",attrs:{clearable:!1,options:t.textProcessingProviders.filter((t=>t.taskType===n)).map((t=>t.class))},on:{input:t.saveChanges},scopedSlots:t._u([{key:"option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t\t\t"+t._s(t.textProcessingProviders.find((t=>t.class===n))?.name)+"\n\t\t\t\t\t")]}},{key:"selected-option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t\t\t"+t._s(t.textProcessingProviders.find((t=>t.class===n))?.name)+"\n\t\t\t\t\t")]}}],null,!0),model:{value:t.settings["ai.textprocessing_provider_preferences"][n],callback:function(e){t.$set(t.settings["ai.textprocessing_provider_preferences"],n,e)},expression:"settings['ai.textprocessing_provider_preferences'][type]"}}),t._v(" "),e("p",[t._v(" ")])],1)]})),t._v(" "),0===t.tpTaskTypes.length?[e("NcNoteCard",{attrs:{type:"info"}},[t._v("\n\t\t\t\t"+t._s(t.t("settings","None of your currently installed apps provide text processing functionality using the Text Processing API."))+"\n\t\t\t")])]:t._e()],2)],1)}),[],!1,null,"0cd2af2a",null).exports;r.nc=btoa(OC.requestToken),o.Ay.prototype.t=t,window.OC=window.OC||{},window.OC.Settings=window.OC.Settings||{},(new(o.Ay.extend(j))).$mount("#ai-settings")},3290:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(71354),o=n.n(r),i=n(76314),a=n.n(i)()(o());a.push([t.id,"\n.draggable__item[data-v-0cd2af2a] {\n\tmargin-bottom: 5px;\n display: flex;\n align-items: center;\n}\n.draggable__item[data-v-0cd2af2a],\n.draggable__item *[data-v-0cd2af2a] {\n cursor: grab;\n}\n.draggable__number[data-v-0cd2af2a] {\n\tborder-radius: 20px;\n\tborder: 2px solid var(--color-primary-element);\n\tcolor: var(--color-primary-element);\n\tpadding: 0px 7px;\n\tmargin-inline-end: 3px;\n}\n.drag-vertical-icon[data-v-0cd2af2a] {\n float: left;\n}\n.ai-settings h3[data-v-0cd2af2a] {\n\tfont-size: 16px; /* to offset against the 20px section heading */\n}\n.provider-select[data-v-0cd2af2a] {\n\tmin-width: 350px !important;\n}\n","",{version:3,sources:["webpack://./apps/settings/src/components/AdminAI.vue"],names:[],mappings:";AA8MA;CACA,kBAAA;EACA,aAAA;EACA,mBAAA;AACA;AAEA;;EAEA,YAAA;AACA;AAEA;CACA,mBAAA;CACA,8CAAA;CACA,mCAAA;CACA,gBAAA;CACA,sBAAA;AACA;AAEA;EACA,WAAA;AACA;AAEA;CACA,eAAA,EAAA,+CAAA;AACA;AAEA;CACA,2BAAA;AACA",sourcesContent:["\x3c!--\n - SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n--\x3e\n\n\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{{ t('settings', 'None of your currently installed apps provide Task processing functionality') }}\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{{ provider.name }}\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{{ t('settings', 'None of your currently installed apps provide image generation functionality') }}\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\x3c!-- TRANSLATORS Text processing is the name of a Nextcloud-internal API --\x3e\n\t\t\t\t\t{{ t('settings', 'None of your currently installed apps provide text processing functionality using the Text Processing API.') }}\n\t\t\t\t\n\t\t\t\n\t\t\n\t