From aa8becce81b3371d067a8d60e54839dfc5a93abf Mon Sep 17 00:00:00 2001 From: Hylke Date: Mon, 27 Oct 2025 13:14:38 +0100 Subject: [PATCH 1/5] Able to use settings as context settings --- core/components/modai/src/API/Prompt/Text.php | 8 ++++-- core/components/modai/src/Settings.php | 28 +++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/core/components/modai/src/API/Prompt/Text.php b/core/components/modai/src/API/Prompt/Text.php index 268ceb8..05801d0 100644 --- a/core/components/modai/src/API/Prompt/Text.php +++ b/core/components/modai/src/API/Prompt/Text.php @@ -18,6 +18,8 @@ class Text extends API public function post(ServerRequestInterface $request): void { + $contextKey = ''; + if (!$this->modx->hasPermission('modai_client_text')) { throw APIException::unauthorized(); } @@ -60,7 +62,7 @@ public function post(ServerRequestInterface $request): void if (!$resource) { throw new LexiconException('modai.error.no_resource_found'); } - + $contextKey = $resource->get('context_key'); $content = $resource->getContent(); if (empty($content)) { @@ -74,9 +76,9 @@ public function post(ServerRequestInterface $request): void $model = Settings::getTextSetting($this->modx, $field, 'model', $namespace); $temperature = (float)Settings::getTextSetting($this->modx, $field, 'temperature', $namespace); $maxTokens = (int)Settings::getTextSetting($this->modx, $field, 'max_tokens', $namespace); - $output = Settings::getTextSetting($this->modx, $field, 'base_output', $namespace, false); + $output = Settings::getTextSetting($this->modx, $field, 'base_output', $namespace, false, $contextKey); $base = Settings::getTextSetting($this->modx, $field, 'base_prompt', $namespace, false); - $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace); + $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace, false); $customOptions = Settings::getTextSetting($this->modx, $field, 'custom_options', $namespace, false); if (!empty($output)) { diff --git a/core/components/modai/src/Settings.php b/core/components/modai/src/Settings.php index 650bbc6..4d94291 100644 --- a/core/components/modai/src/Settings.php +++ b/core/components/modai/src/Settings.php @@ -25,28 +25,38 @@ class Settings * @param string $setting * @return string|null */ - private static function getOption(modX $modx, string $namespace, string $field, string $area, string $setting): ?string + private static function getOption(modX $modx, string $namespace, string $field, string $area, string $setting, string $contextKey = 'web'): ?string { + $handler = $modx; + + if (!empty($contextKey)) { + + $context = $modx->getContext($contextKey); + if ($context) { + $handler = $context; + } + } + if (!empty($field)) { - $value = $modx->getOption("#sys.$field.$area.$setting"); + $value = $handler->getOption("#sys.$field.$area.$setting"); if ($value !== null && $value !== '') { return $value; } } - $value = $modx->getOption("#sys.global.$area.$setting"); + $value = $handler->getOption("#sys.global.$area.$setting"); if ($value !== null && $value !== '') { return $value; } if (!empty($field)) { - $value = $modx->getOption("$namespace.$field.$area.$setting"); + $value = $handler->getOption("$namespace.$field.$area.$setting"); if ($value !== null && $value !== '') { return $value; } } - $value = $modx->getOption("$namespace.global.$area.$setting"); + $value = $handler->getOption("$namespace.global.$area.$setting"); if ($value !== null && $value !== '') { return $value; } @@ -56,13 +66,13 @@ private static function getOption(modX $modx, string $namespace, string $field, } if (!empty($field)) { - $value = $modx->getOption("modai.$field.$area.$setting"); + $value = $handler->getOption("modai.$field.$area.$setting"); if ($value !== null && $value !== '') { return $value; } } - $value = $modx->getOption("modai.global.$area.$setting"); + $value = $handler->getOption("modai.global.$area.$setting"); if ($value !== null && $value !== '') { return $value; } @@ -73,9 +83,9 @@ private static function getOption(modX $modx, string $namespace, string $field, /** * @throws RequiredSettingException */ - public static function getTextSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true): ?string + public static function getTextSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true, string $contextKey = ''): ?string { - $value = self::getOption($modx, $namespace, $field, 'text', $setting); + $value = self::getOption($modx, $namespace, $field, 'text', $setting, $contextKey); if ($required && ($value === null || $value === '')) { throw new RequiredSettingException("modai.global.text.$setting"); From cfa97c70e3a876e4c316b29b53d8d0001b3c6253 Mon Sep 17 00:00:00 2001 From: Hylke Date: Mon, 27 Oct 2025 14:02:23 +0100 Subject: [PATCH 2/5] Send contextkey with the function --- core/components/modai/src/API/Prompt/Text.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/components/modai/src/API/Prompt/Text.php b/core/components/modai/src/API/Prompt/Text.php index 05801d0..d76ac94 100644 --- a/core/components/modai/src/API/Prompt/Text.php +++ b/core/components/modai/src/API/Prompt/Text.php @@ -73,13 +73,13 @@ public function post(ServerRequestInterface $request): void $systemInstructions = []; $stream = intval(Settings::getTextSetting($this->modx, $field, 'stream', $namespace)) === 1; - $model = Settings::getTextSetting($this->modx, $field, 'model', $namespace); - $temperature = (float)Settings::getTextSetting($this->modx, $field, 'temperature', $namespace); - $maxTokens = (int)Settings::getTextSetting($this->modx, $field, 'max_tokens', $namespace); + $model = Settings::getTextSetting($this->modx, $field, 'model', $namespace, 'openai/gpt-4o-mini', $contextKey); + $temperature = (float)Settings::getTextSetting($this->modx, $field, 'temperature', $namespace , 0, $contextKey); + $maxTokens = (int)Settings::getTextSetting($this->modx, $field, 'max_tokens', $namespace, 0, $contextKey); $output = Settings::getTextSetting($this->modx, $field, 'base_output', $namespace, false, $contextKey); - $base = Settings::getTextSetting($this->modx, $field, 'base_prompt', $namespace, false); - $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace, false); - $customOptions = Settings::getTextSetting($this->modx, $field, 'custom_options', $namespace, false); + $base = Settings::getTextSetting($this->modx, $field, 'base_prompt', $namespace, false, $contextKey); + $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace, false, $contextKey); + $customOptions = Settings::getTextSetting($this->modx, $field, 'custom_options', $namespace, false, $contextKey); if (!empty($output)) { $systemInstructions[] = $output; From 4a1da83cc5cca7ec4c020a3911c43dd3e295cc32 Mon Sep 17 00:00:00 2001 From: Hylke Date: Mon, 10 Nov 2025 15:09:03 +0100 Subject: [PATCH 3/5] Feedback --- core/components/modai/src/API/Prompt/Text.php | 10 +++++----- core/components/modai/src/Settings.php | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/components/modai/src/API/Prompt/Text.php b/core/components/modai/src/API/Prompt/Text.php index d76ac94..602dec9 100644 --- a/core/components/modai/src/API/Prompt/Text.php +++ b/core/components/modai/src/API/Prompt/Text.php @@ -18,7 +18,7 @@ class Text extends API public function post(ServerRequestInterface $request): void { - $contextKey = ''; + $contextKey = null; if (!$this->modx->hasPermission('modai_client_text')) { throw APIException::unauthorized(); @@ -73,12 +73,12 @@ public function post(ServerRequestInterface $request): void $systemInstructions = []; $stream = intval(Settings::getTextSetting($this->modx, $field, 'stream', $namespace)) === 1; - $model = Settings::getTextSetting($this->modx, $field, 'model', $namespace, 'openai/gpt-4o-mini', $contextKey); - $temperature = (float)Settings::getTextSetting($this->modx, $field, 'temperature', $namespace , 0, $contextKey); - $maxTokens = (int)Settings::getTextSetting($this->modx, $field, 'max_tokens', $namespace, 0, $contextKey); + $model = Settings::getTextSetting($this->modx, $field, 'model', $namespace, true, $contextKey); + $temperature = (float)Settings::getTextSetting($this->modx, $field, 'temperature', $namespace , true, $contextKey); + $maxTokens = (int)Settings::getTextSetting($this->modx, $field, 'max_tokens', $namespace, true, $contextKey); $output = Settings::getTextSetting($this->modx, $field, 'base_output', $namespace, false, $contextKey); $base = Settings::getTextSetting($this->modx, $field, 'base_prompt', $namespace, false, $contextKey); - $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace, false, $contextKey); + $fieldPrompt = Settings::getTextSetting($this->modx, $field, 'prompt', $namespace, true, $contextKey); $customOptions = Settings::getTextSetting($this->modx, $field, 'custom_options', $namespace, false, $contextKey); if (!empty($output)) { diff --git a/core/components/modai/src/Settings.php b/core/components/modai/src/Settings.php index 4d94291..032a1e2 100644 --- a/core/components/modai/src/Settings.php +++ b/core/components/modai/src/Settings.php @@ -25,12 +25,11 @@ class Settings * @param string $setting * @return string|null */ - private static function getOption(modX $modx, string $namespace, string $field, string $area, string $setting, string $contextKey = 'web'): ?string + private static function getOption(modX $modx, string $namespace, string $field, string $area, string $setting, ?string $contextKey = null): ?string { $handler = $modx; if (!empty($contextKey)) { - $context = $modx->getContext($contextKey); if ($context) { $handler = $context; @@ -83,7 +82,7 @@ private static function getOption(modX $modx, string $namespace, string $field, /** * @throws RequiredSettingException */ - public static function getTextSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true, string $contextKey = ''): ?string + public static function getTextSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true, ?string $contextKey = null): ?string { $value = self::getOption($modx, $namespace, $field, 'text', $setting, $contextKey); From 69e215566eb9d4c1c297b45b8c551151758a4185 Mon Sep 17 00:00:00 2001 From: Hylke Date: Mon, 10 Nov 2025 15:32:56 +0100 Subject: [PATCH 4/5] Add support in vision endpoint --- .../modai/src/API/Prompt/Vision.php | 23 ++++++++++++++----- core/components/modai/src/Settings.php | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/core/components/modai/src/API/Prompt/Vision.php b/core/components/modai/src/API/Prompt/Vision.php index fc3b054..b7b4119 100644 --- a/core/components/modai/src/API/Prompt/Vision.php +++ b/core/components/modai/src/API/Prompt/Vision.php @@ -10,35 +10,46 @@ use modAI\Settings; use modAI\Utils; use Psr\Http\Message\ServerRequestInterface; +use MODX\Revolution\modResource; class Vision extends API { public function post(ServerRequestInterface $request): void { + $contextKey = null; if (!$this->modx->hasPermission('modai_client_vision')) { throw APIException::unauthorized(); } set_time_limit(0); - $data = $request->getParsedBody(); $field = Utils::getOption('field', $data); $namespace = Utils::getOption('namespace', $data, 'modai'); $image = Utils::getOption('image', $data); $prompt = Utils::getOption('prompt', $data); + $resourceId = Utils::getOption('resourceId', $data); if (empty($image)) { throw new LexiconException('modai.error.image_requried'); } - $stream = intval(Settings::getVisionSetting($this->modx, $field, 'stream', $namespace)) === 1; - $model = Settings::getVisionSetting($this->modx, $field, 'model', $namespace); + if (!empty($resourceId)) { + /** @var modResource $resource */ + $resource = $this->modx->getObject('modResource', $resourceId); + if (!$resource) { + throw new LexiconException('modai.error.no_resource_found'); + } + $contextKey = $resource->get('context_key'); + } + + $stream = intval(Settings::getVisionSetting($this->modx, $field, 'stream', $namespace, true, $contextKey)) === 1; + $model = Settings::getVisionSetting($this->modx, $field, 'model', $namespace, true, $contextKey); if (empty($prompt)) { - $prompt = Settings::getVisionSetting($this->modx, $field, 'prompt', $namespace); + $prompt = Settings::getVisionSetting($this->modx, $field, 'prompt', $namespace, true, $contextKey); } - $customOptions = Settings::getVisionSetting($this->modx, $field, 'custom_options', $namespace, false); - $maxTokens = (int)Settings::getVisionSetting($this->modx, $field, 'max_tokens', $namespace); + $customOptions = Settings::getVisionSetting($this->modx, $field, 'custom_options', $namespace, false, $contextKey); + $maxTokens = (int)Settings::getVisionSetting($this->modx, $field, 'max_tokens', $namespace, true, $contextKey); $aiService = AIServiceFactory::new($model, $this->modx); $result = $aiService->getVision( diff --git a/core/components/modai/src/Settings.php b/core/components/modai/src/Settings.php index 032a1e2..977be9c 100644 --- a/core/components/modai/src/Settings.php +++ b/core/components/modai/src/Settings.php @@ -110,9 +110,9 @@ public static function getImageSetting(modX $modx, string $field, string $settin /** * @throws RequiredSettingException */ - public static function getVisionSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true): ?string + public static function getVisionSetting(modX $modx, string $field, string $setting, string $namespace = 'modai', bool $required = true, ?string $contextKey = null): ?string { - $value = self::getOption($modx, $namespace, $field, 'vision', $setting); + $value = self::getOption($modx, $namespace, $field, 'vision', $setting, $contextKey); if ($required && ($value === null || $value === '')) { throw new RequiredSettingException("modai.global.vision.$setting"); From a8816ea01481300768606949b2bf7defe0e9b3a3 Mon Sep 17 00:00:00 2001 From: Jan Peca Date: Wed, 12 Nov 2025 16:31:21 +0100 Subject: [PATCH 5/5] feat: pass resourceId to the vision endpoint from mgr --- _build/js/src/executor/types.ts | 1 + _build/js/src/mgr/resource.ts | 1 + _build/js/src/ui/generateButton/index.ts | 2 ++ assets/components/modai/js/modai.js | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/_build/js/src/executor/types.ts b/_build/js/src/executor/types.ts index bcee86c..fa120a9 100644 --- a/_build/js/src/executor/types.ts +++ b/_build/js/src/executor/types.ts @@ -140,6 +140,7 @@ export type VisionParams = { additionalOptions?: Record; namespace?: string; image: string; + resourceId?: string | number; }; export type ImageParams = { diff --git a/_build/js/src/mgr/resource.ts b/_build/js/src/mgr/resource.ts index 0818038..757ed7c 100644 --- a/_build/js/src/mgr/resource.ts +++ b/_build/js/src/mgr/resource.ts @@ -31,6 +31,7 @@ const attachImagePlus = (imgPlusPanel: Element, fieldName: string) => { targetEl: imagePlus.altTextField.el.dom, input: imagePlus.altTextField.items.items[0].el.dom, field: fieldName, + resource: MODx.request.id, image: imagePlus.imagePreview.el.dom, onUpdate: (data) => { imagePlus.altTextField.items.items[0].setValue(data.content); diff --git a/_build/js/src/ui/generateButton/index.ts b/_build/js/src/ui/generateButton/index.ts index f024788..55417a4 100644 --- a/_build/js/src/ui/generateButton/index.ts +++ b/_build/js/src/ui/generateButton/index.ts @@ -247,6 +247,7 @@ type VisionConfig = { image: HTMLImageElement; input: HTMLElement; field: string; + resource?: number | string; onUpdate: (data: TextData) => void; namespace?: string; }; @@ -276,6 +277,7 @@ const createVisionPrompt = (config: VisionConfig & Target) => { { image: base64Data, field: config.field, + resourceId: config.resource, namespace: config.namespace, }, (data) => { diff --git a/assets/components/modai/js/modai.js b/assets/components/modai/js/modai.js index b9381d3..32373d1 100644 --- a/assets/components/modai/js/modai.js +++ b/assets/components/modai/js/modai.js @@ -28,7 +28,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),q=v,G=x),w===void 0&&( 0%, 80%, 100% { transform: scale(0); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } } - `}let l=document.createElement("style");l.textContent=s,document.head.appendChild(l),r.appendChild(a);let c=window.getComputedStyle(e.parentElement),u;["relative","absolute","fixed"].indexOf(c.position)===-1?(u=document.createElement("div"),u.style.position="relative",u.style.width=`${o.width}px`,u.style.height=`${o.height}px`,u.style.display="inline-block",e.parentNode?.insertBefore(u,e),u.appendChild(e)):u=e.parentElement,r.style.display="none",u.appendChild(r);let d=e.getBoundingClientRect();return u!==e.parentElement&&(u.style.width=`${d.width}px`,u.style.height=`${d.height}px`),r.style.display="flex",e.setAttribute("disabled","disabled"),()=>{r.style.display="none",e.removeAttribute("disabled"),r.remove(),l.remove(),u!==e.parentElement&&(u.parentNode?.insertBefore(e,u),u.remove())}};var Cn=(e,t)=>{let{shadow:n,shadowRoot:r}=Qe(!0),a=O("div","modai--root generate",Q(Y(t?.iconSize||14,Si),e,"btn",{type:"button",title:N("modai.ui.generate_using_ai")}));return r.appendChild(a),{shadow:n,shadowRoot:r,generate:a}},YE=e=>{let t=Q(Y(14,fi),()=>{e.prev()},"history--prev",{type:"button",title:N("modai.ui.previous_version"),role:"navigation"}),n=Q(Y(14,bi),()=>{e.next()},"history--next",{type:"button",title:N("modai.ui.next_version"),role:"navigation"}),r=O("div");r.update=(i,o)=>{r.innerText=`${i}/${o}`};let a=O("div","history--wrapper");return a.show=()=>{a.style.display="inline-flex"},a.hide=()=>{a.style.display="none"},a.prevButton=t,a.nextButton=n,a.info=r,a.appendChild(t),a.appendChild(r),a.appendChild(n),a.hide(),t.disable(),n.disable(),a},HE=e=>{if(!ce.localChat.verifyPermissions(e))return;let{shadow:t}=Cn(()=>{ce.localChat.createModal(e)},{iconSize:e.iconSize});return e.targetEl.appendChild(t),t},qE=({targetEl:e,iconSize:t,input:n,onChange:r,initialValue:a,field:i,...o})=>{if(!we(["modai_client","modai_client_text"]))return;let{shadow:s,generate:l}=Cn(async()=>{let d=Ht(n);try{let m=await $.prompt.text({field:i,...o},p=>{c.insert(p.content,!0)});c.insert(m.content),d()}catch(m){d(),Ye({title:"Failed",content:N("modai.error.failed_try_again",{msg:m instanceof Error?m.message:""}),confirmText:"Close",showCancel:!1,onConfirm:()=>{}})}},{iconSize:t}),c=ci.init(i,(d,m)=>{d.context.els.forEach(({wrapper:p,onFieldChange:g})=>{g(d,m),d.total>0&&p.historyNav.show(),p.historyNav.info.update(d.current,d.total);let S=p.shadowRoot||p.ownerDocument,R=!d.prevStatus&&S.activeElement===p.historyNav.prevButton,A=!d.nextStatus&&S.activeElement===p.historyNav.nextButton;d.prevStatus?p.historyNav.prevButton.enable():p.historyNav.prevButton.disable(),d.nextStatus?p.historyNav.nextButton.enable():p.historyNav.nextButton.disable(),R&&p.historyNav.nextButton.focus(),A&&p.historyNav.prevButton.focus()})},a,{});c.cachedItem.context.els||(c.cachedItem.context.els=[]),c.cachedItem.context.els.push({onFieldChange:r,wrapper:s});let u=YE(c);return l.appendChild(u),s.historyNav=u,e.appendChild(s),s},VE=e=>{if(!we(["modai_client","modai_client_vision"]))return;let{shadow:t}=Cn(async()=>{let n=document.createElement("canvas"),r=n.getContext("2d");if(!r)return;n.width=e.image.width,n.height=e.image.height,r.drawImage(e.image,0,0);let a=n.toDataURL("image/png"),i=Ht(e.input);try{let o=await $.prompt.vision({image:a,field:e.field,namespace:e.namespace},s=>{e.onUpdate(s)});e.onUpdate(o),i()}catch(o){i(),Ye({title:N("modai.error.failed"),content:N("modai.error.failed_try_again",{msg:o instanceof Error?o.message:""}),confirmText:N("modai.ui.close"),showCancel:!1,onConfirm:()=>{}})}},{iconSize:e.iconSize});return e.targetEl.appendChild(t),t},Ui={rawButton:Cn,localChat:HE,forcedText:qE,vision:VE};var Bi=e=>{E.modal.isDragging=!0;let n=E.modal.modal.getBoundingClientRect();E.modal.offsetX=e.clientX-n.left,E.modal.offsetY=e.clientY-n.top,document.body.style.userSelect="none"},qt=e=>{if(!E.modal.isDragging)return;let t=E.modal.modal,n=e.clientX-E.modal.offsetX,r=e.clientY-E.modal.offsetY;t.style.left=n+"px",t.style.top=r+"px",t.style.transform="none"},Vt=()=>{E.modal.isDragging=!1,document.body.style.userSelect=""};var Up=PE(Fp(),1);var br=Up.default;var Ir={};Bt(Ir,{arrayReplaceAt:()=>Ar,assign:()=>xt,escapeHtml:()=>qe,escapeRE:()=>jh,fromCodePoint:()=>Zt,has:()=>Hh,isMdAsciiPunct:()=>dt,isPunctChar:()=>ut,isSpace:()=>X,isString:()=>zn,isValidEntityCode:()=>Wn,isWhiteSpace:()=>ct,lib:()=>eC,normalizeReference:()=>_t,unescapeAll:()=>He,unescapeMd:()=>$h});var Un={};Bt(Un,{decode:()=>Qt,encode:()=>Pn,format:()=>vt,parse:()=>Xt});var Bp={};function Sh(e){let t=Bp[e];if(t)return t;t=Bp[e]=[];for(let n=0;n<128;n++){let r=String.fromCharCode(n);t.push(r)}for(let n=0;n=55296&&u<=57343?a+="\uFFFD\uFFFD\uFFFD":a+=String.fromCharCode(u),i+=6;continue}}if((s&248)===240&&i+91114111?a+="\uFFFD\uFFFD\uFFFD\uFFFD":(d-=65536,a+=String.fromCharCode(55296+(d>>10),56320+(d&1023))),i+=9;continue}}a+="\uFFFD"}return a})}wn.defaultChars=";/?:@&=+$,#";wn.componentChars="";var Qt=wn;var Gp={};function fh(e){let t=Gp[e];if(t)return t;t=Gp[e]=[];for(let n=0;n<128;n++){let r=String.fromCharCode(n);/^[0-9a-z]$/i.test(r)?t.push(r):t.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2))}for(let n=0;n"u"&&(n=!0);let r=fh(t),a="";for(let i=0,o=e.length;i=55296&&s<=57343){if(s>=55296&&s<=56319&&i+1=56320&&l<=57343){a+=encodeURIComponent(e[i]+e[i+1]),i++;continue}}a+="%EF%BF%BD";continue}a+=encodeURIComponent(e[i])}return a}kn.defaultChars=";/?:@&=+$,-_.!~*'()#";kn.componentChars="-_.!~*'()";var Pn=kn;function vt(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function Fn(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var bh=/^([a-z0-9.+-]+:)/i,Th=/:[0-9]*$/,hh=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Ch=["<",">",'"',"`"," ","\r",` + `}let l=document.createElement("style");l.textContent=s,document.head.appendChild(l),r.appendChild(a);let c=window.getComputedStyle(e.parentElement),u;["relative","absolute","fixed"].indexOf(c.position)===-1?(u=document.createElement("div"),u.style.position="relative",u.style.width=`${o.width}px`,u.style.height=`${o.height}px`,u.style.display="inline-block",e.parentNode?.insertBefore(u,e),u.appendChild(e)):u=e.parentElement,r.style.display="none",u.appendChild(r);let d=e.getBoundingClientRect();return u!==e.parentElement&&(u.style.width=`${d.width}px`,u.style.height=`${d.height}px`),r.style.display="flex",e.setAttribute("disabled","disabled"),()=>{r.style.display="none",e.removeAttribute("disabled"),r.remove(),l.remove(),u!==e.parentElement&&(u.parentNode?.insertBefore(e,u),u.remove())}};var Cn=(e,t)=>{let{shadow:n,shadowRoot:r}=Qe(!0),a=O("div","modai--root generate",Q(Y(t?.iconSize||14,Si),e,"btn",{type:"button",title:N("modai.ui.generate_using_ai")}));return r.appendChild(a),{shadow:n,shadowRoot:r,generate:a}},YE=e=>{let t=Q(Y(14,fi),()=>{e.prev()},"history--prev",{type:"button",title:N("modai.ui.previous_version"),role:"navigation"}),n=Q(Y(14,bi),()=>{e.next()},"history--next",{type:"button",title:N("modai.ui.next_version"),role:"navigation"}),r=O("div");r.update=(i,o)=>{r.innerText=`${i}/${o}`};let a=O("div","history--wrapper");return a.show=()=>{a.style.display="inline-flex"},a.hide=()=>{a.style.display="none"},a.prevButton=t,a.nextButton=n,a.info=r,a.appendChild(t),a.appendChild(r),a.appendChild(n),a.hide(),t.disable(),n.disable(),a},HE=e=>{if(!ce.localChat.verifyPermissions(e))return;let{shadow:t}=Cn(()=>{ce.localChat.createModal(e)},{iconSize:e.iconSize});return e.targetEl.appendChild(t),t},qE=({targetEl:e,iconSize:t,input:n,onChange:r,initialValue:a,field:i,...o})=>{if(!we(["modai_client","modai_client_text"]))return;let{shadow:s,generate:l}=Cn(async()=>{let d=Ht(n);try{let m=await $.prompt.text({field:i,...o},p=>{c.insert(p.content,!0)});c.insert(m.content),d()}catch(m){d(),Ye({title:"Failed",content:N("modai.error.failed_try_again",{msg:m instanceof Error?m.message:""}),confirmText:"Close",showCancel:!1,onConfirm:()=>{}})}},{iconSize:t}),c=ci.init(i,(d,m)=>{d.context.els.forEach(({wrapper:p,onFieldChange:g})=>{g(d,m),d.total>0&&p.historyNav.show(),p.historyNav.info.update(d.current,d.total);let S=p.shadowRoot||p.ownerDocument,R=!d.prevStatus&&S.activeElement===p.historyNav.prevButton,A=!d.nextStatus&&S.activeElement===p.historyNav.nextButton;d.prevStatus?p.historyNav.prevButton.enable():p.historyNav.prevButton.disable(),d.nextStatus?p.historyNav.nextButton.enable():p.historyNav.nextButton.disable(),R&&p.historyNav.nextButton.focus(),A&&p.historyNav.prevButton.focus()})},a,{});c.cachedItem.context.els||(c.cachedItem.context.els=[]),c.cachedItem.context.els.push({onFieldChange:r,wrapper:s});let u=YE(c);return l.appendChild(u),s.historyNav=u,e.appendChild(s),s},VE=e=>{if(!we(["modai_client","modai_client_vision"]))return;let{shadow:t}=Cn(async()=>{let n=document.createElement("canvas"),r=n.getContext("2d");if(!r)return;n.width=e.image.width,n.height=e.image.height,r.drawImage(e.image,0,0);let a=n.toDataURL("image/png"),i=Ht(e.input);try{let o=await $.prompt.vision({image:a,field:e.field,resourceId:e.resource,namespace:e.namespace},s=>{e.onUpdate(s)});e.onUpdate(o),i()}catch(o){i(),Ye({title:N("modai.error.failed"),content:N("modai.error.failed_try_again",{msg:o instanceof Error?o.message:""}),confirmText:N("modai.ui.close"),showCancel:!1,onConfirm:()=>{}})}},{iconSize:e.iconSize});return e.targetEl.appendChild(t),t},Ui={rawButton:Cn,localChat:HE,forcedText:qE,vision:VE};var Bi=e=>{E.modal.isDragging=!0;let n=E.modal.modal.getBoundingClientRect();E.modal.offsetX=e.clientX-n.left,E.modal.offsetY=e.clientY-n.top,document.body.style.userSelect="none"},qt=e=>{if(!E.modal.isDragging)return;let t=E.modal.modal,n=e.clientX-E.modal.offsetX,r=e.clientY-E.modal.offsetY;t.style.left=n+"px",t.style.top=r+"px",t.style.transform="none"},Vt=()=>{E.modal.isDragging=!1,document.body.style.userSelect=""};var Up=PE(Fp(),1);var br=Up.default;var Ir={};Bt(Ir,{arrayReplaceAt:()=>Ar,assign:()=>xt,escapeHtml:()=>qe,escapeRE:()=>jh,fromCodePoint:()=>Zt,has:()=>Hh,isMdAsciiPunct:()=>dt,isPunctChar:()=>ut,isSpace:()=>X,isString:()=>zn,isValidEntityCode:()=>Wn,isWhiteSpace:()=>ct,lib:()=>eC,normalizeReference:()=>_t,unescapeAll:()=>He,unescapeMd:()=>$h});var Un={};Bt(Un,{decode:()=>Qt,encode:()=>Pn,format:()=>vt,parse:()=>Xt});var Bp={};function Sh(e){let t=Bp[e];if(t)return t;t=Bp[e]=[];for(let n=0;n<128;n++){let r=String.fromCharCode(n);t.push(r)}for(let n=0;n=55296&&u<=57343?a+="\uFFFD\uFFFD\uFFFD":a+=String.fromCharCode(u),i+=6;continue}}if((s&248)===240&&i+91114111?a+="\uFFFD\uFFFD\uFFFD\uFFFD":(d-=65536,a+=String.fromCharCode(55296+(d>>10),56320+(d&1023))),i+=9;continue}}a+="\uFFFD"}return a})}wn.defaultChars=";/?:@&=+$,#";wn.componentChars="";var Qt=wn;var Gp={};function fh(e){let t=Gp[e];if(t)return t;t=Gp[e]=[];for(let n=0;n<128;n++){let r=String.fromCharCode(n);/^[0-9a-z]$/i.test(r)?t.push(r):t.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2))}for(let n=0;n"u"&&(n=!0);let r=fh(t),a="";for(let i=0,o=e.length;i=55296&&s<=57343){if(s>=55296&&s<=56319&&i+1=56320&&l<=57343){a+=encodeURIComponent(e[i]+e[i+1]),i++;continue}}a+="%EF%BF%BD";continue}a+=encodeURIComponent(e[i])}return a}kn.defaultChars=";/?:@&=+$,-_.!~*'()#";kn.componentChars="-_.!~*'()";var Pn=kn;function vt(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function Fn(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var bh=/^([a-z0-9.+-]+:)/i,Th=/:[0-9]*$/,hh=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Ch=["<",">",'"',"`"," ","\r",` `," "],Rh=["{","}","|","\\","^","`"].concat(Ch),Nh=["'"].concat(Rh),Yp=["%","/","?",";","#"].concat(Nh),Hp=["/","?","#"],yh=255,qp=/^[+a-z0-9A-Z_-]{0,63}$/,Oh=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Vp={javascript:!0,"javascript:":!0},zp={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Ah(e,t){if(e&&e instanceof Fn)return e;let n=new Fn;return n.parse(e,t),n}Fn.prototype.parse=function(e,t){let n,r,a,i=e;if(i=i.trim(),!t&&e.split("#").length===1){let c=hh.exec(i);if(c)return this.pathname=c[1],c[2]&&(this.search=c[2]),this}let o=bh.exec(i);if(o&&(o=o[0],n=o.toLowerCase(),this.protocol=o,i=i.substr(o.length)),(t||o||i.match(/^\/\/[^@\/]+@[^@\/]+/))&&(a=i.substr(0,2)==="//",a&&!(o&&Vp[o])&&(i=i.substr(2),this.slashes=!0)),!Vp[o]&&(a||o&&!zp[o])){let c=-1;for(let g=0;g127?h+="x":h+=A[C];if(!h.match(qp)){let C=g.slice(0,S),y=g.slice(S+1),f=A.match(Oh);f&&(C.push(f[1]),y.unshift(f[2])),y.length&&(i=y.join(".")+i),this.hostname=C.join(".");break}}}}this.hostname.length>yh&&(this.hostname=""),p&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let s=i.indexOf("#");s!==-1&&(this.hash=i.substr(s),i=i.slice(0,s));let l=i.indexOf("?");return l!==-1&&(this.search=i.substr(l),i=i.slice(0,l)),i&&(this.pathname=i),zp[n]&&this.hostname&&!this.pathname&&(this.pathname=""),this};Fn.prototype.parseHost=function(e){let t=Th.exec(e);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var Xt=Ah;var Tr={};Bt(Tr,{Any:()=>Bn,Cc:()=>Gn,Cf:()=>Wp,P:()=>Dt,S:()=>Yn,Z:()=>Hn});var Bn=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;var Gn=/[\0-\x1F\x7F-\x9F]/;var Wp=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;var Dt=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;var Yn=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;var Hn=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;var $p=new Uint16Array('\u1D41<\xD5\u0131\u028A\u049D\u057B\u05D0\u0675\u06DE\u07A2\u07D6\u080F\u0A4A\u0A91\u0DA1\u0E6D\u0F09\u0F26\u10CA\u1228\u12E1\u1415\u149D\u14C3\u14DF\u1525\0\0\0\0\0\0\u156B\u16CD\u198D\u1C12\u1DDD\u1F7E\u2060\u21B0\u228D\u23C0\u23FB\u2442\u2824\u2912\u2D08\u2E48\u2FCE\u3016\u32BA\u3639\u37AC\u38FE\u3A28\u3A71\u3AE0\u3B2E\u0800EMabcfglmnoprstu\\bfms\x7F\x84\x8B\x90\x95\x98\xA6\xB3\xB9\xC8\xCFlig\u803B\xC6\u40C6P\u803B&\u4026cute\u803B\xC1\u40C1reve;\u4102\u0100iyx}rc\u803B\xC2\u40C2;\u4410r;\uC000\u{1D504}rave\u803B\xC0\u40C0pha;\u4391acr;\u4100d;\u6A53\u0100gp\x9D\xA1on;\u4104f;\uC000\u{1D538}plyFunction;\u6061ing\u803B\xC5\u40C5\u0100cs\xBE\xC3r;\uC000\u{1D49C}ign;\u6254ilde\u803B\xC3\u40C3ml\u803B\xC4\u40C4\u0400aceforsu\xE5\xFB\xFE\u0117\u011C\u0122\u0127\u012A\u0100cr\xEA\xF2kslash;\u6216\u0176\xF6\xF8;\u6AE7ed;\u6306y;\u4411\u0180crt\u0105\u010B\u0114ause;\u6235noullis;\u612Ca;\u4392r;\uC000\u{1D505}pf;\uC000\u{1D539}eve;\u42D8c\xF2\u0113mpeq;\u624E\u0700HOacdefhilorsu\u014D\u0151\u0156\u0180\u019E\u01A2\u01B5\u01B7\u01BA\u01DC\u0215\u0273\u0278\u027Ecy;\u4427PY\u803B\xA9\u40A9\u0180cpy\u015D\u0162\u017Aute;\u4106\u0100;i\u0167\u0168\u62D2talDifferentialD;\u6145leys;\u612D\u0200aeio\u0189\u018E\u0194\u0198ron;\u410Cdil\u803B\xC7\u40C7rc;\u4108nint;\u6230ot;\u410A\u0100dn\u01A7\u01ADilla;\u40B8terDot;\u40B7\xF2\u017Fi;\u43A7rcle\u0200DMPT\u01C7\u01CB\u01D1\u01D6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01E2\u01F8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020FoubleQuote;\u601Duote;\u6019\u0200lnpu\u021E\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6A74\u0180git\u022F\u0236\u023Aruent;\u6261nt;\u622FourIntegral;\u622E\u0100fr\u024C\u024E;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6A2Fcr;\uC000\u{1D49E}p\u0100;C\u0284\u0285\u62D3ap;\u624D\u0580DJSZacefios\u02A0\u02AC\u02B0\u02B4\u02B8\u02CB\u02D7\u02E1\u02E6\u0333\u048D\u0100;o\u0179\u02A5trahd;\u6911cy;\u4402cy;\u4405cy;\u440F\u0180grs\u02BF\u02C4\u02C7ger;\u6021r;\u61A1hv;\u6AE4\u0100ay\u02D0\u02D5ron;\u410E;\u4414l\u0100;t\u02DD\u02DE\u6207a;\u4394r;\uC000\u{1D507}\u0100af\u02EB\u0327\u0100cm\u02F0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031Ccute;\u40B4o\u0174\u030B\u030D;\u42D9bleAcute;\u42DDrave;\u4060ilde;\u42DCond;\u62C4ferentialD;\u6146\u0470\u033D\0\0\0\u0342\u0354\0\u0405f;\uC000\u{1D53B}\u0180;DE\u0348\u0349\u034D\u40A8ot;\u60DCqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03CF\u03E2\u03F8ontourIntegra\xEC\u0239o\u0274\u0379\0\0\u037B\xBB\u0349nArrow;\u61D3\u0100eo\u0387\u03A4ft\u0180ART\u0390\u0396\u03A1rrow;\u61D0ightArrow;\u61D4e\xE5\u02CAng\u0100LR\u03AB\u03C4eft\u0100AR\u03B3\u03B9rrow;\u67F8ightArrow;\u67FAightArrow;\u67F9ight\u0100AT\u03D8\u03DErrow;\u61D2ee;\u62A8p\u0241\u03E9\0\0\u03EFrrow;\u61D1ownArrow;\u61D5erticalBar;\u6225n\u0300ABLRTa\u0412\u042A\u0430\u045E\u047F\u037Crrow\u0180;BU\u041D\u041E\u0422\u6193ar;\u6913pArrow;\u61F5reve;\u4311eft\u02D2\u043A\0\u0446\0\u0450ightVector;\u6950eeVector;\u695Eector\u0100;B\u0459\u045A\u61BDar;\u6956ight\u01D4\u0467\0\u0471eeVector;\u695Fector\u0100;B\u047A\u047B\u61C1ar;\u6957ee\u0100;A\u0486\u0487\u62A4rrow;\u61A7\u0100ct\u0492\u0497r;\uC000\u{1D49F}rok;\u4110\u0800NTacdfglmopqstux\u04BD\u04C0\u04C4\u04CB\u04DE\u04E2\u04E7\u04EE\u04F5\u0521\u052F\u0536\u0552\u055D\u0560\u0565G;\u414AH\u803B\xD0\u40D0cute\u803B\xC9\u40C9\u0180aiy\u04D2\u04D7\u04DCron;\u411Arc\u803B\xCA\u40CA;\u442Dot;\u4116r;\uC000\u{1D508}rave\u803B\xC8\u40C8ement;\u6208\u0100ap\u04FA\u04FEcr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65FBerySmallSquare;\u65AB\u0100gp\u0526\u052Aon;\u4118f;\uC000\u{1D53C}silon;\u4395u\u0100ai\u053C\u0549l\u0100;T\u0542\u0543\u6A75ilde;\u6242librium;\u61CC\u0100ci\u0557\u055Ar;\u6130m;\u6A73a;\u4397ml\u803B\xCB\u40CB\u0100ip\u056A\u056Fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058D\u05B2\u05CCy;\u4424r;\uC000\u{1D509}lled\u0253\u0597\0\0\u05A3mallSquare;\u65FCerySmallSquare;\u65AA\u0370\u05BA\0\u05BF\0\0\u05C4f;\uC000\u{1D53D}All;\u6200riertrf;\u6131c\xF2\u05CB\u0600JTabcdfgorst\u05E8\u05EC\u05EF\u05FA\u0600\u0612\u0616\u061B\u061D\u0623\u066C\u0672cy;\u4403\u803B>\u403Emma\u0100;d\u05F7\u05F8\u4393;\u43DCreve;\u411E\u0180eiy\u0607\u060C\u0610dil;\u4122rc;\u411C;\u4413ot;\u4120r;\uC000\u{1D50A};\u62D9pf;\uC000\u{1D53E}eater\u0300EFGLST\u0635\u0644\u064E\u0656\u065B\u0666qual\u0100;L\u063E\u063F\u6265ess;\u62DBullEqual;\u6267reater;\u6AA2ess;\u6277lantEqual;\u6A7Eilde;\u6273cr;\uC000\u{1D4A2};\u626B\u0400Aacfiosu\u0685\u068B\u0696\u069B\u069E\u06AA\u06BE\u06CARDcy;\u442A\u0100ct\u0690\u0694ek;\u42C7;\u405Eirc;\u4124r;\u610ClbertSpace;\u610B\u01F0\u06AF\0\u06B2f;\u610DizontalLine;\u6500\u0100ct\u06C3\u06C5\xF2\u06A9rok;\u4126mp\u0144\u06D0\u06D8ownHum\xF0\u012Fqual;\u624F\u0700EJOacdfgmnostu\u06FA\u06FE\u0703\u0707\u070E\u071A\u071E\u0721\u0728\u0744\u0778\u078B\u078F\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803B\xCD\u40CD\u0100iy\u0713\u0718rc\u803B\xCE\u40CE;\u4418ot;\u4130r;\u6111rave\u803B\xCC\u40CC\u0180;ap\u0720\u072F\u073F\u0100cg\u0734\u0737r;\u412AinaryI;\u6148lie\xF3\u03DD\u01F4\u0749\0\u0762\u0100;e\u074D\u074E\u622C\u0100gr\u0753\u0758ral;\u622Bsection;\u62C2isible\u0100CT\u076C\u0772omma;\u6063imes;\u6062\u0180gpt\u077F\u0783\u0788on;\u412Ef;\uC000\u{1D540}a;\u4399cr;\u6110ilde;\u4128\u01EB\u079A\0\u079Ecy;\u4406l\u803B\xCF\u40CF\u0280cfosu\u07AC\u07B7\u07BC\u07C2\u07D0\u0100iy\u07B1\u07B5rc;\u4134;\u4419r;\uC000\u{1D50D}pf;\uC000\u{1D541}\u01E3\u07C7\0\u07CCr;\uC000\u{1D4A5}rcy;\u4408kcy;\u4404\u0380HJacfos\u07E4\u07E8\u07EC\u07F1\u07FD\u0802\u0808cy;\u4425cy;\u440Cppa;\u439A\u0100ey\u07F6\u07FBdil;\u4136;\u441Ar;\uC000\u{1D50E}pf;\uC000\u{1D542}cr;\uC000\u{1D4A6}\u0580JTaceflmost\u0825\u0829\u082C\u0850\u0863\u09B3\u09B8\u09C7\u09CD\u0A37\u0A47cy;\u4409\u803B<\u403C\u0280cmnpr\u0837\u083C\u0841\u0844\u084Dute;\u4139bda;\u439Bg;\u67EAlacetrf;\u6112r;\u619E\u0180aey\u0857\u085C\u0861ron;\u413Ddil;\u413B;\u441B\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087E\u08A9\u08B1\u08E0\u08E6\u08FC\u092F\u095B\u0390\u096A\u0100nr\u0883\u088FgleBracket;\u67E8row\u0180;BR\u0899\u089A\u089E\u6190ar;\u61E4ightArrow;\u61C6eiling;\u6308o\u01F5\u08B7\0\u08C3bleBracket;\u67E6n\u01D4\u08C8\0\u08D2eeVector;\u6961ector\u0100;B\u08DB\u08DC\u61C3ar;\u6959loor;\u630Aight\u0100AV\u08EF\u08F5rrow;\u6194ector;\u694E\u0100er\u0901\u0917e\u0180;AV\u0909\u090A\u0910\u62A3rrow;\u61A4ector;\u695Aiangle\u0180;BE\u0924\u0925\u0929\u62B2ar;\u69CFqual;\u62B4p\u0180DTV\u0937\u0942\u094CownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61BFar;\u6958ector\u0100;B\u0965\u0966\u61BCar;\u6952ight\xE1\u039Cs\u0300EFGLST\u097E\u098B\u0995\u099D\u09A2\u09ADqualGreater;\u62DAullEqual;\u6266reater;\u6276ess;\u6AA1lantEqual;\u6A7Dilde;\u6272r;\uC000\u{1D50F}\u0100;e\u09BD\u09BE\u62D8ftarrow;\u61DAidot;\u413F\u0180npw\u09D4\u0A16\u0A1Bg\u0200LRlr\u09DE\u09F7\u0A02\u0A10eft\u0100AR\u09E6\u09ECrrow;\u67F5ightArrow;\u67F7ightArrow;\u67F6eft\u0100ar\u03B3\u0A0Aight\xE1\u03BFight\xE1\u03CAf;\uC000\u{1D543}er\u0100LR\u0A22\u0A2CeftArrow;\u6199ightArrow;\u6198\u0180cht\u0A3E\u0A40\u0A42\xF2\u084C;\u61B0rok;\u4141;\u626A\u0400acefiosu\u0A5A\u0A5D\u0A60\u0A77\u0A7C\u0A85\u0A8B\u0A8Ep;\u6905y;\u441C\u0100dl\u0A65\u0A6FiumSpace;\u605Flintrf;\u6133r;\uC000\u{1D510}nusPlus;\u6213pf;\uC000\u{1D544}c\xF2\u0A76;\u439C\u0480Jacefostu\u0AA3\u0AA7\u0AAD\u0AC0\u0B14\u0B19\u0D91\u0D97\u0D9Ecy;\u440Acute;\u4143\u0180aey\u0AB4\u0AB9\u0ABEron;\u4147dil;\u4145;\u441D\u0180gsw\u0AC7\u0AF0\u0B0Eative\u0180MTV\u0AD3\u0ADF\u0AE8ediumSpace;\u600Bhi\u0100cn\u0AE6\u0AD8\xEB\u0AD9eryThi\xEE\u0AD9ted\u0100GL\u0AF8\u0B06reaterGreate\xF2\u0673essLes\xF3\u0A48Line;\u400Ar;\uC000\u{1D511}\u0200Bnpt\u0B22\u0B28\u0B37\u0B3Areak;\u6060BreakingSpace;\u40A0f;\u6115\u0680;CDEGHLNPRSTV\u0B55\u0B56\u0B6A\u0B7C\u0BA1\u0BEB\u0C04\u0C5E\u0C84\u0CA6\u0CD8\u0D61\u0D85\u6AEC\u0100ou\u0B5B\u0B64ngruent;\u6262pCap;\u626DoubleVerticalBar;\u6226\u0180lqx\u0B83\u0B8A\u0B9Bement;\u6209ual\u0100;T\u0B92\u0B93\u6260ilde;\uC000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0BB6\u0BB7\u0BBD\u0BC9\u0BD3\u0BD8\u0BE5\u626Fqual;\u6271ullEqual;\uC000\u2267\u0338reater;\uC000\u226B\u0338ess;\u6279lantEqual;\uC000\u2A7E\u0338ilde;\u6275ump\u0144\u0BF2\u0BFDownHump;\uC000\u224E\u0338qual;\uC000\u224F\u0338e\u0100fs\u0C0A\u0C27tTriangle\u0180;BE\u0C1A\u0C1B\u0C21\u62EAar;\uC000\u29CF\u0338qual;\u62ECs\u0300;EGLST\u0C35\u0C36\u0C3C\u0C44\u0C4B\u0C58\u626Equal;\u6270reater;\u6278ess;\uC000\u226A\u0338lantEqual;\uC000\u2A7D\u0338ilde;\u6274ested\u0100GL\u0C68\u0C79reaterGreater;\uC000\u2AA2\u0338essLess;\uC000\u2AA1\u0338recedes\u0180;ES\u0C92\u0C93\u0C9B\u6280qual;\uC000\u2AAF\u0338lantEqual;\u62E0\u0100ei\u0CAB\u0CB9verseElement;\u620CghtTriangle\u0180;BE\u0CCB\u0CCC\u0CD2\u62EBar;\uC000\u29D0\u0338qual;\u62ED\u0100qu\u0CDD\u0D0CuareSu\u0100bp\u0CE8\u0CF9set\u0100;E\u0CF0\u0CF3\uC000\u228F\u0338qual;\u62E2erset\u0100;E\u0D03\u0D06\uC000\u2290\u0338qual;\u62E3\u0180bcp\u0D13\u0D24\u0D4Eset\u0100;E\u0D1B\u0D1E\uC000\u2282\u20D2qual;\u6288ceeds\u0200;EST\u0D32\u0D33\u0D3B\u0D46\u6281qual;\uC000\u2AB0\u0338lantEqual;\u62E1ilde;\uC000\u227F\u0338erset\u0100;E\u0D58\u0D5B\uC000\u2283\u20D2qual;\u6289ilde\u0200;EFT\u0D6E\u0D6F\u0D75\u0D7F\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uC000\u{1D4A9}ilde\u803B\xD1\u40D1;\u439D\u0700Eacdfgmoprstuv\u0DBD\u0DC2\u0DC9\u0DD5\u0DDB\u0DE0\u0DE7\u0DFC\u0E02\u0E20\u0E22\u0E32\u0E3F\u0E44lig;\u4152cute\u803B\xD3\u40D3\u0100iy\u0DCE\u0DD3rc\u803B\xD4\u40D4;\u441Eblac;\u4150r;\uC000\u{1D512}rave\u803B\xD2\u40D2\u0180aei\u0DEE\u0DF2\u0DF6cr;\u414Cga;\u43A9cron;\u439Fpf;\uC000\u{1D546}enCurly\u0100DQ\u0E0E\u0E1AoubleQuote;\u601Cuote;\u6018;\u6A54\u0100cl\u0E27\u0E2Cr;\uC000\u{1D4AA}ash\u803B\xD8\u40D8i\u016C\u0E37\u0E3Cde\u803B\xD5\u40D5es;\u6A37ml\u803B\xD6\u40D6er\u0100BP\u0E4B\u0E60\u0100ar\u0E50\u0E53r;\u603Eac\u0100ek\u0E5A\u0E5C;\u63DEet;\u63B4arenthesis;\u63DC\u0480acfhilors\u0E7F\u0E87\u0E8A\u0E8F\u0E92\u0E94\u0E9D\u0EB0\u0EFCrtialD;\u6202y;\u441Fr;\uC000\u{1D513}i;\u43A6;\u43A0usMinus;\u40B1\u0100ip\u0EA2\u0EADncareplan\xE5\u069Df;\u6119\u0200;eio\u0EB9\u0EBA\u0EE0\u0EE4\u6ABBcedes\u0200;EST\u0EC8\u0EC9\u0ECF\u0EDA\u627Aqual;\u6AAFlantEqual;\u627Cilde;\u627Eme;\u6033\u0100dp\u0EE9\u0EEEuct;\u620Fortion\u0100;a\u0225\u0EF9l;\u621D\u0100ci\u0F01\u0F06r;\uC000\u{1D4AB};\u43A8\u0200Ufos\u0F11\u0F16\u0F1B\u0F1FOT\u803B"\u4022r;\uC000\u{1D514}pf;\u611Acr;\uC000\u{1D4AC}\u0600BEacefhiorsu\u0F3E\u0F43\u0F47\u0F60\u0F73\u0FA7\u0FAA\u0FAD\u1096\u10A9\u10B4\u10BEarr;\u6910G\u803B\xAE\u40AE\u0180cnr\u0F4E\u0F53\u0F56ute;\u4154g;\u67EBr\u0100;t\u0F5C\u0F5D\u61A0l;\u6916\u0180aey\u0F67\u0F6C\u0F71ron;\u4158dil;\u4156;\u4420\u0100;v\u0F78\u0F79\u611Cerse\u0100EU\u0F82\u0F99\u0100lq\u0F87\u0F8Eement;\u620Builibrium;\u61CBpEquilibrium;\u696Fr\xBB\u0F79o;\u43A1ght\u0400ACDFTUVa\u0FC1\u0FEB\u0FF3\u1022\u1028\u105B\u1087\u03D8\u0100nr\u0FC6\u0FD2gleBracket;\u67E9row\u0180;BL\u0FDC\u0FDD\u0FE1\u6192ar;\u61E5eftArrow;\u61C4eiling;\u6309o\u01F5\u0FF9\0\u1005bleBracket;\u67E7n\u01D4\u100A\0\u1014eeVector;\u695Dector\u0100;B\u101D\u101E\u61C2ar;\u6955loor;\u630B\u0100er\u102D\u1043e\u0180;AV\u1035\u1036\u103C\u62A2rrow;\u61A6ector;\u695Biangle\u0180;BE\u1050\u1051\u1055\u62B3ar;\u69D0qual;\u62B5p\u0180DTV\u1063\u106E\u1078ownVector;\u694FeeVector;\u695Cector\u0100;B\u1082\u1083\u61BEar;\u6954ector\u0100;B\u1091\u1092\u61C0ar;\u6953\u0100pu\u109B\u109Ef;\u611DndImplies;\u6970ightarrow;\u61DB\u0100ch\u10B9\u10BCr;\u611B;\u61B1leDelayed;\u69F4\u0680HOacfhimoqstu\u10E4\u10F1\u10F7\u10FD\u1119\u111E\u1151\u1156\u1161\u1167\u11B5\u11BB\u11BF\u0100Cc\u10E9\u10EEHcy;\u4429y;\u4428FTcy;\u442Ccute;\u415A\u0280;aeiy\u1108\u1109\u110E\u1113\u1117\u6ABCron;\u4160dil;\u415Erc;\u415C;\u4421r;\uC000\u{1D516}ort\u0200DLRU\u112A\u1134\u113E\u1149ownArrow\xBB\u041EeftArrow\xBB\u089AightArrow\xBB\u0FDDpArrow;\u6191gma;\u43A3allCircle;\u6218pf;\uC000\u{1D54A}\u0272\u116D\0\0\u1170t;\u621Aare\u0200;ISU\u117B\u117C\u1189\u11AF\u65A1ntersection;\u6293u\u0100bp\u118F\u119Eset\u0100;E\u1197\u1198\u628Fqual;\u6291erset\u0100;E\u11A8\u11A9\u6290qual;\u6292nion;\u6294cr;\uC000\u{1D4AE}ar;\u62C6\u0200bcmp\u11C8\u11DB\u1209\u120B\u0100;s\u11CD\u11CE\u62D0et\u0100;E\u11CD\u11D5qual;\u6286\u0100ch\u11E0\u1205eeds\u0200;EST\u11ED\u11EE\u11F4\u11FF\u627Bqual;\u6AB0lantEqual;\u627Dilde;\u627FTh\xE1\u0F8C;\u6211\u0180;es\u1212\u1213\u1223\u62D1rset\u0100;E\u121C\u121D\u6283qual;\u6287et\xBB\u1213\u0580HRSacfhiors\u123E\u1244\u1249\u1255\u125E\u1271\u1276\u129F\u12C2\u12C8\u12D1ORN\u803B\xDE\u40DEADE;\u6122\u0100Hc\u124E\u1252cy;\u440By;\u4426\u0100bu\u125A\u125C;\u4009;\u43A4\u0180aey\u1265\u126A\u126Fron;\u4164dil;\u4162;\u4422r;\uC000\u{1D517}\u0100ei\u127B\u1289\u01F2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128E\u1298kSpace;\uC000\u205F\u200ASpace;\u6009lde\u0200;EFT\u12AB\u12AC\u12B2\u12BC\u623Cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uC000\u{1D54B}ipleDot;\u60DB\u0100ct\u12D6\u12DBr;\uC000\u{1D4AF}rok;\u4166\u0AE1\u12F7\u130E\u131A\u1326\0\u132C\u1331\0\0\0\0\0\u1338\u133D\u1377\u1385\0\u13FF\u1404\u140A\u1410\u0100cr\u12FB\u1301ute\u803B\xDA\u40DAr\u0100;o\u1307\u1308\u619Fcir;\u6949r\u01E3\u1313\0\u1316y;\u440Eve;\u416C\u0100iy\u131E\u1323rc\u803B\xDB\u40DB;\u4423blac;\u4170r;\uC000\u{1D518}rave\u803B\xD9\u40D9acr;\u416A\u0100di\u1341\u1369er\u0100BP\u1348\u135D\u0100ar\u134D\u1350r;\u405Fac\u0100ek\u1357\u1359;\u63DFet;\u63B5arenthesis;\u63DDon\u0100;P\u1370\u1371\u62C3lus;\u628E\u0100gp\u137B\u137Fon;\u4172f;\uC000\u{1D54C}\u0400ADETadps\u1395\u13AE\u13B8\u13C4\u03E8\u13D2\u13D7\u13F3rrow\u0180;BD\u1150\u13A0\u13A4ar;\u6912ownArrow;\u61C5ownArrow;\u6195quilibrium;\u696Eee\u0100;A\u13CB\u13CC\u62A5rrow;\u61A5own\xE1\u03F3er\u0100LR\u13DE\u13E8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13F9\u13FA\u43D2on;\u43A5ing;\u416Ecr;\uC000\u{1D4B0}ilde;\u4168ml\u803B\xDC\u40DC\u0480Dbcdefosv\u1427\u142C\u1430\u1433\u143E\u1485\u148A\u1490\u1496ash;\u62ABar;\u6AEBy;\u4412ash\u0100;l\u143B\u143C\u62A9;\u6AE6\u0100er\u1443\u1445;\u62C1\u0180bty\u144C\u1450\u147Aar;\u6016\u0100;i\u144F\u1455cal\u0200BLST\u1461\u1465\u146A\u1474ar;\u6223ine;\u407Ceparator;\u6758ilde;\u6240ThinSpace;\u600Ar;\uC000\u{1D519}pf;\uC000\u{1D54D}cr;\uC000\u{1D4B1}dash;\u62AA\u0280cefos\u14A7\u14AC\u14B1\u14B6\u14BCirc;\u4174dge;\u62C0r;\uC000\u{1D51A}pf;\uC000\u{1D54E}cr;\uC000\u{1D4B2}\u0200fios\u14CB\u14D0\u14D2\u14D8r;\uC000\u{1D51B};\u439Epf;\uC000\u{1D54F}cr;\uC000\u{1D4B3}\u0480AIUacfosu\u14F1\u14F5\u14F9\u14FD\u1504\u150F\u1514\u151A\u1520cy;\u442Fcy;\u4407cy;\u442Ecute\u803B\xDD\u40DD\u0100iy\u1509\u150Drc;\u4176;\u442Br;\uC000\u{1D51C}pf;\uC000\u{1D550}cr;\uC000\u{1D4B4}ml;\u4178\u0400Hacdefos\u1535\u1539\u153F\u154B\u154F\u155D\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417D;\u4417ot;\u417B\u01F2\u1554\0\u155BoWidt\xE8\u0AD9a;\u4396r;\u6128pf;\u6124cr;\uC000\u{1D4B5}\u0BE1\u1583\u158A\u1590\0\u15B0\u15B6\u15BF\0\0\0\0\u15C6\u15DB\u15EB\u165F\u166D\0\u1695\u169B\u16B2\u16B9\0\u16BEcute\u803B\xE1\u40E1reve;\u4103\u0300;Ediuy\u159C\u159D\u15A1\u15A3\u15A8\u15AD\u623E;\uC000\u223E\u0333;\u623Frc\u803B\xE2\u40E2te\u80BB\xB4\u0306;\u4430lig\u803B\xE6\u40E6\u0100;r\xB2\u15BA;\uC000\u{1D51E}rave\u803B\xE0\u40E0\u0100ep\u15CA\u15D6\u0100fp\u15CF\u15D4sym;\u6135\xE8\u15D3ha;\u43B1\u0100ap\u15DFc\u0100cl\u15E4\u15E7r;\u4101g;\u6A3F\u0264\u15F0\0\0\u160A\u0280;adsv\u15FA\u15FB\u15FF\u1601\u1607\u6227nd;\u6A55;\u6A5Clope;\u6A58;\u6A5A\u0380;elmrsz\u1618\u1619\u161B\u161E\u163F\u164F\u1659\u6220;\u69A4e\xBB\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163A\u163C\u163E;\u69A8;\u69A9;\u69AA;\u69AB;\u69AC;\u69AD;\u69AE;\u69AFt\u0100;v\u1645\u1646\u621Fb\u0100;d\u164C\u164D\u62BE;\u699D\u0100pt\u1654\u1657h;\u6222\xBB\xB9arr;\u637C\u0100gp\u1663\u1667on;\u4105f;\uC000\u{1D552}\u0380;Eaeiop\u12C1\u167B\u167D\u1682\u1684\u1687\u168A;\u6A70cir;\u6A6F;\u624Ad;\u624Bs;\u4027rox\u0100;e\u12C1\u1692\xF1\u1683ing\u803B\xE5\u40E5\u0180cty\u16A1\u16A6\u16A8r;\uC000\u{1D4B6};\u402Amp\u0100;e\u12C1\u16AF\xF1\u0288ilde\u803B\xE3\u40E3ml\u803B\xE4\u40E4\u0100ci\u16C2\u16C8onin\xF4\u0272nt;\u6A11\u0800Nabcdefiklnoprsu\u16ED\u16F1\u1730\u173C\u1743\u1748\u1778\u177D\u17E0\u17E6\u1839\u1850\u170D\u193D\u1948\u1970ot;\u6AED\u0100cr\u16F6\u171Ek\u0200ceps\u1700\u1705\u170D\u1713ong;\u624Cpsilon;\u43F6rime;\u6035im\u0100;e\u171A\u171B\u623Dq;\u62CD\u0176\u1722\u1726ee;\u62BDed\u0100;g\u172C\u172D\u6305e\xBB\u172Drk\u0100;t\u135C\u1737brk;\u63B6\u0100oy\u1701\u1741;\u4431quo;\u601E\u0280cmprt\u1753\u175B\u1761\u1764\u1768aus\u0100;e\u010A\u0109ptyv;\u69B0s\xE9\u170Cno\xF5\u0113\u0180ahw\u176F\u1771\u1773;\u43B2;\u6136een;\u626Cr;\uC000\u{1D51F}g\u0380costuvw\u178D\u179D\u17B3\u17C1\u17D5\u17DB\u17DE\u0180aiu\u1794\u1796\u179A\xF0\u0760rc;\u65EFp\xBB\u1371\u0180dpt\u17A4\u17A8\u17ADot;\u6A00lus;\u6A01imes;\u6A02\u0271\u17B9\0\0\u17BEcup;\u6A06ar;\u6605riangle\u0100du\u17CD\u17D2own;\u65BDp;\u65B3plus;\u6A04e\xE5\u1444\xE5\u14ADarow;\u690D\u0180ako\u17ED\u1826\u1835\u0100cn\u17F2\u1823k\u0180lst\u17FA\u05AB\u1802ozenge;\u69EBriangle\u0200;dlr\u1812\u1813\u1818\u181D\u65B4own;\u65BEeft;\u65C2ight;\u65B8k;\u6423\u01B1\u182B\0\u1833\u01B2\u182F\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183E\u184D\u0100;q\u1843\u1846\uC000=\u20E5uiv;\uC000\u2261\u20E5t;\u6310\u0200ptwx\u1859\u185E\u1867\u186Cf;\uC000\u{1D553}\u0100;t\u13CB\u1863om\xBB\u13CCtie;\u62C8\u0600DHUVbdhmptuv\u1885\u1896\u18AA\u18BB\u18D7\u18DB\u18EC\u18FF\u1905\u190A\u1910\u1921\u0200LRlr\u188E\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18A1\u18A2\u18A4\u18A6\u18A8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18B3\u18B5\u18B7\u18B9;\u655D;\u655A;\u655C;\u6559\u0380;HLRhlr\u18CA\u18CB\u18CD\u18CF\u18D1\u18D3\u18D5\u6551;\u656C;\u6563;\u6560;\u656B;\u6562;\u655Fox;\u69C9\u0200LRlr\u18E4\u18E6\u18E8\u18EA;\u6555;\u6552;\u6510;\u650C\u0280;DUdu\u06BD\u18F7\u18F9\u18FB\u18FD;\u6565;\u6568;\u652C;\u6534inus;\u629Flus;\u629Eimes;\u62A0\u0200LRlr\u1919\u191B\u191D\u191F;\u655B;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193B\u6502;\u656A;\u6561;\u655E;\u653C;\u6524;\u651C\u0100ev\u0123\u1942bar\u803B\xA6\u40A6\u0200ceio\u1951\u1956\u195A\u1960r;\uC000\u{1D4B7}mi;\u604Fm\u0100;e\u171A\u171Cl\u0180;bh\u1968\u1969\u196B\u405C;\u69C5sub;\u67C8\u016C\u1974\u197El\u0100;e\u1979\u197A\u6022t\xBB\u197Ap\u0180;Ee\u012F\u1985\u1987;\u6AAE\u0100;q\u06DC\u06DB\u0CE1\u19A7\0\u19E8\u1A11\u1A15\u1A32\0\u1A37\u1A50\0\0\u1AB4\0\0\u1AC1\0\0\u1B21\u1B2E\u1B4D\u1B52\0\u1BFD\0\u1C0C\u0180cpr\u19AD\u19B2\u19DDute;\u4107\u0300;abcds\u19BF\u19C0\u19C4\u19CA\u19D5\u19D9\u6229nd;\u6A44rcup;\u6A49\u0100au\u19CF\u19D2p;\u6A4Bp;\u6A47ot;\u6A40;\uC000\u2229\uFE00\u0100eo\u19E2\u19E5t;\u6041\xEE\u0693\u0200aeiu\u19F0\u19FB\u1A01\u1A05\u01F0\u19F5\0\u19F8s;\u6A4Don;\u410Ddil\u803B\xE7\u40E7rc;\u4109ps\u0100;s\u1A0C\u1A0D\u6A4Cm;\u6A50ot;\u410B\u0180dmn\u1A1B\u1A20\u1A26il\u80BB\xB8\u01ADptyv;\u69B2t\u8100\xA2;e\u1A2D\u1A2E\u40A2r\xE4\u01B2r;\uC000\u{1D520}\u0180cei\u1A3D\u1A40\u1A4Dy;\u4447ck\u0100;m\u1A47\u1A48\u6713ark\xBB\u1A48;\u43C7r\u0380;Ecefms\u1A5F\u1A60\u1A62\u1A6B\u1AA4\u1AAA\u1AAE\u65CB;\u69C3\u0180;el\u1A69\u1A6A\u1A6D\u42C6q;\u6257e\u0261\u1A74\0\0\u1A88rrow\u0100lr\u1A7C\u1A81eft;\u61BAight;\u61BB\u0280RSacd\u1A92\u1A94\u1A96\u1A9A\u1A9F\xBB\u0F47;\u64C8st;\u629Birc;\u629Aash;\u629Dnint;\u6A10id;\u6AEFcir;\u69C2ubs\u0100;u\u1ABB\u1ABC\u6663it\xBB\u1ABC\u02EC\u1AC7\u1AD4\u1AFA\0\u1B0Aon\u0100;e\u1ACD\u1ACE\u403A\u0100;q\xC7\xC6\u026D\u1AD9\0\0\u1AE2a\u0100;t\u1ADE\u1ADF\u402C;\u4040\u0180;fl\u1AE8\u1AE9\u1AEB\u6201\xEE\u1160e\u0100mx\u1AF1\u1AF6ent\xBB\u1AE9e\xF3\u024D\u01E7\u1AFE\0\u1B07\u0100;d\u12BB\u1B02ot;\u6A6Dn\xF4\u0246\u0180fry\u1B10\u1B14\u1B17;\uC000\u{1D554}o\xE4\u0254\u8100\xA9;s\u0155\u1B1Dr;\u6117\u0100ao\u1B25\u1B29rr;\u61B5ss;\u6717\u0100cu\u1B32\u1B37r;\uC000\u{1D4B8}\u0100bp\u1B3C\u1B44\u0100;e\u1B41\u1B42\u6ACF;\u6AD1\u0100;e\u1B49\u1B4A\u6AD0;\u6AD2dot;\u62EF\u0380delprvw\u1B60\u1B6C\u1B77\u1B82\u1BAC\u1BD4\u1BF9arr\u0100lr\u1B68\u1B6A;\u6938;\u6935\u0270\u1B72\0\0\u1B75r;\u62DEc;\u62DFarr\u0100;p\u1B7F\u1B80\u61B6;\u693D\u0300;bcdos\u1B8F\u1B90\u1B96\u1BA1\u1BA5\u1BA8\u622Arcap;\u6A48\u0100au\u1B9B\u1B9Ep;\u6A46p;\u6A4Aot;\u628Dr;\u6A45;\uC000\u222A\uFE00\u0200alrv\u1BB5\u1BBF\u1BDE\u1BE3rr\u0100;m\u1BBC\u1BBD\u61B7;\u693Cy\u0180evw\u1BC7\u1BD4\u1BD8q\u0270\u1BCE\0\0\u1BD2re\xE3\u1B73u\xE3\u1B75ee;\u62CEedge;\u62CFen\u803B\xA4\u40A4earrow\u0100lr\u1BEE\u1BF3eft\xBB\u1B80ight\xBB\u1BBDe\xE4\u1BDD\u0100ci\u1C01\u1C07onin\xF4\u01F7nt;\u6231lcty;\u632D\u0980AHabcdefhijlorstuwz\u1C38\u1C3B\u1C3F\u1C5D\u1C69\u1C75\u1C8A\u1C9E\u1CAC\u1CB7\u1CFB\u1CFF\u1D0D\u1D7B\u1D91\u1DAB\u1DBB\u1DC6\u1DCDr\xF2\u0381ar;\u6965\u0200glrs\u1C48\u1C4D\u1C52\u1C54ger;\u6020eth;\u6138\xF2\u1133h\u0100;v\u1C5A\u1C5B\u6010\xBB\u090A\u016B\u1C61\u1C67arow;\u690Fa\xE3\u0315\u0100ay\u1C6E\u1C73ron;\u410F;\u4434\u0180;ao\u0332\u1C7C\u1C84\u0100gr\u02BF\u1C81r;\u61CAtseq;\u6A77\u0180glm\u1C91\u1C94\u1C98\u803B\xB0\u40B0ta;\u43B4ptyv;\u69B1\u0100ir\u1CA3\u1CA8sht;\u697F;\uC000\u{1D521}ar\u0100lr\u1CB3\u1CB5\xBB\u08DC\xBB\u101E\u0280aegsv\u1CC2\u0378\u1CD6\u1CDC\u1CE0m\u0180;os\u0326\u1CCA\u1CD4nd\u0100;s\u0326\u1CD1uit;\u6666amma;\u43DDin;\u62F2\u0180;io\u1CE7\u1CE8\u1CF8\u40F7de\u8100\xF7;o\u1CE7\u1CF0ntimes;\u62C7n\xF8\u1CF7cy;\u4452c\u026F\u1D06\0\0\u1D0Arn;\u631Eop;\u630D\u0280lptuw\u1D18\u1D1D\u1D22\u1D49\u1D55lar;\u4024f;\uC000\u{1D555}\u0280;emps\u030B\u1D2D\u1D37\u1D3D\u1D42q\u0100;d\u0352\u1D33ot;\u6251inus;\u6238lus;\u6214quare;\u62A1blebarwedg\xE5\xFAn\u0180adh\u112E\u1D5D\u1D67ownarrow\xF3\u1C83arpoon\u0100lr\u1D72\u1D76ef\xF4\u1CB4igh\xF4\u1CB6\u0162\u1D7F\u1D85karo\xF7\u0F42\u026F\u1D8A\0\0\u1D8Ern;\u631Fop;\u630C\u0180cot\u1D98\u1DA3\u1DA6\u0100ry\u1D9D\u1DA1;\uC000\u{1D4B9};\u4455l;\u69F6rok;\u4111\u0100dr\u1DB0\u1DB4ot;\u62F1i\u0100;f\u1DBA\u1816\u65BF\u0100ah\u1DC0\u1DC3r\xF2\u0429a\xF2\u0FA6angle;\u69A6\u0100ci\u1DD2\u1DD5y;\u445Fgrarr;\u67FF\u0900Dacdefglmnopqrstux\u1E01\u1E09\u1E19\u1E38\u0578\u1E3C\u1E49\u1E61\u1E7E\u1EA5\u1EAF\u1EBD\u1EE1\u1F2A\u1F37\u1F44\u1F4E\u1F5A\u0100Do\u1E06\u1D34o\xF4\u1C89\u0100cs\u1E0E\u1E14ute\u803B\xE9\u40E9ter;\u6A6E\u0200aioy\u1E22\u1E27\u1E31\u1E36ron;\u411Br\u0100;c\u1E2D\u1E2E\u6256\u803B\xEA\u40EAlon;\u6255;\u444Dot;\u4117\u0100Dr\u1E41\u1E45ot;\u6252;\uC000\u{1D522}\u0180;rs\u1E50\u1E51\u1E57\u6A9Aave\u803B\xE8\u40E8\u0100;d\u1E5C\u1E5D\u6A96ot;\u6A98\u0200;ils\u1E6A\u1E6B\u1E72\u1E74\u6A99nters;\u63E7;\u6113\u0100;d\u1E79\u1E7A\u6A95ot;\u6A97\u0180aps\u1E85\u1E89\u1E97cr;\u4113ty\u0180;sv\u1E92\u1E93\u1E95\u6205et\xBB\u1E93p\u01001;\u1E9D\u1EA4\u0133\u1EA1\u1EA3;\u6004;\u6005\u6003\u0100gs\u1EAA\u1EAC;\u414Bp;\u6002\u0100gp\u1EB4\u1EB8on;\u4119f;\uC000\u{1D556}\u0180als\u1EC4\u1ECE\u1ED2r\u0100;s\u1ECA\u1ECB\u62D5l;\u69E3us;\u6A71i\u0180;lv\u1EDA\u1EDB\u1EDF\u43B5on\xBB\u1EDB;\u43F5\u0200csuv\u1EEA\u1EF3\u1F0B\u1F23\u0100io\u1EEF\u1E31rc\xBB\u1E2E\u0269\u1EF9\0\0\u1EFB\xED\u0548ant\u0100gl\u1F02\u1F06tr\xBB\u1E5Dess\xBB\u1E7A\u0180aei\u1F12\u1F16\u1F1Als;\u403Dst;\u625Fv\u0100;D\u0235\u1F20D;\u6A78parsl;\u69E5\u0100Da\u1F2F\u1F33ot;\u6253rr;\u6971\u0180cdi\u1F3E\u1F41\u1EF8r;\u612Fo\xF4\u0352\u0100ah\u1F49\u1F4B;\u43B7\u803B\xF0\u40F0\u0100mr\u1F53\u1F57l\u803B\xEB\u40EBo;\u60AC\u0180cip\u1F61\u1F64\u1F67l;\u4021s\xF4\u056E\u0100eo\u1F6C\u1F74ctatio\xEE\u0559nential\xE5\u0579\u09E1\u1F92\0\u1F9E\0\u1FA1\u1FA7\0\0\u1FC6\u1FCC\0\u1FD3\0\u1FE6\u1FEA\u2000\0\u2008\u205Allingdotse\xF1\u1E44y;\u4444male;\u6640\u0180ilr\u1FAD\u1FB3\u1FC1lig;\u8000\uFB03\u0269\u1FB9\0\0\u1FBDg;\u8000\uFB00ig;\u8000\uFB04;\uC000\u{1D523}lig;\u8000\uFB01lig;\uC000fj\u0180alt\u1FD9\u1FDC\u1FE1t;\u666Dig;\u8000\uFB02ns;\u65B1of;\u4192\u01F0\u1FEE\0\u1FF3f;\uC000\u{1D557}\u0100ak\u05BF\u1FF7\u0100;v\u1FFC\u1FFD\u62D4;\u6AD9artint;\u6A0D\u0100ao\u200C\u2055\u0100cs\u2011\u2052\u03B1\u201A\u2030\u2038\u2045\u2048\0\u2050\u03B2\u2022\u2025\u2027\u202A\u202C\0\u202E\u803B\xBD\u40BD;\u6153\u803B\xBC\u40BC;\u6155;\u6159;\u615B\u01B3\u2034\0\u2036;\u6154;\u6156\u02B4\u203E\u2041\0\0\u2043\u803B\xBE\u40BE;\u6157;\u615C5;\u6158\u01B6\u204C\0\u204E;\u615A;\u615D8;\u615El;\u6044wn;\u6322cr;\uC000\u{1D4BB}\u0880Eabcdefgijlnorstv\u2082\u2089\u209F\u20A5\u20B0\u20B4\u20F0\u20F5\u20FA\u20FF\u2103\u2112\u2138\u0317\u213E\u2152\u219E\u0100;l\u064D\u2087;\u6A8C\u0180cmp\u2090\u2095\u209Dute;\u41F5ma\u0100;d\u209C\u1CDA\u43B3;\u6A86reve;\u411F\u0100iy\u20AA\u20AErc;\u411D;\u4433ot;\u4121\u0200;lqs\u063E\u0642\u20BD\u20C9\u0180;qs\u063E\u064C\u20C4lan\xF4\u0665\u0200;cdl\u0665\u20D2\u20D5\u20E5c;\u6AA9ot\u0100;o\u20DC\u20DD\u6A80\u0100;l\u20E2\u20E3\u6A82;\u6A84\u0100;e\u20EA\u20ED\uC000\u22DB\uFE00s;\u6A94r;\uC000\u{1D524}\u0100;g\u0673\u061Bmel;\u6137cy;\u4453\u0200;Eaj\u065A\u210C\u210E\u2110;\u6A92;\u6AA5;\u6AA4\u0200Eaes\u211B\u211D\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6A8Arox\xBB\u2124\u0100;q\u212E\u212F\u6A88\u0100;q\u212E\u211Bim;\u62E7pf;\uC000\u{1D558}\u0100ci\u2143\u2146r;\u610Am\u0180;el\u066B\u214E\u2150;\u6A8E;\u6A90\u8300>;cdlqr\u05EE\u2160\u216A\u216E\u2173\u2179\u0100ci\u2165\u2167;\u6AA7r;\u6A7Aot;\u62D7Par;\u6995uest;\u6A7C\u0280adels\u2184\u216A\u2190\u0656\u219B\u01F0\u2189\0\u218Epro\xF8\u209Er;\u6978q\u0100lq\u063F\u2196les\xF3\u2088i\xED\u066B\u0100en\u21A3\u21ADrtneqq;\uC000\u2269\uFE00\xC5\u21AA\u0500Aabcefkosy\u21C4\u21C7\u21F1\u21F5\u21FA\u2218\u221D\u222F\u2268\u227Dr\xF2\u03A0\u0200ilmr\u21D0\u21D4\u21D7\u21DBrs\xF0\u1484f\xBB\u2024il\xF4\u06A9\u0100dr\u21E0\u21E4cy;\u444A\u0180;cw\u08F4\u21EB\u21EFir;\u6948;\u61ADar;\u610Firc;\u4125\u0180alr\u2201\u220E\u2213rts\u0100;u\u2209\u220A\u6665it\xBB\u220Alip;\u6026con;\u62B9r;\uC000\u{1D525}s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223A\u223E\u2243\u225E\u2263rr;\u61FFtht;\u623Bk\u0100lr\u2249\u2253eftarrow;\u61A9ightarrow;\u61AAf;\uC000\u{1D559}bar;\u6015\u0180clt\u226F\u2274\u2278r;\uC000\u{1D4BD}as\xE8\u21F4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xBB\u1C5B\u0AE1\u22A3\0\u22AA\0\u22B8\u22C5\u22CE\0\u22D5\u22F3\0\0\u22F8\u2322\u2367\u2362\u237F\0\u2386\u23AA\u23B4cute\u803B\xED\u40ED\u0180;iy\u0771\u22B0\u22B5rc\u803B\xEE\u40EE;\u4438\u0100cx\u22BC\u22BFy;\u4435cl\u803B\xA1\u40A1\u0100fr\u039F\u22C9;\uC000\u{1D526}rave\u803B\xEC\u40EC\u0200;ino\u073E\u22DD\u22E9\u22EE\u0100in\u22E2\u22E6nt;\u6A0Ct;\u622Dfin;\u69DCta;\u6129lig;\u4133\u0180aop\u22FE\u231A\u231D\u0180cgt\u2305\u2308\u2317r;\u412B\u0180elp\u071F\u230F\u2313in\xE5\u078Ear\xF4\u0720h;\u4131f;\u62B7ed;\u41B5\u0280;cfot\u04F4\u232C\u2331\u233D\u2341are;\u6105in\u0100;t\u2338\u2339\u621Eie;\u69DDdo\xF4\u2319\u0280;celp\u0757\u234C\u2350\u235B\u2361al;\u62BA\u0100gr\u2355\u2359er\xF3\u1563\xE3\u234Darhk;\u6A17rod;\u6A3C\u0200cgpt\u236F\u2372\u2376\u237By;\u4451on;\u412Ff;\uC000\u{1D55A}a;\u43B9uest\u803B\xBF\u40BF\u0100ci\u238A\u238Fr;\uC000\u{1D4BE}n\u0280;Edsv\u04F4\u239B\u239D\u23A1\u04F3;\u62F9ot;\u62F5\u0100;v\u23A6\u23A7\u62F4;\u62F3\u0100;i\u0777\u23AElde;\u4129\u01EB\u23B8\0\u23BCcy;\u4456l\u803B\xEF\u40EF\u0300cfmosu\u23CC\u23D7\u23DC\u23E1\u23E7\u23F5\u0100iy\u23D1\u23D5rc;\u4135;\u4439r;\uC000\u{1D527}ath;\u4237pf;\uC000\u{1D55B}\u01E3\u23EC\0\u23F1r;\uC000\u{1D4BF}rcy;\u4458kcy;\u4454\u0400acfghjos\u240B\u2416\u2422\u2427\u242D\u2431\u2435\u243Bppa\u0100;v\u2413\u2414\u43BA;\u43F0\u0100ey\u241B\u2420dil;\u4137;\u443Ar;\uC000\u{1D528}reen;\u4138cy;\u4445cy;\u445Cpf;\uC000\u{1D55C}cr;\uC000\u{1D4C0}\u0B80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248D\u2491\u250E\u253D\u255A\u2580\u264E\u265E\u2665\u2679\u267D\u269A\u26B2\u26D8\u275D\u2768\u278B\u27C0\u2801\u2812\u0180art\u2477\u247A\u247Cr\xF2\u09C6\xF2\u0395ail;\u691Barr;\u690E\u0100;g\u0994\u248B;\u6A8Bar;\u6962\u0963\u24A5\0\u24AA\0\u24B1\0\0\0\0\0\u24B5\u24BA\0\u24C6\u24C8\u24CD\0\u24F9ute;\u413Amptyv;\u69B4ra\xEE\u084Cbda;\u43BBg\u0180;dl\u088E\u24C1\u24C3;\u6991\xE5\u088E;\u6A85uo\u803B\xAB\u40ABr\u0400;bfhlpst\u0899\u24DE\u24E6\u24E9\u24EB\u24EE\u24F1\u24F5\u0100;f\u089D\u24E3s;\u691Fs;\u691D\xEB\u2252p;\u61ABl;\u6939im;\u6973l;\u61A2\u0180;ae\u24FF\u2500\u2504\u6AABil;\u6919\u0100;s\u2509\u250A\u6AAD;\uC000\u2AAD\uFE00\u0180abr\u2515\u2519\u251Drr;\u690Crk;\u6772\u0100ak\u2522\u252Cc\u0100ek\u2528\u252A;\u407B;\u405B\u0100es\u2531\u2533;\u698Bl\u0100du\u2539\u253B;\u698F;\u698D\u0200aeuy\u2546\u254B\u2556\u2558ron;\u413E\u0100di\u2550\u2554il;\u413C\xEC\u08B0\xE2\u2529;\u443B\u0200cqrs\u2563\u2566\u256D\u257Da;\u6936uo\u0100;r\u0E19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694Bh;\u61B2\u0280;fgqs\u258B\u258C\u0989\u25F3\u25FF\u6264t\u0280ahlrt\u2598\u25A4\u25B7\u25C2\u25E8rrow\u0100;t\u0899\u25A1a\xE9\u24F6arpoon\u0100du\u25AF\u25B4own\xBB\u045Ap\xBB\u0966eftarrows;\u61C7ight\u0180ahs\u25CD\u25D6\u25DErrow\u0100;s\u08F4\u08A7arpoon\xF3\u0F98quigarro\xF7\u21F0hreetimes;\u62CB\u0180;qs\u258B\u0993\u25FAlan\xF4\u09AC\u0280;cdgs\u09AC\u260A\u260D\u261D\u2628c;\u6AA8ot\u0100;o\u2614\u2615\u6A7F\u0100;r\u261A\u261B\u6A81;\u6A83\u0100;e\u2622\u2625\uC000\u22DA\uFE00s;\u6A93\u0280adegs\u2633\u2639\u263D\u2649\u264Bppro\xF8\u24C6ot;\u62D6q\u0100gq\u2643\u2645\xF4\u0989gt\xF2\u248C\xF4\u099Bi\xED\u09B2\u0180ilr\u2655\u08E1\u265Asht;\u697C;\uC000\u{1D529}\u0100;E\u099C\u2663;\u6A91\u0161\u2669\u2676r\u0100du\u25B2\u266E\u0100;l\u0965\u2673;\u696Alk;\u6584cy;\u4459\u0280;acht\u0A48\u2688\u268B\u2691\u2696r\xF2\u25C1orne\xF2\u1D08ard;\u696Bri;\u65FA\u0100io\u269F\u26A4dot;\u4140ust\u0100;a\u26AC\u26AD\u63B0che\xBB\u26AD\u0200Eaes\u26BB\u26BD\u26C9\u26D4;\u6268p\u0100;p\u26C3\u26C4\u6A89rox\xBB\u26C4\u0100;q\u26CE\u26CF\u6A87\u0100;q\u26CE\u26BBim;\u62E6\u0400abnoptwz\u26E9\u26F4\u26F7\u271A\u272F\u2741\u2747\u2750\u0100nr\u26EE\u26F1g;\u67ECr;\u61FDr\xEB\u08C1g\u0180lmr\u26FF\u270D\u2714eft\u0100ar\u09E6\u2707ight\xE1\u09F2apsto;\u67FCight\xE1\u09FDparrow\u0100lr\u2725\u2729ef\xF4\u24EDight;\u61AC\u0180afl\u2736\u2739\u273Dr;\u6985;\uC000\u{1D55D}us;\u6A2Dimes;\u6A34\u0161\u274B\u274Fst;\u6217\xE1\u134E\u0180;ef\u2757\u2758\u1800\u65CAnge\xBB\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277C\u2785\u2787r\xF2\u08A8orne\xF2\u1D8Car\u0100;d\u0F98\u2783;\u696D;\u600Eri;\u62BF\u0300achiqt\u2798\u279D\u0A40\u27A2\u27AE\u27BBquo;\u6039r;\uC000\u{1D4C1}m\u0180;eg\u09B2\u27AA\u27AC;\u6A8D;\u6A8F\u0100bu\u252A\u27B3o\u0100;r\u0E1F\u27B9;\u601Arok;\u4142\u8400<;cdhilqr\u082B\u27D2\u2639\u27DC\u27E0\u27E5\u27EA\u27F0\u0100ci\u27D7\u27D9;\u6AA6r;\u6A79re\xE5\u25F2mes;\u62C9arr;\u6976uest;\u6A7B\u0100Pi\u27F5\u27F9ar;\u6996\u0180;ef\u2800\u092D\u181B\u65C3r\u0100du\u2807\u280Dshar;\u694Ahar;\u6966\u0100en\u2817\u2821rtneqq;\uC000\u2268\uFE00\xC5\u281E\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288E\u2893\u28A0\u28A5\u28A8\u28DA\u28E2\u28E4\u0A83\u28F3\u2902Dot;\u623A\u0200clpr\u284E\u2852\u2863\u287Dr\u803B\xAF\u40AF\u0100et\u2857\u2859;\u6642\u0100;e\u285E\u285F\u6720se\xBB\u285F\u0100;s\u103B\u2868to\u0200;dlu\u103B\u2873\u2877\u287Bow\xEE\u048Cef\xF4\u090F\xF0\u13D1ker;\u65AE\u0100oy\u2887\u288Cmma;\u6A29;\u443Cash;\u6014asuredangle\xBB\u1626r;\uC000\u{1D52A}o;\u6127\u0180cdn\u28AF\u28B4\u28C9ro\u803B\xB5\u40B5\u0200;acd\u1464\u28BD\u28C0\u28C4s\xF4\u16A7ir;\u6AF0ot\u80BB\xB7\u01B5us\u0180;bd\u28D2\u1903\u28D3\u6212\u0100;u\u1D3C\u28D8;\u6A2A\u0163\u28DE\u28E1p;\u6ADB\xF2\u2212\xF0\u0A81\u0100dp\u28E9\u28EEels;\u62A7f;\uC000\u{1D55E}\u0100ct\u28F8\u28FDr;\uC000\u{1D4C2}pos\xBB\u159D\u0180;lm\u2909\u290A\u290D\u43BCtimap;\u62B8\u0C00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297E\u2989\u2998\u29DA\u29E9\u2A15\u2A1A\u2A58\u2A5D\u2A83\u2A95\u2AA4\u2AA8\u2B04\u2B07\u2B44\u2B7F\u2BAE\u2C34\u2C67\u2C7C\u2CE9\u0100gt\u2947\u294B;\uC000\u22D9\u0338\u0100;v\u2950\u0BCF\uC000\u226B\u20D2\u0180elt\u295A\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61CDightarrow;\u61CE;\uC000\u22D8\u0338\u0100;v\u297B\u0C47\uC000\u226A\u20D2ightarrow;\u61CF\u0100Dd\u298E\u2993ash;\u62AFash;\u62AE\u0280bcnpt\u29A3\u29A7\u29AC\u29B1\u29CCla\xBB\u02DEute;\u4144g;\uC000\u2220\u20D2\u0280;Eiop\u0D84\u29BC\u29C0\u29C5\u29C8;\uC000\u2A70\u0338d;\uC000\u224B\u0338s;\u4149ro\xF8\u0D84ur\u0100;a\u29D3\u29D4\u666El\u0100;s\u29D3\u0B38\u01F3\u29DF\0\u29E3p\u80BB\xA0\u0B37mp\u0100;e\u0BF9\u0C00\u0280aeouy\u29F4\u29FE\u2A03\u2A10\u2A13\u01F0\u29F9\0\u29FB;\u6A43on;\u4148dil;\u4146ng\u0100;d\u0D7E\u2A0Aot;\uC000\u2A6D\u0338p;\u6A42;\u443Dash;\u6013\u0380;Aadqsx\u0B92\u2A29\u2A2D\u2A3B\u2A41\u2A45\u2A50rr;\u61D7r\u0100hr\u2A33\u2A36k;\u6924\u0100;o\u13F2\u13F0ot;\uC000\u2250\u0338ui\xF6\u0B63\u0100ei\u2A4A\u2A4Ear;\u6928\xED\u0B98ist\u0100;s\u0BA0\u0B9Fr;\uC000\u{1D52B}\u0200Eest\u0BC5\u2A66\u2A79\u2A7C\u0180;qs\u0BBC\u2A6D\u0BE1\u0180;qs\u0BBC\u0BC5\u2A74lan\xF4\u0BE2i\xED\u0BEA\u0100;r\u0BB6\u2A81\xBB\u0BB7\u0180Aap\u2A8A\u2A8D\u2A91r\xF2\u2971rr;\u61AEar;\u6AF2\u0180;sv\u0F8D\u2A9C\u0F8C\u0100;d\u2AA1\u2AA2\u62FC;\u62FAcy;\u445A\u0380AEadest\u2AB7\u2ABA\u2ABE\u2AC2\u2AC5\u2AF6\u2AF9r\xF2\u2966;\uC000\u2266\u0338rr;\u619Ar;\u6025\u0200;fqs\u0C3B\u2ACE\u2AE3\u2AEFt\u0100ar\u2AD4\u2AD9rro\xF7\u2AC1ightarro\xF7\u2A90\u0180;qs\u0C3B\u2ABA\u2AEAlan\xF4\u0C55\u0100;s\u0C55\u2AF4\xBB\u0C36i\xED\u0C5D\u0100;r\u0C35\u2AFEi\u0100;e\u0C1A\u0C25i\xE4\u0D90\u0100pt\u2B0C\u2B11f;\uC000\u{1D55F}\u8180\xAC;in\u2B19\u2B1A\u2B36\u40ACn\u0200;Edv\u0B89\u2B24\u2B28\u2B2E;\uC000\u22F9\u0338ot;\uC000\u22F5\u0338\u01E1\u0B89\u2B33\u2B35;\u62F7;\u62F6i\u0100;v\u0CB8\u2B3C\u01E1\u0CB8\u2B41\u2B43;\u62FE;\u62FD\u0180aor\u2B4B\u2B63\u2B69r\u0200;ast\u0B7B\u2B55\u2B5A\u2B5Flle\xEC\u0B7Bl;\uC000\u2AFD\u20E5;\uC000\u2202\u0338lint;\u6A14\u0180;ce\u0C92\u2B70\u2B73u\xE5\u0CA5\u0100;c\u0C98\u2B78\u0100;e\u0C92\u2B7D\xF1\u0C98\u0200Aait\u2B88\u2B8B\u2B9D\u2BA7r\xF2\u2988rr\u0180;cw\u2B94\u2B95\u2B99\u619B;\uC000\u2933\u0338;\uC000\u219D\u0338ghtarrow\xBB\u2B95ri\u0100;e\u0CCB\u0CD6\u0380chimpqu\u2BBD\u2BCD\u2BD9\u2B04\u0B78\u2BE4\u2BEF\u0200;cer\u0D32\u2BC6\u0D37\u2BC9u\xE5\u0D45;\uC000\u{1D4C3}ort\u026D\u2B05\0\0\u2BD6ar\xE1\u2B56m\u0100;e\u0D6E\u2BDF\u0100;q\u0D74\u0D73su\u0100bp\u2BEB\u2BED\xE5\u0CF8\xE5\u0D0B\u0180bcp\u2BF6\u2C11\u2C19\u0200;Ees\u2BFF\u2C00\u0D22\u2C04\u6284;\uC000\u2AC5\u0338et\u0100;e\u0D1B\u2C0Bq\u0100;q\u0D23\u2C00c\u0100;e\u0D32\u2C17\xF1\u0D38\u0200;Ees\u2C22\u2C23\u0D5F\u2C27\u6285;\uC000\u2AC6\u0338et\u0100;e\u0D58\u2C2Eq\u0100;q\u0D60\u2C23\u0200gilr\u2C3D\u2C3F\u2C45\u2C47\xEC\u0BD7lde\u803B\xF1\u40F1\xE7\u0C43iangle\u0100lr\u2C52\u2C5Ceft\u0100;e\u0C1A\u2C5A\xF1\u0C26ight\u0100;e\u0CCB\u2C65\xF1\u0CD7\u0100;m\u2C6C\u2C6D\u43BD\u0180;es\u2C74\u2C75\u2C79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2C8F\u2C94\u2C99\u2C9E\u2CA3\u2CB0\u2CB6\u2CD3\u2CE3ash;\u62ADarr;\u6904p;\uC000\u224D\u20D2ash;\u62AC\u0100et\u2CA8\u2CAC;\uC000\u2265\u20D2;\uC000>\u20D2nfin;\u69DE\u0180Aet\u2CBD\u2CC1\u2CC5rr;\u6902;\uC000\u2264\u20D2\u0100;r\u2CCA\u2CCD\uC000<\u20D2ie;\uC000\u22B4\u20D2\u0100At\u2CD8\u2CDCrr;\u6903rie;\uC000\u22B5\u20D2im;\uC000\u223C\u20D2\u0180Aan\u2CF0\u2CF4\u2D02rr;\u61D6r\u0100hr\u2CFA\u2CFDk;\u6923\u0100;o\u13E7\u13E5ear;\u6927\u1253\u1A95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2D2D\0\u2D38\u2D48\u2D60\u2D65\u2D72\u2D84\u1B07\0\0\u2D8D\u2DAB\0\u2DC8\u2DCE\0\u2DDC\u2E19\u2E2B\u2E3E\u2E43\u0100cs\u2D31\u1A97ute\u803B\xF3\u40F3\u0100iy\u2D3C\u2D45r\u0100;c\u1A9E\u2D42\u803B\xF4\u40F4;\u443E\u0280abios\u1AA0\u2D52\u2D57\u01C8\u2D5Alac;\u4151v;\u6A38old;\u69BClig;\u4153\u0100cr\u2D69\u2D6Dir;\u69BF;\uC000\u{1D52C}\u036F\u2D79\0\0\u2D7C\0\u2D82n;\u42DBave\u803B\xF2\u40F2;\u69C1\u0100bm\u2D88\u0DF4ar;\u69B5\u0200acit\u2D95\u2D98\u2DA5\u2DA8r\xF2\u1A80\u0100ir\u2D9D\u2DA0r;\u69BEoss;\u69BBn\xE5\u0E52;\u69C0\u0180aei\u2DB1\u2DB5\u2DB9cr;\u414Dga;\u43C9\u0180cdn\u2DC0\u2DC5\u01CDron;\u43BF;\u69B6pf;\uC000\u{1D560}\u0180ael\u2DD4\u2DD7\u01D2r;\u69B7rp;\u69B9\u0380;adiosv\u2DEA\u2DEB\u2DEE\u2E08\u2E0D\u2E10\u2E16\u6228r\xF2\u1A86\u0200;efm\u2DF7\u2DF8\u2E02\u2E05\u6A5Dr\u0100;o\u2DFE\u2DFF\u6134f\xBB\u2DFF\u803B\xAA\u40AA\u803B\xBA\u40BAgof;\u62B6r;\u6A56lope;\u6A57;\u6A5B\u0180clo\u2E1F\u2E21\u2E27\xF2\u2E01ash\u803B\xF8\u40F8l;\u6298i\u016C\u2E2F\u2E34de\u803B\xF5\u40F5es\u0100;a\u01DB\u2E3As;\u6A36ml\u803B\xF6\u40F6bar;\u633D\u0AE1\u2E5E\0\u2E7D\0\u2E80\u2E9D\0\u2EA2\u2EB9\0\0\u2ECB\u0E9C\0\u2F13\0\0\u2F2B\u2FBC\0\u2FC8r\u0200;ast\u0403\u2E67\u2E72\u0E85\u8100\xB6;l\u2E6D\u2E6E\u40B6le\xEC\u0403\u0269\u2E78\0\0\u2E7Bm;\u6AF3;\u6AFDy;\u443Fr\u0280cimpt\u2E8B\u2E8F\u2E93\u1865\u2E97nt;\u4025od;\u402Eil;\u6030enk;\u6031r;\uC000\u{1D52D}\u0180imo\u2EA8\u2EB0\u2EB4\u0100;v\u2EAD\u2EAE\u43C6;\u43D5ma\xF4\u0A76ne;\u660E\u0180;tv\u2EBF\u2EC0\u2EC8\u43C0chfork\xBB\u1FFD;\u43D6\u0100au\u2ECF\u2EDFn\u0100ck\u2ED5\u2EDDk\u0100;h\u21F4\u2EDB;\u610E\xF6\u21F4s\u0480;abcdemst\u2EF3\u2EF4\u1908\u2EF9\u2EFD\u2F04\u2F06\u2F0A\u2F0E\u402Bcir;\u6A23ir;\u6A22\u0100ou\u1D40\u2F02;\u6A25;\u6A72n\u80BB\xB1\u0E9Dim;\u6A26wo;\u6A27\u0180ipu\u2F19\u2F20\u2F25ntint;\u6A15f;\uC000\u{1D561}nd\u803B\xA3\u40A3\u0500;Eaceinosu\u0EC8\u2F3F\u2F41\u2F44\u2F47\u2F81\u2F89\u2F92\u2F7E\u2FB6;\u6AB3p;\u6AB7u\xE5\u0ED9\u0100;c\u0ECE\u2F4C\u0300;acens\u0EC8\u2F59\u2F5F\u2F66\u2F68\u2F7Eppro\xF8\u2F43urlye\xF1\u0ED9\xF1\u0ECE\u0180aes\u2F6F\u2F76\u2F7Approx;\u6AB9qq;\u6AB5im;\u62E8i\xED\u0EDFme\u0100;s\u2F88\u0EAE\u6032\u0180Eas\u2F78\u2F90\u2F7A\xF0\u2F75\u0180dfp\u0EEC\u2F99\u2FAF\u0180als\u2FA0\u2FA5\u2FAAlar;\u632Eine;\u6312urf;\u6313\u0100;t\u0EFB\u2FB4\xEF\u0EFBrel;\u62B0\u0100ci\u2FC0\u2FC5r;\uC000\u{1D4C5};\u43C8ncsp;\u6008\u0300fiopsu\u2FDA\u22E2\u2FDF\u2FE5\u2FEB\u2FF1r;\uC000\u{1D52E}pf;\uC000\u{1D562}rime;\u6057cr;\uC000\u{1D4C6}\u0180aeo\u2FF8\u3009\u3013t\u0100ei\u2FFE\u3005rnion\xF3\u06B0nt;\u6A16st\u0100;e\u3010\u3011\u403F\xF1\u1F19\xF4\u0F14\u0A80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30E0\u310E\u312B\u3147\u3162\u3172\u318E\u3206\u3215\u3224\u3229\u3258\u326E\u3272\u3290\u32B0\u32B7\u0180art\u3047\u304A\u304Cr\xF2\u10B3\xF2\u03DDail;\u691Car\xF2\u1C65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307F\u308F\u3094\u30CC\u0100eu\u306D\u3071;\uC000\u223D\u0331te;\u4155i\xE3\u116Emptyv;\u69B3g\u0200;del\u0FD1\u3089\u308B\u308D;\u6992;\u69A5\xE5\u0FD1uo\u803B\xBB\u40BBr\u0580;abcfhlpstw\u0FDC\u30AC\u30AF\u30B7\u30B9\u30BC\u30BE\u30C0\u30C3\u30C7\u30CAp;\u6975\u0100;f\u0FE0\u30B4s;\u6920;\u6933s;\u691E\xEB\u225D\xF0\u272El;\u6945im;\u6974l;\u61A3;\u619D\u0100ai\u30D1\u30D5il;\u691Ao\u0100;n\u30DB\u30DC\u6236al\xF3\u0F1E\u0180abr\u30E7\u30EA\u30EEr\xF2\u17E5rk;\u6773\u0100ak\u30F3\u30FDc\u0100ek\u30F9\u30FB;\u407D;\u405D\u0100es\u3102\u3104;\u698Cl\u0100du\u310A\u310C;\u698E;\u6990\u0200aeuy\u3117\u311C\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xEC\u0FF2\xE2\u30FA;\u4440\u0200clqs\u3134\u3137\u313D\u3144a;\u6937dhar;\u6969uo\u0100;r\u020E\u020Dh;\u61B3\u0180acg\u314E\u315F\u0F44l\u0200;ips\u0F78\u3158\u315B\u109Cn\xE5\u10BBar\xF4\u0FA9t;\u65AD\u0180ilr\u3169\u1023\u316Esht;\u697D;\uC000\u{1D52F}\u0100ao\u3177\u3186r\u0100du\u317D\u317F\xBB\u047B\u0100;l\u1091\u3184;\u696C\u0100;v\u318B\u318C\u43C1;\u43F1\u0180gns\u3195\u31F9\u31FCht\u0300ahlrst\u31A4\u31B0\u31C2\u31D8\u31E4\u31EErrow\u0100;t\u0FDC\u31ADa\xE9\u30C8arpoon\u0100du\u31BB\u31BFow\xEE\u317Ep\xBB\u1092eft\u0100ah\u31CA\u31D0rrow\xF3\u0FEAarpoon\xF3\u0551ightarrows;\u61C9quigarro\xF7\u30CBhreetimes;\u62CCg;\u42DAingdotse\xF1\u1F32\u0180ahm\u320D\u3210\u3213r\xF2\u0FEAa\xF2\u0551;\u600Foust\u0100;a\u321E\u321F\u63B1che\xBB\u321Fmid;\u6AEE\u0200abpt\u3232\u323D\u3240\u3252\u0100nr\u3237\u323Ag;\u67EDr;\u61FEr\xEB\u1003\u0180afl\u3247\u324A\u324Er;\u6986;\uC000\u{1D563}us;\u6A2Eimes;\u6A35\u0100ap\u325D\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6A12ar\xF2\u31E3\u0200achq\u327B\u3280\u10BC\u3285quo;\u603Ar;\uC000\u{1D4C7}\u0100bu\u30FB\u328Ao\u0100;r\u0214\u0213\u0180hir\u3297\u329B\u32A0re\xE5\u31F8mes;\u62CAi\u0200;efl\u32AA\u1059\u1821\u32AB\u65B9tri;\u69CEluhar;\u6968;\u611E\u0D61\u32D5\u32DB\u32DF\u332C\u3338\u3371\0\u337A\u33A4\0\0\u33EC\u33F0\0\u3428\u3448\u345A\u34AD\u34B1\u34CA\u34F1\0\u3616\0\0\u3633cute;\u415Bqu\xEF\u27BA\u0500;Eaceinpsy\u11ED\u32F3\u32F5\u32FF\u3302\u330B\u330F\u331F\u3326\u3329;\u6AB4\u01F0\u32FA\0\u32FC;\u6AB8on;\u4161u\xE5\u11FE\u0100;d\u11F3\u3307il;\u415Frc;\u415D\u0180Eas\u3316\u3318\u331B;\u6AB6p;\u6ABAim;\u62E9olint;\u6A13i\xED\u1204;\u4441ot\u0180;be\u3334\u1D47\u3335\u62C5;\u6A66\u0380Aacmstx\u3346\u334A\u3357\u335B\u335E\u3363\u336Drr;\u61D8r\u0100hr\u3350\u3352\xEB\u2228\u0100;o\u0A36\u0A34t\u803B\xA7\u40A7i;\u403Bwar;\u6929m\u0100in\u3369\xF0nu\xF3\xF1t;\u6736r\u0100;o\u3376\u2055\uC000\u{1D530}\u0200acoy\u3382\u3386\u3391\u33A0rp;\u666F\u0100hy\u338B\u338Fcy;\u4449;\u4448rt\u026D\u3399\0\0\u339Ci\xE4\u1464ara\xEC\u2E6F\u803B\xAD\u40AD\u0100gm\u33A8\u33B4ma\u0180;fv\u33B1\u33B2\u33B2\u43C3;\u43C2\u0400;deglnpr\u12AB\u33C5\u33C9\u33CE\u33D6\u33DE\u33E1\u33E6ot;\u6A6A\u0100;q\u12B1\u12B0\u0100;E\u33D3\u33D4\u6A9E;\u6AA0\u0100;E\u33DB\u33DC\u6A9D;\u6A9Fe;\u6246lus;\u6A24arr;\u6972ar\xF2\u113D\u0200aeit\u33F8\u3408\u340F\u3417\u0100ls\u33FD\u3404lsetm\xE9\u336Ahp;\u6A33parsl;\u69E4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341C\u341D\u6AAA\u0100;s\u3422\u3423\u6AAC;\uC000\u2AAC\uFE00\u0180flp\u342E\u3433\u3442tcy;\u444C\u0100;b\u3438\u3439\u402F\u0100;a\u343E\u343F\u69C4r;\u633Ff;\uC000\u{1D564}a\u0100dr\u344D\u0402es\u0100;u\u3454\u3455\u6660it\xBB\u3455\u0180csu\u3460\u3479\u349F\u0100au\u3465\u346Fp\u0100;s\u1188\u346B;\uC000\u2293\uFE00p\u0100;s\u11B4\u3475;\uC000\u2294\uFE00u\u0100bp\u347F\u348F\u0180;es\u1197\u119C\u3486et\u0100;e\u1197\u348D\xF1\u119D\u0180;es\u11A8\u11AD\u3496et\u0100;e\u11A8\u349D\xF1\u11AE\u0180;af\u117B\u34A6\u05B0r\u0165\u34AB\u05B1\xBB\u117Car\xF2\u1148\u0200cemt\u34B9\u34BE\u34C2\u34C5r;\uC000\u{1D4C8}tm\xEE\xF1i\xEC\u3415ar\xE6\u11BE\u0100ar\u34CE\u34D5r\u0100;f\u34D4\u17BF\u6606\u0100an\u34DA\u34EDight\u0100ep\u34E3\u34EApsilo\xEE\u1EE0h\xE9\u2EAFs\xBB\u2852\u0280bcmnp\u34FB\u355E\u1209\u358B\u358E\u0480;Edemnprs\u350E\u350F\u3511\u3515\u351E\u3523\u352C\u3531\u3536\u6282;\u6AC5ot;\u6ABD\u0100;d\u11DA\u351Aot;\u6AC3ult;\u6AC1\u0100Ee\u3528\u352A;\u6ACB;\u628Alus;\u6ABFarr;\u6979\u0180eiu\u353D\u3552\u3555t\u0180;en\u350E\u3545\u354Bq\u0100;q\u11DA\u350Feq\u0100;q\u352B\u3528m;\u6AC7\u0100bp\u355A\u355C;\u6AD5;\u6AD3c\u0300;acens\u11ED\u356C\u3572\u3579\u357B\u3326ppro\xF8\u32FAurlye\xF1\u11FE\xF1\u11F3\u0180aes\u3582\u3588\u331Bppro\xF8\u331Aq\xF1\u3317g;\u666A\u0680123;Edehlmnps\u35A9\u35AC\u35AF\u121C\u35B2\u35B4\u35C0\u35C9\u35D5\u35DA\u35DF\u35E8\u35ED\u803B\xB9\u40B9\u803B\xB2\u40B2\u803B\xB3\u40B3;\u6AC6\u0100os\u35B9\u35BCt;\u6ABEub;\u6AD8\u0100;d\u1222\u35C5ot;\u6AC4s\u0100ou\u35CF\u35D2l;\u67C9b;\u6AD7arr;\u697Bult;\u6AC2\u0100Ee\u35E4\u35E6;\u6ACC;\u628Blus;\u6AC0\u0180eiu\u35F4\u3609\u360Ct\u0180;en\u121C\u35FC\u3602q\u0100;q\u1222\u35B2eq\u0100;q\u35E7\u35E4m;\u6AC8\u0100bp\u3611\u3613;\u6AD4;\u6AD6\u0180Aan\u361C\u3620\u362Drr;\u61D9r\u0100hr\u3626\u3628\xEB\u222E\u0100;o\u0A2B\u0A29war;\u692Alig\u803B\xDF\u40DF\u0BE1\u3651\u365D\u3660\u12CE\u3673\u3679\0\u367E\u36C2\0\0\0\0\0\u36DB\u3703\0\u3709\u376C\0\0\0\u3787\u0272\u3656\0\0\u365Bget;\u6316;\u43C4r\xEB\u0E5F\u0180aey\u3666\u366B\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uC000\u{1D531}\u0200eiko\u3686\u369D\u36B5\u36BC\u01F2\u368B\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369B\u43B8ym;\u43D1\u0100cn\u36A2\u36B2k\u0100as\u36A8\u36AEppro\xF8\u12C1im\xBB\u12ACs\xF0\u129E\u0100as\u36BA\u36AE\xF0\u12C1rn\u803B\xFE\u40FE\u01EC\u031F\u36C6\u22E7es\u8180\xD7;bd\u36CF\u36D0\u36D8\u40D7\u0100;a\u190F\u36D5r;\u6A31;\u6A30\u0180eps\u36E1\u36E3\u3700\xE1\u2A4D\u0200;bcf\u0486\u36EC\u36F0\u36F4ot;\u6336ir;\u6AF1\u0100;o\u36F9\u36FC\uC000\u{1D565}rk;\u6ADA\xE1\u3362rime;\u6034\u0180aip\u370F\u3712\u3764d\xE5\u1248\u0380adempst\u3721\u374D\u3740\u3751\u3757\u375C\u375Fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65B5own\xBB\u1DBBeft\u0100;e\u2800\u373E\xF1\u092E;\u625Cight\u0100;e\u32AA\u374B\xF1\u105Aot;\u65ECinus;\u6A3Alus;\u6A39b;\u69CDime;\u6A3Bezium;\u63E2\u0180cht\u3772\u377D\u3781\u0100ry\u3777\u377B;\uC000\u{1D4C9};\u4446cy;\u445Brok;\u4167\u0100io\u378B\u378Ex\xF4\u1777head\u0100lr\u3797\u37A0eftarro\xF7\u084Fightarrow\xBB\u0F5D\u0900AHabcdfghlmoprstuw\u37D0\u37D3\u37D7\u37E4\u37F0\u37FC\u380E\u381C\u3823\u3834\u3851\u385D\u386B\u38A9\u38CC\u38D2\u38EA\u38F6r\xF2\u03EDar;\u6963\u0100cr\u37DC\u37E2ute\u803B\xFA\u40FA\xF2\u1150r\u01E3\u37EA\0\u37EDy;\u445Eve;\u416D\u0100iy\u37F5\u37FArc\u803B\xFB\u40FB;\u4443\u0180abh\u3803\u3806\u380Br\xF2\u13ADlac;\u4171a\xF2\u13C3\u0100ir\u3813\u3818sht;\u697E;\uC000\u{1D532}rave\u803B\xF9\u40F9\u0161\u3827\u3831r\u0100lr\u382C\u382E\xBB\u0957\xBB\u1083lk;\u6580\u0100ct\u3839\u384D\u026F\u383F\0\0\u384Arn\u0100;e\u3845\u3846\u631Cr\xBB\u3846op;\u630Fri;\u65F8\u0100al\u3856\u385Acr;\u416B\u80BB\xA8\u0349\u0100gp\u3862\u3866on;\u4173f;\uC000\u{1D566}\u0300adhlsu\u114B\u3878\u387D\u1372\u3891\u38A0own\xE1\u13B3arpoon\u0100lr\u3888\u388Cef\xF4\u382Digh\xF4\u382Fi\u0180;hl\u3899\u389A\u389C\u43C5\xBB\u13FAon\xBB\u389Aparrows;\u61C8\u0180cit\u38B0\u38C4\u38C8\u026F\u38B6\0\0\u38C1rn\u0100;e\u38BC\u38BD\u631Dr\xBB\u38BDop;\u630Eng;\u416Fri;\u65F9cr;\uC000\u{1D4CA}\u0180dir\u38D9\u38DD\u38E2ot;\u62F0lde;\u4169i\u0100;f\u3730\u38E8\xBB\u1813\u0100am\u38EF\u38F2r\xF2\u38A8l\u803B\xFC\u40FCangle;\u69A7\u0780ABDacdeflnoprsz\u391C\u391F\u3929\u392D\u39B5\u39B8\u39BD\u39DF\u39E4\u39E8\u39F3\u39F9\u39FD\u3A01\u3A20r\xF2\u03F7ar\u0100;v\u3926\u3927\u6AE8;\u6AE9as\xE8\u03E1\u0100nr\u3932\u3937grt;\u699C\u0380eknprst\u34E3\u3946\u394B\u3952\u395D\u3964\u3996app\xE1\u2415othin\xE7\u1E96\u0180hir\u34EB\u2EC8\u3959op\xF4\u2FB5\u0100;h\u13B7\u3962\xEF\u318D\u0100iu\u3969\u396Dgm\xE1\u33B3\u0100bp\u3972\u3984setneq\u0100;q\u397D\u3980\uC000\u228A\uFE00;\uC000\u2ACB\uFE00setneq\u0100;q\u398F\u3992\uC000\u228B\uFE00;\uC000\u2ACC\uFE00\u0100hr\u399B\u399Fet\xE1\u369Ciangle\u0100lr\u39AA\u39AFeft\xBB\u0925ight\xBB\u1051y;\u4432ash\xBB\u1036\u0180elr\u39C4\u39D2\u39D7\u0180;be\u2DEA\u39CB\u39CFar;\u62BBq;\u625Alip;\u62EE\u0100bt\u39DC\u1468a\xF2\u1469r;\uC000\u{1D533}tr\xE9\u39AEsu\u0100bp\u39EF\u39F1\xBB\u0D1C\xBB\u0D59pf;\uC000\u{1D567}ro\xF0\u0EFBtr\xE9\u39B4\u0100cu\u3A06\u3A0Br;\uC000\u{1D4CB}\u0100bp\u3A10\u3A18n\u0100Ee\u3980\u3A16\xBB\u397En\u0100Ee\u3992\u3A1E\xBB\u3990igzag;\u699A\u0380cefoprs\u3A36\u3A3B\u3A56\u3A5B\u3A54\u3A61\u3A6Airc;\u4175\u0100di\u3A40\u3A51\u0100bg\u3A45\u3A49ar;\u6A5Fe\u0100;q\u15FA\u3A4F;\u6259erp;\u6118r;\uC000\u{1D534}pf;\uC000\u{1D568}\u0100;e\u1479\u3A66at\xE8\u1479cr;\uC000\u{1D4CC}\u0AE3\u178E\u3A87\0\u3A8B\0\u3A90\u3A9B\0\0\u3A9D\u3AA8\u3AAB\u3AAF\0\0\u3AC3\u3ACE\0\u3AD8\u17DC\u17DFtr\xE9\u17D1r;\uC000\u{1D535}\u0100Aa\u3A94\u3A97r\xF2\u03C3r\xF2\u09F6;\u43BE\u0100Aa\u3AA1\u3AA4r\xF2\u03B8r\xF2\u09EBa\xF0\u2713is;\u62FB\u0180dpt\u17A4\u3AB5\u3ABE\u0100fl\u3ABA\u17A9;\uC000\u{1D569}im\xE5\u17B2\u0100Aa\u3AC7\u3ACAr\xF2\u03CEr\xF2\u0A01\u0100cq\u3AD2\u17B8r;\uC000\u{1D4CD}\u0100pt\u17D6\u3ADCr\xE9\u17D4\u0400acefiosu\u3AF0\u3AFD\u3B08\u3B0C\u3B11\u3B15\u3B1B\u3B21c\u0100uy\u3AF6\u3AFBte\u803B\xFD\u40FD;\u444F\u0100iy\u3B02\u3B06rc;\u4177;\u444Bn\u803B\xA5\u40A5r;\uC000\u{1D536}cy;\u4457pf;\uC000\u{1D56A}cr;\uC000\u{1D4CE}\u0100cm\u3B26\u3B29y;\u444El\u803B\xFF\u40FF\u0500acdefhiosw\u3B42\u3B48\u3B54\u3B58\u3B64\u3B69\u3B6D\u3B74\u3B7A\u3B80cute;\u417A\u0100ay\u3B4D\u3B52ron;\u417E;\u4437ot;\u417C\u0100et\u3B5D\u3B61tr\xE6\u155Fa;\u43B6r;\uC000\u{1D537}cy;\u4436grarr;\u61DDpf;\uC000\u{1D56B}cr;\uC000\u{1D4CF}\u0100jn\u3B85\u3B87;\u600Dj;\u600C'.split("").map(e=>e.charCodeAt(0)));var Kp=new Uint16Array("\u0200aglq \x1B\u026D\0\0p;\u4026os;\u4027t;\u403Et;\u403Cuot;\u4022".split("").map(e=>e.charCodeAt(0)));var hr,Ih=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),Cr=(hr=String.fromCodePoint)!==null&&hr!==void 0?hr:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t};function Rr(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Ih.get(e))!==null&&t!==void 0?t:e}var me;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(me||(me={}));var vh=32,Ze;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Ze||(Ze={}));function Nr(e){return e>=me.ZERO&&e<=me.NINE}function Dh(e){return e>=me.UPPER_A&&e<=me.UPPER_F||e>=me.LOWER_A&&e<=me.LOWER_F}function xh(e){return e>=me.UPPER_A&&e<=me.UPPER_Z||e>=me.LOWER_A&&e<=me.LOWER_Z||Nr(e)}function Mh(e){return e===me.EQUALS||xh(e)}var pe;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(pe||(pe={}));var Pe;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Pe||(Pe={}));var qn=class{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=pe.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Pe.Strict}startEntity(t){this.decodeMode=t,this.state=pe.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case pe.EntityStart:return t.charCodeAt(n)===me.NUM?(this.state=pe.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=pe.NamedEntity,this.stateNamedEntity(t,n));case pe.NumericStart:return this.stateNumericStart(t,n);case pe.NumericDecimal:return this.stateNumericDecimal(t,n);case pe.NumericHex:return this.stateNumericHex(t,n);case pe.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|vh)===me.LOWER_X?(this.state=pe.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=pe.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,r,a){if(n!==r){let i=r-n;this.result=this.result*Math.pow(a,i)+parseInt(t.substr(n,i),a),this.consumed+=i}}stateNumericHex(t,n){let r=n;for(;n>14;for(;n>14,i!==0){if(o===me.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==Pe.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;let{result:n,decodeTree:r}=this,a=(r[n]&Ze.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,a,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,r){let{decodeTree:a}=this;return this.emitCodePoint(n===1?a[t]&~Ze.VALUE_LENGTH:a[t+1],r),n===3&&this.emitCodePoint(a[t+2],r),r}end(){var t;switch(this.state){case pe.NamedEntity:return this.result!==0&&(this.decodeMode!==Pe.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case pe.NumericDecimal:return this.emitNumericEntity(0,2);case pe.NumericHex:return this.emitNumericEntity(0,3);case pe.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case pe.EntityStart:return 0}}};function Qp(e){let t="",n=new qn(e,r=>t+=Cr(r));return function(a,i){let o=0,s=0;for(;(s=a.indexOf("&",s))>=0;){t+=a.slice(o,s),n.startEntity(i);let c=n.write(a,s+1);if(c<0){o=s+n.end();break}o=s+c,s=c===0?o+1:o}let l=t+a.slice(o);return t="",l}}function Lh(e,t,n,r){let a=(t&Ze.BRANCH_LENGTH)>>7,i=t&Ze.JUMP_TABLE;if(a===0)return i!==0&&r===i?n:-1;if(i){let l=r-i;return l<0||l>=a?-1:e[n+l]-1}let o=n,s=o+a-1;for(;o<=s;){let l=o+s>>>1,c=e[l];if(cr)s=l-1;else return e[l+a]}return-1}var wh=Qp($p),vv=Qp(Kp);function Je(e,t=Pe.Legacy){return wh(e,t)}function Vn(e){for(let t=1;te.codePointAt(t):(e,t)=>(e.charCodeAt(t)&64512)===55296?(e.charCodeAt(t)-55296)*1024+e.charCodeAt(t+1)-56320+65536:e.charCodeAt(t);function yr(e,t){return function(r){let a,i=0,o="";for(;a=e.exec(r);)i!==a.index&&(o+=r.substring(i,a.index)),o+=t.get(a[0].charCodeAt(0)),i=a.index+1;return o+r.substring(i)}}var Xp=yr(/[&<>'"]/g,Ph),Zp=yr(/["&\u00A0]/g,new Map([[34,"""],[38,"&"],[160," "]])),Jp=yr(/[&<>\u00A0]/g,new Map([[38,"&"],[60,"<"],[62,">"],[160," "]]));var jp;(function(e){e[e.XML=0]="XML",e[e.HTML=1]="HTML"})(jp||(jp={}));var em;(function(e){e[e.UTF8=0]="UTF8",e[e.ASCII=1]="ASCII",e[e.Extensive=2]="Extensive",e[e.Attribute=3]="Attribute",e[e.Text=4]="Text"})(em||(em={}));function Gh(e){return Object.prototype.toString.call(e)}function zn(e){return Gh(e)==="[object String]"}var Yh=Object.prototype.hasOwnProperty;function Hh(e,t){return Yh.call(e,t)}function xt(e){return Array.prototype.slice.call(arguments,1).forEach(function(n){if(n){if(typeof n!="object")throw new TypeError(n+"must be object");Object.keys(n).forEach(function(r){e[r]=n[r]})}}),e}function Ar(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function Wn(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function Zt(e){if(e>65535){e-=65536;let t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var rm=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,qh=/&([a-z#][a-z0-9]{1,31});/gi,Vh=new RegExp(rm.source+"|"+qh.source,"gi"),zh=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function Wh(e,t){if(t.charCodeAt(0)===35&&zh.test(t)){let r=t[1].toLowerCase()==="x"?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Wn(r)?Zt(r):e}let n=Je(e);return n!==e?n:e}function $h(e){return e.indexOf("\\")<0?e:e.replace(rm,"$1")}function He(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(Vh,function(t,n,r){return n||Wh(t,r)})}var Kh=/[&<>"]/,Qh=/[&<>"]/g,Xh={"&":"&","<":"<",">":">",'"':"""};function Zh(e){return Xh[e]}function qe(e){return Kh.test(e)?e.replace(Qh,Zh):e}var Jh=/[.?*+^$[\]\\(){}|-]/g;function jh(e){return e.replace(Jh,"\\$&")}function X(e){switch(e){case 9:case 32:return!0}return!1}function ct(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function ut(e){return Dt.test(e)||Yn.test(e)}function dt(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function _t(e){return e=e.trim().replace(/\s+/g," "),"\u1E9E".toLowerCase()==="\u1E7E"&&(e=e.replace(/ẞ/g,"\xDF")),e.toLowerCase().toUpperCase()}var eC={mdurl:Un,ucmicro:Tr};var Mr={};Bt(Mr,{parseLinkDestination:()=>Dr,parseLinkLabel:()=>vr,parseLinkTitle:()=>xr});function vr(e,t,n){let r,a,i,o,s=e.posMax,l=e.pos;for(e.pos=t+1,r=1;e.pos32))return i;if(r===41){if(o===0)break;o--}a++}return t===a||o!==0||(i.str=He(e.slice(t,a)),i.pos=a,i.ok=!0),i}function xr(e,t,n,r){let a,i=t,o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(r)o.str=r.str,o.marker=r.marker;else{if(i>=n)return o;let s=e.charCodeAt(i);if(s!==34&&s!==39&&s!==40)return o;t++,i++,s===40&&(s=41),o.marker=s}for(;i"+qe(i.content)+""};Fe.code_block=function(e,t,n,r,a){let i=e[t];return""+qe(e[t].content)+` `};Fe.fence=function(e,t,n,r,a){let i=e[t],o=i.info?He(i.info).trim():"",s="",l="";if(o){let u=o.split(/(\s+)/g);s=u[0],l=u.slice(2).join("")}let c;if(n.highlight?c=n.highlight(i.content,s,l)||qe(i.content):c=qe(i.content),c.indexOf("${c} @@ -109,4 +109,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),q=v,G=x),w===void 0&&( margin: 0 0 0.1em 0; max-width: 100%; } -`,qm=(e,t=[])=>{let n=O("div");n.updateContent=s=>{r.innerHTML=Rt(s),en()};let r=O("div");typeof e=="string"?r.innerHTML=Rt(e):r.append(e);let a=n.attachShadow({mode:"open"}),i=O("style");i.textContent=_0,a.appendChild(i),t.forEach(s=>{a.appendChild(O("link",void 0,"",{rel:"stylesheet",type:"text/css",href:s}))});let o=O("link",void 0,"",{rel:"stylesheet",type:"text/css",href:`${E.config.assetsURL}css/highlight.css`});return a.appendChild(o),a.append(r),n};var p0={selection:e=>{let t=O("span","tooltip",e.value,{tabIndex:-1}),n=O("div","context",[Y(24,hn),t],{tabIndex:0});return n.addEventListener("keydown",r=>{if(r.key==="ArrowUp"||r.key==="ArrowDown"){r.preventDefault();let a=30;t.scrollTop+=r.key==="ArrowDown"?a:-a}}),n}},m0={image:e=>O("div","attachment imagePreview",O("img",void 0,void 0,{src:e.value}))},E0=e=>{let t=O("div",`message-wrapper user ${e.init?"":"new"}`),n=O("div","message user"),r=e.content,a=O("div");a.innerHTML=Rt(r),n.appendChild(a);let i=O("div","attachmentsWrapper"),o=O("div","contextsWrapper");for(let u of e.attachments??[]){let d=m0[u.__type];d&&(i.appendChild(d(u)),i.classList.contains("visible")||i.classList.add("visible"))}for(let u of e.contexts??[]){let d=u.renderer&&p0[u.renderer];d&&(o.appendChild(d(u)),o.classList.contains("visible")||o.classList.add("visible"))}let s=O("div","inputAddons",[i,o]);n.appendChild(s);let l=O("div","actions");l.appendChild(ze({message:e,disabled:E.modal.isLoading,disableCompletedState:!0,icon:_i,label:N("modai.ui.retry_message"),onClick:u=>{Ye({title:N("modai.ui.confirm_retry_message"),content:N("modai.ui.confirm_edit_retry_message"),confirmText:N("modai.ui.retry_message"),onConfirm:async()=>{E.modal.messageInput.setValue(u.content),u.contexts&&u.contexts.forEach(d=>{E.modal.context.addContext(d)}),u.attachments&&u.attachments.forEach(d=>{d.__type==="image"&&E.modal.attachments.addImageAttachment(d.value)}),await E.modal.history.clearHistoryFrom(u.id),E.modal.history.getMessages().length===0&&(E.modal.welcomeMessage.style.display="block"),mt()}})}})),l.appendChild(ze({message:e,disabled:E.modal.isLoading,disableCompletedState:!0,icon:bn,label:N("modai.ui.edit"),onClick:u=>{Ye({title:N("modai.ui.confirm_edit"),content:N("modai.ui.confirm_edit_content"),confirmText:N("modai.ui.edit_message"),onConfirm:()=>{E.modal.messageInput.setValue(u.content),u.contexts&&u.contexts.forEach(d=>{E.modal.context.addContext(d)}),u.attachments&&u.attachments.forEach(d=>{d.__type==="image"&&E.modal.attachments.addImageAttachment(d.value)}),E.modal.history.clearHistoryFrom(u.id),E.modal.history.getMessages().length===0&&(E.modal.welcomeMessage.style.display="block")}})}})),l.appendChild(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),completedText:N("modai.ui.copied"),onClick:Ra})),n.appendChild(l),t.update=u=>{let d=Array.isArray(u.content)?u.content[0].value:u.content;a.innerHTML=Rt(d)},t.appendChild(n);let c=E.modal.chatMessages.lastElementChild;return E.modal.chatMessages.appendChild(t),c&&c.classList.remove("new"),t.syncHeight=()=>{let u=n.clientHeight,d=u<100?-10:-1*(u-62);t.style.setProperty("--user-msg-height",`${E.modal.chatContainer.clientHeight-d-50}px`)},t.syncHeight?.(),t},We=e=>{E.modal.welcomeMessage.style.display="none";let t=O("div","message-wrapper error new"),n=O("div","message error");n.appendChild(Y(14,Ei));let r=O("span");return r.textContent=e,n.appendChild(r),t.appendChild(n),E.modal.chatMessages.appendChild(t),t},g0=e=>{let t=E.modal.config,n=O("div",`message-wrapper ai ${e.init?"":"new"}`),r=O("div","message ai");r.dataset.id=e.id;let a=Ca({html:!0,xhtmlOut:!0,linkify:!0,typographer:!0,breaks:!0,highlight:function(c,u){if(u&&br.getLanguage(u))try{return br.highlight(c,{language:u}).value}catch{}return""}}),i=e.content||"";if(e.contentType==="image"){let c=O("img","","",{src:i||`${E.config.assetsURL}images/no-image.png`}),u=Array.isArray(e.ctx.allUrls)?e.ctx.allUrls:[],d=!1;c.onerror=()=>{if(d=!0,u.length>0){let m=u.pop();e.content=m,c.src=m}else e.content="",c.src=`${E.config.assetsURL}images/no-image.png`,s.innerHTML=""},c.onload=()=>{d&&(e.ctx.allUrls=u,e=E.modal.history.updateMessage(e,{content:e.content,ctx:e.ctx}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,e))},i=c}else i=a.render(i);let o=qm(i,t.customCSS??[]);r.appendChild(o);let s=O("div","actions");if(t.type==="text"&&(t.textActions?.copy!==!1&&s.appendChild(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),completedText:N("modai.ui.copied"),onClick:typeof t.textActions?.copy=="function"?t.textActions.copy:Ra})),typeof t.textActions?.insert=="function"&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Nt,label:N("modai.ui.insert"),completedText:N("modai.ui.inserted"),onClick:t.textActions.insert}))),t.type==="image"&&e.content){t.imageActions?.copy!==!1&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),loadingText:N("modai.ui.downloading"),completedText:N("modai.ui.copied"),onClick:async(u,d)=>{let m=typeof t.textActions?.copy=="function"?t.textActions.copy:Ra;if(!u.content)return;let p=await $.download.image({messageId:u.id,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let g=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];p.fullUrl!==u.content&&g.indexOf(u.content)===-1&&g.push(u.content),u.content=p.fullUrl,u.ctx.downloaded=!0,u.ctx.url=p.url,u.ctx.fullUrl=p.fullUrl,u.ctx.allUrls=g,u=E.modal.history.updateMessage(u,{content:p.fullUrl,ctx:{downloaded:!0,url:p.url,fullUrl:p.fullUrl,allUrls:g}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),m(u,d)}})),t.imageActions?.download&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Ii,label:N("modai.ui.download"),loadingText:N("modai.ui.downloading"),completedText:N("modai.ui.downloaded"),onClick:async(u,d)=>{if(!u.content)return;let m=typeof t.imageActions?.download=="function"?t.imageActions.download:null,p=await $.download.image({messageId:u.id,forceDownload:!0,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let g=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];p.fullUrl!==u.content&&g.indexOf(u.content)===-1&&g.push(u.content),u.content=p.fullUrl,u.ctx.downloaded=!0,u.ctx.url=p.url,u.ctx.fullUrl=p.fullUrl,u.ctx.allUrls=g,u=E.modal.history.updateMessage(u,{content:p.fullUrl,ctx:{downloaded:!0,url:p.url,fullUrl:p.fullUrl,allUrls:g}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),m?.(u,d)}}));let c=t.imageActions?.insert;typeof c=="function"&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Nt,label:N("modai.ui.insert"),completedText:N("modai.ui.inserted"),loadingText:N("modai.ui.downloading"),onClick:async(u,d)=>{if(!u.content)return;let m=await $.download.image({messageId:u.id,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let p=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];m.fullUrl!==u.content&&p.indexOf(u.content)===-1&&p.push(u.content),u.content=m.fullUrl,u.ctx.downloaded=!0,u.ctx.url=m.url,u.ctx.fullUrl=m.fullUrl,u.ctx.allUrls=p,u=E.modal.history.updateMessage(u,{content:m.fullUrl,ctx:{downloaded:!0,url:m.url,fullUrl:m.fullUrl,allUrls:p}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),c(u,d)}}))}if(e.metadata?.model){let c=O("div","info",N("modai.ui.model_info",{model:e.metadata.model}));r.appendChild(c)}r.appendChild(s),n.appendChild(r);let l=E.modal.chatMessages.lastElementChild;return E.modal.chatMessages.appendChild(n),l&&l.classList.remove("new"),n.syncHeight=()=>{if(l?.firstElementChild){let c=l.classList.contains("user")?l.firstElementChild.clientHeight<100?l.firstElementChild.clientHeight:l.firstElementChild.clientHeight-(l.firstElementChild.clientHeight-62)+10:-10;n.style.setProperty("--user-msg-height",`${E.modal.chatContainer.clientHeight-c-50}px`)}},n.update=c=>{let u=c.contentType==="image"?``:a.render(c.content??"");o.updateContent(u)},n.syncHeight?.(),n},et=e=>{if(!e.hidden){if(e.__type==="UserMessage"){let t=E0(e);return e.init||ve("smooth"),t}if(e.__type==="AssistantMessage"){let t=g0(e);return!e.init&&!t.previousElementSibling?.classList.contains("user")&&ve("smooth"),t}}},Ra=async e=>{if(e.content)if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(e.content)}catch{We(N("modai.error.failed_copy"))}else try{let t=O("textarea");t.value=e.content,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch{We(N("modai.error.failed_copy"))}};var Vm=()=>{let e=new Map,t={on:(n,r,a)=>{if(a?.signal?.aborted)return()=>t.off(n,r);let i=r;a?.once&&(i=s=>{t.off(n==="*"?"*":s.eventName,i),r(s)});let o=e.get(n);return o?o.push(i):e.set(n,[i]),a?.signal?.addEventListener("abort",()=>{t.off(n,i)}),()=>t.off(n,i)},onMany:(n,r,a)=>{if(a?.once){let o=!1,s=c=>{o||(o=!0,l.forEach(u=>u()),r(c))},l=n.map(c=>t.on(c,s,{signal:a.signal}));return()=>{l.forEach(c=>c())}}let i=n.map(o=>t.on(o,r,a));return()=>{i.forEach(o=>o())}},off:(n,r)=>{let a=e.get(n);if(!a)return;if(!r)return void e.set(n,[]);let i=a.indexOf(r);i!==-1&&a.splice(i,1)},emit:(n,r)=>{let a=e.get(n);if(a){let s=a.slice();for(let l=0,c=s.length;l{E.modal.isLoading=e;let t=E.modal.history.getMessages().length>0;le.emit("loading",{isLoading:e,isPreloading:!1,hasMessages:t})},Na=e=>{E.modal.isLoading=e;let t=E.modal.history.getMessages().length>0;le.emit("loading",{isLoading:e,isPreloading:!0,hasMessages:t})};le.on("loading",({eventData:e})=>{E.modal.chatMessages.querySelectorAll(".action-button").forEach(n=>{e.isLoading?n.disable?.():n?.enable?.()})});var zm="modai__state",kt=()=>{let e=ya();e.position={width:E.modal.modal.style.width,height:E.modal.modal.style.height,left:E.modal.modal.style.left,top:E.modal.modal.style.top};try{localStorage.setItem(zm,JSON.stringify(e))}catch{}},ya=()=>{try{let e=localStorage.getItem(zm);return e?JSON.parse(e):{}}catch{return{}}};var S0="modAI",De="chats";var Jn=null,jn=async()=>new Promise((e,t)=>{if(Jn){e(Jn);return}let n=indexedDB.open(S0,2);n.onupgradeneeded=r=>{let a=r.target.result;a.objectStoreNames.contains("messages")&&a.deleteObjectStore("messages"),a.objectStoreNames.contains(De)&&a.deleteObjectStore(De);let i=a.createObjectStore(De,{keyPath:["key","user_id"]});i.createIndex("chat_id","chat_id",{unique:!1}),i.createIndex("key","key",{unique:!1}),i.createIndex("user_id","user_id",{unique:!1})},n.onsuccess=r=>{Jn=r.target.result,e(Jn)},n.onerror=r=>{t(r.target.error)}}),Wm=async(e,t)=>{let n=await jn();return new Promise((r,a)=>{let s=n.transaction(De,"readonly").objectStore(De).get([e,t]);s.onsuccess=l=>{let c=l.target.result;r(c?c.chat_id:null)},s.onerror=l=>{a(l.target.error)}})},Et=async(e,t,n)=>{let r=await jn();return new Promise((a,i)=>{let s=r.transaction(De,"readwrite").objectStore(De),l={key:e,chat_id:t,user_id:n},c=s.put(l);c.onsuccess=()=>{a()},c.onerror=u=>{let d=u.target.error;d?.name==="ConstraintError"?i(new Error(`Chat ID "${t}" already exists`)):i(d)}})},$m=async(e,t)=>{let n=await jn();return new Promise((r,a)=>{let s=n.transaction(De,"readwrite").objectStore(De).delete([e,t]);s.onsuccess=()=>{r(!0)},s.onerror=l=>{a(l.target.error)}})},er=async e=>{let t=await jn();return new Promise((n,r)=>{let i=t.transaction(De,"readwrite").objectStore(De),o=i.index("chat_id"),s=0,l=!1,c=o.openCursor(IDBKeyRange.only(e));c.onsuccess=u=>{let d=u.target.result;if(d){let m=i.delete(d.primaryKey);m.onsuccess=()=>{s++,d.continue()},m.onerror=p=>{l=!0,r(p.target.error)}}else l||n(s>0)},c.onerror=u=>{r(u.target.error)}})};var f0=e=>{let t=be(e);if(!t)throw Error("Chat history not inited for this key.");let n=Re(t);n.messages.forEach(r=>{delete n.idRef[r.id],r.el?.remove()}),n.messages=[]},b0=(e,t,n,r=!1)=>{let a=be(e);if(!a)throw Error("Chat history not inited for this key.");let i=Re(a),o=typeof n=="string",s={__type:"UserMessage",content:o?n:n.content,contexts:o?void 0:n.contexts,attachments:o?void 0:n.attachments,role:"user",id:t,hidden:r,ctx:{}};return i.messages.push(s),i.idRef[t]=s,s.el=et(s),s},T0=(e,t,n,r=!1)=>{let a=be(e);if(!a)throw Error("Chat history not inited for this key.");let i=Re(a),o={__type:"ToolResponseMessage",content:n,role:"tool",id:t,hidden:r,ctx:{}};return i.messages.push(o),i.idRef[t]=o,o.el=et(o),o},Oa=(e,t,n=!1)=>{let r=be(e);if(!r)throw Error("Chat history not inited for this key.");let a=Re(r),i={__type:"AssistantMessage",content:void 0,toolCalls:void 0,contentType:"text",role:"assistant",id:t.id,metadata:t.metadata,hidden:n,ctx:{}};return t.__type==="ImageData"?(i.content=t.url,i.contentType="image"):(i.content=t.content,i.toolCalls=t.toolCalls),a.messages.push(i),a.idRef[t.id]=i,i.el=et(i),i},h0=(e,t)=>{let n=be(e);if(!n)throw Error("Chat history not inited for this key.");let r=Re(n);if(!r.idRef[t.id])return Oa(e,t,!1);let a=r.idRef[t.id];return t.__type==="ImageData"?a.content=t.url:a.content=t.content,a.__type==="AssistantMessage"&&a.el&&a.el.update&&a.el.update(a),a},C0=(e,t)=>{let n=be(e);if(!n)throw Error("Chat history not inited for this key.");return Re(n).idRef[t]},R0=(e,t,n)=>{let r=be(e);if(!r)throw Error("Chat history not inited for this key.");return{...Re(r).idRef[t.id],...n}},N0=async e=>{let t=await Wm(e,E.config.user.id);if(t===null){E.modal.chatId=void 0,E.modal.setTitle(void 0),gt();return}let n=be(e);if(!n)throw Error("Chat history not inited for this key.");await Qm(n,t)},y0=async(e,t)=>{let n=be(t);if(!n)throw Error("Chat history not inited for this key.");if(e===void 0){n.chatId=void 0;let r=Re(n);r.idRef={},r.messages=[];return}Aa(),await Et(t,e,E.config.user.id),await Qm(n,e)},Qm=async(e,t)=>{e.chatId=t,E.modal.chatId=t;let n=Re(e);if(n.messages.length>0){E.modal.setTitle(n.title),E.modal.actionButtons.forEach(r=>{r.enable()}),n.messages.forEach(r=>{r.el&&r.el.remove(),r.el=et(r),r.el&&(r.el.classList.remove("new"),E.modal.chatMessages.appendChild(r.el))}),ve("instant"),n.view_only?E.modal.disableSending():E.modal.enableSending();return}Na(!0);try{let r=await $.chat.loadMessages(t);n.title=r.chat.title,n.view_only=r.chat.view_only,E.modal.setTitle(r.chat.title);for(let i of r.messages){if(i.__type==="UserMessage"){let o={init:!0,__type:"UserMessage",content:i.content,contexts:i.contexts,attachments:i.attachments,role:"user",id:i.id,hidden:i.hidden,ctx:{}};n.messages.push(o),n.idRef[i.id]=o,o.el=et(o);continue}if(i.__type==="AssistantMessage"){let o={init:!0,__type:"AssistantMessage",content:void 0,toolCalls:void 0,contentType:"text",role:"assistant",id:i.id,metadata:i.metadata,hidden:i.hidden,ctx:i.ctx,attachments:i.attachments,contexts:i.contexts};i.contentType==="image"?(o.content=i.content,o.contentType="image"):(o.content=i.content,o.toolCalls=i.toolCalls),n.messages.push(o),n.idRef[i.id]=o,o.el=et(o);continue}if(i.__type==="ToolResponseMessage"){let o={init:!0,__type:"ToolResponseMessage",content:i.content,role:"tool",id:i.id,hidden:i.hidden,ctx:{}};n.messages.push(o),n.idRef[i.id]=o,o.el=et(o)}}n.messages.filter(i=>!i.hidden).length===0&>(),ve("instant")}catch(r){$a(r)&&r.statusCode===404&&(er(t),E.modal.chatId=void 0)}Na(!1),n.view_only?E.modal.disableSending():E.modal.enableSending()},ue={config:{},history:{temp:{},chat:{}}},Re=e=>e.chatId?O0(e.chatId):e.persist?Km(e.tempId):Km(e.key),O0=e=>(ue.history.chat[e]||(ue.history.chat[e]={messages:[],idRef:{},view_only:!1}),ue.history.chat[e]),Km=e=>(ue.history.temp[e]||(ue.history.temp[e]={messages:[],idRef:{},view_only:!1}),ue.history.temp[e]),be=e=>ue.config[e]?ue.config[e]:null,tr={init:e=>(ue.config[e.key]||(ue.config[e.key]={key:e.key,persist:e.persist??!1,tempId:window.crypto.randomUUID(),chatId:void 0}),e.persist&&N0(e.key),Aa(),{addUserMessage:(t,n=!1)=>{let r=window.crypto.randomUUID();return b0(e.key,r,t,n)},addAssistantMessage:(t,n=!1)=>Oa(e.key,t,n),addToolCallsMessage:(t,n=!1)=>Oa(e.key,{__type:"ToolsData",id:t.id,content:void 0,toolCalls:t.toolCalls,usage:t.usage,metadata:t.metadata},n),addToolResponseMessage:(t,n,r=!1)=>T0(e.key,t,n,r),updateAssistantMessage:t=>h0(e.key,t),updateMessage:(t,n)=>R0(e.key,t,n),getAssistantMessage:t=>C0(e.key,t),getMessages:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");return Re(t).messages},getMessagesHistory:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");return Re(t).messages.map(r=>({role:r.role,content:r.content,toolCalls:r.toolCalls,contexts:r.contexts,attachments:r.attachments}))},clearHistory:()=>{f0(e.key)},clearHistoryFrom:async t=>{let n=be(e.key);if(!n)throw Error("Chat history not inited for this key.");let r=Re(n),a=r.messages.findIndex(i=>i.id===t);if(a!==-1){for(let i=a;ie.key,getLastMessageId:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");let n=Re(t),r=n.messages.length;return r===0?null:n.messages[r-1].id},switchChatId:t=>{y0(t,e.key)},migrateTempChat:t=>{let n=ue.config[e.key].tempId;ue.config[e.key].chatId=t,ue.history.chat[t]=ue.history.temp[n],delete ue.history.temp[n]},setTitle:t=>{let n=be(e.key);if(!n)throw Error("Chat history not inited for this key.");n.chatId?ue.history.chat[n.chatId].title=t:ue.history.temp[n.tempId].title=t}})};var Ne=e=>O("span","tooltip",e);var $e=O("div","portal");var A0=120,tt={ENTER:"Enter",SPACE:" ",ESCAPE:"Escape",TAB:"Tab",ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",HOME:"Home",END:"End"},W={currentButton:null,currentWrapper:null,currentBodyElement:null,clickHandler:null,keyboardHandler:null,focusTrapHandler:null},nt=(e,t,n)=>{t>=0&&t=0&&n{let r=t.getBoundingClientRect(),a=$e.getBoundingClientRect(),i=r.left-a.left,o=r.bottom-n.top+A0;e.style.left=`${i}px`,e.style.top=`${o}px`},Ia=(e,t,n,r,a)=>{if(W.currentButton===e&&$e.children.length>0){nn(),e.blur();return}nn(),W.currentBodyElement=r||null,W.currentBodyElement&&(W.currentBodyElement.style.pointerEvents="none"),W.currentButton=e,W.currentWrapper=n||null,e.setAttribute("aria-expanded","true"),W.currentWrapper&&W.currentWrapper.classList.add("active"),e.style.pointerEvents="auto",e.style.zIndex="10000";let i=O("div","portal-dropdown",void 0,{role:"menu"});i.setAttribute("aria-labelledby",e.id||"dropdown-button");let o=[];t.forEach(u=>{let d=O("div","portal-dropdown-item",[Y(16,u.icon),O("span",void 0,u.text)],{role:"menuitem",tabIndex:-1,ariaLabel:u.text}),m=()=>{u.onClick(),nn()};d.addEventListener("click",m),d.addEventListener("keydown",p=>{(p.key===tt.ENTER||p.key===tt.SPACE)&&(p.preventDefault(),m())}),d.addEventListener("mouseenter",()=>{o.forEach(p=>{p.classList.remove("focused"),p.setAttribute("tabindex","-1")}),d.classList.add("focused"),d.setAttribute("tabindex","0"),d.focus()}),i.appendChild(d),o.push(d)}),$e.appendChild(i),a&&I0(i,e,a),i.classList.add("show"),o.length>0&&(o[0].setAttribute("tabindex","0"),o[0].classList.add("focused"),requestAnimationFrame(()=>{W.currentButton&&W.currentButton.blur(),o[0].focus()}));let s=u=>{if(!W.currentButton||W.currentButton!==e)return;let d=o.findIndex(m=>m.classList.contains("focused"));switch(u.key){case tt.ESCAPE:u.preventDefault(),u.stopPropagation(),u.stopImmediatePropagation(),nn(!0,e);break;case tt.TAB:if(u.preventDefault(),u.shiftKey)if(d>0)nt(o,d,d-1);else{let m=o.length-1;nt(o,d,m)}else if(d=0?d+1:0;nt(o,d,m)}else nt(o,d,0);break;case tt.ARROW_DOWN:if(u.preventDefault(),d=0?d+1:0;nt(o,d,m)}break;case tt.ARROW_UP:u.preventDefault(),d>0&&nt(o,d,d-1);break;case tt.HOME:u.preventDefault(),d!==0&&nt(o,d,0);break;case tt.END:{u.preventDefault();let m=o.length-1;d!==m&&nt(o,d,m);break}}},l=u=>{u.composedPath().some(p=>p instanceof Element&&i.contains(p))||(u.preventDefault(),u.stopPropagation(),u.stopImmediatePropagation(),nn())},c=u=>{if(!W.currentButton||W.currentButton!==e)return;let d=u.target;if(i.contains(d))return;u.preventDefault(),u.stopPropagation();let m=o.find(p=>p.classList.contains("focused"));if(m){m.focus();return}o.length>0&&(o[0].classList.add("focused"),o[0].setAttribute("tabindex","0"),o[0].focus())};W.clickHandler=l,W.keyboardHandler=s,W.focusTrapHandler=c,document.addEventListener("keydown",s,!0),document.addEventListener("focusin",c,!0),document.addEventListener("click",l,!0),$e.addEventListener("click",l,!0)},nn=(e=!1,t)=>{W.currentBodyElement&&(W.currentBodyElement.style.pointerEvents=""),W.clickHandler&&(document.removeEventListener("click",W.clickHandler,!0),$e.removeEventListener("click",W.clickHandler,!0),W.clickHandler=null),W.keyboardHandler&&(document.removeEventListener("keydown",W.keyboardHandler,!0),W.keyboardHandler=null),W.focusTrapHandler&&(document.removeEventListener("focusin",W.focusTrapHandler,!0),W.focusTrapHandler=null),$e.innerHTML="",W.currentButton&&(W.currentButton.setAttribute("aria-expanded","false"),W.currentButton.style.pointerEvents="",W.currentButton.style.zIndex="",e||W.currentButton.blur());let n=W.currentWrapper;if(W.currentButton=null,W.currentWrapper=null,W.currentBodyElement=null,W.keyboardHandler=null,W.focusTrapHandler=null,e&&t){if(n){let r=n.querySelector(".actions");r&&(r.style.transition="none")}t.focus(),n&&requestAnimationFrame(()=>{n.classList.remove("active");let r=n.querySelector(".actions");r&&(r.offsetHeight,r.style.transition="")});return}n&&n.classList.remove("active")};le.on("chat:new",({eventData:e})=>{gt(),E.modal.chatPublic=e.public,E.modal.chatId=void 0,E.modal.history.switchChatId(void 0),E.modal.setTitle(void 0),E.modal.enableSending(),$m(E.modal.history.getKey(),E.config.user.id),St()});le.on("chat:delete",({eventData:{chatId:e}})=>{E.modal.chatId===e&&(gt(),E.modal.chatId=void 0,E.modal.setTitle(void 0)),er(e),$.chat.deleteChat(e),E.modal.history.clearHistory(),Z.deleteChat(e),Z.sortChats()});var va=async e=>{let t=Z.getChat(e);if(t){if(E.modal.config.type!==t.type){let n=E.modal.modeButtons.find(a=>a.mode===t.type);if(!n)return;E.modal.chatId=e,n.activate();let r=E.modal.config;await Et(`${r.namespace??"modai"}/${r.key}/${t.type}`,e,E.config.user.id),an(t.type),St();return}E.modal.chatId=e,E.modal.history.switchChatId(e),St()}},rn=null,Xm=e=>{if(Z.init(),E.modal.sidebar?.classList.add("open"),rn=e||null,E.modal.sidebar){let t=E.modal.sidebar.sidebar;requestAnimationFrame(()=>{t.focus()})}},St=()=>{E.modal.sidebar?.classList.remove("open"),E.modal.portal&&(E.modal.portal.innerHTML=""),rn&&document.contains(rn)&&rn.focus(),rn=null},Zm=(e,t)=>{let n=Z.getChat(e);n&&(n.pinned=t,Z.sortChats())},Da=async(e,t)=>{let n=Z.getChat(e);n&&(await $.chat.setPublicChat(e,t),n.public=t,Z.markAsStale(),Z.init())},Jm=(e,t)=>{let n=Z.getChat(e);n&&(n.title=t,n.el.setTitle(t),$.chat.setChatTitle(e,t),Z.sortChats())},xa=async e=>{Z.getChat(e)&&(await $.chat.cloneChat(e),Z.markAsStale(),Z.init())};var jm=(e,t)=>{let n=new Map;e.states.forEach((c,u)=>{n.set(c.name,u)});let r=n.get(e.defaultState);if(r===void 0)throw new Error(`Default state "${e.defaultState}" not found in states.`);let a=r,i=(a+1)%e.states.length,o=Y(24,e.states[r].icon),s=Ne(e.states[i].label),l=O("button","",[o,s],{ariaLabel:e.states[i].label});return l.addEventListener("click",()=>{a=(a+1)%e.states.length;let c=(a+1)%e.states.length,u=e.states[a];o.innerHTML=u.icon,s.textContent=e.states[c].label,l.ariaLabel=e.states[c].label,Promise.resolve(t(u))}),l};var ft={ENTER:"Enter",SPACE:" ",ESCAPE:"Escape",TAB:"Tab",ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",HOME:"Home",END:"End"},on=(e,t,n,r,a,i)=>Ye({title:e,content:t,confirmText:n,onConfirm:()=>{r(),i&&requestAnimationFrame(()=>{i.focus(),i.blur()})},onCancel:()=>{i&&requestAnimationFrame(()=>{i.focus(),i.blur()})},onLoad:a}),sn=e=>{e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()})},eE=()=>{let e=O("div","sidebarWrapper",[]),t=O("div","sidebar",[],{role:"dialog",ariaLabel:N("modai.ui.chats_sidebar"),ariaModal:"false",tabIndex:-1});t.addEventListener("click",f=>{f.stopPropagation(),f.stopImmediatePropagation()}),e.addEventListener("click",()=>{St()});let n=Ne(N("modai.ui.close_chats"));n.style.left="80%";let r=Q([Y(24,yi),n],St,void 0,{ariaLabel:N("modai.ui.close_chats")}),a=Q([Y(24,Nt),Ne(N("modai.ui.new_chat"))],()=>{le.emit("chat:new",{public:!0})},void 0,{ariaLabel:N("modai.ui.new_chat")}),i=Q([Y(24,Li),Ne(N("modai.ui.new_private_chat"))],()=>{le.emit("chat:new",{public:!1})},void 0,{ariaLabel:N("modai.ui.new_private_chat")});sn(a),sn(i),a.disable(),E.modal.modalButtons.push(r),E.modal.actionButtons.push(a),E.modal.actionButtons.push(i);let o=jm({states:[{name:"public",icon:Pi,label:"Show Public Chats"},{name:"my",icon:Fi,label:"Show My Chats"},{name:"private",icon:or,label:"Show Private Chats"}],defaultState:"public"},async f=>{Z.setFilter({name:"chatType",value:f.name}),await Z.init()}),s=O("div","buttonsWrapper",[r,a,i]),l=O("div","buttonsWrapper",[o]),c=O("header","header",[s,l]),u=O("div","searchWrapper"),d=O("input",void 0,void 0,{placeholder:N("modai.ui.chat_search")});d.addEventListener("input",async f=>{let I=f.target;m.style.display="";let D=await $.chat.searchChats(I.value);Z.searchChats(D.chats),m.style.display="none"});let m=Y(16,ki);m.classList.add("spinner"),m.style.display="none",u.append(d),u.append(m);let p=O("div","groupedChats",[]);t.append(c),t.append(u),t.append(p),e.append(t);let g=[r,a,i],S=[],R=null,A=()=>{let f=[];return g.forEach(I=>{I.disabled||f.push(I)}),S.forEach(I=>{!I.hasAttribute("disabled")&&I.getAttribute("tabindex")!=="-1"&&f.push(I)}),f},h=f=>{let I=f.target;(A().includes(I)||I===t)&&(R=I)};t.addEventListener("focusin",h);let C=()=>{t.classList.add("no-transitions"),setTimeout(()=>{t.classList.remove("no-transitions")},50)},y=f=>{if(e.classList.contains("open")){if(f.key===ft.TAB){let I=A();if(I.length===0)return;let D=I[0],k=I[I.length-1];if(f.shiftKey){if(C(),R===D){f.preventDefault(),t.focus();return}R===t&&(f.preventDefault(),k.focus());return}C(),R===k&&(f.preventDefault(),t.focus());return}f.key===ft.ESCAPE&&(f.preventDefault(),f.stopPropagation(),f.stopImmediatePropagation(),St())}};return t.addEventListener("keydown",y),e.addChat=f=>{p.append(f),f.querySelectorAll('button, [tabindex="0"]').forEach(D=>{S.push(D)})},e.deleteChats=()=>{p.innerHTML="",S.length=0},e.renderChats=f=>{p.innerHTML="",S.length=0;let I=Object.entries(f);if(I.length===0){let D=O("div","noChatsMessage",N("modai.ui.no_chats"));p.append(D);return}for(let[D,k]of I){let F=k.filter(V=>E.modal.config.availableTypes?.includes(V.type));if(F.length===0)continue;let L=O("div","group",[O("div","title",D),O("div","chats",F.map(V=>V.el))]);p.append(L),F.forEach(V=>{V.el.querySelectorAll('button, [tabindex="0"]').forEach(oe=>{S.push(oe)})})}},e.chats=p,e.sidebar=t,E.modal.sidebar=e,le.on("chat:new",({eventData:f})=>{f.public?(a.disable(),i.enable()):(a.enable(),i.disable())}),le.on("chat:delete",()=>{a.disable(),i.enable()}),le.on("loading",({eventData:f})=>{f.isLoading||!f.hasMessages?(a.disable(),i.disable()):(a.enable(),i.enable()),f.isLoading?r.disable():r.enable()}),e},tE=()=>{let e=Q([Y(24,Ni),Ne(N("modai.ui.open_chats"))],()=>{Xm(e)});e.setAttribute("aria-label",N("modai.ui.open_chats")),sn(e);let t=Q([Y(24,Nt),Ne(N("modai.ui.new_chat"))],()=>{le.emit("chat:new",{public:!0})});return t.setAttribute("aria-label",N("modai.ui.new_chat")),sn(t),t.disable(),E.modal.actionButtons.push(t),E.modal.modalButtons.push(e),le.on("chat:new",({eventData:n})=>{n.public?t.disable():t.enable()}),le.on("chat:delete",()=>{t.disable()}),le.on("loading",({eventData:n})=>{n.isLoading||!n.hasMessages?t.disable():t.enable(),n.isLoading?e.disable():e.enable()}),[e,t]},v0=e=>e.view_only?Y(20,e.type==="text"?Di:xi):e.public?Y(20,e.type==="text"?Yt:Gt):O("div","iconStack",[Y(18,e.type==="text"?Yt:Gt),Y(12,vi)]),nE=e=>{let t=O("div","wrapper",void 0,{tabIndex:-1}),n=O("div","title");n.textContent=e.title;let r=Q([v0(e),n],()=>{va(e.id)},"chat",{title:e.title,ariaLabel:N("modai.ui.select_chat",{title:e.title}),role:"button"});r.addEventListener("keydown",m=>{(m.key===ft.ENTER||m.key===ft.SPACE)&&(m.preventDefault(),va(e.id))});let a=O("div","actions"),i=O("div","gradient"),o=Q([Y(16,Tn),Ne(N("modai.ui.delete_chat"))],()=>{let m=Z.getChat(e.id);m&&Ye({title:N("modai.ui.delete_chat_long"),content:N("modai.ui.delete_chat_desc",{title:m.title}),confirmText:N("modai.ui.delete"),onConfirm:()=>{let p=t,g=p.parentElement,S=g?Array.from(g.querySelectorAll(".wrapper")):[],R=S.indexOf(p),A=null;R>0?A=S[R-1].querySelector("button.chat"):R===0&&S.length>1&&(A=S[R+1].querySelector("button.chat")),le.emit("chat:delete",{chatId:e.id}),requestAnimationFrame(A?()=>{A.focus()}:()=>{E.modal.sidebar?.sidebar.focus()})},onCancel:()=>{requestAnimationFrame(()=>{t.focus(),t.blur()})}})},void 0,{ariaLabel:N("modai.ui.delete_chat_long")}),s=[Y(16,Oi),Ne(N("modai.ui.pin_chat"))],l=[Y(16,Ai),Ne(N("modai.ui.unpin_chat"))],c=Q(e.pinned?l:s,async()=>{let m=Z.getChat(e.id);if(!m)return;let p=!m.pinned;c.disable(),await $.chat.pinChat(e.id,p),c.innerHTML="",c.append(...p?l:s),Zm(e.id,p),c.enable()},void 0,{ariaLabel:e.pinned?N("modai.ui.unpin_chat"):N("modai.ui.pin_chat")}),u=()=>{let m=[];return m.push({icon:it,text:N("modai.ui.clone_chat"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.clone_chat_long"),N("modai.ui.clone_chat_desc",{title:p.title}),N("modai.ui.clone"),()=>{xa(e.id)},void 0,t)}}),e.view_only||(m.push({icon:bn,text:N("modai.ui.rename_chat"),onClick:()=>{let p=Z.getChat(e.id);if(!p)return;let g=O("div","formWrapper"),S=O("input","input",void 0,{value:p.title,type:"text",name:"title"}),R=O("label","label",[S]);g.append(R);let A=on(N("modai.ui.rename_chat_long"),g,N("modai.ui.save"),()=>{let h=S.value.trim();h&&Jm(p.id,h)},()=>{S.focus()},t);S.addEventListener("keypress",h=>{h.key==="Enter"&&A.api.confirmDialog()})}}),e.public?m.push({icon:or,text:N("modai.ui.chat_make_private"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.chat_make_private_long"),N("modai.ui.chat_make_private_desc",{title:p.title}),N("modai.ui.save"),()=>{Da(e.id,!1)},void 0,t)}}):m.push({icon:Mi,text:N("modai.ui.chat_make_public"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.chat_make_public_long"),N("modai.ui.chat_make_public_desc",{title:p.title}),N("modai.ui.save"),()=>{Da(e.id,!0)},void 0,t)}})),m},d=Q([Y(16,wi),Ne(N("modai.ui.more_actions"))],m=>{m.stopPropagation(),m.stopImmediatePropagation(),m.preventDefault(),Ia(d,u(),t,E.modal.sidebar,E.modal.modal.getBoundingClientRect())},void 0,{ariaLabel:N("modai.ui.more_actions"),ariaHasPopup:"true",ariaExpanded:"false"});if(d.addEventListener("keydown",m=>{(m.key===ft.ENTER||m.key===ft.SPACE||m.key===ft.ARROW_DOWN)&&(m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation(),Ia(d,u(),t,E.modal.sidebar,E.modal.modal.getBoundingClientRect()))}),sn(d),!e.view_only)a.append(c),a.append(o),a.append(d),a.append(i);else{let m=Q([Y(16,it),Ne(N("modai.ui.clone_chat"))],()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.clone_chat_long"),N("modai.ui.clone_chat_desc",{title:p.title}),N("modai.ui.clone"),()=>{xa(e.id)},void 0,r)},void 0,{ariaLabel:N("modai.ui.delete_chat_long")});a.append(m)}return t.append(r),t.append(a),t.setTitle=m=>{n.textContent=m},t};var ne={inited:!1,stale:!1,filters:{},chatById:{},chats:{}},Ma=new Date,D0=Ma.toISOString().slice(0,10),aE=new Date(Ma);aE.setDate(Ma.getDate()-1);var x0=aE.toISOString().slice(0,10),iE=e=>{let t=new Date(e.last_message_on),n=t.toISOString().slice(0,10);if(e.pinned)return N("modai.ui.pinned");if(n===D0)return N("modai.ui.today");if(n===x0)return N("modai.ui.yesterday");let r=t.toLocaleString("default",{month:"long"}),a=t.getFullYear();return`${r} ${a}`},M0=()=>{if(!E.modal.sidebar)return;let e=Object.values(ne.chatById).sort((n,r)=>n.pinned!==r.pinned?Number(r.pinned)-Number(n.pinned):r.last_message_on-n.last_message_on),t={};for(let n of e){let r=iE(n);t[r]||(t[r]=[]),t[r].push(ne.chatById[n.id])}ne.chats=t,E.modal.sidebar.renderChats(ne.chats)},rE=()=>{let e={};for(let[t,n]of Object.entries(ne.chats)){let r=n.filter(a=>!(ne.filters.chatIDs&&ne.filters.chatIDs[a.id]===void 0||ne.filters.chatType==="my"&&a.view_only||ne.filters.chatType==="private"&&a.public));r.length>0&&(e[t]=r)}return e},Z={init:async()=>{if(!E.modal.sidebar)return;if(ne.inited&&!ne.stale){E.modal.sidebar.renderChats(rE());return}ne.stale&&(E.modal.sidebar.deleteChats(),ne.chatById={},ne.chats={});let e=await $.chat.loadChats();for(let t of e.chats){let n={...t,el:nE(t)};ne.chatById[n.id]=n;let r=iE(n);ne.chats[r]||(ne.chats[r]=[]),ne.chats[r].push(ne.chatById[n.id])}ne.inited=!0,ne.stale=!1,E.modal.sidebar.renderChats(rE())},sortChats:M0,markAsStale:()=>{ne.stale=!0},getChat:e=>ne.chatById[e],getChats:()=>ne.chats,deleteChat:e=>{delete ne.chatById[e]},searchChats:async e=>{ne.filters.chatIDs=e,await Z.init()},setFilter:e=>{ne.filters[e.name]=e.value},clearFilters:()=>{ne.filters={}}};var La=e=>e.toolCalls!==void 0;var ln=()=>{E.modal.isLoading||(document.removeEventListener("mousemove",e=>qt(e)),document.removeEventListener("mouseup",()=>Vt()),E.modal&&E.modal.remove(),Z.clearFilters(),E.modalOpen=!1)},oE=async(e,t,n,r,a)=>{let i=E.modal.history.addToolCallsMessage(t,!0);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,i,t.content?void 0:t.usage);let o=await $.tools.run({toolCalls:t.toolCalls,agent:n,chatId:E.modal.chatId},a);E.modal.history.addToolResponseMessage(o.id,o.content,!0);let s=await $.prompt.chat({namespace:e.namespace,additionalOptions:r,agent:n,field:e.field||"",messages:E.modal.history.getMessagesHistory()},l=>{(l.__type==="TextDataNoTools"||l.__type==="TextDataMaybeTools")&&E.modal.history.updateAssistantMessage(l)},a);if(s.content){let l=E.modal.history.updateAssistantMessage(s);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,l,s.usage)}La(s)&&await oE(e,s,n,r,E.modal.abortController)},mt=async(e,t)=>{let n=E.modal.config,r=e?e.trim():E.modal.messageInput.value.trim();if(!(!r||E.modal.isLoading)){tn(!0),E.modal.messageInput.value="",E.modal.messageInput.style.height="auto",E.modal.abortController=new AbortController,E.modal.welcomeMessage.style.display="none";try{let a=E.modal.attachments.attachments.length>0?E.modal.attachments.attachments.map(m=>({__type:m.__type,value:m.value})):void 0,i=E.modal.context.contexts.length>0?E.modal.context.contexts.map(m=>({__type:m.__type,name:m.name,renderer:m.renderer,value:m.value})):[];E.modal.attachments.removeAttachments(),E.modal.context.removeContexts();let o=E.modal.history.getLastMessageId(),s=E.modal.history.getMessagesHistory(),l=E.modal.history.addUserMessage({content:r,attachments:a,contexts:i},t),c=E.selectedAgent[`${n.key}/${n.type}`];c&&c.contextProviders&&c.contextProviders.length>0&&(await $.context.get({prompt:r,agent:c.name})).contexts.map(p=>{i.push({__type:"ContextProvider",name:"ContextProvider",renderer:void 0,value:p})}),E.modal.history.updateMessage(l,{contexts:i});let u=Object.entries(E.additionalControls[`${n.key}/${n.type}`]??{}).reduce((m,[p,g])=>(g&&(m[p]=g.value),m),{}),d=null;if(E.config.generateChatTitle&&!o&&(d=$.prompt.chatTitle({message:l.content}).then(m=>(E.modal.setTitle(m.content),m))),n.type==="text"){let m=await $.prompt.chat({persist:n.persist,chatId:E.modal.chatId,chatPublic:E.modal.chatPublic,lastMessageId:o,userMsg:l,agent:c?.name,additionalOptions:u,namespace:n.namespace,field:n.field||"",messages:s},S=>{S.content&&E.modal.history.updateAssistantMessage(S)},E.modal.abortController),p=m.chatId,g=E.modal.chatId||p;if(d!==null&&g&&(d?.then(S=>{S.content&&($.chat.setChatTitle(g,S.content),E.modal.history.setTitle(S.content))}),Z.markAsStale()),!E.modal.chatId&&p&&(Z.markAsStale(),E.modal.chatId=p,Et(E.modal.history.getKey(),p,E.config.user.id),E.modal.history.migrateTempChat(p)),m.content){let S=E.modal.history.updateAssistantMessage(m);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,S,m.usage)}La(m)&&await oE(n,m,c?.name,u,E.modal.abortController)}if(n.type==="image"){let m=await $.prompt.image({persist:n.persist,chatId:E.modal.chatId,chatPublic:E.modal.chatPublic,lastMessageId:o,userMsg:l,additionalOptions:u},E.modal.abortController),p=m.chatId,g=E.modal.chatId||p;d!==null&&g&&(d?.then(R=>{R.content&&($.chat.setChatTitle(g,R.content),E.modal.history.setTitle(R.content))}),Z.markAsStale()),!E.modal.chatId&&p&&(Z.markAsStale(),E.modal.chatId=p,Et(E.modal.history.getKey(),p,E.config.user.id),E.modal.history.migrateTempChat(p));let S=E.modal.history.addAssistantMessage(m);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,S)}E.modal.abortController=void 0}catch(a){if(a instanceof Error){if(a.name==="AbortError")return;tn(!1),We(a.message);return}We(N("modai.error.unknown_error"))}tn(!1),E.modal.messageInput.focus()}},sE=()=>{!E.modal.isLoading||!E.modal.abortController||(E.modal.abortController.abort(),E.modal.abortController=void 0,tn(!1))},an=e=>{let t=E.modal.config;t.type=e,E.modal.history=tr.init({key:`${t.namespace??"modai"}/${t.key}/${t.type}`,persist:t.persist}),E.modal.reloadChatControls(),ve("instant")},lE=()=>{E.modal.history.clearHistory(),E.modal.setTitle(void 0),gt(),L0()},gt=()=>{E.modal.chatMessages.innerHTML="",E.modal.welcomeMessage.style.display="block"},Aa=()=>{E.modal.chatMessages.innerHTML="",E.modal.welcomeMessage.style.display="none"},L0=()=>{E.modal.actionButtons.forEach(e=>{e.disable()})},cn=async(e,t=!1)=>{if(!t&&e instanceof File&&!e.type.startsWith("image/")){We(N("modai.error.only_image_files_are_allowed"));return}if(t){E.modal.attachments.addImageAttachment(e);return}let n=await new Promise((r,a)=>{let i=new FileReader;i.onload=function(o){r(o.target?.result)},i.onerror=function(o){a(o)},i.readAsDataURL(e)});E.modal.attachments.addImageAttachment(n)},ve=(e="smooth")=>{E.modal.chatContainer.scrollTo({top:E.modal.chatContainer.scrollHeight,behavior:e})};var cE=()=>{let e=O("div","chatContainer","",{ariaLive:"polite"}),t=O("div","welcome",[O("p","greeting",E.config.user.name?N("modai.ui.greeting_with_name",{name:E.config.user.name}):N("modai.ui.greeting")),O("p","msg",N("modai.ui.welcome_msg"))]);e.append(t);let n=O("div","history","",{ariaLabel:N("modai.ui.conversation_history")});return e.append(n),E.modal.welcomeMessage=t,E.modal.chatMessages=n,E.modal.chatContainer=e,e};var uE=e=>{let t=e.offsetWidth,n=e.offsetHeight,r=window.innerWidth,a=window.innerHeight,i=r/2-t/2,o=a/2-n/2;e.style.left=`${i}px`,e.style.top=`${o}px`},dE=e=>{let t=Q(Y(24,gi),()=>{ln()},"",{ariaLabel:N("modai.ui.close_dialog")}),n=E.modal.modal.style.width==="90%",r=O("div","buttonsWrapper",[Q(Y(24,n?ir:ar),l=>{let c=l.currentTarget;if(E.modal.modal.style.width==="90%"){E.modal.modal.style.width="",E.modal.modal.style.height="",E.modal.modal.style.transform="none",kt(),c.ariaLabel=N("modai.ui.maximize_dialog"),c.innerHTML="",c.appendChild(Y(24,ar)),uE(E.modal.modal);return}E.modal.modal.style.width="90%",E.modal.modal.style.height="90%",E.modal.modal.style.transform="none",kt(),c.ariaLabel=N("modai.ui.minimize_dialog"),c.innerHTML="",c.appendChild(Y(24,ir)),uE(E.modal.modal)},"",{ariaLabel:n?N("modai.ui.minimize_dialog"):N("modai.ui.maximize_dialog")}),t]),a=O("div","buttonsWrapper");e.persist&&a.append(...tE());let i=O("h1");i.textContent=N("modai.ui.modai_assistant");let o=O("header","header cursor-move",[a,i,r]);o.addEventListener("mousedown",l=>{Bi(l),document.addEventListener("mousemove",qt),document.addEventListener("mouseup",()=>{Vt(),document.removeEventListener("mousemove",qt),document.removeEventListener("mouseup",Vt),kt()})});let s=l=>{if(l.key==="Escape"){if(l.preventDefault(),E.modal.sidebar?.classList.contains("open")){E.modal.sidebar.classList.remove("open");return}ln(),document.removeEventListener("keydown",s)}};return document.addEventListener("keydown",s),le.on("loading",({eventData:l})=>{l.isLoading?t.disable():t.enable()}),E.modal.closeModalBtn=t,E.modal.setTitle=l=>{i.textContent=l||N("modai.ui.modai_assistant")},o};var _E=()=>{let e=O("div","attachmentsWrapper");return e.visible=!1,e.attachments=[],e.show=()=>{e.visible||(e.visible=!0,ae(e,"attachmentsWrapper visible"))},e.hide=()=>{e.visible&&(e.visible=!1,ae(e,"attachmentsWrapper"))},e.addImageAttachment=t=>{w0(t)},e.removeAttachments=()=>{E.modal.attachments.attachments.forEach(t=>{E.modal.attachments.removeAttachment(t)})},e.addAttachment=t=>{e.show(),e.appendChild(t),e.attachments.push(t)},e.removeAttachment=t=>{let n=e.attachments.indexOf(t);n!==-1&&(t.remove(),e.attachments.splice(n,1),e.attachments.length===0&&e.hide())},E.modal.attachments=e,e},w0=e=>{E.modal.attachments.attachments.length>0&&E.modal.attachments.removeAttachments();let t=Q([O("img",void 0,"",{src:e}),O("div","trigger","\xD7",{tabIndex:-1})],()=>{E.modal.attachments.removeAttachment(t)},"attachment imagePreview");t.__type="image",t.value=e,E.modal.attachments.addAttachment(t)};var k0={selection:e=>{let t=O("span","tooltip",e.value,{tabIndex:-1}),n=Q([Y(24,hn),t,O("div","trigger","\xD7",{tabIndex:-1})],()=>{E.modal.context.removeContext(e)},"context");return n.addEventListener("keydown",r=>{if(r.key==="ArrowUp"||r.key==="ArrowDown"){r.preventDefault();let a=30;t.scrollTop+=r.key==="ArrowDown"?a:-a}}),n}},pE=()=>{let e=O("div","contextsWrapper");return e.visible=!1,e.contexts=[],e.show=()=>{e.visible||(e.visible=!0,ae(e,"contextsWrapper visible"))},e.hide=()=>{e.visible&&(e.visible=!1,ae(e,"contextsWrapper"))},e.removeContexts=()=>{E.modal.context.contexts.forEach(t=>{E.modal.context.removeContext(t)})},e.addContexts=t=>{t.forEach(n=>{E.modal.context.addContext(n)})},e.addContext=t=>{let n=e.contexts.push(t)-1,r=k0[t?.renderer||""];if(r){e.show();let a=r(t);e.contexts[n].el=a,e.appendChild(a)}},e.removeContext=t=>{let n=e.contexts.indexOf(t);n!==-1&&(t.el?.remove(),e.contexts.splice(n,1),(e.contexts.length===0||e.contexts.every(r=>r.el===void 0))&&e.hide())},E.modal.context=e,e};function mE(e,t,n,r){let a=new Map,i=new Map,o=new Map,s=!1,l=-1,c=[],u=null,d=O("button","dropdown-button",[r.icon&&Y(24,r.icon),r.selectText&&O("span",void 0,r.selectText),r.tooltip&&O("span","tooltip",r.tooltip)],{ariaHasPopup:"true",ariaExpanded:"false"});d.addEventListener("click",S),d.addEventListener("keydown",f);let m=O("div","dropdown-menu",g(e),{role:"menu"}),p=O("div","nestedSelectContainer",[d,m]);p.enable=()=>{d.disabled=!1},p.disable=()=>{d.disabled=!0};function g(M,U,v=0){return M.map(x=>{if(x.children&&x.children.length>0){let G=O("div","submenu",g(x.children,x,v+1),{role:"menu"});G.style.zIndex=String(1001+v);let q=O("div","dropdown-item has-submenu",[O("div","submenuTrigger",[O("span",void 0,x.name),Y(16,Ci)]),G],{tabIndex:-1,ariaHasPopup:"true",ariaExpanded:"false"});return q.addEventListener("click",K=>{K.stopPropagation(),K.stopImmediatePropagation(),K.preventDefault()}),q.addEventListener("keydown",K=>I(K,x)),a.set(x.id,x),o.set(x.id,q),U&&i.set(x.id,U),q}let w=O("div","dropdown-item",x.name,{role:"menuitem",tabIndex:-1});return w.addEventListener("click",()=>{ie(x)}),w.addEventListener("keydown",G=>I(G,x)),a.set(x.id,x),o.set(x.id,w),U&&i.set(x.id,U),w})}function S(M){M.preventDefault(),M.stopPropagation(),s?A():R()}function R(){if(s=!0,m.classList.add("show"),d.classList.add("open"),d.setAttribute("aria-expanded","true"),y(),l=-1,r.highlightSelectedValue===!0&&(o.values().forEach(M=>{M.classList.remove("selected")}),u)){let M=o.get(u.id);if(M){M.classList.add("selected");let U=i.get(u.id);for(;U;){let v=o.get(U.id);v&&v.classList.add("selected"),U=i.get(U.id)}}}document.addEventListener("click",oe,!0)}function A(){s&&(s=!1,m.classList.remove("show"),d.classList.remove("open"),d.setAttribute("aria-expanded","false"),h(),C(),d.focus(),l=-1,document.removeEventListener("click",oe,!0))}function h(){o.values().forEach(M=>{M.classList.remove("active","keyboard-active"),M.setAttribute("aria-expanded","false")})}function C(){c.forEach(M=>{M.classList.remove("active","keyboard-active")})}function y(M){let U=[];if(c=[],!M)l=-1,U=e;else{let v=a.get(M);v?U=v.children??[]:U=e}U.forEach(v=>{let x=o.get(v.id);x&&c.push(x)})}function f(M){switch(M.key){case"Enter":case" ":case"ArrowDown":M.preventDefault(),s||R(),y(),c.length>0&&L(0);break;case"ArrowUp":M.preventDefault(),s||R(),y(),c.length>0&&L(c.length-1);break;case"Escape":s&&(M.stopImmediatePropagation(),M.stopPropagation(),M.preventDefault(),A());break}}function I(M,U){switch(M.stopPropagation(),M.stopImmediatePropagation(),M.key){case"Enter":case" ":M.preventDefault(),"value"in U?ie(U):D(U);break;case"ArrowDown":M.preventDefault(),k();break;case"ArrowUp":M.preventDefault(),F();break;case"ArrowRight":M.preventDefault(),"value"in U||D(U);break;case"ArrowLeft":M.preventDefault(),V(U);break;case"Escape":s&&(M.preventDefault(),A());break}}function D(M){if(!M.children||M.children.length===0)return;let U=o.get(M.id);U&&(U.classList.add("keyboard-active"),y(M.id),L(0))}function k(){l0?L(l-1):L(c.length-1)}function L(M){C(),l=M,c[M]&&(c[M].focus(),c[M].classList.add("active"))}function V(M){let U=i.get(M.id);if(!U)return;let v=o.get(U.id);if(!v)return;let x=i.get(U.id);v.classList.remove("keyboard-active"),y(x?.id);let w=c.indexOf(v);L(w>=0?w:0)}function ie(M){if(r.showSelectedValue===!0){let U=d.querySelector("span");U&&(U.textContent=M.name)}A(),d.focus(),u=M,n(M)}function oe(M){M.composedPath().includes(p)||A()}return p}var wa=(e,t,n,r)=>{let a=r?.idProperty??"id",i=r?.displayProperty??"name",o={idProperty:a,displayProperty:i,noSelectionText:r?.noSelectionText??"",selectText:r?.selectText??N("modai.ui.select_item"),icon:r?.icon,iconSize:r?.iconSize??24,nullOptionDisplayText:r?.nullOptionDisplayText,tooltip:r?.tooltip??N("modai.ui.select_item")},s=O("div","selectContainer"),l=null;t!=null&&(l=e[t]||null);let c=!1,u=-1,d=[null,...Object.values(e)],m=O("button","selectButton",[],{type:"button",ariaHasPopup:"listbox",ariaExpanded:"false",ariaLabel:o.selectText});s.enable=()=>{m.disabled=!1},s.disable=()=>{m.disabled=!0};let p=()=>{let f=[],I;if(o.icon&&f.push(Y(o.iconSize,o.icon)),l){let D=String(l[o.displayProperty]);f.push(O("span","selectedItemName",D)),I=D}else o.noSelectionText&&f.push(O("span","selectedItemName",o.noSelectionText)),I=o.noSelectionText||N("modai.ui.no_selection");m.innerHTML="",m.append(...f),m.append(O("span","tooltip",o.tooltip)),m.setAttribute("aria-label",I)},g=O("ul","selectDropdown",[],{role:"listbox",tabIndex:-1,ariaHidden:"true"});g.classList.add("hidden");let S=d.map((f,I)=>{let D;f===null?D=o.nullOptionDisplayText??o.noSelectionText:D=String(f[o.displayProperty]);let k=f&&l&&f[o.idProperty]===l[o.idProperty]||!f&&!l,F=O("li","selectOption",D,{role:"option",id:`select-option-${I}`,ariaSelected:k?"true":"false",tabIndex:-1});return F.addEventListener("click",()=>{h(f),A()}),F.addEventListener("keydown",L=>{if(c)switch(L.key){case"ArrowDown":L.preventDefault(),C((I+1)%S.length);break;case"ArrowUp":L.preventDefault(),C((I-1+S.length)%S.length);break;case"Enter":case" ":L.preventDefault(),h(f),A();break;case"Escape":L.preventDefault(),L.stopPropagation(),A();break;case"Tab":A();break;case"Home":L.preventDefault(),C(0);break;case"End":L.preventDefault(),C(S.length-1);break;default:break}}),F});g.append(...S);let R=()=>{c||(c=!0,g.classList.remove("hidden"),g.setAttribute("aria-hidden","false"),m.setAttribute("aria-expanded","true"),u=d.findIndex(f=>f&&l&&f[o.idProperty]===l[o.idProperty]||!f&&!l),u===-1&&(u=0),C(u),document.addEventListener("click",y,!0))},A=()=>{c&&(c=!1,g.classList.add("hidden"),g.setAttribute("aria-hidden","true"),m.setAttribute("aria-expanded","false"),m.focus(),u=-1,document.removeEventListener("click",y,!0))},h=f=>{l=f,p(),S.forEach((I,D)=>{let k=d[D],F=k&&l&&k[o.idProperty]===l[o.idProperty]||!k&&!l;I.setAttribute("aria-selected",F?"true":"false")}),n(l)},C=f=>{if(f<0||f>=S.length)return;S.forEach(D=>{D.classList.remove("focused"),D.tabIndex=-1});let I=S[f];I.tabIndex=0,I.classList.add("focused"),I.scrollIntoView({block:"nearest"}),I.focus(),g.setAttribute("aria-activedescendant",I.id),u=f},y=f=>{f.composedPath().includes(s)||A()};return m.addEventListener("click",f=>{if(f.preventDefault(),f.stopPropagation(),f.stopImmediatePropagation(),c){A();return}R()}),m.addEventListener("keydown",f=>{switch(f.key){case"Enter":case" ":case"ArrowDown":f.preventDefault(),R();break;case"ArrowUp":f.preventDefault(),R(),C(S.length-1);break;case"Escape":c&&(f.stopImmediatePropagation(),f.stopPropagation(),f.preventDefault(),A());break}}),p(),s.append(m,g),s};var EE=e=>{let t=O("div","inputContainer"),n=O("div","inputSection"),r=O("div","inputWrapper"),a=O("textarea","","",{placeholder:N("modai.ui.prompt_placeholder"),rows:1,ariaLabel:N("modai.ui.prompt_label")});a.setValue=h=>{a.value=h,a.focus(),a.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0}))};let i=O("div","loadingDots",[O("div","loadingDot"),O("div","loadingDot"),O("div","loadingDot")],{ariaLabel:N("modai.ui.loading_response")}),o=Q(Y(20,pi),()=>mt(),"",{ariaLabel:N("modai.ui.send_message")});o.disable(),o.enable=()=>{o.disabled=!1,ae(o,"active")},o.disable=()=>{o.disabled=!0,ae(o,"")};let s=Q(Y(20,mi),()=>sE(),"",{ariaLabel:N("modai.ui.stop_generating_response")});s.disable(),s.enable=()=>{s.disabled=!1,ae(s,"active sending")},s.disable=()=>{s.disabled=!0,ae(s,"")},r.append(a,i,o,s);let l=O("div","inputAddons",[_E(),pE()]);n.append(l,r);let c=[];if(e.availableTypes?.includes("text")){let h=Q([Y(24,Yt),O("span","tooltip",N("modai.ui.text_mode"))],()=>{e.type!=="text"&&(an("text"),c.forEach(C=>{ae(C,"")}),ae(h,"active"))},"",{ariaLabel:N("modai.ui.text_mode")});h.activate=()=>{c.forEach(C=>{ae(C,"")}),ae(h,"active")},h.mode="text",e.type==="text"&&ae(h,"active"),c.push(h)}if(e.availableTypes?.includes("image")){let h=Q([Y(24,Gt),O("span","tooltip",N("modai.ui.image_mode"))],()=>{e.type!=="image"&&(an("image"),c.forEach(C=>{ae(C,"")}),ae(h,"active"))},"",{ariaLabel:N("modai.ui.image_mode")});h.activate=()=>{c.forEach(C=>{ae(C,"")}),ae(h,"active")},h.mode="image",e.type==="image"&&ae(h,"active"),c.push(h)}let u=[],d=O("div","options",[],{ariaLabel:N("modai.ui.options_toolbar"),role:"toolbar"}),m=O("div","optionsLeft"),p=O("div","optionsRight");d.append(m,p);let g;e.persist||(g=Q([Y(24,Tn),O("span","tooltip",N("modai.ui.clear_chat"))],()=>{lE()},"",{ariaLabel:N("modai.ui.clear_chat")}),g.disable(),p.append(g));let S=[],R=()=>{if(S=[],m.innerHTML="",u=[],e.type==="text"&&Object.keys(E.config.availableAgents).length>0){let C=wa(E.config.availableAgents,E.selectedAgent[`${e.key}/${e.type}`]?.id,y=>{E.selectedAgent[`${e.key}/${e.type}`]=y??void 0},{idProperty:"id",displayProperty:"name",noSelectionText:N("modai.ui.agents"),selectText:N("modai.ui.select_agent"),nullOptionDisplayText:N("modai.ui.no_agent"),icon:Ti,tooltip:N("modai.ui.select_agent")});u.push(C)}E.config.chatAdditionalControls[e.type]&&E.config.chatAdditionalControls[e.type].forEach(C=>{u.push(wa(Object.entries(C.values).reduce((y,[f,I])=>(y[f]={name:I,value:f},y),{}),E.additionalControls[`${e.key}/${e.type}`]?.[C.name]?.value,y=>{let f=`${e.key}/${e.type}`;E.additionalControls[f]||(E.additionalControls[f]={}),y?E.additionalControls[f][C.name]=y:delete E.additionalControls[f][C.name]},{idProperty:"value",displayProperty:"name",noSelectionText:C.label,selectText:C.label,nullOptionDisplayText:`Default ${C.label}`,icon:C.icon,tooltip:`Select ${C.label}`}))});let h=E.config.promptLibrary[e.type];if(h&&h.length>0){let C=mE(h,void 0,y=>{"value"in y&&a.setValue(y.value)},{icon:Ri,tooltip:N("modai.ui.prompt_library"),showSelectedValue:!1,highlightSelectedValue:!1});S.push(C)}S.push(...u),m.append(...c,...S),E.modal.controlButtons=S};R();let A=Hm();return t.append(A),t.append(n,d),a.addEventListener("keydown",h=>{if(h.key==="Enter"){if(h.shiftKey)return;h.preventDefault(),mt()}}),a.addEventListener("input",function(){this.style.height="auto",this.style.height=this.scrollHeight+"px",this.value.trim()!==""?(o.disabled=!1,ae(o,"active")):(o.disabled=!0,ae(o,""))}),n.addEventListener("dragover",h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection dragOver")}),n.addEventListener("dragleave",h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection")}),n.addEventListener("drop",async h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection");let C=null,y=null,f=h.dataTransfer;if(!f)return;let I=f.files;if(I?.length>0){let D=I[0];D.type.startsWith("image/")&&(C=D)}if(!C){let D=f.getData("text/uri-list");D&&(y=D)}if(C){await cn(C),a.focus();return}if(y){let D=new URL(window.location.href);if(!y.startsWith(D.origin)){await cn(y,!0),a.focus();return}try{let F=await fetch(y);if(F.ok){let L=await F.blob();if(L.type.startsWith("image/")){let V=new File([L],"image.png",{type:L.type});await cn(V)}}}catch{We(N("modai.error.failed_to_fetch_image"))}a.focus();return}We(N("modai.error.only_image_files_are_allowed")),a.focus()}),a.addEventListener("paste",async h=>{let C=h.clipboardData?.items;if(C){for(let y=0;y{o.disable(),a.disabled=h.isLoading,h.isLoading?(i.style.display="flex",h.isPreloading||s.enable()):(i.style.display="none",h.isPreloading||s.disable()),[...c,...S].forEach(C=>h.isLoading?C.disable():C.enable()),g&&(h.isLoading||!h.hasMessages?g.disable():g.enable())}),E.modal.messageInput=a,E.modal.modeButtons=c,E.modal.reloadChatControls=R,E.modal.enableSending=()=>{a.disabled=!1,a.placeholder=N("modai.ui.prompt_placeholder"),E.modal.controlButtons.forEach(h=>h.enable())},E.modal.disableSending=()=>{a.disabled=!0,a.placeholder=N("modai.ui.read_only_chat"),E.modal.controlButtons.forEach(h=>h.disable())},t};var gE=()=>{let e=!1,t=null,n=null,r=null,a=null,i=!1,o=!1,s=O("div"),l=[O("div","resize-handle bottom-right"),O("div","resize-handle bottom-left"),O("div","resize-handle top-right"),O("div","resize-handle top-left")];s.append(...l),l.forEach(p=>{p.addEventListener("pointerdown",c)});function c(p){if(e||p.button!==0)return;e=!0,a=p.currentTarget;let g=E.modal.modal.getBoundingClientRect();r={width:g.width,height:g.height,x:g.left,y:g.top,mouseX:p.clientX,mouseY:p.clientY};let S=(a?.className||"").toString();i=S.includes("left"),o=S.includes("top");let R;i===o?R="nwse-resize":R="nesw-resize",document.body.style.cursor=R;try{a.setPointerCapture(p.pointerId)}catch{}document.addEventListener("pointermove",u,{passive:!1}),document.addEventListener("pointerup",m),p.preventDefault(),p.stopPropagation()}function u(p){!e||!r||(p.preventDefault(),n={clientX:p.clientX,clientY:p.clientY},t||(t=requestAnimationFrame(d)))}function d(){if(!n||!e||!r){t=null;return}let p=n.clientX-r.mouseX,g=n.clientY-r.mouseY,S=468,R=500,A=r.x+r.width,h=r.y+r.height,C=(F,L,V)=>Math.max(L,Math.min(V,F)),y=r.x,f=r.y,I,D;if(i)y=C(r.x+p,0,A-S),I=A-y;else{let F=window.innerWidth-r.x;I=C(r.width+p,S,F)}if(o)f=C(r.y+g,0,h-R),D=h-f;else{let F=window.innerHeight-r.y;D=C(r.height+g,R,F)}let k=E.modal.modal;i&&(k.style.left=y+"px"),o&&(k.style.top=f+"px"),k.style.width=I+"px",k.style.height=D+"px",t=null,n=null}function m(p){if(e){p.preventDefault(),p.stopPropagation(),e=!1,document.body.style.cursor="",t&&(cancelAnimationFrame(t),t=null),r&&(n={clientX:p.clientX,clientY:p.clientY},d()),r=null;try{a?.releasePointerCapture(p.pointerId)}catch{}document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",m),a=null,i=!1,o=!1}}return s};var P0=fn(kt,300),SE=e=>{let{shadow:t,shadowRoot:n}=Qe(!0,()=>{ve("instant"),t.messageInput.focus()}),r=O("div","modai--root chat-modal","",{ariaLabel:N("modai.ui.modai_assistant_chat_dialog")}),a=ya();a.position&&(r.style.width=a.position.width??"",r.style.height=a.position.height??"",r.style.top=a.position.top??"",r.style.left=a.position.left??"",r.style.transform="none"),new ResizeObserver(()=>{P0();let s=E.modal.chatMessages.lastElementChild;s&&s.syncHeight?.()}).observe(r),t.modal=r,E.modal=t,E.modal.actionButtons=[],E.modal.modalButtons=[],e.persist&&r.append(eE()),r.append(dE(e)),r.append(cE()),r.append(EE(e));let o=O("div","disclaimer",N("modai.ui.disclaimer"));return r.append(o),r.append(gE()),n.appendChild(r),n.appendChild($e),document.body.append(t),t.isDragging=!1,t.isLoading=!1,t.abortController=void 0,t.offsetX=0,t.offsetY=0,t.history=tr.init({key:`${e.namespace??"modai"}/${e.key}/${e.type}`,persist:e.persist}),t};var F0=["text","image"],ka=e=>{if(E.modalOpen)return;if(e.persist!==!1&&(e.persist=!0),e.context&&(e.withContexts||(e.withContexts=[]),e.withContexts.push({__type:"selection",name:"Selection",renderer:"selection",value:e.context}),e.context=void 0),!e.key){alert(N("modai.error.key_required"));return}if(e.type||(e.type="text"),!e.type){alert(N("modai.error.type_required"));return}if(!Pa(e))return;let n=SE(e);return n.api={sendMessage:async(r,a)=>{await mt(r,a)},closeModal:()=>{ln()}},E.modal.config=e,e.withContexts&&E.modal.context.addContexts(e.withContexts),E.modalOpen=!0,n},Pa=e=>!(!we(["modai_client"])||!we(["modai_client_chat_image"])&&!we(["modai_client_chat_text"])||(e.availableTypes||(e.availableTypes=[e.type]),e.availableTypes=e.availableTypes.filter(t=>F0.includes(t)).filter(t=>we([t==="text"?"modai_client_chat_text":"modai_client_chat_image"])),e.availableTypes.length>0&&!e.availableTypes.includes(e.type)&&(e.type=e.availableTypes[0]),e.availableTypes.length===0||!e.availableTypes.includes(e.type)));var ce={createLoadingOverlay:Ht,localChat:Object.assign(ka,{createModal:ka,verifyPermissions:Pa}),generateButton:Ui};var fE=()=>{let e={key:"_global",persist:!0,availableTypes:["text","image"],type:"text"};if(!ce.localChat.verifyPermissions(e))return;let t=O("li"),{shadow:n,shadowRoot:r}=Qe(),a=Q(Y(24,hi),()=>{ce.localChat.createModal(e)},"global-button",{title:N("modai.ui.modai_assistant")});r.appendChild(a),t.appendChild(n);let i=document.getElementById("modx-leftbar-trigger");i?.parentNode?.insertBefore(t,i)};var bE=()=>{Ext.override(MODx.tree.Directory,{_modAIOriginals:{initComponent:MODx.tree.Directory.prototype.initComponent},initComponent:function(){this.on("afterrender",()=>{let e=this.tbar.dom.querySelector(".x-toolbar-left-row");if(!e)return;let t=document.createElement("td");t.classList.add("x-toolbar-cell");let{shadow:n}=ce.generateButton.rawButton(()=>{let r=this.cm&&this.cm.activeNode?this.cm.activeNode:!1,a=r&&r.attributes.type=="dir"?r.attributes.pathRelative:"/",i=(a.endsWith("/")?a:a+"/")+"{hash}.png";ce.localChat.createModal({key:`media_browser/${this.config.id}`,type:"image",image:{mediaSource:this.getSource(),path:i},imageActions:{download:(o,s)=>{this.fireEvent("afterUpload"),s.api.closeModal()}}})},{iconSize:16});t.appendChild(n),e.appendChild(t)}),this._modAIOriginals.initComponent.call(this)}})};var U0=(e,t)=>{let n=Ext.getCmp(e.firstElementChild?.id),r=n.el.dom.parentElement?.parentElement?.parentElement?.querySelector("label");if(!r)return;ce.generateButton.localChat({targetEl:r,key:`resource/${MODx.request.id}/${t}`,field:t,type:"image",resource:MODx.request.id,image:{mediaSource:n.imageBrowser.source},imageActions:{insert:(i,o)=>{n.imageBrowser.setValue(i.ctx.url),n.onImageChange(i.ctx.url),o.api.closeModal()}}});let a=ce.generateButton.vision({targetEl:n.altTextField.el.dom,input:n.altTextField.items.items[0].el.dom,field:t,image:n.imagePreview.el.dom,onUpdate:i=>{n.altTextField.items.items[0].setValue(i.content),n.image.altTag=i.content,n.updateValue()}});a&&(a.style.marginTop="6px"),n.altTextField.el.dom.style.display="flex",n.altTextField.el.dom.style.justifyItems="center",n.altTextField.el.dom.style.alignItems="center"},B0=()=>{let t=Ext.getCmp("modx-resource-content").el.dom.querySelector("label");t&&ce.generateButton.localChat({targetEl:t,key:`resource/${MODx.request.id}/res.content`,field:"res.content",type:"text",availableTypes:["text","image"],resource:MODx.request.id})},G0=e=>{let t=Ext.getCmp("modx-panel-resource").getForm();for(let[n,r]of e.tvs||[]){let a=Ext.get(`tv${n}-tr`);if(!a)continue;let i=t.findField(`tv${n}`),o=`tv.${r}`;if(!i){let s=a.dom.querySelector(".imageplus-panel-input");s&&U0(s,o);continue}if(i.xtype==="textfield"||i.xtype==="textarea"){let s=MODx.config[`modai.tv.${r}.text.prompt`],l=a.dom.querySelector("label");if(!l)return;s?ce.generateButton.forcedText({targetEl:l,input:i.el.dom,resourceId:MODx.request.id,field:o,initialValue:i.getValue(),onChange:(c,u)=>{let d=i.getValue();i.setValue(c.value),i.fireEvent("change",i,c.value,d),u&&(i.el.dom.scrollTop=i.el.dom.scrollHeight)}}):ce.generateButton.localChat({targetEl:l,key:`resource/${MODx.request.id}/${o}`,field:o,type:"text",availableTypes:["text","image"],resource:MODx.request.id})}if(i.xtype==="modx-panel-tv-image"||i.xtype==="imagecropper-combo-browser"){let s=a.dom.querySelector("label");if(!s)return;ce.generateButton.localChat({targetEl:s,key:`resource/${MODx.request.id}/${o}`,field:o,type:"image",resource:MODx.request.id,image:{mediaSource:i.source},imageActions:{insert:(l,c)=>{let u={fullRelativeUrl:l.ctx.fullUrl,relativeUrl:l.ctx.url,url:l.ctx.url};i.xtype==="imagecropper-combo-browser"?i.onSelectImage(u.fullRelativeUrl,i.onTrigger1Click,`tv${n}`):i.items.items[1].fireEvent("select",u),i.fireEvent("select",u),c.api.closeModal()}}})}}},Y0=e=>{let t={pagetitle:["modx-resource-pagetitle"],longtitle:["modx-resource-longtitle","seosuite-longtitle"],introtext:["modx-resource-introtext"],description:["modx-resource-description","seosuite-description"],content:["modx-resource-content"]};for(let n of e.resourceFields||[])if(t[n]){if(n==="content"){B0();continue}t[n].forEach(r=>{let a=Ext.getCmp(r);a&&ce.generateButton.forcedText({targetEl:a.label,resourceId:MODx.request.id,field:`res.${n}`,input:a.el.dom,initialValue:a.getValue(),onChange:(i,o)=>{let s=a.getValue();a.setValue(i.value),a.fireEvent("change",a,i.value,s),o&&(a.el.dom.scrollTop=a.el.dom.scrollHeight)}})})}},TE=e=>{Y0(e),G0(e)};var hE={initOnResource:TE,initGlobalButton:fE,initOnMediaBrowser:bE};var H0=e=>(E.config=e,{executor:$,ui:ce,lng:N,mgr:hE,checkPermissions:we}),q0=(e,t,n)=>{ja(e,t),ii(e,n)};return FE(V0);})(); +`,qm=(e,t=[])=>{let n=O("div");n.updateContent=s=>{r.innerHTML=Rt(s),en()};let r=O("div");typeof e=="string"?r.innerHTML=Rt(e):r.append(e);let a=n.attachShadow({mode:"open"}),i=O("style");i.textContent=_0,a.appendChild(i),t.forEach(s=>{a.appendChild(O("link",void 0,"",{rel:"stylesheet",type:"text/css",href:s}))});let o=O("link",void 0,"",{rel:"stylesheet",type:"text/css",href:`${E.config.assetsURL}css/highlight.css`});return a.appendChild(o),a.append(r),n};var p0={selection:e=>{let t=O("span","tooltip",e.value,{tabIndex:-1}),n=O("div","context",[Y(24,hn),t],{tabIndex:0});return n.addEventListener("keydown",r=>{if(r.key==="ArrowUp"||r.key==="ArrowDown"){r.preventDefault();let a=30;t.scrollTop+=r.key==="ArrowDown"?a:-a}}),n}},m0={image:e=>O("div","attachment imagePreview",O("img",void 0,void 0,{src:e.value}))},E0=e=>{let t=O("div",`message-wrapper user ${e.init?"":"new"}`),n=O("div","message user"),r=e.content,a=O("div");a.innerHTML=Rt(r),n.appendChild(a);let i=O("div","attachmentsWrapper"),o=O("div","contextsWrapper");for(let u of e.attachments??[]){let d=m0[u.__type];d&&(i.appendChild(d(u)),i.classList.contains("visible")||i.classList.add("visible"))}for(let u of e.contexts??[]){let d=u.renderer&&p0[u.renderer];d&&(o.appendChild(d(u)),o.classList.contains("visible")||o.classList.add("visible"))}let s=O("div","inputAddons",[i,o]);n.appendChild(s);let l=O("div","actions");l.appendChild(ze({message:e,disabled:E.modal.isLoading,disableCompletedState:!0,icon:_i,label:N("modai.ui.retry_message"),onClick:u=>{Ye({title:N("modai.ui.confirm_retry_message"),content:N("modai.ui.confirm_edit_retry_message"),confirmText:N("modai.ui.retry_message"),onConfirm:async()=>{E.modal.messageInput.setValue(u.content),u.contexts&&u.contexts.forEach(d=>{E.modal.context.addContext(d)}),u.attachments&&u.attachments.forEach(d=>{d.__type==="image"&&E.modal.attachments.addImageAttachment(d.value)}),await E.modal.history.clearHistoryFrom(u.id),E.modal.history.getMessages().length===0&&(E.modal.welcomeMessage.style.display="block"),mt()}})}})),l.appendChild(ze({message:e,disabled:E.modal.isLoading,disableCompletedState:!0,icon:bn,label:N("modai.ui.edit"),onClick:u=>{Ye({title:N("modai.ui.confirm_edit"),content:N("modai.ui.confirm_edit_content"),confirmText:N("modai.ui.edit_message"),onConfirm:()=>{E.modal.messageInput.setValue(u.content),u.contexts&&u.contexts.forEach(d=>{E.modal.context.addContext(d)}),u.attachments&&u.attachments.forEach(d=>{d.__type==="image"&&E.modal.attachments.addImageAttachment(d.value)}),E.modal.history.clearHistoryFrom(u.id),E.modal.history.getMessages().length===0&&(E.modal.welcomeMessage.style.display="block")}})}})),l.appendChild(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),completedText:N("modai.ui.copied"),onClick:Ra})),n.appendChild(l),t.update=u=>{let d=Array.isArray(u.content)?u.content[0].value:u.content;a.innerHTML=Rt(d)},t.appendChild(n);let c=E.modal.chatMessages.lastElementChild;return E.modal.chatMessages.appendChild(t),c&&c.classList.remove("new"),t.syncHeight=()=>{let u=n.clientHeight,d=u<100?-10:-1*(u-62);t.style.setProperty("--user-msg-height",`${E.modal.chatContainer.clientHeight-d-50}px`)},t.syncHeight?.(),t},We=e=>{E.modal.welcomeMessage.style.display="none";let t=O("div","message-wrapper error new"),n=O("div","message error");n.appendChild(Y(14,Ei));let r=O("span");return r.textContent=e,n.appendChild(r),t.appendChild(n),E.modal.chatMessages.appendChild(t),t},g0=e=>{let t=E.modal.config,n=O("div",`message-wrapper ai ${e.init?"":"new"}`),r=O("div","message ai");r.dataset.id=e.id;let a=Ca({html:!0,xhtmlOut:!0,linkify:!0,typographer:!0,breaks:!0,highlight:function(c,u){if(u&&br.getLanguage(u))try{return br.highlight(c,{language:u}).value}catch{}return""}}),i=e.content||"";if(e.contentType==="image"){let c=O("img","","",{src:i||`${E.config.assetsURL}images/no-image.png`}),u=Array.isArray(e.ctx.allUrls)?e.ctx.allUrls:[],d=!1;c.onerror=()=>{if(d=!0,u.length>0){let m=u.pop();e.content=m,c.src=m}else e.content="",c.src=`${E.config.assetsURL}images/no-image.png`,s.innerHTML=""},c.onload=()=>{d&&(e.ctx.allUrls=u,e=E.modal.history.updateMessage(e,{content:e.content,ctx:e.ctx}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,e))},i=c}else i=a.render(i);let o=qm(i,t.customCSS??[]);r.appendChild(o);let s=O("div","actions");if(t.type==="text"&&(t.textActions?.copy!==!1&&s.appendChild(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),completedText:N("modai.ui.copied"),onClick:typeof t.textActions?.copy=="function"?t.textActions.copy:Ra})),typeof t.textActions?.insert=="function"&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Nt,label:N("modai.ui.insert"),completedText:N("modai.ui.inserted"),onClick:t.textActions.insert}))),t.type==="image"&&e.content){t.imageActions?.copy!==!1&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:it,label:N("modai.ui.copy"),loadingText:N("modai.ui.downloading"),completedText:N("modai.ui.copied"),onClick:async(u,d)=>{let m=typeof t.textActions?.copy=="function"?t.textActions.copy:Ra;if(!u.content)return;let p=await $.download.image({messageId:u.id,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let g=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];p.fullUrl!==u.content&&g.indexOf(u.content)===-1&&g.push(u.content),u.content=p.fullUrl,u.ctx.downloaded=!0,u.ctx.url=p.url,u.ctx.fullUrl=p.fullUrl,u.ctx.allUrls=g,u=E.modal.history.updateMessage(u,{content:p.fullUrl,ctx:{downloaded:!0,url:p.url,fullUrl:p.fullUrl,allUrls:g}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),m(u,d)}})),t.imageActions?.download&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Ii,label:N("modai.ui.download"),loadingText:N("modai.ui.downloading"),completedText:N("modai.ui.downloaded"),onClick:async(u,d)=>{if(!u.content)return;let m=typeof t.imageActions?.download=="function"?t.imageActions.download:null,p=await $.download.image({messageId:u.id,forceDownload:!0,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let g=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];p.fullUrl!==u.content&&g.indexOf(u.content)===-1&&g.push(u.content),u.content=p.fullUrl,u.ctx.downloaded=!0,u.ctx.url=p.url,u.ctx.fullUrl=p.fullUrl,u.ctx.allUrls=g,u=E.modal.history.updateMessage(u,{content:p.fullUrl,ctx:{downloaded:!0,url:p.url,fullUrl:p.fullUrl,allUrls:g}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),m?.(u,d)}}));let c=t.imageActions?.insert;typeof c=="function"&&s.append(ze({message:e,disabled:E.modal.isLoading,icon:Nt,label:N("modai.ui.insert"),completedText:N("modai.ui.inserted"),loadingText:N("modai.ui.downloading"),onClick:async(u,d)=>{if(!u.content)return;let m=await $.download.image({messageId:u.id,field:t.field,namespace:t.namespace,resource:t.resource,mediaSource:t.image?.mediaSource,path:t.image?.path});u.ctx.allUrls||(u.ctx.allUrls=[]);let p=Array.isArray(u.ctx.allUrls)?u.ctx.allUrls:[];m.fullUrl!==u.content&&p.indexOf(u.content)===-1&&p.push(u.content),u.content=m.fullUrl,u.ctx.downloaded=!0,u.ctx.url=m.url,u.ctx.fullUrl=m.fullUrl,u.ctx.allUrls=p,u=E.modal.history.updateMessage(u,{content:m.fullUrl,ctx:{downloaded:!0,url:m.url,fullUrl:m.fullUrl,allUrls:p}}),t.persist&&E.modal.chatId&&$.chat.storeMessage(E.modal.chatId,u),c(u,d)}}))}if(e.metadata?.model){let c=O("div","info",N("modai.ui.model_info",{model:e.metadata.model}));r.appendChild(c)}r.appendChild(s),n.appendChild(r);let l=E.modal.chatMessages.lastElementChild;return E.modal.chatMessages.appendChild(n),l&&l.classList.remove("new"),n.syncHeight=()=>{if(l?.firstElementChild){let c=l.classList.contains("user")?l.firstElementChild.clientHeight<100?l.firstElementChild.clientHeight:l.firstElementChild.clientHeight-(l.firstElementChild.clientHeight-62)+10:-10;n.style.setProperty("--user-msg-height",`${E.modal.chatContainer.clientHeight-c-50}px`)}},n.update=c=>{let u=c.contentType==="image"?``:a.render(c.content??"");o.updateContent(u)},n.syncHeight?.(),n},et=e=>{if(!e.hidden){if(e.__type==="UserMessage"){let t=E0(e);return e.init||ve("smooth"),t}if(e.__type==="AssistantMessage"){let t=g0(e);return!e.init&&!t.previousElementSibling?.classList.contains("user")&&ve("smooth"),t}}},Ra=async e=>{if(e.content)if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(e.content)}catch{We(N("modai.error.failed_copy"))}else try{let t=O("textarea");t.value=e.content,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch{We(N("modai.error.failed_copy"))}};var Vm=()=>{let e=new Map,t={on:(n,r,a)=>{if(a?.signal?.aborted)return()=>t.off(n,r);let i=r;a?.once&&(i=s=>{t.off(n==="*"?"*":s.eventName,i),r(s)});let o=e.get(n);return o?o.push(i):e.set(n,[i]),a?.signal?.addEventListener("abort",()=>{t.off(n,i)}),()=>t.off(n,i)},onMany:(n,r,a)=>{if(a?.once){let o=!1,s=c=>{o||(o=!0,l.forEach(u=>u()),r(c))},l=n.map(c=>t.on(c,s,{signal:a.signal}));return()=>{l.forEach(c=>c())}}let i=n.map(o=>t.on(o,r,a));return()=>{i.forEach(o=>o())}},off:(n,r)=>{let a=e.get(n);if(!a)return;if(!r)return void e.set(n,[]);let i=a.indexOf(r);i!==-1&&a.splice(i,1)},emit:(n,r)=>{let a=e.get(n);if(a){let s=a.slice();for(let l=0,c=s.length;l{E.modal.isLoading=e;let t=E.modal.history.getMessages().length>0;le.emit("loading",{isLoading:e,isPreloading:!1,hasMessages:t})},Na=e=>{E.modal.isLoading=e;let t=E.modal.history.getMessages().length>0;le.emit("loading",{isLoading:e,isPreloading:!0,hasMessages:t})};le.on("loading",({eventData:e})=>{E.modal.chatMessages.querySelectorAll(".action-button").forEach(n=>{e.isLoading?n.disable?.():n?.enable?.()})});var zm="modai__state",kt=()=>{let e=ya();e.position={width:E.modal.modal.style.width,height:E.modal.modal.style.height,left:E.modal.modal.style.left,top:E.modal.modal.style.top};try{localStorage.setItem(zm,JSON.stringify(e))}catch{}},ya=()=>{try{let e=localStorage.getItem(zm);return e?JSON.parse(e):{}}catch{return{}}};var S0="modAI",De="chats";var Jn=null,jn=async()=>new Promise((e,t)=>{if(Jn){e(Jn);return}let n=indexedDB.open(S0,2);n.onupgradeneeded=r=>{let a=r.target.result;a.objectStoreNames.contains("messages")&&a.deleteObjectStore("messages"),a.objectStoreNames.contains(De)&&a.deleteObjectStore(De);let i=a.createObjectStore(De,{keyPath:["key","user_id"]});i.createIndex("chat_id","chat_id",{unique:!1}),i.createIndex("key","key",{unique:!1}),i.createIndex("user_id","user_id",{unique:!1})},n.onsuccess=r=>{Jn=r.target.result,e(Jn)},n.onerror=r=>{t(r.target.error)}}),Wm=async(e,t)=>{let n=await jn();return new Promise((r,a)=>{let s=n.transaction(De,"readonly").objectStore(De).get([e,t]);s.onsuccess=l=>{let c=l.target.result;r(c?c.chat_id:null)},s.onerror=l=>{a(l.target.error)}})},Et=async(e,t,n)=>{let r=await jn();return new Promise((a,i)=>{let s=r.transaction(De,"readwrite").objectStore(De),l={key:e,chat_id:t,user_id:n},c=s.put(l);c.onsuccess=()=>{a()},c.onerror=u=>{let d=u.target.error;d?.name==="ConstraintError"?i(new Error(`Chat ID "${t}" already exists`)):i(d)}})},$m=async(e,t)=>{let n=await jn();return new Promise((r,a)=>{let s=n.transaction(De,"readwrite").objectStore(De).delete([e,t]);s.onsuccess=()=>{r(!0)},s.onerror=l=>{a(l.target.error)}})},er=async e=>{let t=await jn();return new Promise((n,r)=>{let i=t.transaction(De,"readwrite").objectStore(De),o=i.index("chat_id"),s=0,l=!1,c=o.openCursor(IDBKeyRange.only(e));c.onsuccess=u=>{let d=u.target.result;if(d){let m=i.delete(d.primaryKey);m.onsuccess=()=>{s++,d.continue()},m.onerror=p=>{l=!0,r(p.target.error)}}else l||n(s>0)},c.onerror=u=>{r(u.target.error)}})};var f0=e=>{let t=be(e);if(!t)throw Error("Chat history not inited for this key.");let n=Re(t);n.messages.forEach(r=>{delete n.idRef[r.id],r.el?.remove()}),n.messages=[]},b0=(e,t,n,r=!1)=>{let a=be(e);if(!a)throw Error("Chat history not inited for this key.");let i=Re(a),o=typeof n=="string",s={__type:"UserMessage",content:o?n:n.content,contexts:o?void 0:n.contexts,attachments:o?void 0:n.attachments,role:"user",id:t,hidden:r,ctx:{}};return i.messages.push(s),i.idRef[t]=s,s.el=et(s),s},T0=(e,t,n,r=!1)=>{let a=be(e);if(!a)throw Error("Chat history not inited for this key.");let i=Re(a),o={__type:"ToolResponseMessage",content:n,role:"tool",id:t,hidden:r,ctx:{}};return i.messages.push(o),i.idRef[t]=o,o.el=et(o),o},Oa=(e,t,n=!1)=>{let r=be(e);if(!r)throw Error("Chat history not inited for this key.");let a=Re(r),i={__type:"AssistantMessage",content:void 0,toolCalls:void 0,contentType:"text",role:"assistant",id:t.id,metadata:t.metadata,hidden:n,ctx:{}};return t.__type==="ImageData"?(i.content=t.url,i.contentType="image"):(i.content=t.content,i.toolCalls=t.toolCalls),a.messages.push(i),a.idRef[t.id]=i,i.el=et(i),i},h0=(e,t)=>{let n=be(e);if(!n)throw Error("Chat history not inited for this key.");let r=Re(n);if(!r.idRef[t.id])return Oa(e,t,!1);let a=r.idRef[t.id];return t.__type==="ImageData"?a.content=t.url:a.content=t.content,a.__type==="AssistantMessage"&&a.el&&a.el.update&&a.el.update(a),a},C0=(e,t)=>{let n=be(e);if(!n)throw Error("Chat history not inited for this key.");return Re(n).idRef[t]},R0=(e,t,n)=>{let r=be(e);if(!r)throw Error("Chat history not inited for this key.");return{...Re(r).idRef[t.id],...n}},N0=async e=>{let t=await Wm(e,E.config.user.id);if(t===null){E.modal.chatId=void 0,E.modal.setTitle(void 0),gt();return}let n=be(e);if(!n)throw Error("Chat history not inited for this key.");await Qm(n,t)},y0=async(e,t)=>{let n=be(t);if(!n)throw Error("Chat history not inited for this key.");if(e===void 0){n.chatId=void 0;let r=Re(n);r.idRef={},r.messages=[];return}Aa(),await Et(t,e,E.config.user.id),await Qm(n,e)},Qm=async(e,t)=>{e.chatId=t,E.modal.chatId=t;let n=Re(e);if(n.messages.length>0){E.modal.setTitle(n.title),E.modal.actionButtons.forEach(r=>{r.enable()}),n.messages.forEach(r=>{r.el&&r.el.remove(),r.el=et(r),r.el&&(r.el.classList.remove("new"),E.modal.chatMessages.appendChild(r.el))}),ve("instant"),n.view_only?E.modal.disableSending():E.modal.enableSending();return}Na(!0);try{let r=await $.chat.loadMessages(t);n.title=r.chat.title,n.view_only=r.chat.view_only,E.modal.setTitle(r.chat.title);for(let i of r.messages){if(i.__type==="UserMessage"){let o={init:!0,__type:"UserMessage",content:i.content,contexts:i.contexts,attachments:i.attachments,role:"user",id:i.id,hidden:i.hidden,ctx:{}};n.messages.push(o),n.idRef[i.id]=o,o.el=et(o);continue}if(i.__type==="AssistantMessage"){let o={init:!0,__type:"AssistantMessage",content:void 0,toolCalls:void 0,contentType:"text",role:"assistant",id:i.id,metadata:i.metadata,hidden:i.hidden,ctx:i.ctx,attachments:i.attachments,contexts:i.contexts};i.contentType==="image"?(o.content=i.content,o.contentType="image"):(o.content=i.content,o.toolCalls=i.toolCalls),n.messages.push(o),n.idRef[i.id]=o,o.el=et(o);continue}if(i.__type==="ToolResponseMessage"){let o={init:!0,__type:"ToolResponseMessage",content:i.content,role:"tool",id:i.id,hidden:i.hidden,ctx:{}};n.messages.push(o),n.idRef[i.id]=o,o.el=et(o)}}n.messages.filter(i=>!i.hidden).length===0&>(),ve("instant")}catch(r){$a(r)&&r.statusCode===404&&(er(t),E.modal.chatId=void 0)}Na(!1),n.view_only?E.modal.disableSending():E.modal.enableSending()},ue={config:{},history:{temp:{},chat:{}}},Re=e=>e.chatId?O0(e.chatId):e.persist?Km(e.tempId):Km(e.key),O0=e=>(ue.history.chat[e]||(ue.history.chat[e]={messages:[],idRef:{},view_only:!1}),ue.history.chat[e]),Km=e=>(ue.history.temp[e]||(ue.history.temp[e]={messages:[],idRef:{},view_only:!1}),ue.history.temp[e]),be=e=>ue.config[e]?ue.config[e]:null,tr={init:e=>(ue.config[e.key]||(ue.config[e.key]={key:e.key,persist:e.persist??!1,tempId:window.crypto.randomUUID(),chatId:void 0}),e.persist&&N0(e.key),Aa(),{addUserMessage:(t,n=!1)=>{let r=window.crypto.randomUUID();return b0(e.key,r,t,n)},addAssistantMessage:(t,n=!1)=>Oa(e.key,t,n),addToolCallsMessage:(t,n=!1)=>Oa(e.key,{__type:"ToolsData",id:t.id,content:void 0,toolCalls:t.toolCalls,usage:t.usage,metadata:t.metadata},n),addToolResponseMessage:(t,n,r=!1)=>T0(e.key,t,n,r),updateAssistantMessage:t=>h0(e.key,t),updateMessage:(t,n)=>R0(e.key,t,n),getAssistantMessage:t=>C0(e.key,t),getMessages:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");return Re(t).messages},getMessagesHistory:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");return Re(t).messages.map(r=>({role:r.role,content:r.content,toolCalls:r.toolCalls,contexts:r.contexts,attachments:r.attachments}))},clearHistory:()=>{f0(e.key)},clearHistoryFrom:async t=>{let n=be(e.key);if(!n)throw Error("Chat history not inited for this key.");let r=Re(n),a=r.messages.findIndex(i=>i.id===t);if(a!==-1){for(let i=a;ie.key,getLastMessageId:()=>{let t=be(e.key);if(!t)throw Error("Chat history not inited for this key.");let n=Re(t),r=n.messages.length;return r===0?null:n.messages[r-1].id},switchChatId:t=>{y0(t,e.key)},migrateTempChat:t=>{let n=ue.config[e.key].tempId;ue.config[e.key].chatId=t,ue.history.chat[t]=ue.history.temp[n],delete ue.history.temp[n]},setTitle:t=>{let n=be(e.key);if(!n)throw Error("Chat history not inited for this key.");n.chatId?ue.history.chat[n.chatId].title=t:ue.history.temp[n.tempId].title=t}})};var Ne=e=>O("span","tooltip",e);var $e=O("div","portal");var A0=120,tt={ENTER:"Enter",SPACE:" ",ESCAPE:"Escape",TAB:"Tab",ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",HOME:"Home",END:"End"},W={currentButton:null,currentWrapper:null,currentBodyElement:null,clickHandler:null,keyboardHandler:null,focusTrapHandler:null},nt=(e,t,n)=>{t>=0&&t=0&&n{let r=t.getBoundingClientRect(),a=$e.getBoundingClientRect(),i=r.left-a.left,o=r.bottom-n.top+A0;e.style.left=`${i}px`,e.style.top=`${o}px`},Ia=(e,t,n,r,a)=>{if(W.currentButton===e&&$e.children.length>0){nn(),e.blur();return}nn(),W.currentBodyElement=r||null,W.currentBodyElement&&(W.currentBodyElement.style.pointerEvents="none"),W.currentButton=e,W.currentWrapper=n||null,e.setAttribute("aria-expanded","true"),W.currentWrapper&&W.currentWrapper.classList.add("active"),e.style.pointerEvents="auto",e.style.zIndex="10000";let i=O("div","portal-dropdown",void 0,{role:"menu"});i.setAttribute("aria-labelledby",e.id||"dropdown-button");let o=[];t.forEach(u=>{let d=O("div","portal-dropdown-item",[Y(16,u.icon),O("span",void 0,u.text)],{role:"menuitem",tabIndex:-1,ariaLabel:u.text}),m=()=>{u.onClick(),nn()};d.addEventListener("click",m),d.addEventListener("keydown",p=>{(p.key===tt.ENTER||p.key===tt.SPACE)&&(p.preventDefault(),m())}),d.addEventListener("mouseenter",()=>{o.forEach(p=>{p.classList.remove("focused"),p.setAttribute("tabindex","-1")}),d.classList.add("focused"),d.setAttribute("tabindex","0"),d.focus()}),i.appendChild(d),o.push(d)}),$e.appendChild(i),a&&I0(i,e,a),i.classList.add("show"),o.length>0&&(o[0].setAttribute("tabindex","0"),o[0].classList.add("focused"),requestAnimationFrame(()=>{W.currentButton&&W.currentButton.blur(),o[0].focus()}));let s=u=>{if(!W.currentButton||W.currentButton!==e)return;let d=o.findIndex(m=>m.classList.contains("focused"));switch(u.key){case tt.ESCAPE:u.preventDefault(),u.stopPropagation(),u.stopImmediatePropagation(),nn(!0,e);break;case tt.TAB:if(u.preventDefault(),u.shiftKey)if(d>0)nt(o,d,d-1);else{let m=o.length-1;nt(o,d,m)}else if(d=0?d+1:0;nt(o,d,m)}else nt(o,d,0);break;case tt.ARROW_DOWN:if(u.preventDefault(),d=0?d+1:0;nt(o,d,m)}break;case tt.ARROW_UP:u.preventDefault(),d>0&&nt(o,d,d-1);break;case tt.HOME:u.preventDefault(),d!==0&&nt(o,d,0);break;case tt.END:{u.preventDefault();let m=o.length-1;d!==m&&nt(o,d,m);break}}},l=u=>{u.composedPath().some(p=>p instanceof Element&&i.contains(p))||(u.preventDefault(),u.stopPropagation(),u.stopImmediatePropagation(),nn())},c=u=>{if(!W.currentButton||W.currentButton!==e)return;let d=u.target;if(i.contains(d))return;u.preventDefault(),u.stopPropagation();let m=o.find(p=>p.classList.contains("focused"));if(m){m.focus();return}o.length>0&&(o[0].classList.add("focused"),o[0].setAttribute("tabindex","0"),o[0].focus())};W.clickHandler=l,W.keyboardHandler=s,W.focusTrapHandler=c,document.addEventListener("keydown",s,!0),document.addEventListener("focusin",c,!0),document.addEventListener("click",l,!0),$e.addEventListener("click",l,!0)},nn=(e=!1,t)=>{W.currentBodyElement&&(W.currentBodyElement.style.pointerEvents=""),W.clickHandler&&(document.removeEventListener("click",W.clickHandler,!0),$e.removeEventListener("click",W.clickHandler,!0),W.clickHandler=null),W.keyboardHandler&&(document.removeEventListener("keydown",W.keyboardHandler,!0),W.keyboardHandler=null),W.focusTrapHandler&&(document.removeEventListener("focusin",W.focusTrapHandler,!0),W.focusTrapHandler=null),$e.innerHTML="",W.currentButton&&(W.currentButton.setAttribute("aria-expanded","false"),W.currentButton.style.pointerEvents="",W.currentButton.style.zIndex="",e||W.currentButton.blur());let n=W.currentWrapper;if(W.currentButton=null,W.currentWrapper=null,W.currentBodyElement=null,W.keyboardHandler=null,W.focusTrapHandler=null,e&&t){if(n){let r=n.querySelector(".actions");r&&(r.style.transition="none")}t.focus(),n&&requestAnimationFrame(()=>{n.classList.remove("active");let r=n.querySelector(".actions");r&&(r.offsetHeight,r.style.transition="")});return}n&&n.classList.remove("active")};le.on("chat:new",({eventData:e})=>{gt(),E.modal.chatPublic=e.public,E.modal.chatId=void 0,E.modal.history.switchChatId(void 0),E.modal.setTitle(void 0),E.modal.enableSending(),$m(E.modal.history.getKey(),E.config.user.id),St()});le.on("chat:delete",({eventData:{chatId:e}})=>{E.modal.chatId===e&&(gt(),E.modal.chatId=void 0,E.modal.setTitle(void 0)),er(e),$.chat.deleteChat(e),E.modal.history.clearHistory(),Z.deleteChat(e),Z.sortChats()});var va=async e=>{let t=Z.getChat(e);if(t){if(E.modal.config.type!==t.type){let n=E.modal.modeButtons.find(a=>a.mode===t.type);if(!n)return;E.modal.chatId=e,n.activate();let r=E.modal.config;await Et(`${r.namespace??"modai"}/${r.key}/${t.type}`,e,E.config.user.id),an(t.type),St();return}E.modal.chatId=e,E.modal.history.switchChatId(e),St()}},rn=null,Xm=e=>{if(Z.init(),E.modal.sidebar?.classList.add("open"),rn=e||null,E.modal.sidebar){let t=E.modal.sidebar.sidebar;requestAnimationFrame(()=>{t.focus()})}},St=()=>{E.modal.sidebar?.classList.remove("open"),E.modal.portal&&(E.modal.portal.innerHTML=""),rn&&document.contains(rn)&&rn.focus(),rn=null},Zm=(e,t)=>{let n=Z.getChat(e);n&&(n.pinned=t,Z.sortChats())},Da=async(e,t)=>{let n=Z.getChat(e);n&&(await $.chat.setPublicChat(e,t),n.public=t,Z.markAsStale(),Z.init())},Jm=(e,t)=>{let n=Z.getChat(e);n&&(n.title=t,n.el.setTitle(t),$.chat.setChatTitle(e,t),Z.sortChats())},xa=async e=>{Z.getChat(e)&&(await $.chat.cloneChat(e),Z.markAsStale(),Z.init())};var jm=(e,t)=>{let n=new Map;e.states.forEach((c,u)=>{n.set(c.name,u)});let r=n.get(e.defaultState);if(r===void 0)throw new Error(`Default state "${e.defaultState}" not found in states.`);let a=r,i=(a+1)%e.states.length,o=Y(24,e.states[r].icon),s=Ne(e.states[i].label),l=O("button","",[o,s],{ariaLabel:e.states[i].label});return l.addEventListener("click",()=>{a=(a+1)%e.states.length;let c=(a+1)%e.states.length,u=e.states[a];o.innerHTML=u.icon,s.textContent=e.states[c].label,l.ariaLabel=e.states[c].label,Promise.resolve(t(u))}),l};var ft={ENTER:"Enter",SPACE:" ",ESCAPE:"Escape",TAB:"Tab",ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",HOME:"Home",END:"End"},on=(e,t,n,r,a,i)=>Ye({title:e,content:t,confirmText:n,onConfirm:()=>{r(),i&&requestAnimationFrame(()=>{i.focus(),i.blur()})},onCancel:()=>{i&&requestAnimationFrame(()=>{i.focus(),i.blur()})},onLoad:a}),sn=e=>{e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()})},eE=()=>{let e=O("div","sidebarWrapper",[]),t=O("div","sidebar",[],{role:"dialog",ariaLabel:N("modai.ui.chats_sidebar"),ariaModal:"false",tabIndex:-1});t.addEventListener("click",f=>{f.stopPropagation(),f.stopImmediatePropagation()}),e.addEventListener("click",()=>{St()});let n=Ne(N("modai.ui.close_chats"));n.style.left="80%";let r=Q([Y(24,yi),n],St,void 0,{ariaLabel:N("modai.ui.close_chats")}),a=Q([Y(24,Nt),Ne(N("modai.ui.new_chat"))],()=>{le.emit("chat:new",{public:!0})},void 0,{ariaLabel:N("modai.ui.new_chat")}),i=Q([Y(24,Li),Ne(N("modai.ui.new_private_chat"))],()=>{le.emit("chat:new",{public:!1})},void 0,{ariaLabel:N("modai.ui.new_private_chat")});sn(a),sn(i),a.disable(),E.modal.modalButtons.push(r),E.modal.actionButtons.push(a),E.modal.actionButtons.push(i);let o=jm({states:[{name:"public",icon:Pi,label:N("modai.ui.show_public_chats")},{name:"my",icon:Fi,label:N("modai.ui.show_my_chats")},{name:"private",icon:or,label:N("modai.ui.show_private_chats")}],defaultState:"public"},async f=>{Z.setFilter({name:"chatType",value:f.name}),await Z.init()}),s=O("div","buttonsWrapper",[r,a,i]),l=O("div","buttonsWrapper",[o]),c=O("header","header",[s,l]),u=O("div","searchWrapper"),d=O("input",void 0,void 0,{placeholder:N("modai.ui.chat_search")});d.addEventListener("input",async f=>{let I=f.target;m.style.display="";let D=await $.chat.searchChats(I.value);Z.searchChats(D.chats),m.style.display="none"});let m=Y(16,ki);m.classList.add("spinner"),m.style.display="none",u.append(d),u.append(m);let p=O("div","groupedChats",[]);t.append(c),t.append(u),t.append(p),e.append(t);let g=[r,a,i],S=[],R=null,A=()=>{let f=[];return g.forEach(I=>{I.disabled||f.push(I)}),S.forEach(I=>{!I.hasAttribute("disabled")&&I.getAttribute("tabindex")!=="-1"&&f.push(I)}),f},h=f=>{let I=f.target;(A().includes(I)||I===t)&&(R=I)};t.addEventListener("focusin",h);let C=()=>{t.classList.add("no-transitions"),setTimeout(()=>{t.classList.remove("no-transitions")},50)},y=f=>{if(e.classList.contains("open")){if(f.key===ft.TAB){let I=A();if(I.length===0)return;let D=I[0],k=I[I.length-1];if(f.shiftKey){if(C(),R===D){f.preventDefault(),t.focus();return}R===t&&(f.preventDefault(),k.focus());return}C(),R===k&&(f.preventDefault(),t.focus());return}f.key===ft.ESCAPE&&(f.preventDefault(),f.stopPropagation(),f.stopImmediatePropagation(),St())}};return t.addEventListener("keydown",y),e.addChat=f=>{p.append(f),f.querySelectorAll('button, [tabindex="0"]').forEach(D=>{S.push(D)})},e.deleteChats=()=>{p.innerHTML="",S.length=0},e.renderChats=f=>{p.innerHTML="",S.length=0;let I=Object.entries(f);if(I.length===0){let D=O("div","noChatsMessage",N("modai.ui.no_chats"));p.append(D);return}for(let[D,k]of I){let F=k.filter(V=>E.modal.config.availableTypes?.includes(V.type));if(F.length===0)continue;let L=O("div","group",[O("div","title",D),O("div","chats",F.map(V=>V.el))]);p.append(L),F.forEach(V=>{V.el.querySelectorAll('button, [tabindex="0"]').forEach(oe=>{S.push(oe)})})}},e.chats=p,e.sidebar=t,E.modal.sidebar=e,le.on("chat:new",({eventData:f})=>{f.public?(a.disable(),i.enable()):(a.enable(),i.disable())}),le.on("chat:delete",()=>{a.disable(),i.enable()}),le.on("loading",({eventData:f})=>{f.isLoading||!f.hasMessages?(a.disable(),i.disable()):(a.enable(),i.enable()),f.isLoading?r.disable():r.enable()}),e},tE=()=>{let e=Q([Y(24,Ni),Ne(N("modai.ui.open_chats"))],()=>{Xm(e)});e.setAttribute("aria-label",N("modai.ui.open_chats")),sn(e);let t=Q([Y(24,Nt),Ne(N("modai.ui.new_chat"))],()=>{le.emit("chat:new",{public:!0})});return t.setAttribute("aria-label",N("modai.ui.new_chat")),sn(t),t.disable(),E.modal.actionButtons.push(t),E.modal.modalButtons.push(e),le.on("chat:new",({eventData:n})=>{n.public?t.disable():t.enable()}),le.on("chat:delete",()=>{t.disable()}),le.on("loading",({eventData:n})=>{n.isLoading||!n.hasMessages?t.disable():t.enable(),n.isLoading?e.disable():e.enable()}),[e,t]},v0=e=>e.view_only?Y(20,e.type==="text"?Di:xi):e.public?Y(20,e.type==="text"?Yt:Gt):O("div","iconStack",[Y(18,e.type==="text"?Yt:Gt),Y(12,vi)]),nE=e=>{let t=O("div","wrapper",void 0,{tabIndex:-1}),n=O("div","title");n.textContent=e.title;let r=Q([v0(e),n],()=>{va(e.id)},"chat",{title:e.title,ariaLabel:N("modai.ui.select_chat",{title:e.title}),role:"button"});r.addEventListener("keydown",m=>{(m.key===ft.ENTER||m.key===ft.SPACE)&&(m.preventDefault(),va(e.id))});let a=O("div","actions"),i=O("div","gradient"),o=Q([Y(16,Tn),Ne(N("modai.ui.delete_chat"))],()=>{let m=Z.getChat(e.id);m&&Ye({title:N("modai.ui.delete_chat_long"),content:N("modai.ui.delete_chat_desc",{title:m.title}),confirmText:N("modai.ui.delete"),onConfirm:()=>{let p=t,g=p.parentElement,S=g?Array.from(g.querySelectorAll(".wrapper")):[],R=S.indexOf(p),A=null;R>0?A=S[R-1].querySelector("button.chat"):R===0&&S.length>1&&(A=S[R+1].querySelector("button.chat")),le.emit("chat:delete",{chatId:e.id}),requestAnimationFrame(A?()=>{A.focus()}:()=>{E.modal.sidebar?.sidebar.focus()})},onCancel:()=>{requestAnimationFrame(()=>{t.focus(),t.blur()})}})},void 0,{ariaLabel:N("modai.ui.delete_chat_long")}),s=[Y(16,Oi),Ne(N("modai.ui.pin_chat"))],l=[Y(16,Ai),Ne(N("modai.ui.unpin_chat"))],c=Q(e.pinned?l:s,async()=>{let m=Z.getChat(e.id);if(!m)return;let p=!m.pinned;c.disable(),await $.chat.pinChat(e.id,p),c.innerHTML="",c.append(...p?l:s),Zm(e.id,p),c.enable()},void 0,{ariaLabel:e.pinned?N("modai.ui.unpin_chat"):N("modai.ui.pin_chat")}),u=()=>{let m=[];return m.push({icon:it,text:N("modai.ui.clone_chat"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.clone_chat_long"),N("modai.ui.clone_chat_desc",{title:p.title}),N("modai.ui.clone"),()=>{xa(e.id)},void 0,t)}}),e.view_only||(m.push({icon:bn,text:N("modai.ui.rename_chat"),onClick:()=>{let p=Z.getChat(e.id);if(!p)return;let g=O("div","formWrapper"),S=O("input","input",void 0,{value:p.title,type:"text",name:"title"}),R=O("label","label",[S]);g.append(R);let A=on(N("modai.ui.rename_chat_long"),g,N("modai.ui.save"),()=>{let h=S.value.trim();h&&Jm(p.id,h)},()=>{S.focus()},t);S.addEventListener("keypress",h=>{h.key==="Enter"&&A.api.confirmDialog()})}}),e.public?m.push({icon:or,text:N("modai.ui.chat_make_private"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.chat_make_private_long"),N("modai.ui.chat_make_private_desc",{title:p.title}),N("modai.ui.save"),()=>{Da(e.id,!1)},void 0,t)}}):m.push({icon:Mi,text:N("modai.ui.chat_make_public"),onClick:()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.chat_make_public_long"),N("modai.ui.chat_make_public_desc",{title:p.title}),N("modai.ui.save"),()=>{Da(e.id,!0)},void 0,t)}})),m},d=Q([Y(16,wi),Ne(N("modai.ui.more_actions"))],m=>{m.stopPropagation(),m.stopImmediatePropagation(),m.preventDefault(),Ia(d,u(),t,E.modal.sidebar,E.modal.modal.getBoundingClientRect())},void 0,{ariaLabel:N("modai.ui.more_actions"),ariaHasPopup:"true",ariaExpanded:"false"});if(d.addEventListener("keydown",m=>{(m.key===ft.ENTER||m.key===ft.SPACE||m.key===ft.ARROW_DOWN)&&(m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation(),Ia(d,u(),t,E.modal.sidebar,E.modal.modal.getBoundingClientRect()))}),sn(d),!e.view_only)a.append(c),a.append(o),a.append(d),a.append(i);else{let m=Q([Y(16,it),Ne(N("modai.ui.clone_chat"))],()=>{let p=Z.getChat(e.id);p&&on(N("modai.ui.clone_chat_long"),N("modai.ui.clone_chat_desc",{title:p.title}),N("modai.ui.clone"),()=>{xa(e.id)},void 0,r)},void 0,{ariaLabel:N("modai.ui.delete_chat_long")});a.append(m)}return t.append(r),t.append(a),t.setTitle=m=>{n.textContent=m},t};var ne={inited:!1,stale:!1,filters:{},chatById:{},chats:{}},Ma=new Date,D0=Ma.toISOString().slice(0,10),aE=new Date(Ma);aE.setDate(Ma.getDate()-1);var x0=aE.toISOString().slice(0,10),iE=e=>{let t=new Date(e.last_message_on),n=t.toISOString().slice(0,10);if(e.pinned)return N("modai.ui.pinned");if(n===D0)return N("modai.ui.today");if(n===x0)return N("modai.ui.yesterday");let r=t.toLocaleString("default",{month:"long"}),a=t.getFullYear();return`${r} ${a}`},M0=()=>{if(!E.modal.sidebar)return;let e=Object.values(ne.chatById).sort((n,r)=>n.pinned!==r.pinned?Number(r.pinned)-Number(n.pinned):r.last_message_on-n.last_message_on),t={};for(let n of e){let r=iE(n);t[r]||(t[r]=[]),t[r].push(ne.chatById[n.id])}ne.chats=t,E.modal.sidebar.renderChats(ne.chats)},rE=()=>{let e={};for(let[t,n]of Object.entries(ne.chats)){let r=n.filter(a=>!(ne.filters.chatIDs&&ne.filters.chatIDs[a.id]===void 0||ne.filters.chatType==="my"&&a.view_only||ne.filters.chatType==="private"&&a.public));r.length>0&&(e[t]=r)}return e},Z={init:async()=>{if(!E.modal.sidebar)return;if(ne.inited&&!ne.stale){E.modal.sidebar.renderChats(rE());return}ne.stale&&(E.modal.sidebar.deleteChats(),ne.chatById={},ne.chats={});let e=await $.chat.loadChats();for(let t of e.chats){let n={...t,el:nE(t)};ne.chatById[n.id]=n;let r=iE(n);ne.chats[r]||(ne.chats[r]=[]),ne.chats[r].push(ne.chatById[n.id])}ne.inited=!0,ne.stale=!1,E.modal.sidebar.renderChats(rE())},sortChats:M0,markAsStale:()=>{ne.stale=!0},getChat:e=>ne.chatById[e],getChats:()=>ne.chats,deleteChat:e=>{delete ne.chatById[e]},searchChats:async e=>{ne.filters.chatIDs=e,await Z.init()},setFilter:e=>{ne.filters[e.name]=e.value},clearFilters:()=>{ne.filters={}}};var La=e=>e.toolCalls!==void 0;var ln=()=>{E.modal.isLoading||(document.removeEventListener("mousemove",e=>qt(e)),document.removeEventListener("mouseup",()=>Vt()),E.modal&&E.modal.remove(),Z.clearFilters(),E.modalOpen=!1)},oE=async(e,t,n,r,a)=>{let i=E.modal.history.addToolCallsMessage(t,!0);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,i,t.content?void 0:t.usage);let o=await $.tools.run({toolCalls:t.toolCalls,agent:n,chatId:E.modal.chatId},a);E.modal.history.addToolResponseMessage(o.id,o.content,!0);let s=await $.prompt.chat({namespace:e.namespace,additionalOptions:r,agent:n,field:e.field||"",messages:E.modal.history.getMessagesHistory()},l=>{(l.__type==="TextDataNoTools"||l.__type==="TextDataMaybeTools")&&E.modal.history.updateAssistantMessage(l)},a);if(s.content){let l=E.modal.history.updateAssistantMessage(s);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,l,s.usage)}La(s)&&await oE(e,s,n,r,E.modal.abortController)},mt=async(e,t)=>{let n=E.modal.config,r=e?e.trim():E.modal.messageInput.value.trim();if(!(!r||E.modal.isLoading)){tn(!0),E.modal.messageInput.value="",E.modal.messageInput.style.height="auto",E.modal.abortController=new AbortController,E.modal.welcomeMessage.style.display="none";try{let a=E.modal.attachments.attachments.length>0?E.modal.attachments.attachments.map(m=>({__type:m.__type,value:m.value})):void 0,i=E.modal.context.contexts.length>0?E.modal.context.contexts.map(m=>({__type:m.__type,name:m.name,renderer:m.renderer,value:m.value})):[];E.modal.attachments.removeAttachments(),E.modal.context.removeContexts();let o=E.modal.history.getLastMessageId(),s=E.modal.history.getMessagesHistory(),l=E.modal.history.addUserMessage({content:r,attachments:a,contexts:i},t),c=E.selectedAgent[`${n.key}/${n.type}`];c&&c.contextProviders&&c.contextProviders.length>0&&(await $.context.get({prompt:r,agent:c.name})).contexts.map(p=>{i.push({__type:"ContextProvider",name:"ContextProvider",renderer:void 0,value:p})}),E.modal.history.updateMessage(l,{contexts:i});let u=Object.entries(E.additionalControls[`${n.key}/${n.type}`]??{}).reduce((m,[p,g])=>(g&&(m[p]=g.value),m),{}),d=null;if(E.config.generateChatTitle&&!o&&(d=$.prompt.chatTitle({message:l.content}).then(m=>(E.modal.setTitle(m.content),m))),n.type==="text"){let m=await $.prompt.chat({persist:n.persist,chatId:E.modal.chatId,chatPublic:E.modal.chatPublic,lastMessageId:o,userMsg:l,agent:c?.name,additionalOptions:u,namespace:n.namespace,field:n.field||"",messages:s},S=>{S.content&&E.modal.history.updateAssistantMessage(S)},E.modal.abortController),p=m.chatId,g=E.modal.chatId||p;if(d!==null&&g&&(d?.then(S=>{S.content&&($.chat.setChatTitle(g,S.content),E.modal.history.setTitle(S.content))}),Z.markAsStale()),!E.modal.chatId&&p&&(Z.markAsStale(),E.modal.chatId=p,Et(E.modal.history.getKey(),p,E.config.user.id),E.modal.history.migrateTempChat(p)),m.content){let S=E.modal.history.updateAssistantMessage(m);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,S,m.usage)}La(m)&&await oE(n,m,c?.name,u,E.modal.abortController)}if(n.type==="image"){let m=await $.prompt.image({persist:n.persist,chatId:E.modal.chatId,chatPublic:E.modal.chatPublic,lastMessageId:o,userMsg:l,additionalOptions:u},E.modal.abortController),p=m.chatId,g=E.modal.chatId||p;d!==null&&g&&(d?.then(R=>{R.content&&($.chat.setChatTitle(g,R.content),E.modal.history.setTitle(R.content))}),Z.markAsStale()),!E.modal.chatId&&p&&(Z.markAsStale(),E.modal.chatId=p,Et(E.modal.history.getKey(),p,E.config.user.id),E.modal.history.migrateTempChat(p));let S=E.modal.history.addAssistantMessage(m);E.modal.chatId&&await $.chat.storeMessage(E.modal.chatId,S)}E.modal.abortController=void 0}catch(a){if(a instanceof Error){if(a.name==="AbortError")return;tn(!1),We(a.message);return}We(N("modai.error.unknown_error"))}tn(!1),E.modal.messageInput.focus()}},sE=()=>{!E.modal.isLoading||!E.modal.abortController||(E.modal.abortController.abort(),E.modal.abortController=void 0,tn(!1))},an=e=>{let t=E.modal.config;t.type=e,E.modal.history=tr.init({key:`${t.namespace??"modai"}/${t.key}/${t.type}`,persist:t.persist}),E.modal.reloadChatControls(),ve("instant")},lE=()=>{E.modal.history.clearHistory(),E.modal.setTitle(void 0),gt(),L0()},gt=()=>{E.modal.chatMessages.innerHTML="",E.modal.welcomeMessage.style.display="block"},Aa=()=>{E.modal.chatMessages.innerHTML="",E.modal.welcomeMessage.style.display="none"},L0=()=>{E.modal.actionButtons.forEach(e=>{e.disable()})},cn=async(e,t=!1)=>{if(!t&&e instanceof File&&!e.type.startsWith("image/")){We(N("modai.error.only_image_files_are_allowed"));return}if(t){E.modal.attachments.addImageAttachment(e);return}let n=await new Promise((r,a)=>{let i=new FileReader;i.onload=function(o){r(o.target?.result)},i.onerror=function(o){a(o)},i.readAsDataURL(e)});E.modal.attachments.addImageAttachment(n)},ve=(e="smooth")=>{E.modal.chatContainer.scrollTo({top:E.modal.chatContainer.scrollHeight,behavior:e})};var cE=()=>{let e=O("div","chatContainer","",{ariaLive:"polite"}),t=O("div","welcome",[O("p","greeting",E.config.user.name?N("modai.ui.greeting_with_name",{name:E.config.user.name}):N("modai.ui.greeting")),O("p","msg",N("modai.ui.welcome_msg"))]);e.append(t);let n=O("div","history","",{ariaLabel:N("modai.ui.conversation_history")});return e.append(n),E.modal.welcomeMessage=t,E.modal.chatMessages=n,E.modal.chatContainer=e,e};var uE=e=>{let t=e.offsetWidth,n=e.offsetHeight,r=window.innerWidth,a=window.innerHeight,i=r/2-t/2,o=a/2-n/2;e.style.left=`${i}px`,e.style.top=`${o}px`},dE=e=>{let t=Q(Y(24,gi),()=>{ln()},"",{ariaLabel:N("modai.ui.close_dialog")}),n=E.modal.modal.style.width==="90%",r=O("div","buttonsWrapper",[Q(Y(24,n?ir:ar),l=>{let c=l.currentTarget;if(E.modal.modal.style.width==="90%"){E.modal.modal.style.width="",E.modal.modal.style.height="",E.modal.modal.style.transform="none",kt(),c.ariaLabel=N("modai.ui.maximize_dialog"),c.innerHTML="",c.appendChild(Y(24,ar)),uE(E.modal.modal);return}E.modal.modal.style.width="90%",E.modal.modal.style.height="90%",E.modal.modal.style.transform="none",kt(),c.ariaLabel=N("modai.ui.minimize_dialog"),c.innerHTML="",c.appendChild(Y(24,ir)),uE(E.modal.modal)},"",{ariaLabel:n?N("modai.ui.minimize_dialog"):N("modai.ui.maximize_dialog")}),t]),a=O("div","buttonsWrapper");e.persist&&a.append(...tE());let i=O("h1");i.textContent=N("modai.ui.modai_assistant");let o=O("header","header cursor-move",[a,i,r]);o.addEventListener("mousedown",l=>{Bi(l),document.addEventListener("mousemove",qt),document.addEventListener("mouseup",()=>{Vt(),document.removeEventListener("mousemove",qt),document.removeEventListener("mouseup",Vt),kt()})});let s=l=>{if(l.key==="Escape"){if(l.preventDefault(),E.modal.sidebar?.classList.contains("open")){E.modal.sidebar.classList.remove("open");return}ln(),document.removeEventListener("keydown",s)}};return document.addEventListener("keydown",s),le.on("loading",({eventData:l})=>{l.isLoading?t.disable():t.enable()}),E.modal.closeModalBtn=t,E.modal.setTitle=l=>{i.textContent=l||N("modai.ui.modai_assistant")},o};var _E=()=>{let e=O("div","attachmentsWrapper");return e.visible=!1,e.attachments=[],e.show=()=>{e.visible||(e.visible=!0,ae(e,"attachmentsWrapper visible"))},e.hide=()=>{e.visible&&(e.visible=!1,ae(e,"attachmentsWrapper"))},e.addImageAttachment=t=>{w0(t)},e.removeAttachments=()=>{E.modal.attachments.attachments.forEach(t=>{E.modal.attachments.removeAttachment(t)})},e.addAttachment=t=>{e.show(),e.appendChild(t),e.attachments.push(t)},e.removeAttachment=t=>{let n=e.attachments.indexOf(t);n!==-1&&(t.remove(),e.attachments.splice(n,1),e.attachments.length===0&&e.hide())},E.modal.attachments=e,e},w0=e=>{E.modal.attachments.attachments.length>0&&E.modal.attachments.removeAttachments();let t=Q([O("img",void 0,"",{src:e}),O("div","trigger","\xD7",{tabIndex:-1})],()=>{E.modal.attachments.removeAttachment(t)},"attachment imagePreview");t.__type="image",t.value=e,E.modal.attachments.addAttachment(t)};var k0={selection:e=>{let t=O("span","tooltip",e.value,{tabIndex:-1}),n=Q([Y(24,hn),t,O("div","trigger","\xD7",{tabIndex:-1})],()=>{E.modal.context.removeContext(e)},"context");return n.addEventListener("keydown",r=>{if(r.key==="ArrowUp"||r.key==="ArrowDown"){r.preventDefault();let a=30;t.scrollTop+=r.key==="ArrowDown"?a:-a}}),n}},pE=()=>{let e=O("div","contextsWrapper");return e.visible=!1,e.contexts=[],e.show=()=>{e.visible||(e.visible=!0,ae(e,"contextsWrapper visible"))},e.hide=()=>{e.visible&&(e.visible=!1,ae(e,"contextsWrapper"))},e.removeContexts=()=>{E.modal.context.contexts.forEach(t=>{E.modal.context.removeContext(t)})},e.addContexts=t=>{t.forEach(n=>{E.modal.context.addContext(n)})},e.addContext=t=>{let n=e.contexts.push(t)-1,r=k0[t?.renderer||""];if(r){e.show();let a=r(t);e.contexts[n].el=a,e.appendChild(a)}},e.removeContext=t=>{let n=e.contexts.indexOf(t);n!==-1&&(t.el?.remove(),e.contexts.splice(n,1),(e.contexts.length===0||e.contexts.every(r=>r.el===void 0))&&e.hide())},E.modal.context=e,e};function mE(e,t,n,r){let a=new Map,i=new Map,o=new Map,s=!1,l=-1,c=[],u=null,d=O("button","dropdown-button",[r.icon&&Y(24,r.icon),r.selectText&&O("span",void 0,r.selectText),r.tooltip&&O("span","tooltip",r.tooltip)],{ariaHasPopup:"true",ariaExpanded:"false"});d.addEventListener("click",S),d.addEventListener("keydown",f);let m=O("div","dropdown-menu",g(e),{role:"menu"}),p=O("div","nestedSelectContainer",[d,m]);p.enable=()=>{d.disabled=!1},p.disable=()=>{d.disabled=!0};function g(M,U,v=0){return M.map(x=>{if(x.children&&x.children.length>0){let G=O("div","submenu",g(x.children,x,v+1),{role:"menu"});G.style.zIndex=String(1001+v);let q=O("div","dropdown-item has-submenu",[O("div","submenuTrigger",[O("span",void 0,x.name),Y(16,Ci)]),G],{tabIndex:-1,ariaHasPopup:"true",ariaExpanded:"false"});return q.addEventListener("click",K=>{K.stopPropagation(),K.stopImmediatePropagation(),K.preventDefault()}),q.addEventListener("keydown",K=>I(K,x)),a.set(x.id,x),o.set(x.id,q),U&&i.set(x.id,U),q}let w=O("div","dropdown-item",x.name,{role:"menuitem",tabIndex:-1});return w.addEventListener("click",()=>{ie(x)}),w.addEventListener("keydown",G=>I(G,x)),a.set(x.id,x),o.set(x.id,w),U&&i.set(x.id,U),w})}function S(M){M.preventDefault(),M.stopPropagation(),s?A():R()}function R(){if(s=!0,m.classList.add("show"),d.classList.add("open"),d.setAttribute("aria-expanded","true"),y(),l=-1,r.highlightSelectedValue===!0&&(o.values().forEach(M=>{M.classList.remove("selected")}),u)){let M=o.get(u.id);if(M){M.classList.add("selected");let U=i.get(u.id);for(;U;){let v=o.get(U.id);v&&v.classList.add("selected"),U=i.get(U.id)}}}document.addEventListener("click",oe,!0)}function A(){s&&(s=!1,m.classList.remove("show"),d.classList.remove("open"),d.setAttribute("aria-expanded","false"),h(),C(),d.focus(),l=-1,document.removeEventListener("click",oe,!0))}function h(){o.values().forEach(M=>{M.classList.remove("active","keyboard-active"),M.setAttribute("aria-expanded","false")})}function C(){c.forEach(M=>{M.classList.remove("active","keyboard-active")})}function y(M){let U=[];if(c=[],!M)l=-1,U=e;else{let v=a.get(M);v?U=v.children??[]:U=e}U.forEach(v=>{let x=o.get(v.id);x&&c.push(x)})}function f(M){switch(M.key){case"Enter":case" ":case"ArrowDown":M.preventDefault(),s||R(),y(),c.length>0&&L(0);break;case"ArrowUp":M.preventDefault(),s||R(),y(),c.length>0&&L(c.length-1);break;case"Escape":s&&(M.stopImmediatePropagation(),M.stopPropagation(),M.preventDefault(),A());break}}function I(M,U){switch(M.stopPropagation(),M.stopImmediatePropagation(),M.key){case"Enter":case" ":M.preventDefault(),"value"in U?ie(U):D(U);break;case"ArrowDown":M.preventDefault(),k();break;case"ArrowUp":M.preventDefault(),F();break;case"ArrowRight":M.preventDefault(),"value"in U||D(U);break;case"ArrowLeft":M.preventDefault(),V(U);break;case"Escape":s&&(M.preventDefault(),A());break}}function D(M){if(!M.children||M.children.length===0)return;let U=o.get(M.id);U&&(U.classList.add("keyboard-active"),y(M.id),L(0))}function k(){l0?L(l-1):L(c.length-1)}function L(M){C(),l=M,c[M]&&(c[M].focus(),c[M].classList.add("active"))}function V(M){let U=i.get(M.id);if(!U)return;let v=o.get(U.id);if(!v)return;let x=i.get(U.id);v.classList.remove("keyboard-active"),y(x?.id);let w=c.indexOf(v);L(w>=0?w:0)}function ie(M){if(r.showSelectedValue===!0){let U=d.querySelector("span");U&&(U.textContent=M.name)}A(),d.focus(),u=M,n(M)}function oe(M){M.composedPath().includes(p)||A()}return p}var wa=(e,t,n,r)=>{let a=r?.idProperty??"id",i=r?.displayProperty??"name",o={idProperty:a,displayProperty:i,noSelectionText:r?.noSelectionText??"",selectText:r?.selectText??N("modai.ui.select_item"),icon:r?.icon,iconSize:r?.iconSize??24,nullOptionDisplayText:r?.nullOptionDisplayText,tooltip:r?.tooltip??N("modai.ui.select_item")},s=O("div","selectContainer"),l=null;t!=null&&(l=e[t]||null);let c=!1,u=-1,d=[null,...Object.values(e)],m=O("button","selectButton",[],{type:"button",ariaHasPopup:"listbox",ariaExpanded:"false",ariaLabel:o.selectText});s.enable=()=>{m.disabled=!1},s.disable=()=>{m.disabled=!0};let p=()=>{let f=[],I;if(o.icon&&f.push(Y(o.iconSize,o.icon)),l){let D=String(l[o.displayProperty]);f.push(O("span","selectedItemName",D)),I=D}else o.noSelectionText&&f.push(O("span","selectedItemName",o.noSelectionText)),I=o.noSelectionText||N("modai.ui.no_selection");m.innerHTML="",m.append(...f),m.append(O("span","tooltip",o.tooltip)),m.setAttribute("aria-label",I)},g=O("ul","selectDropdown",[],{role:"listbox",tabIndex:-1,ariaHidden:"true"});g.classList.add("hidden");let S=d.map((f,I)=>{let D;f===null?D=o.nullOptionDisplayText??o.noSelectionText:D=String(f[o.displayProperty]);let k=f&&l&&f[o.idProperty]===l[o.idProperty]||!f&&!l,F=O("li","selectOption",D,{role:"option",id:`select-option-${I}`,ariaSelected:k?"true":"false",tabIndex:-1});return F.addEventListener("click",()=>{h(f),A()}),F.addEventListener("keydown",L=>{if(c)switch(L.key){case"ArrowDown":L.preventDefault(),C((I+1)%S.length);break;case"ArrowUp":L.preventDefault(),C((I-1+S.length)%S.length);break;case"Enter":case" ":L.preventDefault(),h(f),A();break;case"Escape":L.preventDefault(),L.stopPropagation(),A();break;case"Tab":A();break;case"Home":L.preventDefault(),C(0);break;case"End":L.preventDefault(),C(S.length-1);break;default:break}}),F});g.append(...S);let R=()=>{c||(c=!0,g.classList.remove("hidden"),g.setAttribute("aria-hidden","false"),m.setAttribute("aria-expanded","true"),u=d.findIndex(f=>f&&l&&f[o.idProperty]===l[o.idProperty]||!f&&!l),u===-1&&(u=0),C(u),document.addEventListener("click",y,!0))},A=()=>{c&&(c=!1,g.classList.add("hidden"),g.setAttribute("aria-hidden","true"),m.setAttribute("aria-expanded","false"),m.focus(),u=-1,document.removeEventListener("click",y,!0))},h=f=>{l=f,p(),S.forEach((I,D)=>{let k=d[D],F=k&&l&&k[o.idProperty]===l[o.idProperty]||!k&&!l;I.setAttribute("aria-selected",F?"true":"false")}),n(l)},C=f=>{if(f<0||f>=S.length)return;S.forEach(D=>{D.classList.remove("focused"),D.tabIndex=-1});let I=S[f];I.tabIndex=0,I.classList.add("focused"),I.scrollIntoView({block:"nearest"}),I.focus(),g.setAttribute("aria-activedescendant",I.id),u=f},y=f=>{f.composedPath().includes(s)||A()};return m.addEventListener("click",f=>{if(f.preventDefault(),f.stopPropagation(),f.stopImmediatePropagation(),c){A();return}R()}),m.addEventListener("keydown",f=>{switch(f.key){case"Enter":case" ":case"ArrowDown":f.preventDefault(),R();break;case"ArrowUp":f.preventDefault(),R(),C(S.length-1);break;case"Escape":c&&(f.stopImmediatePropagation(),f.stopPropagation(),f.preventDefault(),A());break}}),p(),s.append(m,g),s};var EE=e=>{let t=O("div","inputContainer"),n=O("div","inputSection"),r=O("div","inputWrapper"),a=O("textarea","","",{placeholder:N("modai.ui.prompt_placeholder"),rows:1,ariaLabel:N("modai.ui.prompt_label")});a.setValue=h=>{a.value=h,a.focus(),a.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0}))};let i=O("div","loadingDots",[O("div","loadingDot"),O("div","loadingDot"),O("div","loadingDot")],{ariaLabel:N("modai.ui.loading_response")}),o=Q(Y(20,pi),()=>mt(),"",{ariaLabel:N("modai.ui.send_message")});o.disable(),o.enable=()=>{o.disabled=!1,ae(o,"active")},o.disable=()=>{o.disabled=!0,ae(o,"")};let s=Q(Y(20,mi),()=>sE(),"",{ariaLabel:N("modai.ui.stop_generating_response")});s.disable(),s.enable=()=>{s.disabled=!1,ae(s,"active sending")},s.disable=()=>{s.disabled=!0,ae(s,"")},r.append(a,i,o,s);let l=O("div","inputAddons",[_E(),pE()]);n.append(l,r);let c=[];if(e.availableTypes?.includes("text")){let h=Q([Y(24,Yt),O("span","tooltip",N("modai.ui.text_mode"))],()=>{e.type!=="text"&&(an("text"),c.forEach(C=>{ae(C,"")}),ae(h,"active"))},"",{ariaLabel:N("modai.ui.text_mode")});h.activate=()=>{c.forEach(C=>{ae(C,"")}),ae(h,"active")},h.mode="text",e.type==="text"&&ae(h,"active"),c.push(h)}if(e.availableTypes?.includes("image")){let h=Q([Y(24,Gt),O("span","tooltip",N("modai.ui.image_mode"))],()=>{e.type!=="image"&&(an("image"),c.forEach(C=>{ae(C,"")}),ae(h,"active"))},"",{ariaLabel:N("modai.ui.image_mode")});h.activate=()=>{c.forEach(C=>{ae(C,"")}),ae(h,"active")},h.mode="image",e.type==="image"&&ae(h,"active"),c.push(h)}let u=[],d=O("div","options",[],{ariaLabel:N("modai.ui.options_toolbar"),role:"toolbar"}),m=O("div","optionsLeft"),p=O("div","optionsRight");d.append(m,p);let g;e.persist||(g=Q([Y(24,Tn),O("span","tooltip",N("modai.ui.clear_chat"))],()=>{lE()},"",{ariaLabel:N("modai.ui.clear_chat")}),g.disable(),p.append(g));let S=[],R=()=>{if(S=[],m.innerHTML="",u=[],e.type==="text"&&Object.keys(E.config.availableAgents).length>0){let C=wa(E.config.availableAgents,E.selectedAgent[`${e.key}/${e.type}`]?.id,y=>{E.selectedAgent[`${e.key}/${e.type}`]=y??void 0},{idProperty:"id",displayProperty:"name",noSelectionText:N("modai.ui.agents"),selectText:N("modai.ui.select_agent"),nullOptionDisplayText:N("modai.ui.no_agent"),icon:Ti,tooltip:N("modai.ui.select_agent")});u.push(C)}E.config.chatAdditionalControls[e.type]&&E.config.chatAdditionalControls[e.type].forEach(C=>{u.push(wa(Object.entries(C.values).reduce((y,[f,I])=>(y[f]={name:I,value:f},y),{}),E.additionalControls[`${e.key}/${e.type}`]?.[C.name]?.value,y=>{let f=`${e.key}/${e.type}`;E.additionalControls[f]||(E.additionalControls[f]={}),y?E.additionalControls[f][C.name]=y:delete E.additionalControls[f][C.name]},{idProperty:"value",displayProperty:"name",noSelectionText:C.label,selectText:C.label,nullOptionDisplayText:`Default ${C.label}`,icon:C.icon,tooltip:`Select ${C.label}`}))});let h=E.config.promptLibrary[e.type];if(h&&h.length>0){let C=mE(h,void 0,y=>{"value"in y&&a.setValue(y.value)},{icon:Ri,tooltip:N("modai.ui.prompt_library"),showSelectedValue:!1,highlightSelectedValue:!1});S.push(C)}S.push(...u),m.append(...c,...S),E.modal.controlButtons=S};R();let A=Hm();return t.append(A),t.append(n,d),a.addEventListener("keydown",h=>{if(h.key==="Enter"){if(h.shiftKey)return;h.preventDefault(),mt()}}),a.addEventListener("input",function(){this.style.height="auto",this.style.height=this.scrollHeight+"px",this.value.trim()!==""?(o.disabled=!1,ae(o,"active")):(o.disabled=!0,ae(o,""))}),n.addEventListener("dragover",h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection dragOver")}),n.addEventListener("dragleave",h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection")}),n.addEventListener("drop",async h=>{h.preventDefault(),h.stopPropagation(),ae(n,"inputSection");let C=null,y=null,f=h.dataTransfer;if(!f)return;let I=f.files;if(I?.length>0){let D=I[0];D.type.startsWith("image/")&&(C=D)}if(!C){let D=f.getData("text/uri-list");D&&(y=D)}if(C){await cn(C),a.focus();return}if(y){let D=new URL(window.location.href);if(!y.startsWith(D.origin)){await cn(y,!0),a.focus();return}try{let F=await fetch(y);if(F.ok){let L=await F.blob();if(L.type.startsWith("image/")){let V=new File([L],"image.png",{type:L.type});await cn(V)}}}catch{We(N("modai.error.failed_to_fetch_image"))}a.focus();return}We(N("modai.error.only_image_files_are_allowed")),a.focus()}),a.addEventListener("paste",async h=>{let C=h.clipboardData?.items;if(C){for(let y=0;y{o.disable(),a.disabled=h.isLoading,h.isLoading?(i.style.display="flex",h.isPreloading||s.enable()):(i.style.display="none",h.isPreloading||s.disable()),[...c,...S].forEach(C=>h.isLoading?C.disable():C.enable()),g&&(h.isLoading||!h.hasMessages?g.disable():g.enable())}),E.modal.messageInput=a,E.modal.modeButtons=c,E.modal.reloadChatControls=R,E.modal.enableSending=()=>{a.disabled=!1,a.placeholder=N("modai.ui.prompt_placeholder"),E.modal.controlButtons.forEach(h=>h.enable())},E.modal.disableSending=()=>{a.disabled=!0,a.placeholder=N("modai.ui.read_only_chat"),E.modal.controlButtons.forEach(h=>h.disable())},t};var gE=()=>{let e=!1,t=null,n=null,r=null,a=null,i=!1,o=!1,s=O("div"),l=[O("div","resize-handle bottom-right"),O("div","resize-handle bottom-left"),O("div","resize-handle top-right"),O("div","resize-handle top-left")];s.append(...l),l.forEach(p=>{p.addEventListener("pointerdown",c)});function c(p){if(e||p.button!==0)return;e=!0,a=p.currentTarget;let g=E.modal.modal.getBoundingClientRect();r={width:g.width,height:g.height,x:g.left,y:g.top,mouseX:p.clientX,mouseY:p.clientY};let S=(a?.className||"").toString();i=S.includes("left"),o=S.includes("top");let R;i===o?R="nwse-resize":R="nesw-resize",document.body.style.cursor=R;try{a.setPointerCapture(p.pointerId)}catch{}document.addEventListener("pointermove",u,{passive:!1}),document.addEventListener("pointerup",m),p.preventDefault(),p.stopPropagation()}function u(p){!e||!r||(p.preventDefault(),n={clientX:p.clientX,clientY:p.clientY},t||(t=requestAnimationFrame(d)))}function d(){if(!n||!e||!r){t=null;return}let p=n.clientX-r.mouseX,g=n.clientY-r.mouseY,S=468,R=500,A=r.x+r.width,h=r.y+r.height,C=(F,L,V)=>Math.max(L,Math.min(V,F)),y=r.x,f=r.y,I,D;if(i)y=C(r.x+p,0,A-S),I=A-y;else{let F=window.innerWidth-r.x;I=C(r.width+p,S,F)}if(o)f=C(r.y+g,0,h-R),D=h-f;else{let F=window.innerHeight-r.y;D=C(r.height+g,R,F)}let k=E.modal.modal;i&&(k.style.left=y+"px"),o&&(k.style.top=f+"px"),k.style.width=I+"px",k.style.height=D+"px",t=null,n=null}function m(p){if(e){p.preventDefault(),p.stopPropagation(),e=!1,document.body.style.cursor="",t&&(cancelAnimationFrame(t),t=null),r&&(n={clientX:p.clientX,clientY:p.clientY},d()),r=null;try{a?.releasePointerCapture(p.pointerId)}catch{}document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",m),a=null,i=!1,o=!1}}return s};var P0=fn(kt,300),SE=e=>{let{shadow:t,shadowRoot:n}=Qe(!0,()=>{ve("instant"),t.messageInput.focus()}),r=O("div","modai--root chat-modal","",{ariaLabel:N("modai.ui.modai_assistant_chat_dialog")}),a=ya();a.position&&(r.style.width=a.position.width??"",r.style.height=a.position.height??"",r.style.top=a.position.top??"",r.style.left=a.position.left??"",r.style.transform="none"),new ResizeObserver(()=>{P0();let s=E.modal.chatMessages.lastElementChild;s&&s.syncHeight?.()}).observe(r),t.modal=r,E.modal=t,E.modal.actionButtons=[],E.modal.modalButtons=[],e.persist&&r.append(eE()),r.append(dE(e)),r.append(cE()),r.append(EE(e));let o=O("div","disclaimer",N("modai.ui.disclaimer"));return r.append(o),r.append(gE()),n.appendChild(r),n.appendChild($e),document.body.append(t),t.isDragging=!1,t.isLoading=!1,t.abortController=void 0,t.offsetX=0,t.offsetY=0,t.history=tr.init({key:`${e.namespace??"modai"}/${e.key}/${e.type}`,persist:e.persist}),t};var F0=["text","image"],ka=e=>{if(E.modalOpen)return;if(e.persist!==!1&&(e.persist=!0),e.context&&(e.withContexts||(e.withContexts=[]),e.withContexts.push({__type:"selection",name:"Selection",renderer:"selection",value:e.context}),e.context=void 0),!e.key){alert(N("modai.error.key_required"));return}if(e.type||(e.type="text"),!e.type){alert(N("modai.error.type_required"));return}if(!Pa(e))return;let n=SE(e);return n.api={sendMessage:async(r,a)=>{await mt(r,a)},closeModal:()=>{ln()}},E.modal.config=e,e.withContexts&&E.modal.context.addContexts(e.withContexts),E.modalOpen=!0,n},Pa=e=>!(!we(["modai_client"])||!we(["modai_client_chat_image"])&&!we(["modai_client_chat_text"])||(e.availableTypes||(e.availableTypes=[e.type]),e.availableTypes=e.availableTypes.filter(t=>F0.includes(t)).filter(t=>we([t==="text"?"modai_client_chat_text":"modai_client_chat_image"])),e.availableTypes.length>0&&!e.availableTypes.includes(e.type)&&(e.type=e.availableTypes[0]),e.availableTypes.length===0||!e.availableTypes.includes(e.type)));var ce={createLoadingOverlay:Ht,localChat:Object.assign(ka,{createModal:ka,verifyPermissions:Pa}),generateButton:Ui};var fE=()=>{let e={key:"_global",persist:!0,availableTypes:["text","image"],type:"text"};if(!ce.localChat.verifyPermissions(e))return;let t=O("li"),{shadow:n,shadowRoot:r}=Qe(),a=Q(Y(24,hi),()=>{ce.localChat.createModal(e)},"global-button",{title:N("modai.ui.modai_assistant")});r.appendChild(a),t.appendChild(n);let i=document.getElementById("modx-leftbar-trigger");i?.parentNode?.insertBefore(t,i)};var bE=()=>{Ext.override(MODx.tree.Directory,{_modAIOriginals:{initComponent:MODx.tree.Directory.prototype.initComponent},initComponent:function(){this.on("afterrender",()=>{let e=this.tbar.dom.querySelector(".x-toolbar-left-row");if(!e)return;let t=document.createElement("td");t.classList.add("x-toolbar-cell");let{shadow:n}=ce.generateButton.rawButton(()=>{let r=this.cm&&this.cm.activeNode?this.cm.activeNode:!1,a=r&&r.attributes.type=="dir"?r.attributes.pathRelative:"/",i=(a.endsWith("/")?a:a+"/")+"{hash}.png";ce.localChat.createModal({key:`media_browser/${this.config.id}`,type:"image",image:{mediaSource:this.getSource(),path:i},imageActions:{download:(o,s)=>{this.fireEvent("afterUpload"),s.api.closeModal()}}})},{iconSize:16});t.appendChild(n),e.appendChild(t)}),this._modAIOriginals.initComponent.call(this)}})};var U0=(e,t)=>{let n=Ext.getCmp(e.firstElementChild?.id),r=n.el.dom.parentElement?.parentElement?.parentElement?.querySelector("label");if(!r)return;ce.generateButton.localChat({targetEl:r,key:`resource/${MODx.request.id}/${t}`,field:t,type:"image",resource:MODx.request.id,image:{mediaSource:n.imageBrowser.source},imageActions:{insert:(i,o)=>{n.imageBrowser.setValue(i.ctx.url),n.onImageChange(i.ctx.url),o.api.closeModal()}}});let a=ce.generateButton.vision({targetEl:n.altTextField.el.dom,input:n.altTextField.items.items[0].el.dom,field:t,resource:MODx.request.id,image:n.imagePreview.el.dom,onUpdate:i=>{n.altTextField.items.items[0].setValue(i.content),n.image.altTag=i.content,n.updateValue()}});a&&(a.style.marginTop="6px"),n.altTextField.el.dom.style.display="flex",n.altTextField.el.dom.style.justifyItems="center",n.altTextField.el.dom.style.alignItems="center"},B0=()=>{let t=Ext.getCmp("modx-resource-content").el.dom.querySelector("label");t&&ce.generateButton.localChat({targetEl:t,key:`resource/${MODx.request.id}/res.content`,field:"res.content",type:"text",availableTypes:["text","image"],resource:MODx.request.id})},G0=e=>{let t=Ext.getCmp("modx-panel-resource").getForm();for(let[n,r]of e.tvs||[]){let a=Ext.get(`tv${n}-tr`);if(!a)continue;let i=t.findField(`tv${n}`),o=`tv.${r}`;if(!i){let s=a.dom.querySelector(".imageplus-panel-input");s&&U0(s,o);continue}if(i.xtype==="textfield"||i.xtype==="textarea"){let s=MODx.config[`modai.tv.${r}.text.prompt`],l=a.dom.querySelector("label");if(!l)return;s?ce.generateButton.forcedText({targetEl:l,input:i.el.dom,resourceId:MODx.request.id,field:o,initialValue:i.getValue(),onChange:(c,u)=>{let d=i.getValue();i.setValue(c.value),i.fireEvent("change",i,c.value,d),u&&(i.el.dom.scrollTop=i.el.dom.scrollHeight)}}):ce.generateButton.localChat({targetEl:l,key:`resource/${MODx.request.id}/${o}`,field:o,type:"text",availableTypes:["text","image"],resource:MODx.request.id})}if(i.xtype==="modx-panel-tv-image"||i.xtype==="imagecropper-combo-browser"){let s=a.dom.querySelector("label");if(!s)return;ce.generateButton.localChat({targetEl:s,key:`resource/${MODx.request.id}/${o}`,field:o,type:"image",resource:MODx.request.id,image:{mediaSource:i.source},imageActions:{insert:(l,c)=>{let u={fullRelativeUrl:l.ctx.fullUrl,relativeUrl:l.ctx.url,url:l.ctx.url};i.xtype==="imagecropper-combo-browser"?i.onSelectImage(u.fullRelativeUrl,i.onTrigger1Click,`tv${n}`):i.items.items[1].fireEvent("select",u),i.fireEvent("select",u),c.api.closeModal()}}})}}},Y0=e=>{let t={pagetitle:["modx-resource-pagetitle"],longtitle:["modx-resource-longtitle","seosuite-longtitle"],introtext:["modx-resource-introtext"],description:["modx-resource-description","seosuite-description"],content:["modx-resource-content"]};for(let n of e.resourceFields||[])if(t[n]){if(n==="content"){B0();continue}t[n].forEach(r=>{let a=Ext.getCmp(r);a&&ce.generateButton.forcedText({targetEl:a.label,resourceId:MODx.request.id,field:`res.${n}`,input:a.el.dom,initialValue:a.getValue(),onChange:(i,o)=>{let s=a.getValue();a.setValue(i.value),a.fireEvent("change",a,i.value,s),o&&(a.el.dom.scrollTop=a.el.dom.scrollHeight)}})})}},TE=e=>{Y0(e),G0(e)};var hE={initOnResource:TE,initGlobalButton:fE,initOnMediaBrowser:bE};var H0=e=>(E.config=e,{executor:$,ui:ce,lng:N,mgr:hE,checkPermissions:we}),q0=(e,t,n)=>{ja(e,t),ii(e,n)};return FE(V0);})();