forked from bombastictranz/token-lists
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discourse-ai-2bda0eae9d3c7a07db9e56d5ef598fe86d06b39c7ae9059f8d03e99d2bcbcd96.br.js.download
523 lines (521 loc) Β· 216 KB
/
discourse-ai-2bda0eae9d3c7a07db9e56d5ef598fe86d06b39c7ae9059f8d03e99d2bcbcd96.br.js.download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
define("discourse/plugins/discourse-ai/discourse/admin-discourse-ai-plugin-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"admin.adminPlugins.show",path:"/plugins",map(){this.route("discourse-ai-personas",{path:"ai-personas"},(function(){this.route("new"),this.route("show",{path:"/:id"})})),this.route("discourse-ai-llms",{path:"ai-llms"},(function(){this.route("new"),this.route("show",{path:"/:id"})}))}}})),define("discourse/plugins/discourse-ai/discourse/admin-discourse-ai-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"admin.dashboard",path:"/dashboard",map(){this.route("admin.dashboardSentiment",{path:"/dashboard/sentiment",resetNamespace:!0})}}})),define("discourse/plugins/discourse-ai/discourse/admin/adapters/ai-llm",["exports","discourse/adapters/rest"],(function(e,t){"use strict"
function i(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class r extends t.default{constructor(){super(...arguments),i(this,"jsonMode",!0)}basePath(){return"/admin/plugins/discourse-ai/"}pathFor(e,t,i){let r=this.basePath(e,t,i)+e.pluralize(this.apiNameFor(t))
return this.appendQueryParams(r,i)}apiNameFor(){return"ai-llm"}}e.default=r})),define("discourse/plugins/discourse-ai/discourse/admin/adapters/ai-persona",["exports","discourse/adapters/rest"],(function(e,t){"use strict"
function i(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class r extends t.default{constructor(){super(...arguments),i(this,"jsonMode",!0)}basePath(){return"/admin/plugins/discourse-ai/"}pathFor(e,t,i){let r=this.basePath(e,t,i)+e.pluralize(this.apiNameFor(t))
return this.appendQueryParams(r,i)}apiNameFor(){return"ai-persona"}}e.default=r})),define("discourse/plugins/discourse-ai/discourse/admin/models/ai-llm",["exports","discourse/lib/ajax","discourse/models/rest"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class r extends i.default{createProperties(){return this.getProperties("id","display_name","name","provider","tokenizer","max_prompt_tokens","url","api_key")}updateProperties(){const e=this.createProperties()
return e.id=this.id,e}async testConfig(){return await(0,t.ajax)("/admin/plugins/discourse-ai/ai-llms/test.json",{data:{ai_llm:this.createProperties()}})}}e.default=r})),define("discourse/plugins/discourse-ai/discourse/admin/models/ai-persona",["exports","@glimmer/tracking","discourse/lib/ajax","discourse/models/rest"],(function(e,t,i,r){"use strict"
var o,s
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const n=["id","name","description","commands","system_prompt","allowed_group_ids","enabled","system","priority","top_p","temperature","user_id","mentionable","default_llm","user","max_context_posts","vision_enabled","vision_max_pixels","rag_uploads","rag_chunk_tokens","rag_chunk_overlap_tokens","rag_conversation_chunks","question_consolidator_llm","allow_chat"],a=["id","allowed_group_ids","enabled","system","priority","user_id","mentionable","default_llm","user","max_context_posts","vision_enabled","vision_max_pixels","rag_uploads","rag_chunk_tokens","rag_chunk_overlap_tokens","rag_conversation_chunks","question_consolidator_llm","allow_chat"]
let l=(o=class{constructor(){var e,t,i,r
e=this,t="value",r=this,(i=s)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}},u=o.prototype,c="value",d=[t.tracked],p={configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}},g={},Object.keys(p).forEach((function(e){g[e]=p[e]})),g.enumerable=!!g.enumerable,g.configurable=!!g.configurable,("value"in g||g.initializer)&&(g.writable=!0),g=d.slice().reverse().reduce((function(e,t){return t(u,c,e)||e}),g),m&&void 0!==g.initializer&&(g.value=g.initializer?g.initializer.call(m):void 0,g.initializer=void 0),void 0===g.initializer&&(Object.defineProperty(u,c,g),g=null),s=g,o)
var u,c,d,p,m,g
class b extends r.default{init(e){e.commands&&(e.commands=e.commands.map((e=>{if("string"==typeof e)return e
{let[t,i]=e
for(let e in i)i.hasOwnProperty(e)&&(this.getCommandOption(t,e).value=i[e])
return t}}))),super.init(e),this.commands=e.commands}async createUser(){const e=await(0,i.ajax)(`/admin/plugins/discourse-ai/ai-personas/${this.id}/create-user.json`,{type:"POST"})
return this.user=e.user,this.user_id=this.user.id,this.user}getCommandOption(e,t){return this.commandOptions||={},this.commandOptions[e]||={},this.commandOptions[e][t]||=new l}populateCommandOptions(e){if(!e.commands)return
let t=[]
e.commands.forEach((e=>{if("string"!=typeof e&&(e=e[0]),this.commandOptions&&this.commandOptions[e]){let i=this.commandOptions[e],r={}
for(let e in i){if(!i.hasOwnProperty(e))continue
let t=i[e]
r[e]=t.value}t.push([e,r])}else t.push(e)})),e.commands=t}updateProperties(){let e=this.system?this.getProperties(a):this.getProperties(n)
return e.id=this.id,this.populateCommandOptions(e),e}createProperties(){let e=this.getProperties(n)
return this.populateCommandOptions(e),e}workingCopy(){let e=this.getProperties(n)
return this.populateCommandOptions(e),b.create(e)}}e.default=b})),define("discourse/plugins/discourse-ai/discourse/components/ai-bot-header-icon",["exports","@glimmer/component","@ember/object","@ember/service","truth-helpers","discourse/components/d-button","discourse-common/helpers/i18n","discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u){"use strict"
var c,d,p,m
function g(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function b(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){super(...arguments),g(this,"siteSettings",d,this),g(this,"composer",p,this)}get bots(){return this.siteSettings.ai_bot_add_to_header?this.siteSettings.ai_bot_enabled_chat_bots.split("|").filter(Boolean):[]}compose(){(0,a.composeAiBotMessage)(this.bots[0],this.composer)}},(0,l.setComponentTemplate)((0,u.createTemplateFactory)({id:"InHIewYI",block:'[[[1,"\\n"],[41,[28,[32,0],[[30,0,["bots","length"]],0],null],[[[1," "],[10,"li"],[12],[1,"\\n "],[8,[32,1],[[16,"title",[28,[32,2],["discourse_ai.ai_bot.shortcut_title"],null]],[24,0,"ai-bot-button icon btn-flat"]],[["@action","@icon"],[[30,0,["compose"]],"robot"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-bot-header-icon.js",scope:()=>[o.gt,s.default,n.default],isStrictMode:!0}),m),d=b((c=m).prototype,"siteSettings",[r.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),p=b(c.prototype,"composer",[r.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),b(c.prototype,"compose",[i.action],Object.getOwnPropertyDescriptor(c.prototype,"compose"),c.prototype),c)})),define("discourse/plugins/discourse-ai/discourse/components/ai-command-selector",["exports","@ember/object","select-kit/components/multi-select"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=i.default.extend({_modelDisabledChanged:(0,t.observer)("attrs.disabled",(function(){this.selectKit.options.set("disabled",this.get("attrs.disabled.value"))})),content:(0,t.computed)((function(){return this.commands})),value:"",selectKitOptions:{filterable:!0}})})),define("discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","discourse/components/d-button","discourse-common/helpers/i18n","truth-helpers/helpers/not","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m
function g(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="_customPromptInput",r=this,(i=p)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}setupCustomPrompt(){this._customPromptInput=document.querySelector(".ai-custom-prompt__input"),this._customPromptInput.focus()}sendInput(){return this.args.submit(this.args.promptArgs)}},(0,r.setComponentTemplate)((0,c.createTemplateFactory)({id:"R9H8RJGc",block:'[[[1,"\\n "],[11,0],[24,0,"ai-custom-prompt"],[4,[32,0],[[30,0,["setupCustomPrompt"]]],null],[12],[1,"\\n "],[8,[32,1],[[16,"placeholder",[28,[32,2],["discourse_ai.ai_helper.context_menu.custom_prompt.placeholder"],null]],[24,0,"ai-custom-prompt__input"]],[["@value","@enter"],[[30,1],[30,0,["sendInput"]]]],null],[1,"\\n\\n "],[8,[32,3],[[24,0,"ai-custom-prompt__submit btn-primary"]],[["@icon","@action","@disabled"],["discourse-sparkles",[28,[32,4],[[30,2],[30,3]],null],[28,[32,5],[[30,1,["length"]]],null]]],null],[1,"\\n "],[13],[1,"\\n "]],["@value","@submit","@promptArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt.js",scope:()=>[n.default,r.Input,l.default,a.default,o.fn,u.default],isStrictMode:!0}),m),p=g((d=m).prototype,"_customPromptInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g(d.prototype,"setupCustomPrompt",[s.action],Object.getOwnPropertyDescriptor(d.prototype,"setupCustomPrompt"),d.prototype),g(d.prototype,"sendInput",[s.action],Object.getOwnPropertyDescriptor(d.prototype,"sendInput"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/components/ai-helper-loading",["exports","discourse/components/d-button","discourse-common/helpers/i18n","@ember/component","@ember/template-factory","@ember/component/template-only"],(function(e,t,i,r,o,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const n=(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"Av2n/cr8",block:'[[[1,"\\n "],[10,0],[14,0,"ai-helper-context-menu__loading"],[12],[1,"\\n "],[10,0],[14,0,"dot-falling"],[12],[13],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[28,[32,0],["discourse_ai.ai_helper.context_menu.loading"],null]],[1,"\\n "],[13],[1,"\\n "],[8,[32,1],[[24,0,"btn-flat cancel-request"]],[["@icon","@title","@action"],["times","discourse_ai.ai_helper.context_menu.cancel",[30,1]]],null],[1,"\\n "],[13],[1,"\\n"]],["@cancel"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-helper-loading.js",scope:()=>[i.default,t.default],isStrictMode:!0}),(0,s.default)())
e.default=n})),define("discourse/plugins/discourse-ai/discourse/components/ai-llm-editor",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/object","@ember/runloop","@ember/service","discourse/components/back-button","discourse/components/d-button","discourse/lib/ajax-error","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","discourse-i18n","select-kit/components/combo-box","float-kit/components/d-tooltip","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_,y,v,w,j,S,x
function P(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function O(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(x=class extends t.default{constructor(){super(...arguments),P(this,"toasts",f,this),P(this,"router",_,this),P(this,"dialog",y,this),P(this,"isSaving",v,this),P(this,"testRunning",w,this),P(this,"testResult",j,this),P(this,"testError",S,this)}get selectedProviders(){return this.args.llms.resultSetMeta.providers.map((e=>{return{id:e,name:(t=e,p.default.t(`discourse_ai.llms.providers.${t}`))}
var t}))}async save(){this.isSaving=!0
const e=this.args.model.isNew
try{const t=await this.args.model.save()
this.args.model.setProperties(t.responseJson.ai_persona),e?(this.args.llms.addObject(this.args.model),this.router.transitionTo("adminPlugins.show.discourse-ai-llms.index")):this.toasts.success({data:{message:p.default.t("discourse_ai.llms.saved")},duration:2e3})}catch(t){(0,u.popupAjaxError)(t)}finally{(0,s.later)((()=>{this.isSaving=!1}),1e3)}}async test(){this.testRunning=!0
try{const e=await this.args.model.testConfig()
this.testResult=e.success,this.testResult?this.testError=null:this.testError=e.error}catch(e){(0,u.popupAjaxError)(e)}finally{(0,s.later)((()=>{this.testRunning=!1}),1e3)}}get testErrorMessage(){return p.default.t("discourse_ai.llms.tests.failure",{error:this.testError})}get displayTestResult(){return this.testRunning||null!==this.testResult}delete(){return this.dialog.confirm({message:p.default.t("discourse_ai.llms.confirm_delete"),didConfirm:()=>this.args.model.destroyRecord().then((()=>{this.args.llms.removeObject(this.args.model),this.router.transitionTo("adminPlugins.show.discourse-ai-llms.index")})).catch(u.popupAjaxError)})}},(0,r.setComponentTemplate)((0,b.createTemplateFactory)({id:"BaAZNDzA",block:'[[[1,"\\n "],[8,[32,0],null,[["@route","@label"],["adminPlugins.show.discourse-ai-llms","discourse_ai.llms.back"]],null],[1,"\\n "],[10,"form"],[14,0,"form-horizontal ai-llm-editor"],[12],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,1],["discourse_ai.llms.display_name"],null]],[13],[1,"\\n "],[8,[32,2],[[24,0,"ai-llm-editor-input ai-llm-editor__display-name"]],[["@type","@value"],["text",[30,1,["display_name"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,1],["discourse_ai.llms.name"],null]],[13],[1,"\\n "],[8,[32,2],[[24,0,"ai-llm-editor-input ai-llm-editor__name"]],[["@type","@value"],["text",[30,1,["name"]]]],null],[1,"\\n "],[8,[32,3],null,[["@icon","@content"],["question-circle",[28,[32,4,["t"]],["discourse_ai.llms.hints.name"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,4,["t"]],["discourse_ai.llms.provider"],null]],[13],[1,"\\n "],[8,[32,5],null,[["@value","@content"],[[30,1,["provider"]],[30,0,["selectedProviders"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,4,["t"]],["discourse_ai.llms.url"],null]],[13],[1,"\\n "],[8,[32,2],[[24,0,"ai-llm-editor-input ai-llm-editor__url"]],[["@type","@value"],["text",[30,1,["url"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,4,["t"]],["discourse_ai.llms.api_key"],null]],[13],[1,"\\n "],[8,[32,2],[[24,0,"ai-llm-editor-input ai-llm-editor__api-key"]],[["@type","@value"],["text",[30,1,["api_key"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,4,["t"]],["discourse_ai.llms.tokenizer"],null]],[13],[1,"\\n "],[8,[32,5],null,[["@value","@content"],[[30,1,["tokenizer"]],[30,2,["resultSetMeta","tokenizers"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,1],["discourse_ai.llms.max_prompt_tokens"],null]],[13],[1,"\\n "],[8,[32,2],[[24,0,"ai-llm-editor-input ai-llm-editor__max-prompt-tokens"],[24,"step","any"],[24,"min","0"],[24,"lang","en"]],[["@type","@value"],["number",[30,1,["max_prompt_tokens"]]]],null],[1,"\\n "],[8,[32,3],null,[["@icon","@content"],["question-circle",[28,[32,4,["t"]],["discourse_ai.llms.hints.max_prompt_tokens"],null]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"control-group ai-llm-editor__action_panel"],[12],[1,"\\n "],[8,[32,6],[[24,0,"ai-llm-editor__test"]],[["@action","@disabled"],[[30,0,["test"]],[30,0,["testRunning"]]]],[["default"],[[[[1,"\\n "],[1,[28,[32,4,["t"]],["discourse_ai.llms.tests.title"],null]],[1,"\\n "]],[]]]]],[1,"\\n\\n "],[8,[32,6],[[24,0,"btn-primary ai-llm-editor__save"]],[["@action","@disabled"],[[30,0,["save"]],[30,0,["isSaving"]]]],[["default"],[[[[1,"\\n "],[1,[28,[32,4,["t"]],["discourse_ai.llms.save"],null]],[1,"\\n "]],[]]]]],[1,"\\n"],[41,[51,[30,1,["isNew"]]],[[[1," "],[8,[32,6],[[24,0,"btn-danger ai-llm-editor__delete"]],[["@action"],[[30,0,["delete"]]]],[["default"],[[[[1,"\\n "],[1,[28,[32,4,["t"]],["discourse_ai.llms.delete"],null]],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"control-group ai-llm-editor-tests"],[12],[1,"\\n"],[41,[30,0,["displayTestResult"]],[[[41,[30,0,["testRunning"]],[[[1," "],[10,0],[14,0,"spinner small"],[12],[13],[1,"\\n "],[1,[28,[32,4,["t"]],["discourse_ai.llms.tests.running"],null]],[1,"\\n"]],[]],[[[41,[30,0,["testResult"]],[[[1," "],[10,0],[14,0,"ai-llm-editor-tests__success"],[12],[1,"\\n "],[1,[28,[32,7],["check"],null]],[1,"\\n "],[1,[28,[32,4,["t"]],["discourse_ai.llms.tests.success"],null]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"ai-llm-editor-tests__failure"],[12],[1,"\\n "],[1,[28,[32,7],["times"],null]],[1,"\\n "],[1,[30,0,["testErrorMessage"]]],[1,"\\n "],[13],[1,"\\n"]],[]]]],[]]]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "]],["@model","@llms"],false,["unless","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-llm-editor.js",scope:()=>[a.default,d.default,r.Input,g.default,p.default,m.default,l.default,c.default],isStrictMode:!0}),x),f=O((h=x).prototype,"toasts",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=O(h.prototype,"router",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=O(h.prototype,"dialog",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v=O(h.prototype,"isSaving",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),w=O(h.prototype,"testRunning",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),j=O(h.prototype,"testResult",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),S=O(h.prototype,"testError",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),O(h.prototype,"save",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"save"),h.prototype),O(h.prototype,"test",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"test"),h.prototype),O(h.prototype,"delete",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"delete"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/components/ai-llm-selector",["exports","@ember/object","discourse-i18n","select-kit/components/combo-box"],(function(e,t,i,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=r.default.extend({_modelDisabledChanged:(0,t.observer)("attrs.disabled",(function(){this.selectKit.options.set("disabled",this.get("attrs.disabled.value"))})),content:(0,t.computed)((function(){return[{id:"blank",name:i.default.t("discourse_ai.ai_persona.no_llm_selected")}].concat(this.llms)})),selectKitOptions:{filterable:!0}})})),define("discourse/plugins/discourse-ai/discourse/components/ai-llms-list-editor",["exports","@glimmer/component","@ember/helper","@ember/routing","discourse/components/d-breadcrumbs-item","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/ai-llm-editor","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class p extends t.default{get hasLLMElements(){return 0!==this.args.llms.length}}e.default=p,d=p,(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"DuEqYB1C",block:'[[[1,"\\n "],[8,[32,0],null,null,[["default"],[[[[1,"\\n "],[8,[32,1],[[16,0,[30,1]]],[["@route"],["adminPlugins.show.discourse-ai-personas"]],[["default"],[[[[1,"\\n "],[1,[28,[32,2],["discourse_ai.llms.short_title"],null]],[1,"\\n "]],[]]]]],[1,"\\n "]],[1]]]]],[1,"\\n\\n "],[10,"section"],[14,0,"ai-llms-list-editor admin-detail pull-left"],[12],[1,"\\n"],[41,[30,2],[[[1," "],[8,[32,3],null,[["@model","@llms"],[[30,2],[30,3]]],null],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"ai-llms-list-editor__header"],[12],[1,"\\n "],[10,"h3"],[12],[1,[28,[32,2],["discourse_ai.llms.short_title"],null]],[13],[1,"\\n"],[41,[51,[30,2,["isNew"]]],[[[1," "],[8,[32,1],[[24,0,"btn btn-small btn-primary"]],[["@route"],["adminPlugins.show.discourse-ai-llms.new"]],[["default"],[[[[1,"\\n "],[1,[28,[32,4],["plus"],null]],[1,"\\n "],[10,1],[12],[1,[28,[32,5,["t"]],["discourse_ai.llms.new"],null]],[13],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["hasLLMElements"]],[[[1," "],[10,"table"],[14,0,"content-list ai-persona-list-editor"],[12],[1,"\\n "],[10,"thead"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"th"],[12],[1,[28,[32,2],["discourse_ai.llms.display_name"],null]],[13],[1,"\\n "],[10,"th"],[12],[1,[28,[32,2],["discourse_ai.llms.provider"],null]],[13],[1,"\\n "],[10,"th"],[12],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tbody"],[12],[1,"\\n"],[42,[28,[31,3],[[28,[31,3],[[30,3]],null]],null],null,[[[1," "],[10,"tr"],[15,"data-persona-id",[30,4,["id"]]],[14,0,"ai-llm-list__row"],[12],[1,"\\n "],[10,"td"],[12],[10,"strong"],[12],[1,[30,4,["display_name"]]],[13],[13],[1,"\\n "],[10,"td"],[12],[1,[28,[32,2],[[28,[32,6],["discourse_ai.llms.providers.",[30,4,["provider"]]],null]],null]],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[8,[32,1],[[24,"current-when","true"],[24,0,"btn btn-text btn-small"]],[["@route","@model"],["adminPlugins.show.discourse-ai-llms.show",[30,4]]],[["default"],[[[[1,[28,[32,2],["discourse_ai.llms.edit"],null]]],[]]]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[4]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]]],[1," "],[13],[1,"\\n "]],["linkClass","@currentLlm","@llms","llm"],false,["if","unless","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-llms-list-editor.js",scope:()=>[o.default,r.LinkTo,n.default,l.default,s.default,a.default,i.concat],isStrictMode:!0}),d)})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor",["exports","@glimmer/component","@ember/component","@ember/modifier","@ember/object","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n,a
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(a=class extends t.default{get isBoolean(){return"boolean"===this.args.option.type}get selectedValue(){return"true"===this.args.option.value.value}onCheckboxChange(e){this.args.option.value.value=e.target.checked?"true":"false"}},(0,i.setComponentTemplate)((0,s.createTemplateFactory)({id:"TVmYtqUc",block:'[[[1,"\\n "],[10,0],[14,0,"control-group ai-persona-command-option-editor"],[12],[1,"\\n "],[10,"label"],[12],[1,"\\n "],[1,[30,1,["name"]]],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,""],[12],[1,"\\n"],[41,[30,0,["isBoolean"]],[[[1," "],[11,"input"],[16,"checked",[30,0,["selectedValue"]]],[24,4,"checkbox"],[4,[32,0],["click",[30,0,["onCheckboxChange"]]],null],[12],[13],[1,"\\n "],[1,[30,1,["description"]]],[1,"\\n"]],[]],[[[1," "],[8,[32,1],null,[["@value"],[[30,1,["value","value"]]]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"],[41,[51,[30,0,["isBoolean"]]],[[[1," "],[10,0],[14,0,"ai-persona-command-option-editor__instructions"],[12],[1,"\\n "],[1,[30,1,["description"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "]],["@option"],false,["if","unless"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor.js",scope:()=>[r.on,i.Input],isStrictMode:!0}),a),l=(n=a).prototype,u="onCheckboxChange",c=[o.action],d=Object.getOwnPropertyDescriptor(n.prototype,"onCheckboxChange"),p=n.prototype,m={},Object.keys(d).forEach((function(e){m[e]=d[e]})),m.enumerable=!!m.enumerable,m.configurable=!!m.configurable,("value"in m||m.initializer)&&(m.writable=!0),m=c.slice().reverse().reduce((function(e,t){return t(l,u,e)||e}),m),p&&void 0!==m.initializer&&(m.value=m.initializer?m.initializer.call(p):void 0,m.initializer=void 0),void 0===m.initializer&&(Object.defineProperty(l,u,m),m=null),n)
var l,u,c,d,p,m})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options",["exports","@glimmer/component","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{get showCommandOptions(){const e=this.args.allCommands
return!!e&&this.commandNames.any((t=>e.find((e=>e.id===t))?.options))}get commandNames(){return this.args.commands?this.args.commands.map((e=>"string"==typeof e?e:e[0])):[]}get commandOptions(){if(!this.args.commands)return[]
const e=this.args.allCommands
if(!e)return[]
const t=[]
return this.commandNames.forEach((i=>{const r=e.find((e=>e.id===i)),o=r?.name,s=r?.options
if(s){const e=Object.keys(s).map((e=>{const t=this.args.persona.getCommandOption(i,e)
return Object.assign({},s[e],{id:e,value:t})}))
t.push({commandName:o,options:e})}})),t}}e.default=a,n=a,(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"4ZSHKwgK",block:'[[[1,"\\n"],[41,[30,0,["showCommandOptions"]],[[[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.command_options"],null]],[13],[1,"\\n "],[10,0],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["commandOptions"]]],null]],null],null,[[[1," "],[10,0],[14,0,"ai-persona-editor__command-options"],[12],[1,"\\n "],[10,0],[14,0,"ai-persona-editor__command-options-name"],[12],[1,"\\n "],[1,[30,1,["commandName"]]],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"ai-persona-editor__command-option-options"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,1,["options"]]],null]],null],null,[[[1," "],[8,[32,1],null,[["@option"],[[30,2]]],null],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],["commandOption","option"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options.js",scope:()=>[i.default,r.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-editor",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/render-modifiers/modifiers/did-update","@ember/routing","@ember/runloop","@ember/service","discourse/components/back-button","discourse/components/d-button","discourse/components/d-textarea","discourse/components/d-toggle-switch","discourse/helpers/bound-avatar-template","discourse/lib/ajax-error","discourse/models/group","discourse-i18n","admin/models/admin-user","select-kit/components/combo-box","select-kit/components/group-chooser","float-kit/components/d-tooltip","discourse/plugins/discourse-ai/discourse/components/ai-command-selector","discourse/plugins/discourse-ai/discourse/components/ai-llm-selector","discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options","discourse/plugins/discourse-ai/discourse/components/persona-rag-uploader","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b,h,f,_,y,v,w,j,S,x,P,O,z){"use strict"
var k,T,C,M,E,A,I,R,N,D,U,q,L,F,B
function V(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function H(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function G(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i
throw new TypeError("Private element is not present on this object")}function $(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(B=new WeakSet,F=class extends t.default{constructor(){super(...arguments),H(this,B),V(this,"router",T,this),V(this,"store",C,this),V(this,"dialog",M,this),V(this,"toasts",E,this),V(this,"siteSettings",A,this),V(this,"allGroups",I,this),V(this,"isSaving",R,this),V(this,"editingModel",N,this),V(this,"showDelete",D,this),V(this,"maxPixelsValue",U,this),V(this,"ragIndexingStatuses",q,this),V(this,"showIndexingOptions",L,this)}get chatPluginEnabled(){return this.siteSettings.chat_enabled}updateModel(){this.editingModel=this.args.model.workingCopy(),this.showDelete=!this.args.model.isNew&&!this.args.model.system,this.maxPixelsValue=this.findClosestPixelValue(this.editingModel.vision_max_pixels)}toggleIndexingOptions(e){this.showIndexingOptions=!this.showIndexingOptions,e.preventDefault(),e.stopPropagation()}findClosestPixelValue(e){let t="high"
return this.maxPixelValues.forEach((i=>{e===i.pixels&&(t=i.id)})),t}get maxPixelValues(){const e=e=>_.default.t(`discourse_ai.ai_persona.vision_max_pixel_sizes.${e}`)
return[{id:"low",name:e("low"),pixels:65536},{id:"medium",name:e("medium"),pixels:262144},{id:"high",name:e("high"),pixels:1048576}]}get indexingOptionsText(){return this.showIndexingOptions?_.default.t("discourse_ai.ai_persona.hide_indexing_options"):_.default.t("discourse_ai.ai_persona.show_indexing_options")}async updateAllGroups(){this.allGroups=await f.default.findAll()}async save(){const e=this.args.model.isNew
this.isSaving=!0
const t=this.args.model.workingCopy()
this.args.model.setProperties(this.editingModel)
try{await this.args.model.save(),G(B,this,K).call(this),e&&0===this.args.model.rag_uploads.length?(this.args.personas.addObject(this.args.model),this.router.transitionTo("adminPlugins.show.discourse-ai-personas.show",this.args.model)):this.toasts.success({data:{message:_.default.t("discourse_ai.ai_persona.saved")},duration:2e3})}catch(i){this.args.model.setProperties(t),(0,h.popupAjaxError)(i)}finally{(0,u.later)((()=>{this.isSaving=!1}),1e3)}}get showTemperature(){return this.editingModel?.temperature||!this.editingModel?.system}get showTopP(){return this.editingModel?.top_p||!this.editingModel?.system}get adminUser(){return y.default.create(this.editingModel?.user)}get mappedQuestionConsolidatorLlm(){return this.editingModel?.question_consolidator_llm||"blank"}set mappedQuestionConsolidatorLlm(e){this.editingModel.question_consolidator_llm="blank"===e?null:e}get mappedDefaultLlm(){return this.editingModel?.default_llm||"blank"}set mappedDefaultLlm(e){this.editingModel.default_llm="blank"===e?null:e}onChangeMaxPixels(e){const t=this.maxPixelValues.findBy("id",e)
t&&(this.maxPixelsValue=e,this.editingModel.vision_max_pixels=t.pixels)}delete(){return this.dialog.confirm({message:_.default.t("discourse_ai.ai_persona.confirm_delete"),didConfirm:()=>this.args.model.destroyRecord().then((()=>{this.args.personas.removeObject(this.args.model),this.router.transitionTo("adminPlugins.show.discourse-ai-personas.index")}))})}updateAllowedGroups(e){this.editingModel.set("allowed_group_ids",e)}async toggleEnabled(){await this.toggleField("enabled")}async togglePriority(){await this.toggleField("priority",!0)}async toggleMentionable(){await this.toggleField("mentionable")}async toggleAllowChat(){await this.toggleField("allow_chat")}async toggleVisionEnabled(){await this.toggleField("vision_enabled")}async createUser(){try{let e=await this.args.model.createUser()
this.editingModel.set("user",e),this.editingModel.set("user_id",e.id)}catch(e){(0,h.popupAjaxError)(e)}}updateUploads(e){this.editingModel.rag_uploads=e}removeUpload(e){this.editingModel.rag_uploads.removeObject(e),this.args.model.isNew||this.save()}async toggleField(e,t){if(this.args.model.set(e,!this.args.model[e]),this.editingModel.set(e,this.args.model[e]),!this.args.model.isNew)try{const i={}
i[e]=this.args.model[e],await this.args.model.update(i),t&&G(B,this,K).call(this)}catch(i){(0,h.popupAjaxError)(i)}}},(0,r.setComponentTemplate)((0,z.createTemplateFactory)({id:"TFmacbZg",block:'[[[1,"\\n "],[8,[32,0],null,[["@route","@label"],["adminPlugins.show.discourse-ai-personas","discourse_ai.ai_persona.back"]],null],[1,"\\n "],[11,"form"],[24,0,"form-horizontal ai-persona-editor"],[4,[32,1],[[30,0,["updateModel"]],[30,1,["id"]]],null],[4,[32,2],[[30,0,["updateModel"]],[30,1,["id"]]],null],[4,[32,2],[[30,0,["updateAllGroups"]],[30,1,["id"]]],null],[12],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[8,[32,3],[[24,0,"ai-persona-editor__enabled"],[4,[32,4],["click",[30,0,["toggleEnabled"]]],null]],[["@state","@label"],[[30,1,["enabled"]],"discourse_ai.ai_persona.enabled"]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group ai-persona-editor__priority"],[12],[1,"\\n "],[8,[32,3],[[24,0,"ai-persona-editor__priority"],[4,[32,4],["click",[30,0,["togglePriority"]]],null]],[["@state","@label"],[[30,1,["priority"]],"discourse_ai.ai_persona.priority"]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.priority_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["editingModel","user"]],[[[41,[30,0,["chatPluginEnabled"]],[[[1," "],[10,0],[14,0,"control-group ai-persona-editor__allow_chat"],[12],[1,"\\n "],[8,[32,3],[[24,0,"ai-persona-editor__allow_chat_toggle"],[4,[32,4],["click",[30,0,["toggleAllowChat"]]],null]],[["@state","@label"],[[30,1,["allow_chat"]],"discourse_ai.ai_persona.allow_chat"]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.allow_chat_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[10,0],[14,0,"control-group ai-persona-editor__mentionable"],[12],[1,"\\n "],[8,[32,3],[[24,0,"ai-persona-editor__mentionable_toggle"],[4,[32,4],["click",[30,0,["toggleMentionable"]]],null]],[["@state","@label"],[[30,1,["mentionable"]],"discourse_ai.ai_persona.mentionable"]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.mentionable_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[10,0],[14,0,"control-group ai-persona-editor__vision_enabled"],[12],[1,"\\n "],[8,[32,3],[[4,[32,4],["click",[30,0,["toggleVisionEnabled"]]],null]],[["@state","@label"],[[30,1,["vision_enabled"]],"discourse_ai.ai_persona.vision_enabled"]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.vision_enabled_help"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.name"],null]],[13],[1,"\\n "],[8,[32,7],[[24,0,"ai-persona-editor__name"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@type","@value"],["text",[30,0,["editingModel","name"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.description"],null]],[13],[1,"\\n "],[8,[32,8],[[24,0,"ai-persona-editor__description"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@value"],[[30,0,["editingModel","description"]]]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.default_llm"],null]],[13],[1,"\\n "],[8,[32,9],[[24,0,"ai-persona-editor__llms"]],[["@value","@llms"],[[30,0,["mappedDefaultLlm"]],[30,2,["resultSetMeta","llms"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.default_llm_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"],[41,[51,[30,1,["isNew"]]],[[[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.user"],null]],[13],[1,"\\n"],[41,[30,0,["editingModel","user"]],[[[1," "],[10,3],[14,0,"avatar"],[15,6,[30,0,["editingModel","user","path"]]],[15,"data-user-card",[30,0,["editingModel","user","username"]]],[12],[1,"\\n "],[1,[28,[32,10],[[30,0,["editingModel","user","avatar_template"]],"small"],null]],[1,"\\n "],[13],[1,"\\n "],[8,[32,11],null,[["@route","@model"],["adminUser",[30,0,["adminUser"]]]],[["default"],[[[[1,"\\n "],[1,[30,0,["editingModel","user","username"]]],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],[[[1," "],[8,[32,12],[[24,0,"ai-persona-editor__create-user"]],[["@action"],[[30,0,["createUser"]]]],[["default"],[[[[1,"\\n "],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.create_user"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.create_user_help"],null]]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.commands"],null]],[13],[1,"\\n "],[8,[32,13],[[24,0,"ai-persona-editor__commands"]],[["@value","@disabled","@commands"],[[30,0,["editingModel","commands"]],[30,0,["editingModel","system"]],[30,2,["resultSetMeta","commands"]]]],null],[1,"\\n "],[13],[1,"\\n"],[41,[51,[30,0,["editingModel","system"]]],[[[1," "],[8,[32,14],null,[["@persona","@commands","@allCommands"],[[30,0,["editingModel"]],[30,0,["editingModel","commands"]],[30,2,["resultSetMeta","commands"]]]],null],[1,"\\n"]],[]],null],[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.allowed_groups"],null]],[13],[1,"\\n "],[8,[32,15],null,[["@value","@content","@onChange"],[[30,0,["editingModel","allowed_group_ids"]],[30,0,["allGroups"]],[30,0,["updateAllowedGroups"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[14,"for","ai-persona-editor__system_prompt"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.system_prompt"],null]],[13],[1,"\\n "],[8,[32,8],[[24,0,"ai-persona-editor__system_prompt"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@value"],[[30,0,["editingModel","system_prompt"]]]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.max_context_posts"],null]],[13],[1,"\\n "],[8,[32,7],[[24,"lang","en"],[24,0,"ai-persona-editor__max_context_posts"]],[["@type","@value"],["number",[30,0,["editingModel","max_context_posts"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.max_context_posts_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"],[41,[30,1,["vision_enabled"]],[[[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.vision_max_pixels"],null]],[13],[1,"\\n "],[8,[32,16],null,[["@value","@content","@onChange"],[[30,0,["maxPixelsValue"]],[30,0,["maxPixelValues"]],[30,0,["onChangeMaxPixels"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n"],[41,[30,0,["showTemperature"]],[[[1," "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.temperature"],null]],[13],[1,"\\n "],[8,[32,7],[[24,0,"ai-persona-editor__temperature"],[24,"step","any"],[24,"lang","en"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@type","@value"],["number",[30,0,["editingModel","temperature"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.temperature_help"],null]]],null],[1,"\\n"]],[]],null],[41,[30,0,["showTopP"]],[[[1," "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.top_p"],null]],[13],[1,"\\n "],[8,[32,7],[[24,"step","any"],[24,"lang","en"],[24,0,"ai-persona-editor__top_p"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@type","@value"],["number",[30,0,["editingModel","top_p"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.top_p_help"],null]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[8,[32,17],null,[["@persona","@updateUploads","@onRemove"],[[30,0,["editingModel"]],[30,0,["updateUploads"]],[30,0,["removeUpload"]]]],null],[1,"\\n"],[41,[30,0,["editingModel","rag_uploads"]],[[[1," "],[11,3],[24,6,"#"],[24,0,"ai-persona-editor__indexing-options"],[4,[32,4],["click",[30,0,["toggleIndexingOptions"]]],null],[12],[1,[30,0,["indexingOptionsText"]]],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"],[41,[30,0,["showIndexingOptions"]],[[[1," "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_chunk_tokens"],null]],[13],[1,"\\n "],[8,[32,7],[[24,"step","any"],[24,"lang","en"],[24,0,"ai-persona-editor__rag_chunk_tokens"]],[["@type","@value"],["number",[30,0,["editingModel","rag_chunk_tokens"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_chunk_tokens_help"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_chunk_overlap_tokens"],null]],[13],[1,"\\n "],[8,[32,7],[[24,"step","any"],[24,"lang","en"],[24,0,"ai-persona-editor__rag_chunk_overlap_tokens"]],[["@type","@value"],["number",[30,0,["editingModel","rag_chunk_overlap_tokens"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_chunk_overlap_tokens_help"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_conversation_chunks"],null]],[13],[1,"\\n "],[8,[32,7],[[24,"step","any"],[24,"lang","en"],[24,0,"ai-persona-editor__rag_conversation_chunks"]],[["@type","@value"],["number",[30,0,["editingModel","rag_conversation_chunks"]]]],null],[1,"\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.rag_conversation_chunks_help"],null]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"control-group"],[12],[1,"\\n "],[10,"label"],[12],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.question_consolidator_llm"],null]],[13],[1,"\\n "],[8,[32,9],[[24,0,"ai-persona-editor__llms"]],[["@value","@llms"],[[30,0,["mappedQuestionConsolidatorLlm"]],[30,2,["resultSetMeta","llms"]]]],null],[1,"\\n\\n "],[8,[32,5],null,[["@icon","@content"],["question-circle",[28,[32,6,["t"]],["discourse_ai.ai_persona.question_consolidator_llm_help"],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]],null],[1," "],[10,0],[14,0,"control-group ai-persona-editor__action_panel"],[12],[1,"\\n "],[8,[32,12],[[24,0,"btn-primary ai-persona-editor__save"]],[["@action","@disabled"],[[30,0,["save"]],[30,0,["isSaving"]]]],[["default"],[[[[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.save"],null]]],[]]]]],[1,"\\n"],[41,[30,0,["showDelete"]],[[[1," "],[8,[32,12],[[24,0,"btn-danger ai-persona-editor__delete"]],[["@action"],[[30,0,["delete"]]]],[["default"],[[[[1,"\\n "],[1,[28,[32,6,["t"]],["discourse_ai.ai_persona.delete"],null]],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "]],["@model","@personas"],false,["if","unless"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-editor.js",scope:()=>[d.default,a.default,n.default,g.default,o.on,j.default,_.default,r.Input,m.default,x.default,b.default,l.LinkTo,p.default,S.default,P.default,w.default,v.default,O.default],isStrictMode:!0}),F),T=$((k=F).prototype,"router",[c.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),C=$(k.prototype,"store",[c.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),M=$(k.prototype,"dialog",[c.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),E=$(k.prototype,"toasts",[c.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),A=$(k.prototype,"siteSettings",[c.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),I=$(k.prototype,"allGroups",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),R=$(k.prototype,"isSaving",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),N=$(k.prototype,"editingModel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),D=$(k.prototype,"showDelete",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),U=$(k.prototype,"maxPixelsValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),q=$(k.prototype,"ragIndexingStatuses",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),L=$(k.prototype,"showIndexingOptions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),$(k.prototype,"updateModel",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"updateModel"),k.prototype),$(k.prototype,"toggleIndexingOptions",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"toggleIndexingOptions"),k.prototype),$(k.prototype,"maxPixelValues",[i.cached],Object.getOwnPropertyDescriptor(k.prototype,"maxPixelValues"),k.prototype),$(k.prototype,"updateAllGroups",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"updateAllGroups"),k.prototype),$(k.prototype,"save",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"save"),k.prototype),$(k.prototype,"onChangeMaxPixels",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"onChangeMaxPixels"),k.prototype),$(k.prototype,"delete",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"delete"),k.prototype),$(k.prototype,"updateAllowedGroups",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"updateAllowedGroups"),k.prototype),$(k.prototype,"toggleEnabled",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"toggleEnabled"),k.prototype),$(k.prototype,"togglePriority",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"togglePriority"),k.prototype),$(k.prototype,"toggleMentionable",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"toggleMentionable"),k.prototype),$(k.prototype,"toggleAllowChat",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"toggleAllowChat"),k.prototype),$(k.prototype,"toggleVisionEnabled",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"toggleVisionEnabled"),k.prototype),$(k.prototype,"createUser",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"createUser"),k.prototype),$(k.prototype,"updateUploads",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"updateUploads"),k.prototype),$(k.prototype,"removeUpload",[s.action],Object.getOwnPropertyDescriptor(k.prototype,"removeUpload"),k.prototype),k)
function K(){const e=this.args.personas.toArray().sort(((e,t)=>e.priority&&!t.priority?-1:!e.priority&&t.priority?1:e.name.localeCompare(t.name)))
this.args.personas.clear(),this.args.personas.setObjects(e)}})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-list-editor",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/modifier","@ember/object","@ember/routing","discourse/components/d-breadcrumbs-item","discourse/components/d-toggle-switch","discourse/helpers/concat-class","discourse/lib/ajax-error","discourse/lib/text","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/ai-persona-editor","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b,h,f){"use strict"
var _,y,v
function w(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(v=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="_noPersonaText",r=this,(i=y)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}get noPersonaText(){if(null===this._noPersonaText){const e=g.default.t("discourse_ai.ai_persona.no_persona_selected");(0,d.cook)(e).then((e=>{this._noPersonaText=e}))}return this._noPersonaText}async toggleEnabled(e){const t=e.enabled,i=!t
try{e.set("enabled",i),await e.save()}catch(r){e.set("enabled",t),(0,c.popupAjaxError)(r)}}},(0,h.setComponentTemplate)((0,f.createTemplateFactory)({id:"lKSnHit0",block:'[[[1,"\\n "],[8,[32,0],null,null,[["default"],[[[[1,"\\n "],[8,[32,1],[[16,0,[30,1]]],[["@route"],["adminPlugins.show.discourse-ai-personas"]],[["default"],[[[[1,"\\n "],[1,[28,[32,2],["discourse_ai.ai_persona.short_title"],null]],[1,"\\n "]],[]]]]],[1,"\\n "]],[1]]]]],[1,"\\n\\n "],[10,"section"],[14,0,"ai-persona-list-editor__current admin-detail pull-left"],[12],[1,"\\n"],[41,[30,2],[[[1," "],[8,[32,3],null,[["@model","@personas"],[[30,2],[30,3]]],null],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"ai-persona-list-editor__header"],[12],[1,"\\n "],[10,"h3"],[12],[1,[28,[32,2],["discourse_ai.ai_persona.short_title"],null]],[13],[1,"\\n"],[41,[51,[30,2,["isNew"]]],[[[1," "],[8,[32,1],[[24,0,"btn btn-small btn-primary"]],[["@route"],["adminPlugins.show.discourse-ai-personas.new"]],[["default"],[[[[1,"\\n "],[1,[28,[32,4],["plus"],null]],[1,"\\n "],[10,1],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.new"],null]],[13],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"ai-persona-list-editor__empty"],[12],[1,"\\n "],[10,"details"],[14,0,"details__boxed"],[12],[1,"\\n "],[10,"summary"],[12],[1,[28,[32,2],["discourse_ai.ai_persona.what_are_personas"],null]],[13],[1,"\\n "],[1,[30,0,["noPersonaText"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"table"],[14,0,"content-list ai-persona-list-editor"],[12],[1,"\\n "],[10,"thead"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"th"],[12],[1,[28,[32,2],["discourse_ai.ai_persona.name"],null]],[13],[1,"\\n "],[10,"th"],[12],[1,[28,[32,2],["discourse_ai.ai_persona.enabled"],null]],[13],[1,"\\n "],[10,"th"],[12],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tbody"],[12],[1,"\\n"],[42,[28,[31,3],[[28,[31,3],[[30,3]],null]],null],null,[[[1," "],[10,"tr"],[15,"data-persona-id",[30,4,["id"]]],[15,0,[28,[32,6],["ai-persona-list__row",[52,[30,4,["priority"]],"priority"]],null]],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,0],[14,0,"ai-persona-list__name-with-description"],[12],[1,"\\n "],[10,0],[14,0,"ai-persona-list__name"],[12],[1,"\\n "],[10,"strong"],[12],[1,"\\n "],[1,[30,4,["name"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"ai-persona-list__description"],[12],[1,"\\n "],[1,[30,4,["description"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[8,[32,7],[[4,[32,8],["click",[28,[32,9],[[30,0,["toggleEnabled"]],[30,4]],null]],null]],[["@state"],[[30,4,["enabled"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[8,[32,1],[[24,0,"btn btn-text btn-small"]],[["@route","@model"],["adminPlugins.show.discourse-ai-personas.show",[30,4]]],[["default"],[[[[1,[28,[32,2],["discourse_ai.ai_persona.edit"],null]],[1," "]],[]]]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[4]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "]],["linkClass","@currentPersona","@personas","persona"],false,["if","unless","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-list-editor.js",scope:()=>[a.default,n.LinkTo,m.default,b.default,p.default,g.default,u.default,l.default,o.on,r.fn],isStrictMode:!0}),v),y=w((_=v).prototype,"_noPersonaText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),w(_.prototype,"toggleEnabled",[s.action],Object.getOwnPropertyDescriptor(_.prototype,"toggleEnabled"),_.prototype),_)})),define("discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/modifier","@ember/object","@ember/service","discourse/components/d-button","discourse/helpers/category-badge","discourse/lib/ajax","discourse/lib/ajax-error","float-kit/components/d-menu","truth-helpers/helpers/eq","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g){"use strict"
var b,h,f,_,y,v,w
function j(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function S(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function x(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(w=class extends t.default{constructor(){super(...arguments),j(this,"site",h,this),j(this,"menu",f,this),j(this,"suggestions",_,this),j(this,"loading",y,this),j(this,"icon",v,this),S(this,"SUGGESTION_TYPES",{title:"suggest_title",category:"suggest_category",tag:"suggest_tags"})}get input(){return this.args.selectedPosts.map((e=>e.cooked)).join("\n")}get disabled(){return this.loading||this.suggestions.length>0}loadSuggestions(){this.loading||this.suggestions.length>0||(this.loading=!0,(0,u.ajax)(`/discourse-ai/ai-helper/${this.args.mode}`,{method:"POST",data:{text:this.input}}).then((e=>{if(this.args.mode===this.SUGGESTION_TYPES.title)this.suggestions=e.suggestions
else if(this.args.mode===this.SUGGESTION_TYPES.category){const t=e.assistant.map((e=>e.name)),i=this.site.categories.filter((e=>t.includes(e.name.toLowerCase())))
this.suggestions=i}else this.suggestions=e.assistant.map((e=>e.name))})).catch(c.popupAjaxError).finally((()=>{this.loading=!1})))}applySuggestion(e,t){if(this.args.mode){if(this.args.mode===this.SUGGESTION_TYPES.title)return this.args.updateAction(e),t.close()
if(this.args.mode===this.SUGGESTION_TYPES.category)return this.args.updateAction(e.id),t.close()
if(this.args.mode===this.SUGGESTION_TYPES.tag){if(this.args.currentValue)if(Array.isArray(this.args.currentValue)){const t=[...this.args.currentValue,e]
this.args.updateAction([...new Set(t)])}else{const t=[this.args.currentValue,e]
this.args.updateAction([...new Set(t)])}else this.args.updateAction(e)
return t.close()}}}},(0,m.setComponentTemplate)((0,g.createTemplateFactory)({id:"OK/TJTRS",block:'[[[1,"\\n"],[41,[30,0,["loading"]],[[[1," "],[8,[32,0],[[24,0,"ai-split-topic-loading-placeholder"]],[["@disabled","@icon"],[true,"spinner"]],null],[1,"\\n"]],[]],null],[1," "],[8,[32,1],[[24,0,"ai-split-topic-suggestion-button"],[16,"data-suggestion-mode",[30,1]],[4,[32,2],["click",[30,0,["loadSuggestions"]]],null]],[["@icon","@interactive","@identifier"],["discourse-sparkles",true,"ai-split-topic-suggestion-menu"]],[["default"],[[[[1,"\\n "],[10,"ul"],[14,0,"ai-split-topic-suggestion__results"],[12],[1,"\\n"],[41,[51,[30,0,["loading"]]],[[[42,[28,[31,3],[[28,[31,3],[[30,0,["suggestions"]]],null]],null],null,[[[41,[28,[32,3],[[30,1],"suggest_category"],null],[[[1," "],[11,"li"],[16,"data-name",[30,3,["name"]]],[16,"data-value",[30,3,["id"]]],[24,0,"ai-split-topic-suggestion__category-result"],[24,"role","button"],[4,[32,2],["click",[28,[32,4],[[30,0,["applySuggestion"]],[30,3],[30,2]],null]],null],[12],[1,"\\n "],[1,[28,[32,5],[[30,3]],null]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"li"],[15,"data-name",[30,3]],[15,"data-value",[30,4]],[12],[1,"\\n "],[8,[32,0],null,[["@translatedLabel","@action"],[[30,3],[28,[32,4],[[30,0,["applySuggestion"]],[30,3],[30,2]],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]]]],[3,4]],null]],[]],null],[1," "],[13],[1,"\\n "]],[2]]]]],[1,"\\n "]],["@mode","menu","suggestion","index"],false,["if","unless","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester.js",scope:()=>[a.default,d.default,o.on,p.default,r.fn,l.default],isStrictMode:!0}),w),h=x((b=w).prototype,"site",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=x(b.prototype,"menu",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=x(b.prototype,"suggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),y=x(b.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v=x(b.prototype,"icon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse-sparkles"}}),x(b.prototype,"loadSuggestions",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"loadSuggestions"),b.prototype),x(b.prototype,"applySuggestion",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"applySuggestion"),b.prototype),b)})),define("discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/service","discourse/components/d-button","discourse/lib/ajax","discourse/lib/ajax-error","discourse-common/utils/decorators","I18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m){"use strict"
var g,b,h,f,_,y,v,w,j,S,x,P
function O(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function z(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function k(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function T(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i
throw new TypeError("Private element is not present on this object")}function C(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(P=new WeakSet,x=class extends t.default{constructor(){super(...arguments),z(this,P),O(this,"dialog",b,this),O(this,"siteSettings",h,this),O(this,"composer",f,this),O(this,"loading",_,this),O(this,"showMenu",y,this),O(this,"generatedSuggestions",v,this),O(this,"suggestIcon",w,this),O(this,"showErrors",j,this),O(this,"error",S,this),k(this,"SUGGESTION_TYPES",{title:"suggest_title",category:"suggest_category",tag:"suggest_tags"})}willDestroy(){super.willDestroy(...arguments),document.removeEventListener("click",this.onClickOutside)}get showAIButton(){const e=this.composer.model.replyLength>40,t=document.querySelector(".composer-fields")
return t&&(e?t.classList.add("showing-ai-suggestions"):t.classList.remove("showing-ai-suggestions")),e}get disableSuggestionButton(){return this.loading}applyClasses(){this.showAIButton?document.querySelector(".composer-fields")?.classList.add("showing-ai-suggestions"):document.querySelector(".composer-fields")?.classList.remove("showing-ai-suggestions")}onClickOutside(e){const t=document.querySelector(".ai-title-suggestions-menu")
if(e.target!==t)return T(P,this,M).call(this)}handleClickOutside(){document.addEventListener("click",this.onClickOutside)}applySuggestion(e){if(!this.args.mode)return
const t=this.args?.composer
if(t){if(this.args.mode===this.SUGGESTION_TYPES.title)return t.set("title",e),T(P,this,M).call(this)
if(this.args.mode===this.SUGGESTION_TYPES.category){const i=this.composer.categories.find((t=>t.slug===e)).id
return t.set("categoryId",i),T(P,this,M).call(this)}this.args.mode===this.SUGGESTION_TYPES.tag&&T(P,this,E).call(this,e,t)}}async performSuggestion(){if(this.args.mode)return 0===this.composer.model.replyLength?this.dialog.alert(d.default.t("discourse_ai.ai_helper.missing_content")):(this.loading=!0,this.suggestIcon="spinner",(0,l.ajax)(`/discourse-ai/ai-helper/${this.args.mode}`,{method:"POST",data:{text:this.composer.model.reply}}).then((e=>{T(P,this,I).call(this,e,this.args.mode)})).catch(u.popupAjaxError).finally((()=>{this.loading=!1,this.suggestIcon="sync-alt",this.showMenu=!0,"suggest_category"===this.args.mode&&document.querySelector(".category-input")?.classList.add("showing-ai-suggestion-menu")})))}},(0,p.setComponentTemplate)((0,m.createTemplateFactory)({id:"Cn6HectJ",block:'[[[1,"\\n"],[41,[30,0,["showAIButton"]],[[[1," "],[8,[32,0],[[16,0,[29,["suggestion-button ",[52,[30,0,["loading"]],"is-loading"]]]],[17,1]],[["@icon","@title","@action","@disabled"],[[30,0,["suggestIcon"]],"discourse_ai.ai_helper.suggest",[30,0,["performSuggestion"]],[30,0,["disableSuggestionButton"]]]],null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showMenu"]],[[[1," "],[11,"ul"],[24,0,"popup-menu ai-suggestions-menu"],[4,[32,1],[[30,0,["handleClickOutside"]]],null],[12],[1,"\\n"],[41,[30,0,["showErrors"]],[[[1," "],[10,"li"],[14,0,"ai-suggestions-menu__errors"],[12],[1,[30,0,["error"]]],[13],[1,"\\n"]],[]],null],[42,[28,[31,2],[[28,[31,2],[[30,0,["generatedSuggestions"]]],null]],null],null,[[[1," "],[10,"li"],[15,"data-name",[30,2]],[15,"data-value",[30,3]],[12],[1,"\\n "],[8,[32,0],[[24,0,"popup-menu-btn"]],[["@translatedLabel","@action"],[[30,2],[28,[32,2],[[30,0,["applySuggestion"]],[30,2]],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[2,3]],null],[1," "],[13],[1,"\\n"]],[]],null],[1," "]],["&attrs","suggestion","index"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown.js",scope:()=>[a.default,s.default,r.fn],isStrictMode:!0}),x),b=C((g=x).prototype,"dialog",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),h=C(g.prototype,"siteSettings",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=C(g.prototype,"composer",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=C(g.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),y=C(g.prototype,"showMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v=C(g.prototype,"generatedSuggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),w=C(g.prototype,"suggestIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse-sparkles"}}),j=C(g.prototype,"showErrors",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),S=C(g.prototype,"error",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),C(g.prototype,"applyClasses",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"applyClasses"),g.prototype),C(g.prototype,"onClickOutside",[c.bind],Object.getOwnPropertyDescriptor(g.prototype,"onClickOutside"),g.prototype),C(g.prototype,"handleClickOutside",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"handleClickOutside"),g.prototype),C(g.prototype,"applySuggestion",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"applySuggestion"),g.prototype),C(g.prototype,"performSuggestion",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"performSuggestion"),g.prototype),g)
function M(){this.showMenu&&"suggest_category"===this.args.mode&&document.querySelector(".category-input")?.classList.remove("showing-ai-suggestion-menu"),this.suggestIcon="discourse-sparkles",this.showMenu=!1,this.showErrors=!1,this.errors=""}function E(e,t){const i=this.siteSettings.max_tags_per_topic
if(!t.tags)return t.set("tags",[e]),void(this.generatedSuggestions=this.generatedSuggestions.filter((t=>t!==e)))
const r=t.tags
return r?.length>=i?(this.showErrors=!0,void(this.error=d.default.t("select_kit.max_content_reached",{count:i}))):(r.push(e),t.set("tags",[...r]),this.generatedSuggestions=this.generatedSuggestions.filter((t=>t!==e)))}function A(){return this.args.composer?.tags&&this.args.composer?.tags.length>0}function I(e,t){if(t===this.SUGGESTION_TYPES.title)return this.generatedSuggestions=e.suggestions
const i=e.assistant.map((e=>e.name))
return t===this.SUGGESTION_TYPES.tag&&T(P,this,A).call(this)?this.generatedSuggestions=i.filter((e=>!this.args.composer.tags.includes(e))):this.generatedSuggestions=i}})),define("discourse/plugins/discourse-ai/discourse/components/modal/debug-ai-modal",["exports","@glimmer/component","@glimmer/tracking","@ember/modifier","@ember/object","@ember/runloop","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse/lib/ajax","discourse/lib/utilities","discourse-common/helpers/i18n","discourse-common/lib/later","discourse-i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_,y,v
function w(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function j(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(v=class extends t.default{constructor(){super(...arguments),w(this,"info",f,this),w(this,"justCopiedText",_,this),w(this,"activeTab",y,this),(0,s.next)((()=>{this.loadApiRequestInfo()}))}get htmlContext(){if(!this.info)return""
let e
try{if("request"!==this.activeTab)return this.formattedResponse(this.info.raw_response_payload)
e=JSON.parse(this.info.raw_request_payload)}catch(t){return this.info.raw_request_payload}return(0,n.htmlSafe)(this.jsonToHtml(e))}formattedResponse(e){const t=e.split("\n").map((e=>(0,c.escapeExpression)(e))).join("<br>")
return(0,n.htmlSafe)(t)}jsonToHtml(e){let t="<ul>"
for(let i in e)if(e.hasOwnProperty(i)){if(t+="<li>","object"==typeof e[i]&&Array.isArray(e[i]))t+=`<strong>${(0,c.escapeExpression)(i)}:</strong> ${this.jsonToHtml(e[i])}`
else if("object"==typeof e[i])t+=`<strong>${(0,c.escapeExpression)(i)}:</strong> <ul><li>${this.jsonToHtml(e[i])}</li></ul>`
else{let r=e[i]
"string"==typeof r&&(r=(0,c.escapeExpression)(r),r=r.replace(/\n/g,"<br>")),t+=`<strong>${(0,c.escapeExpression)(i)}:</strong> ${r}`}t+="</li>"}return t+="</ul>",t}copyRequest(){this.copy(this.info.raw_request_payload)}copyResponse(){this.copy(this.info.raw_response_payload)}copy(e){(0,c.clipboardCopy)(e),this.justCopiedText=m.default.t("discourse_ai.ai_bot.conversation_shared"),(0,p.default)((()=>{this.justCopiedText=""}),2e3)}loadApiRequestInfo(){(0,u.ajax)(`/discourse-ai/ai-bot/post/${this.args.model.id}/show-debug-info.json`).then((e=>{this.info=e}))}get requestActive(){return"request"===this.activeTab?"active":""}get responseActive(){return"response"===this.activeTab?"active":""}requestClicked(e){this.activeTab="request",e.preventDefault()}responseClicked(e){this.activeTab="response",e.preventDefault()}},(0,g.setComponentTemplate)((0,b.createTemplateFactory)({id:"SZ4z76vH",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"ai-debug-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_bot.debug_ai_modal.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n "],[10,"ul"],[14,0,"nav nav-pills ai-debug-modal__nav"],[12],[1,"\\n "],[10,"li"],[12],[11,3],[24,6,""],[16,0,[30,0,["requestActive"]]],[4,[32,2],["click",[30,0,["requestClicked"]]],null],[12],[1,[28,[32,1],["discourse_ai.ai_bot.debug_ai_modal.request"],null]],[13],[13],[1,"\\n "],[10,"li"],[12],[11,3],[24,6,""],[16,0,[30,0,["responseActive"]]],[4,[32,2],["click",[30,0,["responseClicked"]]],null],[12],[1,[28,[32,1],["discourse_ai.ai_bot.debug_ai_modal.response"],null]],[13],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"ai-debug-modal__tokens"],[12],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[28,[32,1],["discourse_ai.ai_bot.debug_ai_modal.request_tokens"],null]],[1,"\\n "],[1,[30,0,["info","request_tokens"]]],[1,"\\n "],[13],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[28,[32,1],["discourse_ai.ai_bot.debug_ai_modal.response_tokens"],null]],[1,"\\n "],[1,[30,0,["info","response_tokens"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"debug-ai-modal__preview"],[12],[1,"\\n "],[1,[30,0,["htmlContext"]]],[1,"\\n "],[13],[1,"\\n "]],[]],[[[1,"\\n "],[8,[32,3],[[24,0,"btn confirm"]],[["@icon","@action","@label"],["copy",[30,0,["copyRequest"]],"discourse_ai.ai_bot.debug_ai_modal.copy_request"]],null],[1,"\\n "],[8,[32,3],[[24,0,"btn confirm"]],[["@icon","@action","@label"],["copy",[30,0,["copyResponse"]],"discourse_ai.ai_bot.debug_ai_modal.copy_response"]],null],[1,"\\n "],[10,1],[14,0,"ai-debut-modal__just-copied"],[12],[1,[30,0,["justCopiedText"]]],[13],[1,"\\n "]],[]]]]],[1,"\\n "]],["@closeModal"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/debug-ai-modal.js",scope:()=>[l.default,d.default,r.on,a.default],isStrictMode:!0}),v),f=j((h=v).prototype,"info",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),_=j(h.prototype,"justCopiedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),y=j(h.prototype,"activeTab",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"request"}}),j(h.prototype,"copyRequest",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"copyRequest"),h.prototype),j(h.prototype,"copyResponse",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"copyResponse"),h.prototype),j(h.prototype,"requestClicked",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"requestClicked"),h.prototype),j(h.prototype,"responseClicked",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"responseClicked"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/components/modal/diff-modal",["exports","@glimmer/component","@ember/object","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l){"use strict"
var u,c
function d(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(c=class extends t.default{triggerConfirmChanges(){this.args.closeModal(),this.args.confirm()}triggerRevertChanges(){this.args.closeModal(),this.args.revert()}},(0,a.setComponentTemplate)((0,l.createTemplateFactory)({id:"tqHStVL1",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"composer-ai-helper-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_helper.context_menu.changes"],null],[30,1]]],[["body","footer"],[[[[1,"\\n"],[41,[30,2],[[[1," "],[1,[28,[32,2],[[30,2]],null]],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"composer-ai-helper-modal__old-value"],[12],[1,"\\n "],[1,[30,3]],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"composer-ai-helper-modal__new-value"],[12],[1,"\\n "],[1,[30,4]],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "]],[]],[[[1,"\\n "],[8,[32,3],[[24,0,"btn-primary confirm"]],[["@action","@label"],[[30,0,["triggerConfirmChanges"]],"discourse_ai.ai_helper.context_menu.confirm"]],null],[1,"\\n "],[8,[32,3],[[24,0,"btn-flat"]],[["@action","@label"],[[30,0,["triggerRevertChanges"]],"discourse_ai.ai_helper.context_menu.revert"]],null],[1,"\\n "]],[]]]]],[1,"\\n "]],["@closeModal","@diff","@oldValue","@newValue"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/diff-modal.js",scope:()=>[s.default,n.default,r.htmlSafe,o.default],isStrictMode:!0}),c),d((u=c).prototype,"triggerConfirmChanges",[i.action],Object.getOwnPropertyDescriptor(u.prototype,"triggerConfirmChanges"),u.prototype),d(u.prototype,"triggerRevertChanges",[i.action],Object.getOwnPropertyDescriptor(u.prototype,"triggerRevertChanges"),u.prototype),u)})),define("discourse/plugins/discourse-ai/discourse/components/modal/share-full-topic-modal",["exports","@glimmer/component","@glimmer/tracking","@ember/object","@ember/service","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/utilities","discourse-common/helpers/i18n","discourse-common/lib/get-url","discourse-i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_,y
function v(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function w(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(y=class extends t.default{constructor(){super(...arguments),v(this,"toasts",f,this),v(this,"shareKey",_,this),this.shareKey=this.args.model.share_key}get htmlContext(){let e=[]
return this.args.model.context.forEach((t=>{e.push(`<p><b>${t.username}:</b></p>`),e.push(t.cooked)})),(0,s.htmlSafe)(e.join("\n"))}async generateShareURL(){try{const e=await(0,l.ajax)("/discourse-ai/ai-bot/shared-ai-conversations",{type:"POST",data:{topic_id:this.args.model.topic_id}}),t=(0,p.getAbsoluteURL)(`/discourse-ai/ai-bot/shared-ai-conversations/${e.share_key}`)
return this.shareKey=e.share_key,new Blob([t],{type:"text/plain"})}catch(e){return void(0,u.popupAjaxError)(e)}}get primaryLabel(){return this.shareKey?"discourse_ai.ai_bot.share_full_topic_modal.update":"discourse_ai.ai_bot.share_full_topic_modal.share"}async deleteLink(){try{await(0,l.ajax)(`/discourse-ai/ai-bot/shared-ai-conversations/${this.shareKey}.json`,{type:"DELETE"}),this.shareKey=null}catch(e){(0,u.popupAjaxError)(e)}}async share(){await(0,c.clipboardCopyAsync)(this.generateShareURL.bind(this)),this.toasts.success({duration:3e3,data:{message:m.default.t("discourse_ai.ai_bot.conversation_shared")}})}},(0,g.setComponentTemplate)((0,b.createTemplateFactory)({id:"In8VW+gA",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"ai-share-full-topic-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_bot.share_full_topic_modal.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n "],[10,0],[14,0,"ai-share-full-topic-modal__body"],[12],[1,"\\n "],[1,[30,0,["htmlContext"]]],[1,"\\n "],[13],[1,"\\n "]],[]],[[[1,"\\n "],[8,[32,2],[[24,0,"btn-primary confirm"]],[["@icon","@action","@label"],["copy",[30,0,["share"]],[30,0,["primaryLabel"]]]],null],[1,"\\n"],[41,[30,0,["shareKey"]],[[[1," "],[8,[32,2],[[24,0,"btn-danger"]],[["@icon","@action","@label"],["far-trash-alt",[30,0,["deleteLink"]],"discourse_ai.ai_bot.share_full_topic_modal.delete"]],null],[1,"\\n"]],[]],null],[1," "]],[]]]]],[1,"\\n "]],["@closeModal"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/share-full-topic-modal.js",scope:()=>[a.default,d.default,n.default],isStrictMode:!0}),y),f=w((h=y).prototype,"toasts",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=w(h.prototype,"shareKey",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),w(h.prototype,"deleteLink",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"deleteLink"),h.prototype),w(h.prototype,"share",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"share"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/components/modal/share-modal",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/modifier","@ember/object","@ember/service","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse-common/helpers/i18n","discourse-common/lib/later","discourse-i18n","discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper","discourse/plugins/discourse-ai/discourse/lib/copy-conversation","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_,y,v,w,j,S,x,P
function O(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function z(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(P=class extends t.default{constructor(){super(...arguments),O(this,"modal",f,this),O(this,"siteSettings",_,this),O(this,"currentUser",y,this),O(this,"contextValue",v,this),O(this,"htmlContext",w,this),O(this,"maxContext",j,this),O(this,"allPosts",S,this),O(this,"justCopiedText",x,this)
const e=this.args.model.topic.get("postStream")
let t=[]
for(let i=1;i<=this.args.model.post_number;i++)t.push(i)
this.allPosts=t.map((t=>{let i=e.findPostIdForPostNumber(t)
if(i)return e.findLoadedPost(i)})).filter((e=>e)),this.maxContext=this.allPosts.length/2,this.contextValue=1,this.updateHtmlContext()}updateHtmlContext(){let e=[]
for(let t=this.allPosts.length-2*this.contextValue;t<this.allPosts.length;t++){const i=this.allPosts[t]
e.push(`<p><b>${i.username}:</b></p>`),e.push(i.cooked)}this.htmlContext=(0,a.htmlSafe)(e.join("\n"))}async copyContext(){const e=this.allPosts[this.allPosts.length-2*this.contextValue].post_number,t=this.args.model.post_number
await(0,g.default)(this.args.model.topic,e,t),this.justCopiedText=p.default.t("discourse_ai.ai_bot.conversation_shared"),(0,d.default)((()=>{this.justCopiedText=""}),2e3)}shareConversationModal(e){return e?.preventDefault(),this.args.closeModal(),(0,m.showShareConversationModal)(this.modal,this.args.model.topic_id),!1}},(0,r.setComponentTemplate)((0,b.createTemplateFactory)({id:"Ccsc9yzh",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"ai-share-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_bot.share_modal.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n "],[10,0],[14,0,"ai-share-modal__preview"],[12],[1,"\\n "],[1,[30,0,["htmlContext"]]],[1,"\\n "],[13],[1,"\\n "]],[]],[[[1,"\\n "],[10,0],[14,0,"ai-share-modal__slider"],[12],[1,"\\n "],[8,[32,2],[[24,"min","1"],[16,"max",[30,0,["maxContext"]]],[4,[32,3],["change",[30,0,["updateHtmlContext"]]],null]],[["@type","@value"],["range",[30,0,["contextValue"]]]],null],[1,"\\n "],[10,0],[14,0,"ai-share-modal__context"],[12],[1,"\\n "],[1,[28,[32,1],["discourse_ai.ai_bot.share_modal.context"],null]],[1,"\\n "],[1,[30,0,["contextValue"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[8,[32,4],[[24,0,"btn-primary confirm"]],[["@icon","@action","@label"],["copy",[30,0,["copyContext"]],"discourse_ai.ai_bot.share_modal.copy"]],null],[1,"\\n "],[10,1],[14,0,"ai-share-modal__just-copied"],[12],[1,[30,0,["justCopiedText"]]],[13],[1,"\\n"],[41,[30,0,["currentUser","can_share_ai_bot_conversations"]],[[[1," "],[11,3],[24,6,""],[4,[32,3],["click",[30,0,["shareConversationModal"]]],null],[12],[1,"\\n "],[10,1],[14,0,"ai-share-modal__share-tip"],[12],[1,"\\n "],[1,[28,[32,1],["discourse_ai.ai_bot.share_modal.share_tip"],null]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[]]]]],[1,"\\n "]],["@closeModal"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/share-modal.js",scope:()=>[u.default,c.default,r.Input,o.on,l.default],isStrictMode:!0}),P),f=z((h=P).prototype,"modal",[n.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=z(h.prototype,"siteSettings",[n.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=z(h.prototype,"currentUser",[n.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v=z(h.prototype,"contextValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),w=z(h.prototype,"htmlContext",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),j=z(h.prototype,"maxContext",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),S=z(h.prototype,"allPosts",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),x=z(h.prototype,"justCopiedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),z(h.prototype,"updateHtmlContext",[s.action],Object.getOwnPropertyDescriptor(h.prototype,"updateHtmlContext"),h.prototype),z(h.prototype,"copyContext",[s.action],Object.getOwnPropertyDescriptor(h.prototype,"copyContext"),h.prototype),z(h.prototype,"shareConversationModal",[s.action],Object.getOwnPropertyDescriptor(h.prototype,"shareConversationModal"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/components/modal/thumbnail-suggestions",["exports","@glimmer/component","@glimmer/tracking","@ember/object","discourse/components/d-button","discourse/components/d-modal","discourse/components/d-modal-cancel","discourse-common/helpers/i18n","discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m
function g(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="selectedImages",r=this,(i=p)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}get isDisabled(){return 0===this.selectedImages.length}addSelection(e){const t=`![${e.original_filename}|${e.width}x${e.height}](${e.short_url})`
this.selectedImages=[...this.selectedImages,t]}removeSelection(e){const t=`![${e.original_filename}|${e.width}x${e.height}](${e.short_url})`
this.selectedImages=this.selectedImages.filter((e=>{if(e!==t)return e}))}appendSelectedImages(){const e="\n\n"+this.selectedImages.join("\n"),t=document.querySelector(".d-editor-input")
t.setSelectionRange(t.value.length,t.value.length),t.focus(),document.execCommand("insertText",!1,e),this.args.closeModal()}},(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"rVPkxzzs",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"thumbnail-suggestions-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_helper.thumbnail_suggestions.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n "],[10,0],[14,0,"ai-thumbnail-suggestions"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,2]],null]],null],null,[[[1," "],[8,[32,2],null,[["@thumbnail","@addSelection","@removeSelection"],[[30,3],[30,0,["addSelection"]],[30,0,["removeSelection"]]]],null],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n "]],[]],[[[1,"\\n "],[8,[32,3],[[24,0,"btn-primary create"]],[["@action","@label","@disabled"],[[30,0,["appendSelectedImages"]],"save",[30,0,["isDisabled"]]]],null],[1,"\\n "],[8,[32,4],null,[["@close"],[[30,1]]],null],[1,"\\n "]],[]]]]],[1,"\\n "]],["@closeModal","@thumbnails","thumbnail"],false,["each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/thumbnail-suggestions.js",scope:()=>[s.default,a.default,l.default,o.default,n.default],isStrictMode:!0}),m),p=g((d=m).prototype,"selectedImages",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),g(d.prototype,"addSelection",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"addSelection"),d.prototype),g(d.prototype,"removeSelection",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"removeSelection"),d.prototype),g(d.prototype,"appendSelectedImages",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"appendSelectedImages"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/components/model-accuracies",["exports","@ember/component","@ember/component/template-only","@ember/template-factory"],(function(e,t,i,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const o=(0,r.createTemplateFactory)({id:"r8usWg+W",block:'[[[41,[30,1],[[[1," "],[10,"table"],[14,0,"reviewable-scores"],[12],[1,"\\n "],[10,"tbody"],[12],[1,"\\n"],[42,[28,[37,2],[[30,1]],null],null,[[[1," "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[14,"colspan","4"],[12],[1,[28,[35,3],["discourse_ai.reviewables.model_used"],null]],[13],[1,"\\n "],[10,"td"],[14,"colspan","3"],[12],[1,[30,3]],[13],[1,"\\n "],[10,"td"],[14,"colspan","4"],[12],[1,[28,[35,3],["discourse_ai.reviewables.accuracy"],null]],[13],[1,"\\n "],[10,"td"],[14,"colspan","3"],[12],[1,[30,2]],[1,"%"],[13],[1,"\\n "],[13],[1,"\\n"]],[2,3]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],["@accuracies","acc","model"],false,["if","each","-each-in","i18n"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/model-accuracies.hbs",isStrictMode:!1})
e.default=(0,t.setComponentTemplate)(o,(0,i.default)())})),define("discourse/plugins/discourse-ai/discourse/components/persona-rag-uploader",["exports","@glimmer/tracking","@ember/component","@ember/helper","@ember/modifier","@ember/object","@ember/service","discourse/components/d-button","discourse/lib/ajax","discourse/mixins/uppy-upload","discourse-common/helpers/d-icon","discourse-common/lib/debounce","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/rag-upload-progress","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g){"use strict"
var b,h,f,_,y,v,w
function j(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function S(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function x(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(w=class extends(i.default.extend(u.default)){constructor(){super(...arguments),j(this,"appEvents",h,this),j(this,"term",f,this),j(this,"filteredUploads",_,this),j(this,"ragIndexingStatuses",y,this),j(this,"ragUploads",v,this),S(this,"id","discourse-ai-persona-rag-uploader"),S(this,"maxFiles",20),S(this,"uploadUrl","/admin/plugins/discourse-ai/ai-personas/files/upload"),S(this,"preventDirectS3Uploads",!0)}didReceiveAttrs(){super.didReceiveAttrs(...arguments),this.inProgressUploads?.length>0&&this._uppyInstance?.cancelAll(),this.ragUploads=this.persona?.rag_uploads||[],this.filteredUploads=this.ragUploads,this.ragUploads?.length&&this.persona?.id&&(0,l.ajax)(`/admin/plugins/discourse-ai/ai-personas/${this.persona.id}/files/status.json`).then((e=>{this.set("ragIndexingStatuses",e)})),this.appEvents.on(`upload-mixin:${this.id}:all-uploads-complete`,this,"_updatePersonaWithUploads")}willDestroy(){super.willDestroy(...arguments),this.appEvents.off(`upload-mixin:${this.id}:all-uploads-complete`,this,"_updatePersonaWithUploads")}_updatePersonaWithUploads(){this.updateUploads(this.ragUploads)}uploadDone(e){const t=e.upload
t.status="uploaded",t.statusText=p.default.t("discourse_ai.ai_persona.uploads.uploaded"),this.ragUploads.pushObject(t),this.debouncedSearch()}submitFiles(){this.fileInputEl.click()}cancelUploading(e){this.appEvents.trigger(`upload-mixin:${this.id}:cancel-upload`,{fileId:e.id})}search(){this.term?this.filteredUploads=this.ragUploads.filter((e=>e.original_filename.toUpperCase().indexOf(this.term.toUpperCase())>-1)):this.filteredUploads=this.ragUploads}debouncedSearch(){(0,d.default)(this,this.search,100)}removeUpload(e){this.ragUploads.removeObject(e),this.onRemove(e),this.debouncedSearch()}},(0,i.setComponentTemplate)((0,g.createTemplateFactory)({id:"EpNZUCWj",block:'[[[1,"\\n "],[10,0],[14,0,"persona-rag-uploader"],[12],[1,"\\n "],[10,"h3"],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.uploads.title"],null]],[13],[1,"\\n "],[10,2],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.uploads.description"],null]],[13],[1,"\\n\\n"],[41,[30,0,["ragUploads"]],[[[1," "],[10,0],[14,0,"persona-rag-uploader__search-input-container"],[12],[1,"\\n "],[10,0],[14,0,"persona-rag-uploader__search-input"],[12],[1,"\\n "],[1,[28,[32,1],["search"],[["class"],["persona-rag-uploader__search-input__search-icon"]]]],[1,"\\n "],[8,[32,2],[[24,0,"persona-rag-uploader__search-input__input"],[16,"placeholder",[28,[32,0,["t"]],["discourse_ai.ai_persona.uploads.filter"],null]],[4,[32,3],["keyup",[30,0,["debouncedSearch"]]],null]],[["@value"],[[30,0,["term"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,"table"],[14,0,"persona-rag-uploader__uploads-list"],[12],[1,"\\n "],[10,"tbody"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["filteredUploads"]]],null]],null],null,[[[1," "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,1],[14,0,"persona-rag-uploader__rag-file-icon"],[12],[1,[28,[32,1],["file"],null]],[13],[1,"\\n "],[1,[30,1,["original_filename"]]],[1,"\\n "],[13],[1,"\\n "],[8,[32,4],null,[["@upload","@ragIndexingStatuses"],[[30,1],[30,0,["ragIndexingStatuses"]]]],null],[1,"\\n "],[10,"td"],[14,0,"persona-rag-uploader__remove-file"],[12],[1,"\\n "],[8,[32,5],null,[["@icon","@title","@action","@class"],["times","discourse_ai.ai_persona.uploads.remove",[28,[32,6],[[30,0,["removeUpload"]],[30,1]],null],"btn-flat"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[42,[28,[31,2],[[28,[31,2],[[30,0,["inProgressUploads"]]],null]],null],null,[[[1," "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[10,1],[14,0,"persona-rag-uploader__rag-file-icon"],[12],[1,[28,[32,1],["file"],null]],[13],[1,"\\n "],[1,[30,2,["original_filename"]]],[13],[1,"\\n "],[10,"td"],[14,0,"persona-rag-uploader__upload-status"],[12],[1,"\\n "],[10,0],[14,0,"spinner small"],[12],[13],[1,"\\n "],[10,1],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.uploads.uploading"],null]],[1,"\\n "],[1,[30,2,["uploadProgress"]]],[1,"%"],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[14,0,"persona-rag-uploader__remove-file"],[12],[1,"\\n "],[8,[32,5],null,[["@icon","@title","@action","@class"],["times","discourse_ai.ai_persona.uploads.remove",[28,[32,6],[[30,0,["cancelUploading"]],[30,2]],null],"btn-flat"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"input"],[14,0,"hidden-upload-field"],[15,"disabled",[30,0,["uploading"]]],[14,"multiple","multiple"],[14,"accept",".txt,.md"],[14,4,"file"],[12],[13],[1,"\\n "],[8,[32,5],[[24,0,"btn-default"]],[["@label","@icon","@title","@action"],["discourse_ai.ai_persona.uploads.button","plus","discourse_ai.ai_persona.uploads.button",[30,0,["submitFiles"]]]],null],[1,"\\n "],[13],[1,"\\n "]],["upload","upload"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/persona-rag-uploader.js",scope:()=>[p.default,c.default,i.Input,o.on,m.default,a.default,r.fn],isStrictMode:!0}),w),h=x((b=w).prototype,"appEvents",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=x(b.prototype,"term",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),_=x(b.prototype,"filteredUploads",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),y=x(b.prototype,"ragIndexingStatuses",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),v=x(b.prototype,"ragUploads",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),x(b.prototype,"submitFiles",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"submitFiles"),b.prototype),x(b.prototype,"cancelUploading",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"cancelUploading"),b.prototype),x(b.prototype,"search",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"search"),b.prototype),x(b.prototype,"debouncedSearch",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"debouncedSearch"),b.prototype),x(b.prototype,"removeUpload",[s.action],Object.getOwnPropertyDescriptor(b.prototype,"removeUpload"),b.prototype),b)})),define("discourse/plugins/discourse-ai/discourse/components/rag-upload-progress",["exports","@glimmer/component","@glimmer/tracking","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/service","discourse-common/helpers/d-icon","discourse-common/utils/decorators","discourse-i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m,g
function b(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function h(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(g=class extends t.default{constructor(){super(...arguments),b(this,"messageBus",p,this),b(this,"updatedProgress",m,this)}willDestroy(){super.willDestroy(...arguments),this.messageBus.unsubscribe(`/discourse-ai/ai-persona-rag/${this.args.upload.id}`)}trackProgress(){this.messageBus.subscribe(`/discourse-ai/ai-persona-rag/${this.args.upload.id}`,this.onIndexingUpdate)}onIndexingUpdate(e){(!this.updatedProgress||0===e.total||this.updatedProgress.left>e.left)&&(this.updatedProgress=e)}get calculateProgress(){return 0===this.progress.total?0:Math.ceil(100*this.progress.indexed/this.progress.total)}get fullyIndexed(){return this.progress&&0!==this.progress.total&&0===this.progress.left}get progress(){return this.updatedProgress?this.updatedProgress:this.args.ragIndexingStatuses?this.args.ragIndexingStatuses[this.args.upload.id]:[]}},(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"otL3+nu2",block:'[[[1,"\\n "],[11,"td"],[24,0,"persona-rag-uploader__upload-status"],[4,[32,0],[[30,0,["trackProgress"]]],null],[12],[1,"\\n"],[41,[30,0,["progress"]],[[[41,[30,0,["fullyIndexed"]],[[[1," "],[10,1],[14,0,"indexed"],[12],[1,"\\n "],[1,[28,[32,1],["check"],null]],[1,"\\n "],[1,[28,[32,2,["t"]],["discourse_ai.ai_persona.uploads.indexed"],null]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"indexing"],[12],[1,"\\n "],[1,[28,[32,1],["robot"],null]],[1,"\\n "],[1,[28,[32,2,["t"]],["discourse_ai.ai_persona.uploads.indexing"],null]],[1,"\\n "],[1,[30,0,["calculateProgress"]]],[1,"%\\n "],[13],[1,"\\n"]],[]]]],[]],[[[1," "],[10,1],[14,0,"uploaded"],[12],[1,[28,[32,2,["t"]],["discourse_ai.ai_persona.uploads.uploaded"],null]],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/rag-upload-progress.js",scope:()=>[o.default,n.default,l.default],isStrictMode:!0}),g),p=h((d=g).prototype,"messageBus",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),m=h(d.prototype,"updatedProgress",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),h(d.prototype,"trackProgress",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"trackProgress"),d.prototype),h(d.prototype,"onIndexingUpdate",[a.bind],Object.getOwnPropertyDescriptor(d.prototype,"onIndexingUpdate"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/components/reviewable-ai-chat-message",["exports","@ember/component","@glimmer/component","discourse/plugins/chat/discourse/models/chat-channel","@ember/template-factory"],(function(e,t,i,r,o){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const s=(0,o.createTemplateFactory)({id:"yKOx21Wk",block:'[[[41,[30,0,["chatChannel"]],[[[1," "],[10,0],[14,0,"flagged-post-header"],[12],[1,"\\n "],[8,[39,1],null,[["@route","@models"],["chat.channel.near-message",[28,[37,2],[[30,0,["chatChannel","slugifiedTitle"]],[30,0,["chatChannel","id"]],[30,1,["target_id"]]],null]]],[["default"],[[[[1,"\\n "],[8,[39,3],null,[["@channel"],[[30,0,["chatChannel"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[10,0],[14,0,"post-contents-wrapper"],[12],[1,"\\n "],[8,[39,4],null,[["@user","@tagName"],[[30,1,["target_created_by"]],""]],null],[1,"\\n "],[10,0],[14,0,"post-contents"],[12],[1,"\\n "],[8,[39,5],null,[["@reviewable","@createdBy","@tagName"],[[30,1],[30,1,["target_created_by"]],""]],null],[1,"\\n\\n "],[10,0],[14,0,"post-body"],[12],[1,"\\n "],[1,[28,[35,6],[[28,[37,7],[[30,1,["payload","message_cooked"]],[30,1,["cooked"]]],null]],null]],[1,"\\n "],[13],[1,"\\n\\n "],[18,2,null],[1,"\\n\\n "],[8,[39,9],null,[["@accuracies"],[[30,1,["payload","accuracies"]]]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@reviewable","&default"],false,["if","link-to","array","chat-channel-title","reviewable-created-by","reviewable-post-header","html-safe","or","yield","model-accuracies"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/reviewable-ai-chat-message.hbs",isStrictMode:!1})
class n extends i.default{get chatChannel(){if(this.args.reviewable.chat_channel)return r.default.create(this.args.reviewable.chat_channel)}}e.default=n,(0,t.setComponentTemplate)(s,n)})),define("discourse/plugins/discourse-ai/discourse/components/reviewable-ai-post",["exports","@ember/component","@ember/component/template-only","@ember/template-factory"],(function(e,t,i,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const o=(0,r.createTemplateFactory)({id:"XJ3JIp4P",block:'[[[10,0],[14,0,"flagged-post-header"],[12],[1,"\\n "],[8,[39,0],null,[["@reviewable","@tagName"],[[30,1],""]],null],[1,"\\n "],[8,[39,1],null,[["@reviewable","@tagName"],[[30,1],""]],null],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"post-contents-wrapper"],[12],[1,"\\n "],[8,[39,2],null,[["@user","@tagName"],[[30,1,["target_created_by"]],""]],null],[1,"\\n "],[10,0],[14,0,"post-contents"],[12],[1,"\\n "],[8,[39,3],null,[["@reviewable","@createdBy","@tagName"],[[30,1],[30,1,["target_created_by"]],""]],null],[1,"\\n "],[10,0],[14,0,"post-body"],[12],[1,"\\n"],[41,[30,1,["blank_post"]],[[[1," "],[10,2],[12],[1,[28,[35,5],["review.deleted_post"],null]],[13],[1,"\\n"]],[]],[[[1," "],[1,[28,[35,6],[[30,1,["cooked"]]],null]],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n\\n "],[18,2,null],[1,"\\n\\n "],[8,[39,8],null,[["@accuracies"],[[30,1,["payload","accuracies"]]]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@reviewable","&default"],false,["reviewable-topic-link","reviewable-post-edits","reviewable-created-by","reviewable-post-header","if","i18n","html-safe","yield","model-accuracies"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/reviewable-ai-post.hbs",isStrictMode:!1})
e.default=(0,t.setComponentTemplate)(o,(0,i.default)())})),define("discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","discourse/components/d-button","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a){"use strict"
var l,u,c,d,p
function m(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function g(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(p=class extends t.default{constructor(){super(...arguments),m(this,"selected",u,this),m(this,"selectIcon",c,this),m(this,"selectLabel",d,this)}toggleSelection(e){return this.selected?(this.selectIcon="far-circle",this.selectLabel="discourse_ai.ai_helper.thumbnail_suggestions.select",this.selected=!1,this.args.removeSelection(e)):(this.selectIcon="check-circle",this.selectLabel="discourse_ai.ai_helper.thumbnail_suggestions.selected",this.selected=!0,this.args.addSelection(e))}},(0,n.setComponentTemplate)((0,a.createTemplateFactory)({id:"BsBgpDKw",block:'[[[1,"\\n "],[10,0],[14,0,"ai-thumbnail-suggestions__item"],[12],[1,"\\n "],[8,[32,0],[[16,0,[52,[30,0,["selected"]],"btn-primary"]]],[["@icon","@label","@action"],[[30,0,["selectIcon"]],[30,0,["selectLabel"]],[28,[32,1],[[30,0,["toggleSelection"]],[30,1]],null]]],null],[1,"\\n "],[10,"img"],[15,"src",[30,1,["url"]]],[14,"loading","lazy"],[15,"width",[30,1,["thumbnail_width"]]],[15,"height",[30,1,["thumbnail_height"]]],[12],[13],[1,"\\n "],[13],[1,"\\n "]],["@thumbnail"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item.js",scope:()=>[s.default,r.fn],isStrictMode:!0}),p),u=g((l=p).prototype,"selected",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),c=g(l.prototype,"selectIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"far-circle"}}),d=g(l.prototype,"selectLabel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse_ai.ai_helper.thumbnail_suggestions.select"}}),g(l.prototype,"toggleSelection",[o.action],Object.getOwnPropertyDescriptor(l.prototype,"toggleSelection"),l.prototype),l)}))
define("discourse/plugins/discourse-ai/discourse/connectors/admin-dashboard-tabs-after/admin-sentiment-dashbboard",["exports","@glimmer/component","@ember/routing","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return t.siteSettings.ai_sentiment_enabled}}e.default=a,n=a,(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"aCrw9598",block:'[[[1,"\\n "],[10,"li"],[14,0,"navigation-item sentiment"],[12],[1,"\\n "],[8,[32,0],[[24,0,"navigation-link"]],[["@route"],["admin.dashboardSentiment"]],[["default"],[[[[1,"\\n "],[1,[28,[32,1],["discourse_ai.sentiments.dashboard.title"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/admin-dashboard-tabs-after/admin-sentiment-dashbboard.js",scope:()=>[i.LinkTo,r.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-category-input/ai-category-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="siteSettings",r=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}static shouldRender(e,t){return(0,o.showComposerAIHelper)(e,t,"suggestions")}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"tgy79Whv",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1," "],[8,[32,0],[[24,0,"suggest-category-button"]],[["@mode","@composer"],["suggest_category",[30,1,["composer"]]]],null],[1,"\\n"]],[]],null],[1," "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-category-input/ai-category-suggestion.js",scope:()=>[r.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},b={},Object.keys(m).forEach((function(e){b[e]=m[e]})),b.enumerable=!!b.enumerable,b.configurable=!!b.configurable,("value"in b||b.initializer)&&(b.writable=!0),b=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),b),g&&void 0!==b.initializer&&(b.value=b.initializer?b.initializer.call(g):void 0,b.initializer=void 0),void 0===b.initializer&&(Object.defineProperty(c,d,b),b=null),l=b,a)
var c,d,p,m,g,b})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-tag-input/ai-tag-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="siteSettings",r=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}static shouldRender(e,t){return(0,o.showComposerAIHelper)(e,t,"suggestions")}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"qB6wq01S",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1," "],[8,[32,0],[[24,0,"suggest-tags-button"]],[["@mode","@composer"],["suggest_tags",[30,1,["composer"]]]],null],[1,"\\n"]],[]],null],[1," "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-tag-input/ai-tag-suggestion.js",scope:()=>[r.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},b={},Object.keys(m).forEach((function(e){b[e]=m[e]})),b.enumerable=!!b.enumerable,b.configurable=!!b.configurable,("value"in b||b.initializer)&&(b.writable=!0),b=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),b),g&&void 0!==b.initializer&&(b.value=b.initializer?b.initializer.call(g):void 0,b.initializer=void 0),void 0===b.initializer&&(Object.defineProperty(c,d,b),b=null),l=b,a)
var c,d,p,m,g,b})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-title-input/ai-title-suggestion",["exports","@glimmer/component","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return(0,r.showComposerAIHelper)(e,t,"suggestions")}}e.default=a,n=a,(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"4En7i5/x",block:'[[[1,"\\n "],[8,[32,0],[[24,0,"suggest-titles-button"]],[["@mode","@composer"],["suggest_title",[30,1,["composer"]]]],null],[1,"\\n "]],["@outletArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-title-input/ai-title-suggestion.js",scope:()=>[i.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-d-editor/ai-helper-context-menu",["exports","@glimmer/component","@glimmer/tracking","@ember/object","@ember/service","@popperjs/core","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/utilities","discourse-common/config/environment","discourse-common/utils/decorators","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper"],(function(e,t,i,r,o,s,n,a,l,u,c,d){"use strict"
var p,m,g,b,h,f,_,y,v,w,j,S,x,P,O,z,k,T,C,M,E,A,I,R,N,D,U,q,L
function F(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function B(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function V(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(p=(0,c.debounce)(u.INPUT_DELAY),m=class extends t.default{constructor(){super(...arguments),F(this,"currentUser",g,this),F(this,"siteSettings",b,this),F(this,"modal",h,this),F(this,"capabilities",f,this),F(this,"showContextMenu",_,this),F(this,"caretCoords",y,this),F(this,"virtualElement",v,this),F(this,"selectedText",w,this),F(this,"newSelectedText",j,this),F(this,"loading",S,this),F(this,"lastUsedOption",x,this),F(this,"showDiffModal",P,this),F(this,"showThumbnailModal",O,this),F(this,"diff",z,this),F(this,"popperPlacement",k,this),F(this,"previousMenuState",T,this),F(this,"customPromptValue",C,this),F(this,"initialValue",M,this),F(this,"thumbnailSuggestions",E,this),F(this,"selectionRange",A,this),F(this,"lastSelectionRange",I,this),B(this,"CONTEXT_MENU_STATES",{triggers:"TRIGGERS",options:"OPTIONS",resets:"RESETS",loading:"LOADING",review:"REVIEW"}),B(this,"prompts",[]),B(this,"promptTypes",{}),B(this,"minSelectionChars",3),F(this,"_menuState",R,this),F(this,"_popper",N,this),F(this,"_dEditorInput",D,this),F(this,"_customPromptInput",U,this)
F(this,"_contextMenu",q,this),F(this,"_activeAIRequest",L,this)}static shouldRender(e,t){return(0,d.showComposerAIHelper)(e,t,"context_menu")}willDestroy(){super.willDestroy(...arguments),document.removeEventListener("selectionchange",this.selectionChanged),document.removeEventListener("keydown",this.onKeyDown),this._popper?.destroy()}get menuState(){return this._menuState}set menuState(e){this.previousMenuState=this._menuState,this._menuState=e}get helperOptions(){let e=this.currentUser?.ai_helper_prompts
e=e.filter((e=>e.location.includes("composer"))).filter((e=>"generate_titles"!==e.name))
const t=e.findIndex((e=>"custom_prompt"===e.name))
if(-1!==t){const i=e.splice(t,1)[0]
e.unshift(i)}return this._showUserCustomPrompts()||(e=e.filter((e=>"custom_prompt"!==e.name))),e.forEach((e=>{this.prompts[e.id]=e})),this.promptTypes=e.reduce(((e,t)=>(e[t.name]=t.prompt_type,e)),{}),e}selectionChanged(){if(document.activeElement!==this._dEditorInput)return
const e=Boolean(window.getSelection()&&document.activeElement&&document.activeElement.value)
this.selectedText=e?document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd):"",this.selectionRange=e?{x:document.activeElement.selectionStart,y:document.activeElement.selectionEnd}:{x:0,y:0},0!==this.selectedText?.length?this.selectedText?.length<this.minSelectionChars||this._onSelectionChanged():this.closeContextMenu()}updatePosition(){this.showContextMenu&&this.positionContextMenu()}onKeyDown(e){return"Escape"===e.key||"Backspace"===e.key&&this.selectedText&&this.menuState===this.CONTEXT_MENU_STATES.triggers?this.closeContextMenu():void 0}_onSelectionChanged(){this.positionContextMenu(),this.showContextMenu=!0}generateGetBoundingClientRect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0
return()=>({width:e,height:t,top:r,right:i,bottom:r,left:i})}get canCloseContextMenu(){return document.activeElement!==this._customPromptInput&&((!this.loading||null===this._activeAIRequest)&&this.menuState!==this.CONTEXT_MENU_STATES.review)}closeContextMenu(){this.canCloseContextMenu&&(this.showContextMenu=!1,this.menuState=this.CONTEXT_MENU_STATES.triggers,this.customPromptValue="")}_updateSuggestedByAI(e){this.newSelectedText=e.suggestions[0],e.diff&&(this.diff=e.diff),this._insertAt(this.selectionRange.x,this.selectionRange.y,this.newSelectedText),this.menuState=this.CONTEXT_MENU_STATES.review}_insertAt(e,t,i){this._dEditorInput.setSelectionRange(e,t),this._dEditorInput.focus(),document.execCommand("insertText",!1,i)}_toggleLoadingState(e){return e?(this._dEditorInput.classList.add("loading"),this.loading=!0):(this._dEditorInput.classList.remove("loading"),this.loading=!1)}_showUserCustomPrompts(){return this.currentUser?.can_use_custom_prompts}handleBoundaries(){const e=document.querySelector(".d-editor-textarea-wrapper").getBoundingClientRect(),t=document.querySelector(".d-editor-button-bar").getBoundingClientRect().bottom,i=e.bottom,r=this._contextMenu.getBoundingClientRect()
r.top<t||r.bottom>i?this._contextMenu.classList.add("out-of-bounds"):this._contextMenu.classList.remove("out-of-bounds"),this.caretCoords.y-r.height<t?this.popperPlacement="bottom-start":this.popperPlacement="top-start"}positionContextMenu(){this._contextMenu=document.querySelector(".ai-helper-context-menu"),this._dEditorInput&&this._contextMenu&&(this.caretCoords=(0,l.getCaretPosition)(this._dEditorInput,{pos:(0,l.caretPosition)(this._dEditorInput)}),this.handleBoundaries(),this.virtualElement={getBoundingClientRect:this.generateGetBoundingClientRect(this._contextMenu.clientWidth,this._contextMenu.clientHeight,this.caretCoords.x,this.caretCoords.y)},this._popper=(0,s.createPopper)(this.virtualElement,this._contextMenu,{placement:this.popperPlacement,modifiers:[{name:"offset",options:{offset:[10,0]}}]}))}setupContextMenu(){document.addEventListener("selectionchange",this.selectionChanged),document.addEventListener("keydown",this.onKeyDown),this._dEditorInput=document.querySelector(".d-editor-input"),this._dEditorInput&&this._dEditorInput.addEventListener("scroll",this.updatePosition)}setupCustomPrompt(){this._customPromptInput=document.querySelector(".ai-custom-prompt__input"),this._customPromptInput.focus()}toggleAiHelperOptions(){this.menuState=this.CONTEXT_MENU_STATES.options}undoAIAction(){if(this.capabilities.isFirefox){const e=this.selectedText.length-this.initialValue.length,t=this.lastSelectionRange.y-e
this._insertAt(this.lastSelectionRange.x,t,this.initialValue)}else document.execCommand("undo",!1,null)
this.menuState=this.CONTEXT_MENU_STATES.resets,this.closeContextMenu()}async updateSelected(e){return this._toggleLoadingState(!0),this.lastUsedOption=e,this.menuState=this.CONTEXT_MENU_STATES.loading,this.initialValue=this.selectedText,this.lastSelectionRange=this.selectionRange,this._activeAIRequest=(0,n.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:e.id,text:this.selectedText,custom_prompt:this.customPromptValue}}),this._activeAIRequest.then((t=>{this.diff=null,this.newSelectedText=null,this.thumbnailSuggestions=null,"illustrate_post"===e.name?(this._toggleLoadingState(!1),this.closeContextMenu(),this.showThumbnailModal=!0,this.thumbnailSuggestions=t.thumbnails):this._updateSuggestedByAI(t)})).catch(a.popupAjaxError).finally((()=>{this._toggleLoadingState(!1)})),this._activeAIRequest}viewChanges(){this.showDiffModal=!0}confirmChanges(){this.menuState=this.CONTEXT_MENU_STATES.resets}cancelAIAction(){this._activeAIRequest&&(this._activeAIRequest.abort(),this._activeAIRequest=null,this._toggleLoadingState(!1),this.closeContextMenu())}togglePreviousMenu(){this.menuState=this.previousMenuState}},g=V(m.prototype,"currentUser",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),b=V(m.prototype,"siteSettings",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),h=V(m.prototype,"modal",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=V(m.prototype,"capabilities",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=V(m.prototype,"showContextMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),y=V(m.prototype,"caretCoords",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v=V(m.prototype,"virtualElement",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),w=V(m.prototype,"selectedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),j=V(m.prototype,"newSelectedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),S=V(m.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),x=V(m.prototype,"lastUsedOption",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),P=V(m.prototype,"showDiffModal",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),O=V(m.prototype,"showThumbnailModal",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),z=V(m.prototype,"diff",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),k=V(m.prototype,"popperPlacement",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"top-start"}}),T=V(m.prototype,"previousMenuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),C=V(m.prototype,"customPromptValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),M=V(m.prototype,"initialValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),E=V(m.prototype,"thumbnailSuggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),A=V(m.prototype,"selectionRange",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{x:0,y:0}}}),I=V(m.prototype,"lastSelectionRange",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),R=V(m.prototype,"_menuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return this.CONTEXT_MENU_STATES.triggers}}),N=V(m.prototype,"_popper",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),D=V(m.prototype,"_dEditorInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),U=V(m.prototype,"_customPromptInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),q=V(m.prototype,"_contextMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),L=V(m.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),V(m.prototype,"selectionChanged",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"selectionChanged"),m.prototype),V(m.prototype,"updatePosition",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"updatePosition"),m.prototype),V(m.prototype,"onKeyDown",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"onKeyDown"),m.prototype),V(m.prototype,"_onSelectionChanged",[p],Object.getOwnPropertyDescriptor(m.prototype,"_onSelectionChanged"),m.prototype),V(m.prototype,"positionContextMenu",[c.afterRender],Object.getOwnPropertyDescriptor(m.prototype,"positionContextMenu"),m.prototype),V(m.prototype,"setupContextMenu",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"setupContextMenu"),m.prototype),V(m.prototype,"setupCustomPrompt",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"setupCustomPrompt"),m.prototype),V(m.prototype,"toggleAiHelperOptions",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"toggleAiHelperOptions"),m.prototype),V(m.prototype,"undoAIAction",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"undoAIAction"),m.prototype),V(m.prototype,"updateSelected",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"updateSelected"),m.prototype),V(m.prototype,"viewChanges",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"viewChanges"),m.prototype),V(m.prototype,"confirmChanges",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"confirmChanges"),m.prototype),V(m.prototype,"cancelAIAction",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"cancelAIAction"),m.prototype),V(m.prototype,"togglePreviousMenu",[r.action],Object.getOwnPropertyDescriptor(m.prototype,"togglePreviousMenu"),m.prototype),m)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-d-editor/composer-open",["exports","@glimmer/component","@ember/object","@ember/service","discourse-i18n"],(function(e,t,i,r,o){"use strict"
var s,n,a,l,u
function c(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function d(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(s=(0,i.computed)("composerModel.targetRecipients","composerModel.title"),n=(0,i.computed)("composerModel.targetRecipients"),a=class extends t.default{constructor(){super(...arguments),c(this,"currentUser",l,this),c(this,"siteSettings",u,this)}get composerModel(){return this.args?.outletArgs?.composer}get renderChatWarning(){return this.siteSettings.ai_bot_enable_chat_warning}get aiBotClasses(){return this.composerModel?.title===o.default.t("discourse_ai.ai_bot.default_pm_prefix")?"ai-bot-chat":"ai-bot-pm"}get isAiBotChat(){if(this.composerModel&&this.composerModel.targetRecipients&&this.currentUser.ai_enabled_chat_bots){let e=this.composerModel.targetRecipients.split(",")
return this.currentUser.ai_enabled_chat_bots.any((t=>e.any((e=>e===t.username))))}return!1}},l=d(a.prototype,"currentUser",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=d(a.prototype,"siteSettings",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),d(a.prototype,"aiBotClasses",[s],Object.getOwnPropertyDescriptor(a.prototype,"aiBotClasses"),a.prototype),d(a.prototype,"isAiBotChat",[n],Object.getOwnPropertyDescriptor(a.prototype,"isAiBotChat"),a.prototype),a)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-search-result-entry/search-result-decoration",["exports","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","@ember/component","@ember/template-factory","@ember/component/template-only"],(function(e,t,i,r,o,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const n=(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"+zzrKPCx",block:'[[[1,"\\n "],[10,0],[14,0,"ai-result__icon"],[15,"title",[28,[32,0],["discourse_ai.embeddings.ai_generated_result"],null]],[12],[1,"\\n "],[1,[28,[32,1],["discourse-sparkles"],null]],[1,"\\n "],[13],[1,"\\n"]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-search-result-entry/search-result-decoration.js",scope:()=>[i.default,t.default],isStrictMode:!0}),(0,s.default)())
e.default=n})),define("discourse/plugins/discourse-ai/discourse/connectors/composer-after-save-or-cancel/ai-image-caption-loader",["exports","@glimmer/component","@ember/service","discourse/helpers/loading-spinner","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="imageCaptionPopup",r=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"/15Zu2iM",block:'[[[1,"\\n"],[41,[30,0,["imageCaptionPopup","showAutoCaptionLoader"]],[[[1," "],[10,0],[14,0,"auto-image-caption-loader"],[12],[1,"\\n "],[1,[28,[32,0],null,[["size"],["small"]]]],[1,"\\n "],[10,1],[12],[1,[28,[32,1],["discourse_ai.ai_helper.image_caption.automatic_caption_loading"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/composer-after-save-or-cancel/ai-image-caption-loader.js",scope:()=>[r.default,o.default],isStrictMode:!0}),u),c=(a=u).prototype,d="imageCaptionPopup",p=[i.service],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},b={},Object.keys(m).forEach((function(e){b[e]=m[e]})),b.enumerable=!!b.enumerable,b.configurable=!!b.configurable,("value"in b||b.initializer)&&(b.writable=!0),b=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),b),g&&void 0!==b.initializer&&(b.value=b.initializer?b.initializer.call(g):void 0,b.initializer=void 0),void 0===b.initializer&&(Object.defineProperty(c,d,b),b=null),l=b,a)
var c,d,p,m,g,b})),define("discourse/plugins/discourse-ai/discourse/connectors/composer-fields/persona-llm-selector",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/runloop","@ember/service","discourse/lib/key-value-store","I18n","select-kit/components/dropdown-select-box","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m,g,b
function h(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function f(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(b=class extends t.default{static shouldRender(e,t){return t?.currentUser?.ai_enabled_personas&&function(e,t){if(e&&e.targetRecipients&&t.ai_enabled_chat_bots){const i=e.targetRecipients.split(",")
return t.ai_enabled_chat_bots.any((e=>i.any((t=>t===e.username))))}return!1}(e.model,t.currentUser)}constructor(){if(super(...arguments),h(this,"currentUser",p,this),h(this,"siteSettings",m,this),h(this,"llm",g,this),f(this,"STORE_NAMESPACE","discourse_ai_persona_selector_"),f(this,"LLM_STORE_NAMESPACE","discourse_ai_llm_selector_"),f(this,"preferredPersonaStore",new n.default(this.STORE_NAMESPACE)),f(this,"preferredLlmStore",new n.default(this.LLM_STORE_NAMESPACE)),this.botOptions&&this.composer){let e=this.preferredPersonaStore.getObject("id")
this._value=this.botOptions[0].id,e&&(e=parseInt(e,10),this.botOptions.any((t=>t.id===e))&&(this._value=e)),this.composer.metaData={ai_persona_id:this._value}
let t=this.preferredLlmStore.getObject("id")
t=t||this.llmOptions[0].id,t&&(0,o.next)((()=>{this.currentLlm=t}))}}get composer(){return this.args?.outletArgs?.model}get botOptions(){if(this.currentUser.ai_enabled_personas)return this.currentUser.ai_enabled_personas.map((e=>({id:e.id,name:e.name,description:e.description})))}get filterable(){return this.botOptions.length>4}get value(){return this._value}set value(e){this._value=e,this.preferredPersonaStore.setObject({key:"id",value:e}),this.composer.metaData={ai_persona_id:e}}get currentLlm(){return this.llm}set currentLlm(e){this.llm=e
const t=this.currentUser.ai_enabled_chat_bots.find((e=>e.model_name===this.llm)).username
this.preferredLlmStore.setObject({key:"id",value:e}),this.composer.set("targetRecipients",t)}get llmOptions(){return this.siteSettings.ai_bot_enabled_chat_bots.split("|").filter(Boolean).map((e=>({id:e,name:a.default.t(`discourse_ai.ai_bot.bot_names.${e}`)})))}},(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"d7DsFQBO",block:'[[[1,"\\n "],[10,0],[14,0,"persona-llm-selector"],[12],[1,"\\n "],[10,0],[14,0,"gpt-persona"],[12],[1,"\\n "],[8,[32,0],[[24,0,"persona-llm-selector__persona-dropdown"]],[["@value","@content","@options"],[[30,0,["value"]],[30,0,["botOptions"]],[28,[32,1],null,[["icon","filterable"],["robot",[30,0,["filterable"]]]]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"llm-selector"],[12],[1,"\\n "],[8,[32,0],[[24,0,"persona-llm-selector__llm-dropdown"]],[["@value","@content","@options"],[[30,0,["currentLlm"]],[30,0,["llmOptions"]],[28,[32,1],null,[["icon"],["globe"]]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/composer-fields/persona-llm-selector.js",scope:()=>[l.default,r.hash],isStrictMode:!0}),b),p=_((d=b).prototype,"currentUser",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),m=_(d.prototype,"siteSettings",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g=_(d.prototype,"llm",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),d)})),define("discourse/plugins/discourse-ai/discourse/connectors/editor-preview/ai-image-caption-container",["exports","@glimmer/component","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/render-modifiers/modifiers/did-update","@ember/render-modifiers/modifiers/will-destroy","@ember/service","discourse/components/conditional-loading-spinner","discourse/components/d-button","discourse/components/d-textarea","discourse/modifiers/auto-focus","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_
function y(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(_=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="imageCaptionPopup",r=this,(i=f)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}updateCaption(e){e.preventDefault(),this.imageCaptionPopup.newCaption=e.target.value}saveCaption(){this.imageCaptionPopup.updateCaption(),this.hidePopup()}resizeTextarea(e){const t=window.getComputedStyle(e),i=parseInt(t.borderTopWidth,10),r=parseInt(t.borderBottomWidth,10)
e.scrollTop=0,e.style.height=`${e.scrollHeight+i+r}px`}hidePopup(){this.imageCaptionPopup.showPopup=!1,this.imageCaptionPopup._request&&(this.imageCaptionPopup._request.abort(),this.imageCaptionPopup._request=null,this.imageCaptionPopup.toggleLoadingState(!1))}},(0,g.setComponentTemplate)((0,b.createTemplateFactory)({id:"84lcZtW4",block:'[[[1,"\\n"],[41,[30,0,["imageCaptionPopup","showPopup"]],[[[1," "],[11,0],[24,0,"composer-popup education-message ai-caption-popup"],[4,[32,0],[[30,0,["hidePopup"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@condition"],[[30,0,["imageCaptionPopup","loading"]]]],[["default"],[[[[1,"\\n "],[8,[32,2],[[4,[32,3],[[30,0,["resizeTextarea"]]],null],[4,[32,4],[[30,0,["resizeTextarea"]],[30,0,["imageCaptionPopup","newCaption"]]],null],[4,[32,5],["change",[30,0,["updateCaption"]]],null],[4,[32,6],null,null]],[["@value"],[[30,0,["imageCaptionPopup","newCaption"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n\\n "],[10,0],[14,0,"actions"],[12],[1,"\\n "],[8,[32,7],[[24,0,"btn-primary"]],[["@label","@icon","@action"],["discourse_ai.ai_helper.image_caption.save_caption","check",[30,0,["saveCaption"]]]],null],[1,"\\n "],[8,[32,7],[[24,0,"btn-flat cancel-request"]],[["@label","@action"],["cancel",[30,0,["hidePopup"]]]],null],[1,"\\n\\n "],[10,1],[14,0,"credits"],[12],[1,"\\n "],[1,[28,[32,8],["discourse-sparkles"],null]],[1,"\\n "],[10,1],[12],[1,[28,[32,9],["discourse_ai.ai_helper.image_caption.credits"],null]],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/editor-preview/ai-image-caption-container.js",scope:()=>[n.default,l.default,c.default,o.default,s.default,i.on,d.default,u.default,p.default,m.default],isStrictMode:!0}),_),f=y((h=_).prototype,"imageCaptionPopup",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y(h.prototype,"updateCaption",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"updateCaption"),h.prototype),y(h.prototype,"saveCaption",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"saveCaption"),h.prototype),y(h.prototype,"resizeTextarea",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"resizeTextarea"),h.prototype),y(h.prototype,"hidePopup",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"hidePopup"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/connectors/fast-edit-footer-after/ai-edit-suggestion-button",["exports","@glimmer/component","@glimmer/tracking","@ember/object","@ember/service","discourse/components/d-button","discourse/lib/ajax","discourse/lib/ajax-error","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m,g,b,h
function f(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function _(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(h=class extends t.default{constructor(){super(...arguments),f(this,"currentUser",p,this),f(this,"loading",m,this),f(this,"suggestion",g,this),f(this,"_activeAIRequest",b,this)}static shouldRender(e,t){return(0,l.showPostAIHelper)(e,t)}get disabled(){return this.loading||this.suggestion?.length>0}get mode(){return this.currentUser?.ai_helper_prompts.find((e=>"proofread"===e.name))}suggest(){return this.loading=!0,this._activeAIRequest=(0,n.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:this.mode.id,text:this.args.outletArgs.initialValue,custom_prompt:""}}),this._activeAIRequest.then((e=>{let{suggestions:t}=e
this.suggestion=t[0].trim(),this.args.outletArgs.updateValue(this.suggestion)})).catch(a.popupAjaxError).finally((()=>{this.loading=!1})),this._activeAIRequest}},(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"9jHc25oQ",block:'[[[1,"\\n"],[41,[51,[30,1,["newValue"]]],[[[1," "],[8,[32,0],[[24,0,"btn-small btn-ai-suggest-edit"]],[["@action","@icon","@label","@isLoading","@disabled"],[[30,0,["suggest"]],"discourse-sparkles","discourse_ai.ai_helper.fast_edit.suggest_button",[30,0,["loading"]],[30,0,["disabled"]]]],null],[1,"\\n"]],[]],null],[1," "]],["@outletArgs"],false,["unless"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/fast-edit-footer-after/ai-edit-suggestion-button.js",scope:()=>[s.default],isStrictMode:!0}),h),p=_((d=h).prototype,"currentUser",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),m=_(d.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),g=_(d.prototype,"suggestion",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),b=_(d.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),_(d.prototype,"suggest",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"suggest"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/connectors/full-page-search-below-search-header/semantic-search",["exports","@glimmer/component","@glimmer/tracking","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/service","discourse/components/d-toggle-switch","discourse/controllers/full-page-search","discourse/lib/ajax","discourse/lib/plugin-api","discourse/lib/search","discourse-common/helpers/d-icon","I18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b){"use strict"
var h,f,_,y,v,w,j,S
function x(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function P(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function O(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(S=class extends t.default{constructor(){super(...arguments),x(this,"appEvents",f,this),x(this,"siteSettings",_,this),x(this,"searchPreferencesManager",y,this),x(this,"searching",v,this),x(this,"AIResults",w,this),x(this,"showingAIResults",j,this),P(this,"initialSearchTerm",this.args.outletArgs.search)}static shouldRender(e,t){let{siteSettings:i}=t
return i.ai_embeddings_semantic_search_enabled}get disableToggleSwitch(){if(this.searching||0===this.AIResults.length||0!==this.args.outletArgs.sortOrder)return!0}get searchStateText(){return this.AIResults.length>0?this.showingAIResults?m.default.t("discourse_ai.embeddings.semantic_search_results.toggle",{count:this.AIResults.length}):m.default.t("discourse_ai.embeddings.semantic_search_results.toggle_hidden",{count:this.AIResults.length}):this.searching?m.default.t("discourse_ai.embeddings.semantic_search_loading"):0===this.AIResults.length&&this.searchTerm!==this.initialSearchTerm?m.default.t("discourse_ai.embeddings.semantic_search_results.new"):0===this.AIResults.length?m.default.t("discourse_ai.embeddings.semantic_search_results.none"):void 0}get searchTerm(){return this.initialSearchTerm!==this.args.outletArgs.search&&(this.initialSearchTerm=void 0),this.args.outletArgs.search}get searchEnabled(){return this.args.outletArgs.type===l.SEARCH_TYPE_DEFAULT&&(0,d.isValidSearchTerm)(this.searchTerm,this.siteSettings)&&0===this.args.outletArgs.sortOrder}toggleAIResults(){this.showingAIResults?this.args.outletArgs.addSearchResults([],"topic_id"):this.args.outletArgs.addSearchResults(this.AIResults,"topic_id"),this.showingAIResults=!this.showingAIResults}resetAIResults(){this.AIResults=[],this.showingAIResults=!1,this.args.outletArgs.addSearchResults([],"topic_id")}handleSearch(){if(this.searchEnabled)return this.initialSearchTerm&&!this.searching?this.performHyDESearch():void(0,c.withPluginApi)("1.15.0",(e=>{e.onAppEvent("full-page-search:trigger-search",(()=>{if(!this.searching)return this.resetAIResults(),this.performHyDESearch()}))}))}performHyDESearch(){this.searching=!0,this.resetAIResults(),(0,u.ajax)("/discourse-ai/embeddings/semantic-search",{data:{q:this.searchTerm}}).then((async e=>{const t=await(0,d.translateResults)(e)||{}
0!==t.posts?.length?(t.posts.forEach((e=>{e.generatedByAI=!0})),this.AIResults=t.posts):this.searching=!1})).finally((()=>this.searching=!1))}},(0,g.setComponentTemplate)((0,b.createTemplateFactory)({id:"3cSLRgPA",block:'[[[1,"\\n"],[41,[30,0,["searchEnabled"]],[[[1," "],[10,0],[14,0,"semantic-search__container search-results"],[14,"role","region"],[12],[1,"\\n "],[11,0],[24,0,"semantic-search__results"],[4,[32,0],[[30,0,["handleSearch"]]],null],[12],[1,"\\n "],[10,0],[15,0,[29,["semantic-search__searching\\n ",[52,[30,0,["searching"]],"in-progress"]]]],[12],[1,"\\n "],[8,[32,1],[[16,"disabled",[30,0,["disableToggleSwitch"]]],[24,"title","AI search results hidden"],[24,0,"semantic-search__results-toggle"],[4,[32,2],["click",[30,0,["toggleAIResults"]]],null]],[["@state"],[[30,0,["showingAIResults"]]]],null],[1,"\\n\\n "],[10,0],[14,0,"semantic-search__searching-text"],[12],[1,"\\n "],[1,[28,[32,3],["discourse-sparkles"],null]],[1,"\\n "],[1,[30,0,["searchStateText"]]],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["searching"]],[[[1," "],[10,1],[14,0,"semantic-search__indicator-wave"],[12],[1,"\\n "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/full-page-search-below-search-header/semantic-search.js",scope:()=>[s.default,a.default,r.on,p.default],isStrictMode:!0}),S),f=O((h=S).prototype,"appEvents",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=O(h.prototype,"siteSettings",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=O(h.prototype,"searchPreferencesManager",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v=O(h.prototype,"searching",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),w=O(h.prototype,"AIResults",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),j=O(h.prototype,"showingAIResults",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),O(h.prototype,"toggleAIResults",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"toggleAIResults"),h.prototype),O(h.prototype,"resetAIResults",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"resetAIResults"),h.prototype),O(h.prototype,"handleSearch",[o.action],Object.getOwnPropertyDescriptor(h.prototype,"handleSearch"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/connectors/post-text-buttons/ai-helper-options-menu",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/render-modifiers/modifiers/will-destroy","@ember/service","discourse/components/cook-text","discourse/components/d-button","discourse/components/fast-edit","discourse/components/modal/fast-edit","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/text","discourse/lib/utilities","discourse-common/utils/decorators","discourse-i18n","truth-helpers/helpers/eq","discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt","discourse/plugins/discourse-ai/discourse/components/ai-helper-loading","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d,p,m,g,b,h,f,_,y,v,w,j,S){"use strict"
var x,P,O,z,k,T,C,M,E,A,I,R,N,D,U,q,L,F,B,V,H,G,$
function K(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function W(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function X(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=($=class extends t.default{constructor(){super(...arguments),K(this,"messageBus",P,this),K(this,"site",O,this),K(this,"modal",z,this),K(this,"siteSettings",k,this),K(this,"currentUser",T,this),K(this,"menu",C,this),K(this,"menuState",M,this),K(this,"loading",E,this),K(this,"suggestion",A,this),K(this,"showMainButtons",I,this),K(this,"customPromptValue",R,this),K(this,"copyButtonIcon",N,this),K(this,"copyButtonLabel",D,this),K(this,"showFastEdit",U,this),K(this,"showAiButtons",q,this),K(this,"originalPostHTML",L,this),K(this,"postHighlighted",F,this),K(this,"streaming",B,this),K(this,"lastSelectedOption",V,this),K(this,"isSavingFootnote",H,this),W(this,"MENU_STATES",{triggers:"TRIGGERS",options:"OPTIONS",loading:"LOADING",result:"RESULT"}),K(this,"_activeAIRequest",G,this)}static shouldRender(e,t){return(0,w.showPostAIHelper)(e,t)}highlightSelectedText(){const e=this.args.outletArgs.data.quoteState.postId,t=document.querySelector(`article[data-post-id='${e}'] .cooked`)
if(!t)return
this.originalPostHTML=t.innerHTML,this.selectedText=this.args.outletArgs.data.quoteState.buffer
const i=window.getSelection()
if(!i.rangeCount)return
const r=i.getRangeAt(0)
if(r.startContainer.nodeType===Node.TEXT_NODE&&r.startOffset>0){const e=r.startContainer.splitText(r.startOffset)
r.setStart(e,0)}r.endContainer.nodeType===Node.TEXT_NODE&&r.endOffset<r.endContainer.length&&r.endContainer.splitText(r.endOffset)
const o=document.createTreeWalker(r.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>r.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}),s=[]
if(o.currentNode?.nodeType===Node.TEXT_NODE)s.push(o.currentNode)
else for(;o.nextNode();)s.push(o.currentNode)
for(let n of s){const e=document.createElement("span")
e.classList.add("ai-helper-highlighted-selection")
const t=n.cloneNode(!0)
e.appendChild(t),n.parentNode.replaceChild(e,n)}i.removeAllRanges(),this.postHighlighted=!0}removeHighlightedText(){if(!this.postHighlighted)return
const e=this.args.outletArgs.data.quoteState.postId,t=document.querySelector(`article[data-post-id='${e}'] .cooked`)
t&&(t.innerHTML=this.originalPostHTML,this.postHighlighted=!1)}willDestroy(){super.willDestroy(...arguments),this.removeHighlightedText()}async showAIHelperOptions(){this.highlightSelectedText(),this.showMainButtons=!1,this.menuState=this.MENU_STATES.options}subscribe(){const e=`/discourse-ai/ai-helper/explain/${this.args.outletArgs.data.quoteState.postId}`
this.messageBus.subscribe(e,this._updateResult)}unsubscribe(){this.messageBus.unsubscribe("/discourse-ai/ai-helper/explain/*",this._updateResult)}_updateResult(e){this.streaming=!e.done,this.suggestion=e.result}get highlightedTextToggleIcon(){return this.showHighlightedText?"angle-double-left":"angle-double-right"}toggleHighlightedTextPreview(){this.showHighlightedText=!this.showHighlightedText}async performAISuggestion(e){if(this.menuState=this.MENU_STATES.loading,this.lastSelectedOption=e,"explain"===e.name){this.menuState=this.MENU_STATES.result
const t=this.menu.getByIdentifier("post-text-selection-toolbar")
t&&(t.options.placement="bottom")
const i="/discourse-ai/ai-helper/explain"
this._activeAIRequest=(0,p.ajax)(i,{method:"POST",data:{mode:e.value,text:this.args.outletArgs.data.quoteState.buffer,post_id:this.args.outletArgs.data.quoteState.postId}})}else this._activeAIRequest=(0,p.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:e.id,text:this.args.outletArgs.data.quoteState.buffer,custom_prompt:this.customPromptValue}})
return"explain"!==e.name&&this._activeAIRequest.then((t=>{let{suggestions:i}=t
if(this.suggestion=i[0].trim(),"proofread"===e.name)return this.showAiButtons=!1,this.site.desktopView?void(this.showFastEdit=!0):this.modal.show(d.default,{model:{initialValue:this.args.outletArgs.data.quoteState.buffer,newValue:this.suggestion,post:this.args.outletArgs.post,close:this.closeFastEdit}})})).catch(m.popupAjaxError).finally((()=>{this.loading=!1,this.menuState=this.MENU_STATES.result})),this._activeAIRequest}cancelAIAction(){this._activeAIRequest&&(this._activeAIRequest.abort(),this._activeAIRequest=null,this.loading=!1,this.menuState=this.MENU_STATES.options)}copySuggestion(){this.suggestion?.length>0&&((0,b.clipboardCopy)(this.suggestion),this.copyButtonIcon="check",this.copyButtonLabel="discourse_ai.ai_helper.post_options_menu.copied",setTimeout((()=>{this.copyButtonIcon="copy",this.copyButtonLabel="discourse_ai.ai_helper.post_options_menu.copy"}),3500))}get helperOptions(){let e=this.currentUser?.ai_helper_prompts
e=e.filter((e=>e.location.includes("post")))
const t=e.findIndex((e=>"custom_prompt"===e.name))
if(-1!==t){const i=e.splice(t,1)[0]
e.unshift(i)}return this._showUserCustomPrompts()||(e=e.filter((e=>"custom_prompt"!==e.name))),this.args.outletArgs.data.canEditPost||(e=e.filter((e=>"proofread"!==e.name))),e}_showUserCustomPrompts(){return this.currentUser?.can_use_custom_prompts}async closeFastEdit(){this.showFastEdit=!1,await this.args.outletArgs.data.hideToolbar()}sanitizeForFootnote(e){return e=(e=(e=e.replace(/[\r\n]+/g," ")).replace(/^(#+)\s+/gm,"")).trim(),(0,g.sanitize)(e)}async insertFootnote(){if(this.isSavingFootnote=!0,this.allowInsertFootnote)try{const e=await(0,p.ajax)(`/posts/${this.args.outletArgs.post.id}`),t=this.sanitizeForFootnote(this.suggestion),i=f.default.t("discourse_ai.ai_helper.post_options_menu.footnote_credits"),r=`${this.selectedText} ^[${t} (${i})]`,o=e.raw.replace(this.selectedText,r)
await this.args.outletArgs.post.save({raw:o})}catch(e){(0,m.popupAjaxError)(e)}finally{this.isSavingFootnote=!1,this.menu.close()}}get allowInsertFootnote(){const e=this.siteSettings,t=this.args.outletArgs.data.canEditPost
return!!(e?.enable_markdown_footnotes&&e?.display_footnotes_inline&&t)&&"explain"===this.lastSelectedOption?.name}},(0,j.setComponentTemplate)((0,S.createTemplateFactory)({id:"kG8Uplse",block:'[[[1,"\\n"],[41,[30,0,["showMainButtons"]],[[[1," "],[18,3,null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showAiButtons"]],[[[1," "],[10,0],[14,0,"ai-post-helper"],[12],[1,"\\n"],[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","triggers"]]],null],[[[1," "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__trigger"]],[["@icon","@title","@label","@action"],["discourse-sparkles","discourse_ai.ai_helper.post_options_menu.title","discourse_ai.ai_helper.post_options_menu.trigger",[30,0,["showAIHelperOptions"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","options"]]],null],[[[1," "],[10,0],[14,0,"ai-post-helper__options"],[12],[1,"\\n"],[42,[28,[31,3],[[28,[31,3],[[30,0,["helperOptions"]]],null]],null],null,[[[41,[28,[32,0],[[30,1,["name"]],"custom_prompt"],null],[[[1," "],[8,[32,2],null,[["@value","@promptArgs","@submit"],[[30,0,["customPromptValue"]],[30,1],[30,0,["performAISuggestion"]]]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],[[16,"data-name",[30,1,["name"]]],[16,"data-value",[30,1,["id"]]],[24,0,"btn-flat ai-post-helper__options-button"]],[["@icon","@translatedLabel","@action"],[[30,1,["icon"]],[30,1,["translated_name"]],[28,[32,3],[[30,0,["performAISuggestion"]],[30,1]],null]]],null],[1,"\\n"]],[]]]],[1]],null],[1," "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","loading"]]],null],[[[1," "],[8,[32,4],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","result"]]],null],[[[1," "],[11,0],[24,0,"ai-post-helper__suggestion"],[4,[32,5],[[30,0,["subscribe"]]],null],[4,[32,6],[[30,0,["unsubscribe"]]],null],[12],[1,"\\n"],[41,[30,0,["suggestion"]],[[[1," "],[10,0],[14,0,"ai-post-helper__suggestion__text"],[14,"dir","auto"],[12],[1,"\\n "],[8,[32,7],null,[["@rawText"],[[30,0,["suggestion"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"ai-post-helper__suggestion__buttons"],[12],[1,"\\n "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__suggestion__cancel"]],[["@icon","@label","@action"],["times","discourse_ai.ai_helper.post_options_menu.cancel",[30,0,["cancelAIAction"]]]],null],[1,"\\n "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__suggestion__copy"]],[["@icon","@label","@action","@disabled"],[[30,0,["copyButtonIcon"]],[30,0,["copyButtonLabel"]],[30,0,["copySuggestion"]],[30,0,["streaming"]]]],null],[1,"\\n"],[41,[30,0,["allowInsertFootnote"]],[[[1," "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__suggestion__insert-footnote"]],[["@icon","@label","@action","@isLoading","@disabled"],["asterisk","discourse_ai.ai_helper.post_options_menu.insert_footnote",[30,0,["insertFootnote"]],[30,0,["isSavingFootnote"]],[30,0,["streaming"]]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[]],[[[1," "],[8,[32,4],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "]],[]],null]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showFastEdit"]],[[[1," "],[10,0],[14,0,"ai-post-helper__fast-edit"],[12],[1,"\\n "],[8,[32,8],null,[["@initialValue","@newValue","@post","@close"],[[30,2,["data","quoteState","buffer"]],[30,0,["suggestion"]],[30,2,["post"]],[30,0,["closeFastEdit"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],["option","@outletArgs","&default"],false,["if","yield","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/post-text-buttons/ai-helper-options-menu.js",scope:()=>[_.default,u.default,y.default,r.fn,v.default,s.default,n.default,l.default,c.default],isStrictMode:!0}),$),P=X((x=$).prototype,"messageBus",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),O=X(x.prototype,"site",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),z=X(x.prototype,"modal",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),k=X(x.prototype,"siteSettings",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),T=X(x.prototype,"currentUser",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),C=X(x.prototype,"menu",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),M=X(x.prototype,"menuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return this.MENU_STATES.triggers}}),E=X(x.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),A=X(x.prototype,"suggestion",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),I=X(x.prototype,"showMainButtons",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),R=X(x.prototype,"customPromptValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),N=X(x.prototype,"copyButtonIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"copy"}}),D=X(x.prototype,"copyButtonLabel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse_ai.ai_helper.post_options_menu.copy"}}),U=X(x.prototype,"showFastEdit",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),q=X(x.prototype,"showAiButtons",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),L=X(x.prototype,"originalPostHTML",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),F=X(x.prototype,"postHighlighted",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),B=X(x.prototype,"streaming",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),V=X(x.prototype,"lastSelectedOption",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),H=X(x.prototype,"isSavingFootnote",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),G=X(x.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),X(x.prototype,"showAIHelperOptions",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"showAIHelperOptions"),x.prototype),X(x.prototype,"subscribe",[h.bind],Object.getOwnPropertyDescriptor(x.prototype,"subscribe"),x.prototype),X(x.prototype,"unsubscribe",[h.bind],Object.getOwnPropertyDescriptor(x.prototype,"unsubscribe"),x.prototype),X(x.prototype,"_updateResult",[h.bind],Object.getOwnPropertyDescriptor(x.prototype,"_updateResult"),x.prototype),X(x.prototype,"toggleHighlightedTextPreview",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"toggleHighlightedTextPreview"),x.prototype),X(x.prototype,"performAISuggestion",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"performAISuggestion"),x.prototype),X(x.prototype,"cancelAIAction",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"cancelAIAction"),x.prototype),X(x.prototype,"copySuggestion",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"copySuggestion"),x.prototype),X(x.prototype,"closeFastEdit",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"closeFastEdit"),x.prototype),X(x.prototype,"insertFootnote",[o.action],Object.getOwnPropertyDescriptor(x.prototype,"insertFootnote"),x.prototype),x)})),define("discourse/plugins/discourse-ai/discourse/connectors/search-menu-before-advanced-search/ai-quick-search-loader",["exports","@glimmer/component","@ember/service","discourse/helpers/loading-spinner","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n,a,l
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(l=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="quickSearch",r=this,(i=a)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}},(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"apo2cAJf",block:'[[[1,"\\n"],[41,[30,0,["quickSearch","loading"]],[[[1," "],[10,0],[14,0,"ai-quick-search-spinner"],[12],[1,"\\n "],[1,[32,0]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/search-menu-before-advanced-search/ai-quick-search-loader.js",scope:()=>[r.default],isStrictMode:!0}),l),u=(n=l).prototype,c="quickSearch",d=[i.inject],p={configurable:!0,enumerable:!0,writable:!0,initializer:null},g={},Object.keys(p).forEach((function(e){g[e]=p[e]})),g.enumerable=!!g.enumerable,g.configurable=!!g.configurable,("value"in g||g.initializer)&&(g.writable=!0),g=d.slice().reverse().reduce((function(e,t){return t(u,c,e)||e}),g),m&&void 0!==g.initializer&&(g.value=g.initializer?g.initializer.call(m):void 0,g.initializer=void 0),void 0===g.initializer&&(Object.defineProperty(u,c,g),g=null),a=g,n)
var u,c,d,p,m,g})),define("discourse/plugins/discourse-ai/discourse/connectors/search-menu-initial-options/ai-quick-semantic-search",["exports","@glimmer/component","@ember/object","@ember/service","discourse/components/search-menu/results/assistant-item","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/search","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c){"use strict"
var d,p,m,g,b
function h(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function f(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(b=class extends t.default{constructor(){super(...arguments),h(this,"search",p,this),h(this,"quickSearch",m,this),h(this,"siteSettings",g,this)}static shouldRender(e,t){let{siteSettings:i}=t
return i.ai_embeddings_semantic_quick_search_enabled}async searchTermChanged(){if(this.search.activeGlobalSearchTerm){if(!(0,a.isValidSearchTerm)(this.search.activeGlobalSearchTerm,this.siteSettings))return this.search.noResults=!0,this.search.results={},this.quickSearch.loading=!1,void(this.quickSearch.invalidTerm=!0)
await this.performSearch()}else this.search.noResults=!1,this.search.results={},this.quickSearch.loading=!1,this.quickSearch.invalidTerm=!1}async performSearch(){this.quickSearch.loading=!0,this.quickSearch.invalidTerm=!1
try{const e=await(0,s.ajax)("/discourse-ai/embeddings/quick-search",{data:{q:this.search.activeGlobalSearchTerm}}),t=await(0,a.translateResults)(e)
t&&(this.search.noResults=0===e.resultTypes.length,this.search.results=t)}catch(e){(0,n.popupAjaxError)(e)}finally{this.quickSearch.loading=!1}}},(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"xqHDbd5x",block:'[[[1,"\\n "],[18,3,null],[1,"\\n\\n"],[41,[30,0,["search","activeGlobalSearchTerm"]],[[[1," "],[8,[32,0],null,[["@suffix","@icon","@closeSearchMenu","@searchTermChanged","@suggestionKeyword"],[[28,[32,1],["discourse_ai.embeddings.quick_search.suffix"],null],"discourse-sparkles",[30,1],[30,0,["searchTermChanged"]],[30,2]]],null],[1,"\\n"]],[]],null],[1," "]],["@closeSearchMenu","@suggestionKeyword","&default"],false,["yield","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/search-menu-initial-options/ai-quick-semantic-search.js",scope:()=>[o.default,l.default],isStrictMode:!0}),b),p=f((d=b).prototype,"search",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),m=f(d.prototype,"quickSearch",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g=f(d.prototype,"siteSettings",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f(d.prototype,"searchTermChanged",[i.action],Object.getOwnPropertyDescriptor(d.prototype,"searchTermChanged"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/connectors/search-menu-results-top/ai-quick-search-info",["exports","@glimmer/component","@ember/service","discourse/lib/search","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u,c,d
function p(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function m(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(d=class extends t.default{constructor(){super(...arguments),p(this,"search",l,this),p(this,"siteSettings",u,this),p(this,"quickSearch",c,this)}get termTooShort(){return!(0,r.isValidSearchTerm)(this.search.activeGlobalSearchTerm,this.siteSettings)&&this.quickSearch.invalidTerm&&this.search.activeGlobalSearchTerm?.length>0}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"k6uzZwr4",block:'[[[1,"\\n"],[41,[30,0,["termTooShort"]],[[[1," "],[10,0],[14,0,"no-results"],[12],[1,[28,[32,0],["search.too_short"],null]],[13],[1,"\\n"]],[]],null],[1," "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/search-menu-results-top/ai-quick-search-info.js",scope:()=>[o.default],isStrictMode:!0}),d),l=m((a=d).prototype,"search",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=m(a.prototype,"siteSettings",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),c=m(a.prototype,"quickSearch",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),a)})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-category-after/ai-category-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="siteSettings",r=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}static shouldRender(e,t){return(0,o.showPostAIHelper)(e,t)}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"4O7HJkah",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1," "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction"],[[30,1,["selectedPosts"]],"suggest_category",[30,1,["updateCategoryId"]]]],null],[1,"\\n"]],[]],null],[1," "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-category-after/ai-category-suggestion.js",scope:()=>[r.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},b={},Object.keys(m).forEach((function(e){b[e]=m[e]})),b.enumerable=!!b.enumerable,b.configurable=!!b.configurable,("value"in b||b.initializer)&&(b.writable=!0),b=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),b),g&&void 0!==b.initializer&&(b.value=b.initializer?b.initializer.call(g):void 0,b.initializer=void 0),void 0===b.initializer&&(Object.defineProperty(c,d,b),b=null),l=b,a)
var c,d,p,m,g,b})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-tag-after/ai-tag-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="siteSettings",r=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}static shouldRender(e,t){return(0,o.showPostAIHelper)(e,t)}},(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"jo6+zYZR",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1," "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction","@currentValue"],[[30,1,["selectedPosts"]],"suggest_tags",[30,1,["updateTags"]],[30,1,["tags"]]]],null],[1,"\\n"]],[]],null],[1," "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-tag-after/ai-tag-suggestion.js",scope:()=>[r.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},b={},Object.keys(m).forEach((function(e){b[e]=m[e]})),b.enumerable=!!b.enumerable,b.configurable=!!b.configurable,("value"in b||b.initializer)&&(b.writable=!0),b=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),b),g&&void 0!==b.initializer&&(b.value=b.initializer?b.initializer.call(g):void 0,b.initializer=void 0),void 0===b.initializer&&(Object.defineProperty(c,d,b),b=null),l=b,a)
var c,d,p,m,g,b})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-title-after/ai-title-suggestion",["exports","@glimmer/component","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return(0,r.showPostAIHelper)(e,t)}}e.default=a,n=a,(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"obhR2Q8M",block:'[[[1,"\\n "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction"],[[30,1,["selectedPosts"]],"suggest_title",[30,1,["updateTopicName"]]]],null],[1,"\\n "]],["@outletArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-title-after/ai-title-suggestion.js",scope:()=>[i.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/topic-more-content/related-topics",["exports","@glimmer/component","@ember/object","@ember/service","I18n"],(function(e,t,i,r,o){"use strict"
var s,n,a,l,u
function c(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function d(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var r=i.call(e,t||"default")
if("object"!=typeof r)return r
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string")
return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function p(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(s=(0,i.computed)("moreTopicsPreferenceTracking.selectedTab"),n=class extends t.default{constructor(){super(...arguments),c(this,"store",a,this),c(this,"site",l,this),c(this,"moreTopicsPreferenceTracking",u,this),d(this,"listId","related-topics")}static shouldRender(e){return(e.model.related_topics?.length||0)>0}get hidden(){return this.moreTopicsPreferenceTracking.selectedTab!==this.listId}get relatedTopics(){return this.args.outletArgs.model.related_topics.map((e=>this.store.createRecord("topic",e)))}registerList(){this.moreTopicsPreferenceTracking.registerTopicList({name:o.default.t("discourse_ai.related_topics.pill"),id:this.listId,icon:"discourse-sparkles"})}removeList(){this.moreTopicsPreferenceTracking.removeTopicList(this.listId)}},a=p(n.prototype,"store",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),l=p(n.prototype,"site",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=p(n.prototype,"moreTopicsPreferenceTracking",[r.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),p(n.prototype,"hidden",[s],Object.getOwnPropertyDescriptor(n.prototype,"hidden"),n.prototype),p(n.prototype,"registerList",[i.action],Object.getOwnPropertyDescriptor(n.prototype,"registerList"),n.prototype),p(n.prototype,"removeList",[i.action],Object.getOwnPropertyDescriptor(n.prototype,"removeList"),n.prototype),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/user-preferences-nav/ai-preferences",["exports","@glimmer/component","@ember/routing","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","@ember/component","@ember/template-factory"],(function(e,t,i,r,o,s,n){"use strict"
var a
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class l extends t.default{static shouldRender(e,t){return t.siteSettings.discourse_ai_enabled&&(i=e.model,i?.user_allowed_ai_auto_image_captions)
var i}}e.default=l,a=l,(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"/y5E1bgJ",block:'[[[1,"\\n "],[10,"li"],[14,0,"user-nav__preferences-ai"],[12],[1,"\\n "],[8,[32,0],null,[["@route"],["preferences.ai"]],[["default"],[[[[1,"\\n "],[1,[28,[32,1],["discourse-sparkles"],null]],[1,"\\n "],[10,1],[12],[1,[28,[32,2],["discourse_ai.title"],null]],[13],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/user-preferences-nav/ai-preferences.js",scope:()=>[i.LinkTo,r.default,o.default],isStrictMode:!0}),a)})),define("discourse/plugins/discourse-ai/discourse/controllers/admin-dashboard-sentiment",["exports","@ember/object","admin/controllers/admin-dashboard-tab"],(function(e,t,i){"use strict"
var r,o
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(r=(0,t.computed)("startDate","endDate"),o=class extends i.default{get filters(){return{startDate:this.startDate,endDate:this.endDate}}},s=o.prototype,n="filters",a=[r],l=Object.getOwnPropertyDescriptor(o.prototype,"filters"),u=o.prototype,c={},Object.keys(l).forEach((function(e){c[e]=l[e]})),c.enumerable=!!c.enumerable,c.configurable=!!c.configurable,("value"in c||c.initializer)&&(c.writable=!0),c=a.slice().reverse().reduce((function(e,t){return t(s,n,e)||e}),c),u&&void 0!==c.initializer&&(c.value=c.initializer?c.initializer.call(u):void 0,c.initializer=void 0),void 0===c.initializer&&(Object.defineProperty(s,n,c),c=null),o)
var s,n,a,l,u,c})),define("discourse/plugins/discourse-ai/discourse/controllers/preferences-ai",["exports","@glimmer/tracking","@ember/controller","@ember/object","@ember/service","discourse/lib/ajax-error","discourse-common/config/environment"],(function(e,t,i,r,o,s,n){"use strict"
var a,l,u
function c(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function d(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const p=["auto_image_caption"]
e.default=(a=class extends i.default{constructor(){super(...arguments),c(this,"siteSettings",l,this),c(this,"saved",u,this)}save(){return this.saved=!1,this.model.save(p).then((()=>{this.saved=!0,(0,n.isTesting)()||location.reload()})).catch(s.popupAjaxError)}},l=d(a.prototype,"siteSettings",[o.service],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=d(a.prototype,"saved",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),d(a.prototype,"save",[r.action],Object.getOwnPropertyDescriptor(a.prototype,"save"),a.prototype),a)})),define("discourse/plugins/discourse-ai/discourse/discourse-ai-shared-conversation-show-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){this.route("discourse-ai-shared-conversation-show",{path:"/discourse-ai/ai-bot/shared-ai-conversations/:share_key"})}})),define("discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper",["exports","discourse/lib/ajax","discourse/lib/ajax-error","discourse/models/composer","I18n","discourse/plugins/discourse-ai/discourse/components/modal/share-full-topic-modal"],(function(e,t,i,r,o,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.composeAiBotMessage=function(e,t){let i=t.currentUser.ai_enabled_chat_bots.find((t=>t.model_name===e)).username
t.focusComposer({fallbackToNewTopic:!0,openOpts:{action:r.default.PRIVATE_MESSAGE,recipients:i,topicTitle:o.default.t("discourse_ai.ai_bot.default_pm_prefix"),archetypeId:"private_message",draftKey:"private_message_ai",hasGroups:!1,warningsDisabled:!0,skipDraftCheck:!0}})},e.showShareConversationModal=function(e,r){(0,t.ajax)(`/discourse-ai/ai-bot/shared-ai-conversations/preview/${r}.json`).then((t=>{e.show(s.default,{model:t})})).catch(i.popupAjaxError)}})),define("discourse/plugins/discourse-ai/discourse/lib/ai-streamer",["exports","@ember/runloop","discourse/lib/load-morphlex","discourse/lib/text"],(function(e,t,i,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.MIN_LETTERS_PER_INTERVAL=void 0,e.addProgressDot=c,e.applyProgress=m,e.default=function(e,t){if(t.noop)return;(e.aiStreamingStatus=e.aiStreamingStatus||{})[t.post_id]=t,g(e)}
const o=40,s=6e4,n=e.MIN_LETTERS_PER_INTERVAL=6,a=800
let l=null
function u(e){let t=e.lastChild
for(;t&&t.nodeType===Node.TEXT_NODE&&!/\S/.test(t.textContent);)t=t.previousSibling
return t}function c(e){let t=e
for(;;){let e=u(t)
if(!e)break
if(e.nodeType!==Node.ELEMENT_NODE)break
t=e}const i=document.createElement("span")
i.classList.add("progress-dot"),t.appendChild(i)}class d{set streaming(e){throw"not implemented"}async setCooked(){throw"not implemented"}async setRaw(){throw"not implemented"}get element(){throw"not implemented"}get raw(){throw"not implemented"}}class p extends d{constructor(e,t){super(),this.postStream=e,this.postId=t,this.post=e.findLoadedPost(t),this.post&&(this.postElement=document.querySelector(`#post_${this.post.post_number}`))}get element(){return this.postElement}set streaming(e){this.postElement&&(e?this.postElement.classList.add("streaming"):this.postElement.classList.remove("streaming"))}async setRaw(e,t){this.post.set("raw",e)
const i=await(0,r.cook)(e)
this.element.classList.remove("streaming"),this.element.offsetWidth,this.element.classList.add("streaming")
const o=document.createElement("div")
o.innerHTML=i,t||c(o),await this.setCooked(o.innerHTML)}async setCooked(e){this.post.set("cooked",e)
const t=this.postElement.querySelector(".cooked"),r=t.cloneNode(!1)
r.innerHTML=e,(await(0,i.default)()).morph(t,r)}get raw(){return this.post.get("raw")||""}}async function m(e,t){if(e.startTime=e.startTime||Date.now(),Date.now()-e.startTime>s)return t.streaming=!1,!0
if(!t.element)return!1
const i=t.raw
if(e.raw===i&&!e.done){if(t.element.querySelector(".progress-dot"))return!1}if(void 0!==e.raw){let r=e.raw
if(!e.done)if(0===i.length&&-1!==r.indexOf("</details>"))r=e.raw
else{const t=r.length-i.length
let s=Math.floor(t/(a/o))
s<n&&(s=n),r=e.raw.substring(0,i.length+s)}await t.setRaw(r,e.done)}return e.done&&(e.cooked&&await t.setCooked(e.cooked),t.streaming=!1),e.done}function g(e){l||(l=(0,t.later)((async()=>{const t=await async function(e){const t=e.aiStreamingStatus
let i=!1
const r=Object.keys(t).map((async r=>{let o=t[r]
const s=new p(e,o.post_id)
await m(o,s)?delete t[r]:i=!0}))
return await Promise.all(r),i}(e)
l=null,t&&g(e)}),o))}})),define("discourse/plugins/discourse-ai/discourse/lib/copy-conversation",["exports","discourse/lib/ajax","discourse/lib/utilities","discourse-i18n"],(function(e,t,i,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=async function(e,o,s){await(0,i.clipboardCopyAsync)((async()=>{const i=await async function(e,i,o){const s=e.get("postStream")
let n=[]
for(let t=i;t<=o;t++)n.push(t)
const a=n.map((e=>s.findPostIdForPostNumber(e))),l=`/t/${e.id}/posts.json`,u={post_ids:a,include_raw:!0},c=await(0,t.ajax)(l,{data:u})
let d=[]
d.push("<details class='ai-quote'>"),d.push("<summary>"),d.push(`<span>${e.title}</span>`),d.push(`<span title='${r.default.t("discourse_ai.ai_bot.ai_title")}'>${r.default.t("discourse_ai.ai_bot.ai_label")}</span>`),d.push("</summary>"),c.post_stream.posts.forEach((e=>{d.push(""),d.push(`**${e.username}:**`),d.push(""),d.push(e.raw)})),d.push("</details>")
const p=d.join("\n")
return p}(e,o,s)
return new Blob([i],{type:"text/plain"})}))}})),define("discourse/plugins/discourse-ai/discourse/lib/show-ai-helper",["exports"],(function(e){"use strict"
function t(e){return e.discourse_ai_enabled&&e.composer_ai_helper_enabled}Object.defineProperty(e,"__esModule",{value:!0}),e.showComposerAIHelper=function(e,i,r){const o=t(i.siteSettings),s=i.currentUser.can_use_assistant,n=i.siteSettings.ai_helper_allowed_in_pm,a=i.siteSettings.ai_helper_enabled_features.includes(r)
if(e?.composer?.privateMessage)return o&&s&&n&&a
return o&&s&&a},e.showPostAIHelper=function(e,i){return t(i.siteSettings)&&i.currentUser?.can_use_assistant_in_post}})),define("discourse/plugins/discourse-ai/discourse/lib/utilities",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.IMAGE_MARKDOWN_REGEX=void 0
e.IMAGE_MARKDOWN_REGEX=/!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g})),define("discourse/plugins/discourse-ai/discourse/preferences-ai-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"user.preferences",map(){this.route("ai")}}}))
define("discourse/plugins/discourse-ai/discourse/routes/discourse-ai-shared-conversation-show",["exports","@ember/service","discourse/routes/discourse"],(function(e,t,i){"use strict"
var r,o
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(r=class extends i.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="currentUser",r=this,(i=o)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}beforeModel(e){this.currentUser?.user_option?.external_links_in_new_tab?window.open(e.intent.url,"_blank"):this.redirect(e.intent.url),e.abort()}redirect(e){window.location=e}},s=r.prototype,n="currentUser",a=[t.service],l={configurable:!0,enumerable:!0,writable:!0,initializer:null},c={},Object.keys(l).forEach((function(e){c[e]=l[e]})),c.enumerable=!!c.enumerable,c.configurable=!!c.configurable,("value"in c||c.initializer)&&(c.writable=!0),c=a.slice().reverse().reduce((function(e,t){return t(s,n,e)||e}),c),u&&void 0!==c.initializer&&(c.value=c.initializer?c.initializer.call(u):void 0,c.initializer=void 0),void 0===c.initializer&&(Object.defineProperty(s,n,c),c=null),o=c,r)
var s,n,a,l,u,c})),define("discourse/plugins/discourse-ai/discourse/routes/preferences-ai",["exports","@ember/service","discourse/lib/utilities","discourse/routes/restricted-user"],(function(e,t,i,r){"use strict"
var o,s
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(o=class extends r.default{constructor(){var e,t,i,r
super(...arguments),e=this,t="siteSettings",r=this,(i=s)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}setupController(e,t){if(!this.siteSettings.discourse_ai_enabled)return this.router.transitionTo(`discovery.${(0,i.defaultHomepage)()}`)
e.set("model",t)}},n=o.prototype,a="siteSettings",l=[t.service],u={configurable:!0,enumerable:!0,writable:!0,initializer:null},d={},Object.keys(u).forEach((function(e){d[e]=u[e]})),d.enumerable=!!d.enumerable,d.configurable=!!d.configurable,("value"in d||d.initializer)&&(d.writable=!0),d=l.slice().reverse().reduce((function(e,t){return t(n,a,e)||e}),d),c&&void 0!==d.initializer&&(d.value=d.initializer?d.initializer.call(c):void 0,d.initializer=void 0),void 0===d.initializer&&(Object.defineProperty(n,a,d),d=null),s=d,o)
var n,a,l,u,c,d})),define("discourse/plugins/discourse-ai/discourse/services/image-caption-popup",["exports","@glimmer/tracking","@ember/service","discourse/plugins/discourse-ai/discourse/lib/utilities"],(function(e,t,i,r){"use strict"
var o,s,n,a,l,u,c,d,p,m,g
function b(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function h(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(o=class extends i.default{constructor(){super(...arguments),b(this,"composer",s,this),b(this,"appEvents",n,this),b(this,"showPopup",a,this),b(this,"imageIndex",l,this),b(this,"imageSrc",u,this),b(this,"newCaption",c,this),b(this,"loading",d,this),b(this,"popupTrigger",p,this),b(this,"showAutoCaptionLoader",m,this),b(this,"_request",g,this)}updateCaption(){const e=this.composer.model.reply.match(r.IMAGE_MARKDOWN_REGEX)
if(e){const t=e[this.imageIndex],i=t.replace(r.IMAGE_MARKDOWN_REGEX,`![${this.newCaption}|$2$3$4]($5)`)
t&&this.appEvents.trigger("composer:replace-text",t,i)}}toggleLoadingState(e){return e?(this.popupTrigger?.classList.add("disabled"),this.loading=!0):(this.popupTrigger?.classList.remove("disabled"),this.loading=!1)}},s=h(o.prototype,"composer",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),n=h(o.prototype,"appEvents",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),a=h(o.prototype,"showPopup",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),l=h(o.prototype,"imageIndex",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),u=h(o.prototype,"imageSrc",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),c=h(o.prototype,"newCaption",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),d=h(o.prototype,"loading",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),p=h(o.prototype,"popupTrigger",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),m=h(o.prototype,"showAutoCaptionLoader",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),g=h(o.prototype,"_request",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),o)})),define("discourse/plugins/discourse-ai/discourse/services/quick-search",["exports","@glimmer/tracking","@ember/service"],(function(e,t,i){"use strict"
var r,o,s
function n(e,t,i,r){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(r):void 0})}function a(e,t,i,r,o){var s={}
return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(r=class extends i.default{constructor(){super(...arguments),n(this,"loading",o,this),n(this,"invalidTerm",s,this)}},o=a(r.prototype,"loading",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),s=a(r.prototype,"invalidTerm",[t.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),r)})),define("discourse/plugins/discourse-ai/discourse/templates/admin-dashboard-sentiment",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"nGq01/Xy",block:'[[[10,0],[14,0,"sentiment section"],[12],[1,"\\n "],[10,0],[14,0,"period-section"],[12],[1,"\\n "],[10,0],[14,0,"section-title"],[12],[1,"\\n "],[10,"h2"],[12],[1,"\\n "],[1,[28,[35,0],["discourse_ai.sentiments.dashboard.title"],null]],[1,"\\n "],[13],[1,"\\n\\n "],[8,[39,1],null,[["@period","@setPeriod","@startDate","@endDate","@setCustomDateRange"],[[30,0,["period"]],[30,0,["setPeriod"]],[30,0,["startDate"]],[30,0,["endDate"]],[30,0,["setCustomDateRange"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"section-body"],[12],[1,"\\n "],[10,0],[14,0,"charts"],[12],[1,"\\n "],[8,[39,2],null,[["@dataSourceName","@filters","@showHeader"],["overall_sentiment",[30,0,["filters"]],true]],null],[1,"\\n\\n "],[8,[39,2],null,[["@dataSourceName","@filters","@showHeader"],["post_emotion",[30,0,["filters"]],true]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],[],false,["i18n","dashboard-period-selector","admin-report"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/admin-dashboard-sentiment.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/ai-helper-context-menu",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"9lPQdG4P",block:'[[[11,0],[4,[38,0],[[30,0,["setupContextMenu"]]],null],[12],[1,"\\n"],[41,[30,0,["showContextMenu"]],[[[1," "],[10,0],[14,0,"ai-helper-context-menu"],[12],[1,"\\n"],[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","triggers"]]],null],[[[1," "],[10,"ul"],[14,0,"ai-helper-context-menu__trigger"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@action","@label"],["discourse-sparkles",[30,0,["toggleAiHelperOptions"]],"discourse_ai.ai_helper.context_menu.trigger"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","options"]]],null],[[[1," "],[10,"ul"],[14,0,"ai-helper-context-menu__options"],[12],[1,"\\n"],[42,[28,[37,5],[[28,[37,5],[[30,0,["helperOptions"]]],null]],null],null,[[[41,[28,[37,2],[[30,1,["name"]],"custom_prompt"],null],[[[1," "],[8,[39,6],null,[["@value","@promptArgs","@submit"],[[30,0,["customPromptValue"]],[30,1],[30,0,["updateSelected"]]]],null],[1,"\\n"]],[]],[[[1," "],[10,"li"],[15,"data-name",[30,1,["translated_name"]]],[15,"data-value",[30,1,["id"]]],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@translatedLabel","@action"],[[30,1,["icon"]],[30,1,["translated_name"]],[28,[37,7],[[30,0,["updateSelected"]],[30,1]],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]]]],[1]],null],[1," "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","loading"]]],null],[[[1," "],[8,[39,8],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","review"]]],null],[[[1," "],[10,"ul"],[14,0,"ai-helper-context-menu__review"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat view-changes"]],[["@icon","@label","@action"],["exchange-alt","discourse_ai.ai_helper.context_menu.view_changes",[30,0,["viewChanges"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat revert"]],[["@icon","@label","@action"],["undo","discourse_ai.ai_helper.context_menu.revert",[30,0,["undoAIAction"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat confirm"]],[["@icon","@label","@action"],["check","discourse_ai.ai_helper.context_menu.confirm",[30,0,["confirmChanges"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","resets"]]],null],[[[1," "],[10,"ul"],[14,0,"ai-helper-context-menu__resets"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat undo"]],[["@icon","@label","@action"],["undo","discourse_ai.ai_helper.context_menu.undo",[30,0,["undoAIAction"]]]],null],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@label","@action"],["discourse-sparkles","discourse_ai.ai_helper.context_menu.regen",[28,[37,7],[[30,0,["updateSelected"]],[30,0,["lastUsedOption"]]],null]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "]],[]],null]],[]]]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[13],[1,"\\n\\n"],[41,[30,0,["showDiffModal"]],[[[1," "],[8,[39,9],null,[["@confirm","@diff","@oldValue","@newValue","@revert","@closeModal"],[[30,0,["confirmChanges"]],[30,0,["diff"]],[30,0,["initialValue"]],[30,0,["newSelectedText"]],[30,0,["undoAIAction"]],[28,[37,7],[[28,[37,10],[[30,0,["showDiffModal"]]],null],false],null]]],null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showThumbnailModal"]],[[[1," "],[8,[39,11],null,[["@thumbnails","@closeModal"],[[30,0,["thumbnailSuggestions"]],[28,[37,7],[[28,[37,10],[[30,0,["showThumbnailModal"]]],null],false],null]]],null],[1,"\\n"]],[]],null]],["option"],false,["did-insert","if","eq","d-button","each","-track-array","ai-helper-custom-prompt","fn","ai-helper-loading","modal/diff-modal","mut","modal/thumbnail-suggestions"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/ai-helper-context-menu.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/composer-open",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"+kLlck0i",block:'[[[41,[30,0,["isAiBotChat"]],[[[1," "],[8,[39,1],null,[["@bodyClass"],[[30,0,["aiBotClasses"]]]],null],[1,"\\n"],[41,[30,0,["renderChatWarning"]],[[[1," "],[10,0],[14,0,"ai-bot-chat-warning"],[12],[1,[28,[35,2],["discourse_ai.ai_bot.pm_warning"],null]],[13],[1,"\\n"]],[]],null]],[]],null]],[],false,["if","d-section","i18n"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/composer-open.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/topic-more-content/related-topics",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"6Oz8VQA3",block:'[[[11,0],[24,1,"related-topics"],[16,0,[29,["more-topics__list ",[52,[30,0,["hidden"]],"hidden"]]]],[24,"role","complementary"],[24,"aria-labelledby","related-topics-title"],[4,[38,1],[[30,0,["registerList"]]],null],[4,[38,2],[[30,0,["removeList"]]],null],[12],[1,"\\n "],[10,"h3"],[14,1,"related-topics-title"],[14,0,"more-topics__list-title"],[12],[1,"\\n "],[1,[28,[35,3],["discourse_ai.related_topics.title"],null]],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"topics"],[12],[1,"\\n "],[8,[39,4],null,[["@topics"],[[30,0,["relatedTopics"]]]],null],[1,"\\n "],[13],[1,"\\n"],[13]],[],false,["if","did-insert","will-destroy","i18n","basic-topic-list"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/topic-more-content/related-topics.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/preferences/ai",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"wSbgol0u",block:'[[[10,"label"],[14,0,"control-label"],[12],[1,[28,[35,0],["discourse_ai.title"],null]],[13],[1,"\\n\\n"],[10,0],[14,0,"control-group ai-setting"],[12],[1,"\\n "],[8,[39,1],[[24,"data-setting-name","auto-image-caption"],[24,0,"pref-auto-image-caption"]],[["@labelKey","@checked"],["discourse_ai.ai_helper.image_caption.automatic_caption_setting",[30,0,["model","user_option","auto_image_caption"]]]],null],[1,"\\n"],[13],[1,"\\n\\n"],[8,[39,2],null,[["@id","@model","@action","@saved"],["user_ai_preference_save",[30,0,["model"]],[30,0,["save"]],[30,0,["saved"]]]],null]],[],false,["i18n","preference-checkbox","save-controls"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/preferences/ai.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/initializers/admin-plugin-configuration-nav",["exports","discourse/lib/admin-plugin-config-nav","discourse/lib/plugin-api"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-ai-admin-plugin-configuration-nav",initialize(e){const r=e.lookup("service:current-user")
r&&r.admin&&(0,i.withPluginApi)("1.1.0",(e=>{e.addAdminPluginConfigurationNav("discourse-ai",t.PLUGIN_NAV_MODE_TOP,[{label:"discourse_ai.ai_persona.short_title",route:"adminPlugins.show.discourse-ai-personas"},{label:"discourse_ai.llms.short_title",route:"adminPlugins.show.discourse-ai-llms"}])}))}}})),define("discourse/plugins/discourse-ai/initializers/ai-bot-replies",["exports","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/plugin-api","discourse/widgets/render-glimmer","discourse/plugins/discourse-ai/discourse/components/modal/debug-ai-modal","discourse/plugins/discourse-ai/discourse/components/modal/share-modal","discourse/plugins/discourse-ai/discourse/lib/ai-streamer","discourse/plugins/discourse-ai/discourse/lib/copy-conversation","discourse/plugins/discourse-ai/discourse/components/ai-bot-header-icon","discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper","@ember/template-factory"],(function(e,t,i,r,o,s,n,a,l,u,c,d){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
let p=[],m=!1
function g(e){return e&&p.includes(e.id)}function b(e){e.headerIcons.add("ai",u.default)}function h(e){e.addPostMenuButton("cancel-gpt",(e=>{if(g(e.user))return{icon:"pause",action:"cancelStreaming",title:"discourse_ai.ai_bot.cancel_streaming",className:"btn btn-default cancel-streaming",position:"first"}})),e.attachWidgetAction("post","cancelStreaming",(function(){(0,t.ajax)(`/discourse-ai/ai-bot/post/${this.model.id}/stop-streaming`,{type:"POST"}).then((()=>{document.querySelector(`#post_${this.model.post_number}`).classList.remove("streaming")})).catch(i.popupAjaxError)})),e.modifyClass("controller:topic",{pluginId:"discourse-ai",onAIBotStreamedReply:function(e){(0,a.default)(this.model.postStream,e)},subscribe:function(){this._super(),this.model.isPrivateMessage&&this.model.details.allowed_users&&this.model.details.allowed_users.filter(g).length>=1&&this.messageBus.subscribe(`discourse-ai/ai-bot/topic/${this.model.id}`,this.onAIBotStreamedReply.bind(this),-2)},unsubscribe:function(){this.messageBus.unsubscribe("discourse-ai/ai-bot/topic/*"),this._super()}})}function f(e){let t=null
e.decorateWidget("poster-name:after",(i=>{if(g(i.attrs.user))return t=t||e.container.lookup("controller:topic"),i.widget.attach("persona-flair",{topicController:t})})),(0,o.registerWidgetShim)("persona-flair","span.persona-flair",(0,d.createTemplateFactory)({id:"9jYzNJdM",block:'[[[1,[30,1,["topicController","model","ai_persona_name"]]]],["@data"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/initializers/ai-bot-replies.js",isStrictMode:!1}))}e.default={name:"discourse-ai-bot-replies",initialize(e){const t=e.lookup("service:current-user")
t?.ai_enabled_chat_bots&&(p=t.ai_enabled_chat_bots.map((e=>e.id)),m=t.can_debug_ai_bot_conversations,(0,r.withPluginApi)("1.6.0",b),(0,r.withPluginApi)("1.6.0",h),(0,r.withPluginApi)("1.6.0",f),(0,r.withPluginApi)("1.22.0",(e=>function(e){const t=e.getCurrentUser()
if(!t||!t.ai_enabled_chat_bots||!m)return
let i=async function(t){let{post:i}=t
e.container.lookup("service:modal").show(s.default,{model:i})}
e.addPostMenuButton("debugAi",(e=>{if("private_message"===e.topic?.archetype&&(t.ai_enabled_chat_bots.any((t=>e.username===t.username))||!(e.user_id>-1200)))return{action:i,icon:"info",className:"post-action-menu__debug-ai",title:"discourse_ai.ai_bot.debug_ai",position:"first"}}))}(e))),(0,r.withPluginApi)("1.22.0",(e=>function(e){const t=e.getCurrentUser()
if(!t||!t.ai_enabled_chat_bots)return
let i=async function(t){let{post:i,showFeedback:r}=t
i.post_number<=4?(await(0,l.default)(i.topic,1,i.post_number),r("discourse_ai.ai_bot.conversation_shared")):e.container.lookup("service:modal").show(n.default,{model:i})}
e.addPostMenuButton("share",(e=>{if("private_message"===e.topic?.archetype&&(t.ai_enabled_chat_bots.any((t=>e.username===t.username))||!(e.user_id>-1200)))return{action:i,icon:"share",className:"post-action-menu__share",title:"discourse_ai.ai_bot.share",position:"first"}}))}(e))),(0,r.withPluginApi)("1.22.0",(e=>function(e){const t=e.container.lookup("service:modal"),i=e.container.lookup("current-user:main")
e.registerTopicFooterButton({id:"share-ai-conversation",icon:"share-alt",label:"discourse_ai.ai_bot.share_ai_conversation.name",title:"discourse_ai.ai_bot.share_ai_conversation.title",action(){(0,c.showShareConversationModal)(t,this.topic.id)},classNames:["share-ai-conversation-button"],dependentKeys:["topic.ai_persona_name"],displayed(){return i?.can_share_ai_bot_conversations&&this.topic.ai_persona_name}})}(e))))}}})),define("discourse/plugins/discourse-ai/initializers/ai-image-caption",["exports","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/api","discourse/lib/uploads","discourse-i18n","discourse/plugins/discourse-ai/discourse/lib/utilities"],(function(e,t,i,r,o,s,n){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,r.apiInitializer)("1.25.0",(e=>{const r={label:s.default.t("discourse_ai.ai_helper.image_caption.button_label"),icon:"discourse-sparkles",class:"generate-caption"},a=e.container.lookup("service:site-settings"),l=e.getCurrentUser()
if(!a.ai_helper_enabled_features.includes("image_caption")||!l?.can_use_assistant)return
function u(e){return e.length<20||1===e.split(" ").length}async function c(e,r){try{return(await(0,t.ajax)("/discourse-ai/ai-helper/caption_image",{method:"POST",data:{image_url:e,image_url_type:r}})).caption}catch(o){(0,i.popupAjaxError)(o)}}e.addSaveableUserOptionField("auto_image_caption"),e.addComposerImageWrapperButton(r.label,r.class,r.icon,(r=>{const o=e.container.lookup("service:imageCaptionPopup")
if(o.popupTrigger=r.target,o.popupTrigger.classList.contains("generate-caption")){const s=r.target.closest(".button-wrapper"),n=parseInt(s.getAttribute("data-image-index"),10),a=r.target.closest(".image-wrapper").querySelector("img").getAttribute("src")
o.toggleLoadingState(!0)
const l=e.container.lookup("site:main")
l.mobileView||(o.showPopup=!o.showPopup),o._request=(0,t.ajax)("/discourse-ai/ai-helper/caption_image",{method:"POST",data:{image_url:a,image_url_type:"long_url"}}),o._request.then((e=>{let{caption:t}=e
o.imageSrc=a,o.imageIndex=n,o.newCaption=t,l.mobileView&&o.updateCaption()})).catch(i.popupAjaxError).finally((()=>{o.toggleLoadingState(!1)}))}}))
const d=a?.ai_auto_image_caption_allowed_groups.split("|").map((e=>parseInt(e,10)))
l.groups.map((e=>e.id)).some((e=>d.includes(e)))&&(e.addComposerUploadMarkdownResolver((async e=>{if(!l.get("user_option.auto_image_caption")||!(0,o.isImage)(e.url)||!u(e.original_filename)||(t=e.width,i=e.height,t*i/1e6<=.4))return(0,o.getUploadMarkdown)(e)
var t,i
return`![${await c(e.url,"long_url")}|${e.thumbnail_width}x${e.thumbnail_height}](${e.short_url})`})),e.composerBeforeSave((()=>new Promise(((t,i)=>{const r=e.container.lookup("service:dialog"),o=e.container.lookup("service:composer"),a="discourse_ai.ai_helper.image_caption.automatic_caption_dialog",d=l.get("user_option.auto_image_caption"),p=o.model.reply.match(n.IMAGE_MARKDOWN_REGEX)
p?.length>0||t()
const m=p.filter((e=>u(e.substring(e.indexOf("[")+1,e.indexOf("]")).split("|")[0]))),g=m?.length>0,b=e.container.lookup("service:key-value-store"),h=e.container.lookup("service:imageCaptionPopup"),f="ai-auto-caption-seen",_=b.getItem(f)
if(d||!g||_)return t()
b.setItem(f,!0),r.confirm({message:s.default.t(`${a}.prompt`),confirmButtonLabel:`${a}.confirm`,cancelButtonLabel:`${a}.cancel`,class:"ai-image-caption-prompt-dialog",didConfirm:async()=>{try{l.set("user_option.auto_image_caption",!0),await l.save(["auto_image_caption"]),m.forEach((async e=>{const i=function(e){const t=e.match(/\(upload:\/\/([^)]+)\)/)
return t?`upload://${t[1]}`:null}(e)
h.showAutoCaptionLoader=!0
const r=await c(i,"short_url"),s=new RegExp(`(!\\[)[^|]+(\\|[^\\]]+\\]\\(${i}\\))`),n=o.model.reply.replace(s,`$1${r}$2`)
o.model.set("reply",n),h.showAutoCaptionLoader=!1,t()}))}catch(e){i(e)}},didCancel:()=>{t()}})})))))}))})),define("discourse/plugins/discourse-ai/initializers/ai-semantic-search",["exports","discourse/lib/api"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.apiInitializer)("1.15.0",(e=>{e.modifyClass("component:search-result-entry",{pluginId:"discourse-ai",classNameBindings:["bulkSelectEnabled","post.generatedByAI:ai-result"]})}))})),define("discourse/plugins/discourse-ai/initializers/related-topics",["exports","discourse/lib/plugin-api"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-ai-related-topics",initialize(e){const i=e.lookup("service:site-settings")
i.ai_embeddings_enabled&&i.ai_embeddings_semantic_related_topics_enabled&&(0,t.withPluginApi)("1.1.0",(e=>{e.modifyClass("model:post-stream",{pluginId:"discourse-ai",_setSuggestedTopics(e){this._super(...arguments),e.related_topics&&this.topic.setProperties({related_topics:e.related_topics})}})}))}}})),define("discourse/plugins/discourse-ai/lib/discourse-markdown/ai-tags",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.setup=function(e){e.allowList(["details[class=ai-quote]"])}}))
//# sourceMappingURL=discourse-ai-d1e5ecfe59893bb0c49f5ee04ad93c131697f702f35361f14d2fe0f485a7f672.map
//!
;