(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,850123,e=>{"use strict";var t=e.i(841015);e.s(["mountPluginMonacoActions",0,function(e,n,r){for(let a of t.pluginRegistry.monacoEditorActions)r(a)&&(e.getAction(a.id)||e.addAction({id:a.id,label:a.label,keybindings:a.keybindings,contextMenuGroupId:a.contextMenuGroupId,contextMenuOrder:a.contextMenuOrder,run:e=>a.run(e,n)}))}])},727612,e=>{"use strict";let t=(0,e.i(475254).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],727612)},107233,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",0,t],107233)},886871,e=>{"use strict";var t=e.i(843476),n=e.i(488784);let r=new WeakSet;function a(e){return e?`Ln ${e.lineNumber}, Col ${e.column}`:"Ln 1, Col 1"}function o(e){return(t,n)=>{t.addAction({id:"bridgelink.action.clipboardPaste",label:"Paste",contextMenuGroupId:"9_cutcopypaste",contextMenuOrder:4,run:async e=>{let t;if(!navigator.clipboard?.readText)return;try{t=await navigator.clipboard.readText()}catch{return}if(!t)return;let n=e.getSelections();n?.length&&(e.executeEdits("clipboard-paste",n.map(e=>({range:e,text:t,forceMoveMarkers:!0}))),e.focus())}});let o=t.getContribution("editor.contrib.contextmenu");if(o&&"function"==typeof o._getMenuActions&&!o.__blPasteEntryRemoved){let e=o._getMenuActions.bind(o);o._getMenuActions=(...t)=>e(...t).filter(e=>e?.id!=="editor.action.clipboardPasteAction"),o.__blPasteEntryRemoved=!0}!function(e,t){if(e.getModel?.()?.getLanguageId()!=="rhino-js"||r.has(e))return;r.add(e);let n=document.createElement("div");n.className="bl-editor-cursor-status",n.textContent=a(e.getPosition());let o={getId:()=>"bridgelink.overlay.cursorStatus",getDomNode:()=>n,getPosition:()=>({preference:t.editor.OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER})};e.addOverlayWidget(o);let s=e.onDidChangeCursorPosition(e=>{n.textContent=a(e.position)});e.onDidDispose(()=>{s.dispose(),e.removeOverlayWidget(o)})}(t,n),e?.(t,n)}}e.s(["MonacoEditor",0,function({onMount:e,...r}){return(0,t.jsx)(n.default,{...r,onMount:o(e)})},"composeEditorMount",0,o],886871)},128907,e=>{"use strict";var t=e.i(318878);let n=null,r={renderWhitespace:"none",automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace",fontSize:13,lineNumbers:"on",tabSize:2,insertSpaces:!0,wordWrap:"off",fixedOverflowWidgets:!0,occurrencesHighlight:"off"};Object.defineProperty(r,"overflowWidgetsDomNode",{enumerable:!0,get:function(){if("u">typeof document)return n&&n.isConnected||((n=document.createElement("div")).className="monaco-editor monaco-overflow-widgets-root",document.body.appendChild(n)),n}}),e.s(["MONACO_BASE_OPTIONS",0,r,"getRhinoEditorOptions",0,function(e){let n=(0,t.loadAdminPrefs)();return{...r,fontFamily:n.editorFontFamily,fontSize:n.editorFontSize,tabSize:n.editorTabSize,insertSpaces:n.editorInsertSpaces,detectIndentation:!1,minimap:{enabled:n.editorMinimap},stickyScroll:{enabled:n.editorStickyScroll},guides:{indentation:n.editorIndentGuides},renderWhitespace:n.editorRenderWhitespace?"all":"none",renderLineHighlight:"line",snippetSuggestions:"top",tabCompletion:"off",quickSuggestions:!!n.autoCompleteIncludeLetters&&{other:!0,comments:!1,strings:!1},quickSuggestionsDelay:n.autoCompleteDelay,wordBasedSuggestions:n.autoCompleteCharacters?"currentDocument":"off",...e}}])},496087,e=>{"use strict";var t=e.i(271645);let n=Object.freeze({translate:"none",transform:"none",inset:0,margin:"auto"});e.s(["MONACO_DIALOG_CENTER_STYLE",0,n,"useMonacoOverflowHost",0,function(){let[e]=(0,t.useState)(()=>{if("u"<typeof document)return null;let e=document.createElement("div");return e.className="monaco-editor",e.style.position="absolute",e}),n=(0,t.useCallback)(t=>{t&&e&&e.parentNode!==t&&t.appendChild(e)},[e]);return{overflowHost:e,hostRef:n}}])},672515,e=>{"use strict";function t(e){if(!e||0===e.length)return"";let t=e.map(e=>`- Line ${e.line}: ${e.message}`).join("\n");return`

The editor currently reports these validation errors:
${t}`}function n(e){let t=e.length>16e3?`${e.slice(0,16e3)}
// … script truncated for length (${e.length} chars total)`:e;return`\`\`\`javascript
${t}
\`\`\``}function r(e){let t=[];return e.channelName&&t.push(`Channel: ${e.channelName}`),e.mode&&t.push(`Mode: ${e.mode}`),void 0!==e.isSource&&t.push(`Connector: ${e.isSource?"Source":"Destination"}`),e.connectorType&&(t.push(`Connector type: ${e.connectorType}`),"connector-script"===e.location&&t.push(`Script role: ${function(e){switch(e){case"JavaScript Reader":return"This is a JavaScript Reader source connector polling script that runs on each poll cycle. It must RETURN the message (or a list/array of messages) to inject into the channel for processing; there is no inbound `msg` variable, because nothing has arrived yet — this script produces the channel's input. This is not a filter/transformer script.";case"JavaScript Writer":return"This is a JavaScript Writer destination connector dispatch script that runs once per message. It performs the outbound delivery itself and may return a Response/status object (or nothing); it does not assign output to `msg`. This is not a filter/transformer script.";case"Database Reader":return"This is a Database Reader source connector script in JavaScript mode. The SELECT script must return the result set (rows) for the channel to process; the optional post-process (\"run after\") script marks rows as processed and reads column values via `$('columnName')` result variables. This is not a filter/transformer script.";case"Database Writer":return"This is a Database Writer destination connector script in JavaScript mode, run once per message. The script performs the database write itself via a JDBC connection; it does not transform the message or assign to `msg`. This is not a filter/transformer script.";case"JavaScript Attachment Handler":return"This is a JavaScript Attachment Handler script that runs for each inbound message before it is processed. Use it to pull attachment data out of the `message` variable — call `addAttachment(data, type, base64Encode)` to store an attachment (its returned token replaces the data inside the message) — and RETURN the (possibly modified) `message`. This is not a filter/transformer script. It is also not a destination writer.";case"HTTP Listener":case"WebService Listener":return"This is an inbound-request HTTP authentication script for a listener connector. It returns an `AuthenticationResult` — `Success()` to allow the request, `Failure()` to reject it (a `Challenged()` variant also exists for issuing an authentication challenge). This is not a filter/transformer script.";default:return"This is a connector script whose exact contract depends on the connector type. Describe what the code actually does; do not assume transformer semantics or that assigning to `msg` produces output. This is not a filter/transformer script."}}(e.connectorType)}`)),e.inboundDataType&&t.push(`Inbound data type: ${e.inboundDataType}`),e.outboundDataType&&t.push(`Outbound data type: ${e.outboundDataType}`),e.inboundTemplate&&t.push(`Inbound template (truncated):
${e.inboundTemplate.slice(0,16e3)}`),e.outboundTemplate&&t.push(`Outbound template (truncated):
${e.outboundTemplate.slice(0,16e3)}`),e.templateName&&t.push(`Code template: ${e.templateName} (${e.templateType??""})`),t.length>0?`

Context:
${t.join("\n")}`:""}let a={processingError:"Processing Error",postProcessorError:"Postprocessor Error",responseError:"Response Error"},o=["Review what's here"];function s(e){let t=e.trim(),n=/^[ \t]*```[a-zA-Z]*\r?\n/;return n.test(t)?t.replace(n,"").replace(/\r?\n[ \t]*```[ \t]*$/,""):t}e.s(["buildChatMessages",0,function(e,a,o,s,i){let l=r(a),c=`You are a BridgeLink JavaScript assistant. Answer concisely.${l}`,u=s?.trim(),p=u?`Current script:
${n(u)}

`:"",d=`${p}${e}${t(i)}`,h=0;for(;h<o.length&&"assistant"===o[h].role;)h++;let m=o.slice(h);if(0===m.length)return[{role:"user",content:`${c}

${d}`}];let[f,...g]=m;return[{role:"user",content:`${c}

${f.content}`},...g.map(({role:e,content:t})=>({role:e,content:t})),{role:"user",content:d}]},"buildContextSummary",0,function(e){var t;let n=[];return(e.inboundDataType&&e.outboundDataType?n.push(`${e.inboundDataType} → ${e.outboundDataType}`):e.inboundDataType?n.push(e.inboundDataType):e.outboundDataType&&n.push(e.outboundDataType),e.mode&&n.push((t=e.mode)?"responseTransformer"===t?"Response Transformer":t.charAt(0).toUpperCase()+t.slice(1):""),e.connectorType&&n.push(e.connectorType),e.templateName&&n.push(e.templateName),0===n.length&&e.channelName&&n.push(e.channelName),n.length>0)?n.join(" | "):"channel-script"===e.location?"Channel Script":"global-script"===e.location?"Global Script":"No context available"},"buildDescriptionPrompt",0,function(e,t,n){let r=t.trim(),a=r?`

The channel already has this description — improve and expand it, keeping any accurate specifics, rather than starting over:
"""
${r}
"""`:"",o=n?.trim()?`

Additional guidance from the user: ${n.trim()}`:"";return`Write a clear, thorough description for the following BridgeLink channel, for display in its "Channel Description" field. Base it strictly on the channel configuration below — do not invent connectors, transformers, or behavior that is not shown.

Channel configuration:
"""
${e}
"""${a}${o}

Write a verbose, complete description that explains, in plain prose:
- what the channel does end to end (where messages arrive, how they are processed, and where they are sent),
- the source connector and each destination connector and their roles,
- the data formats involved and any filtering or transformation that shapes the message,
- any notable configuration worth calling out (disabled connectors, message storage mode, channel scripts).

Use short paragraphs, with bullet lists where they help. Write for an integration engineer seeing this channel for the first time. Return ONLY the description text — no title, no preamble, no code fences, no commentary.`},"buildErrorExplainPrompt",0,function(e){let t=["Diagnose this BridgeLink message processing error. Explain the most likely cause and suggest a concrete fix.","","Context:",`Channel: ${e.channelName}`,`Connector: ${e.isSource?"Source":"Destination"} "${e.connectorName}"`,`Error type: ${a[e.errorType]}`,"","Error / stack trace:","```",e.errorText.slice(0,16e3),"```"];e.messageContent&&t.push("","Incoming message (as received by this connector):","```",e.messageContent.slice(0,16e3),"```");let r=32e3;if(e.scripts.length>0){t.push("","Scripts on the failing connector:");let a=0;for(let o of e.scripts){let e=n(o.script.trim());if(e.length>r){a++;continue}r-=e.length,t.push("",`### ${o.label}`,e)}a>0&&t.push("",`(${a} script(s) omitted to bound prompt size.)`)}if(e.codeTemplates.length>0){t.push("","Code templates this channel depends on:");let a=0;for(let o of e.codeTemplates){let e=n(o.code.trim());if(e.length>r){a++;continue}r-=e.length,t.push("",`### ${o.name}`,e)}a>0&&t.push("",`(${a} code template(s) omitted to bound prompt size.)`)}return t.join("\n")},"buildExplainPrompt",0,function(e,t){let n=r(t);return`Explain this BridgeLink JavaScript:${n}

\`\`\`javascript
${e}
\`\`\``},"buildFixPrompt",0,function(e,n,a){let o=r(n);return`Fix and improve this BridgeLink JavaScript. Return the improved code in a \`\`\`javascript fence. After the closing fence, add a **Changes made:** section with one bullet per logical change. Format each bullet as: • <what changed> (<why>)${o}${t(a)}

Fix and improve for:
- ES5/Rhino incompatibilities (let/const → var, arrow functions → function expressions, template literals → string concatenation)
- BridgeLink best practices
- Readability and maintainability
- Logic bugs or error-prone patterns

\`\`\`javascript
${e}
\`\`\``},"buildGeneratePrompt",0,function(e,t,a){let o=r(t),s=`Generate BridgeLink JavaScript: ${e}${o}`,i=a?.trim();return i?`${s}

Current script:
${n(i)}

Integrate the requested code with the current script and return ONE complete, updated script in a single \`\`\`javascript fence — not a fragment. Preserve the existing logic unless the request says to change it.`:s},"buildSampleMessagePrompt",0,function(e,t,n){let r;switch(e){case"HL7V2":r="a realistic HL7 v2.x message. Pick an appropriate message type for the request (default to ADT^A01 if none is implied), including only the commonly used segments (e.g. MSH, EVN, PID, PV1) with correctly ordered segments and sensible field values";break;case"XML":r="a well-formed XML clinical/interface document sample";break;case"JSON":r="a valid JSON payload sample";break;case"HL7V3":r="a well-formed HL7 v3 XML message sample";break;case"DICOM":r="a textual DICOM metadata listing (tag, VR, name, value per line)";break;case"EDI/X12":r="a valid EDI X12 transaction sample with correct segment structure";break;case"NCPDP":r="a valid NCPDP telecommunication message sample";break;case"DELIMITED":r="a delimited text sample (CSV-style rows with a consistent column layout)";break;default:r=`a plain-text sample message appropriate for the "${e}" data type`}let a=n?.trim()?`

Request: ${n.trim()}`:"";return`Generate ${r} to use as the ${t} message template of a BridgeLink channel.${a}

Keep the sample concise — include only the segments/elements/fields needed to represent a typical message, not every optional or repeated one, unless the request above asks for a fuller message.

All demographic data (names, MRNs, account numbers, addresses, phone numbers, dates of birth) MUST be clearly fictional — never use real patient data.

Return ONLY the sample message in a single fenced code block, with no commentary before or after it.`},"buildSelectionAttachment",0,function(e){return`Selected snippet:
${n(e)}`},"buildSuggestionPrompt",0,function(e,t){let n=r(t);switch(e){case 1:return`Review this BridgeLink JavaScript for Rhino/ES5 issues and logic bugs.${n}

Check for:
- ES6+ syntax that Rhino cannot run (let/const → must be var; arrow functions → must be function expressions; template literals → must be string concatenation)
- Common BridgeLink scripting errors (e.g., incorrect use of msg, tmp, maps, responseMap)
- Logic bugs, null-dereference risks, and error-prone patterns

Provide a structured Code Review: list each issue found with a brief explanation and the corrected line.`;case 2:return`Show a relevant BridgeLink JavaScript code example for this context.${n}

Provide a practical, working code example that demonstrates a useful pattern for this data type and mode. Use only ES5/Rhino-compatible syntax (var, function expressions, string concatenation — no let/const/arrow functions/template literals). Include brief inline comments explaining each key step.`;case 3:return`Based on the current BridgeLink JavaScript context, suggest what to write next.${n}

Recommend the natural next step for this script given its mode, data types, and connector role. Provide a concrete code snippet (ES5/Rhino-compatible) the engineer can adapt, with a short explanation of why this is a good next step.`}},"buildWelcomePrompt",0,function(e,t,a){let o=r(e),s=o.length>0,i=a&&a.length>0?`

The editor currently reports these validation errors:
${a.map(e=>`- Line ${e.line}: ${e.message}`).join("\n")}
Mention the error directly in your opening sentence, and make one of the OPTIONS below "Fix the validation error".`:"";if(!s){let e=t?.trim();return e?`You are a BridgeLink JavaScript assistant. The user just opened the AI assistant panel with this script open:

${n(e)}${i}

In 1–2 short sentences, start your response with "I" and state directly what this script does.
Use casual, direct language like a coworker who glanced at the screen (e.g. "I see this function...").

Do NOT use passive or hedged language like "is likely" or "appears to".

Then output exactly:

OPTIONS:
1. [specific action for option 1, under 60 characters]
2. [specific action for option 2, under 60 characters — only if you have a genuinely different second suggestion]
3. [specific action for option 3, under 60 characters — only if you have a genuinely different third suggestion]

Output only as many numbered OPTIONS as genuinely apply (1 to 3). No prose after OPTIONS:. No markdown in the options.`:`You are a BridgeLink JavaScript assistant. The user just opened the AI assistant panel.

Write one short sentence starting with "I" that offers to help. Be casual and direct.
Do NOT include numbered options, lists, or "Type 1–4". Just a friendly opener.`}let l=t?.trim(),c=l?`

The script currently open in the editor:
${n(l)}`:"";return`You are a BridgeLink JavaScript assistant. The user just opened the AI assistant panel.${o}${c}${i}

In 1–2 short sentences, start your response with "I" and state directly what you see —
what this channel does, what data it handles, or what mode it's in.
Use casual, direct language like a coworker who glanced at the screen (e.g. "I see you're working on...").

Do NOT use passive or hedged language like "is likely" or "appears to".

Then output exactly:

OPTIONS:
1. [specific action for option 1, under 60 characters]
2. [specific action for option 2, under 60 characters — only if you have a genuinely different second suggestion]
3. [specific action for option 3, under 60 characters — only if you have a genuinely different third suggestion]

Output only as many numbered OPTIONS as genuinely apply (1 to 3). No prose after OPTIONS:. No markdown in the options.`},"diffLines",0,function(e,t){let n=e.split("\n"),r=t.split("\n"),a=n.length,o=r.length,s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=n[e-1]===r[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);let i=[],l=a,c=o;for(;l>0&&c>0;)n[l-1]===r[c-1]?(i.unshift({type:"equal",text:n[l-1]}),l--,c--):s[l-1][c]>=s[l][c-1]?(i.unshift({type:"removed",text:n[l-1]}),l--):(i.unshift({type:"added",text:r[c-1]}),c--);for(;l>0;)i.unshift({type:"removed",text:n[--l]});for(;c>0;)i.unshift({type:"added",text:r[--c]});return i},"hasRhinoIncompatibility",0,function(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/"(?:[^"\\]|\\.)*"/g,'""').replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/\/(?:[^/\\\n]|\\.)+\/[gimsuy]*/g,"/re/");return/\blet\b|\bconst\b|=>|`/.test(t)},"parseFixResponse",0,function(e){try{let t,n,r=/```(?:javascript|js)?\r?\n/.exec(e);if(r){let a=r.index+r[0].length,o=e.slice(a),s=/\r?\n```[ \t]*(?:\r?\n|$)/.exec(o);s?(t=o.slice(0,s.index).trim(),n=a+s.index+s[0].length):(t=o.trimEnd(),n=e.length)}else t=s(e),n=e.length;let a=e.slice(n).split("\n"),o=a.findIndex(e=>/\*\*Changes made:\*\*|\*\*Reasoning:\*\*/i.test(e));if(-1===o)return{code:t,reasoning:[]};let i=a.slice(o+1).map(e=>e.replace(/^[\s•\-*]+/,"").trim()).filter(e=>e.length>0);return{code:t,reasoning:i}}catch{return{code:s(e),reasoning:[]}}},"parseWelcomeResponse",0,function(e){try{let t="\nOPTIONS:",n=e.indexOf(t);if(-1===n)return{assertion:e.trim(),options:[...o]};let r=e.slice(0,n).trimEnd(),a=e.slice(n+t.length).split("\n").map(e=>{let t=/^\d+\.\s+(.+)$/.exec(e.trim());return t?t[1].trim():null}).filter(e=>null!==e);if(a.length<1)return{assertion:r,options:[...o]};return{assertion:r,options:a.slice(0,3)}}catch{return{assertion:e.trim(),options:[...o]}}},"stripCodeFence",0,s,"stripTemplateContext",0,function(e){return null==e.inboundTemplate&&null==e.outboundTemplate?e:{...e,inboundTemplate:void 0,outboundTemplate:void 0}}])},165101,e=>{"use strict";var t=e.i(786103),n=e.i(244128);async function*r(e,r){let o=r?.model??(0,t.getModel)(),s=r?.max_tokens??(0,t.getMaxTokens)(),i="u">typeof sessionStorage?(0,n.getServerUrl)():"",l=await fetch("/api/claude-proxy",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",...i?{"x-bl-server":i}:{}},body:JSON.stringify({messages:e,model:o,max_tokens:s}),signal:r?.signal});if(503===l.status)throw new a("AI not available — configure the org API key in Settings → Claude AI.",503);if(!l.ok)throw new a(`Proxy returned HTTP ${l.status}`,l.status);let c=l.body?.getReader();if(!c)throw new a("Response body is not readable",0);let u=new TextDecoder,p="";try{for(;;){let{done:e,value:t}=await c.read();if(e)break;let n=(p+=u.decode(t,{stream:!0})).split("\n");for(let e of(p=n.pop()??"",n)){if(!e.startsWith("data: "))continue;let t=e.slice(6).trim();if("[DONE]"===t)return;try{let e=JSON.parse(t);if("text"===e.type&&e.text)yield e.text;else if("stop"===e.type&&e.stop_reason)r?.onStop?.(e.stop_reason);else if("error"===e.type)throw new a(e.message??"Upstream error",0)}catch(e){if(e instanceof a)throw e}}}}finally{c.releaseLock()}}class a extends Error{statusCode;constructor(e,t){super(e),this.statusCode=t,this.name="ClaudeStreamError"}}e.s(["ClaudeStreamError",0,a,"claudeStream",0,r])},657150,e=>{"use strict";let t=(0,e.i(475254).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["default",0,t])},531245,e=>{"use strict";var t=e.i(657150);e.s(["Bot",()=>t.default])},565352,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(531245),a=e.i(846696),o=e.i(167881),s=e.i(23750),i=e.i(630374),l=e.i(131770),c=e.i(9718),u=e.i(823366);function p(e){return e?(0,u.parseFilterFromXml)(e).elements.length:0}function d(e){return e?(0,u.parseTransformerFromXml)(e).elements.length:0}function h(e,t){let n=e.trim();return n.length>0&&n!==t.trim()}function m(e,t){let n=[`${t}Data: ${e.inboundDataType} → ${e.outboundDataType}`];return e.filterRuleCount>0&&n.push(`${t}Filter: ${e.filterRuleCount} rule(s)`),e.transformerStepCount>0&&n.push(`${t}Transformer: ${e.transformerStepCount} step(s)`),e.responseTransformerStepCount&&e.responseTransformerStepCount>0&&n.push(`${t}Response transformer: ${e.responseTransformerStepCount} step(s)`),n}var f=e.i(165101),g=e.i(329294),y=e.i(672515),b=e.i(786103),v=e.i(685430);e.s(["DescriptionGeneratePanel",0,function({value:e,setValue:u,channelName:T,channelXml:S}){(0,l.useCompactMode)();let[x]=(0,n.useState)(()=>(0,b.getEnabled)()),[w,$]=(0,n.useState)(!1),[C,k]=(0,n.useState)(""),[D,N]=(0,n.useState)(""),[I,M]=(0,n.useState)(!1),P=(0,n.useRef)(null),R=(0,n.useRef)(0);if((0,n.useEffect)(()=>()=>{P.current?.abort()},[]),!x)return null;let E=e.trim().length>0?"Improve":"Generate";function O(){R.current++,P.current?.abort(),P.current=null}function A(e){$(e),e||(O(),M(!1),N(""),k(""))}async function L(){let t;O();let n=new AbortController;P.current=n;let r=R.current;M(!0),N("");try{let e,n,r,a,o,s,i,l,u,f,g,y;t=(e=(0,c.parseSummaryFromXml)(S),n=(0,c.parseSourceConnectorFromXml)(S),r=(0,c.parseDestinationConnectorsFromXml)(S),a=(0,c.parseDataTypesFromXml)(S),o=(0,c.parseScriptsFromXml)(S),s=a.connectors.find(e=>"source"===e.id),i={name:"Source",transportName:n.transportName,inboundDataType:s?.inboundDataType??"RAW",outboundDataType:s?.outboundDataType??"RAW",filterRuleCount:p(n.filterXml),transformerStepCount:d(n.transformerXml)},l=r.map((e,t)=>{let n=a.connectors.find(e=>e.id===`dest-${t}`),r=a.connectors.find(e=>e.id===`dest-${t}-response`);return{name:e.name,transportName:e.transportName,enabled:e.enabled,inboundDataType:n?.inboundDataType??"RAW",outboundDataType:n?.outboundDataType??"RAW",filterRuleCount:p(e.filterXml),transformerStepCount:d(e.transformerXml),responseTransformerStepCount:r?d(e.responseTransformerXml):0}}),u={preprocessor:h(o.preprocessing,c.DEFAULT_SCRIPTS.preprocessing),postprocessor:h(o.postprocessing,c.DEFAULT_SCRIPTS.postprocessing),deploy:h(o.deploy,c.DEFAULT_SCRIPTS.deploy),undeploy:h(o.undeploy,c.DEFAULT_SCRIPTS.undeploy)},{...f={channelName:(0,c.parseChannelName)(S)||e.name||"Untitled channel",enabled:e.enabled,initialState:e.initialState,messageStorageMode:e.messageStorageMode,source:i,destinations:l,scripts:u},text:((g=[]).push(`Channel: ${f.channelName}`),g.push(`Status: ${f.enabled?"enabled":"disabled"}, initial state ${f.initialState}`),g.push(`Message storage: ${f.messageStorageMode}`),g.push(""),g.push(`Source connector: ${f.source.transportName}`),g.push(...m(f.source,"  ")),g.push(""),0===f.destinations.length?g.push("Destinations: none"):(g.push(`Destinations (${f.destinations.length}):`),f.destinations.forEach((e,t)=>{let n=!1===e.enabled?" (disabled)":"";g.push(`  ${t+1}. ${e.name} — ${e.transportName}${n}`),g.push(...m(e,"     "))})),(y=Object.entries(f.scripts).filter(([,e])=>e).map(([e])=>e)).length>0&&(g.push(""),g.push(`Channel scripts: ${y.join(", ")}`)),g.join("\n"))}).text}catch{M(!1),a.toast.error("Could not read the channel configuration for context.");return}let o=[{role:"user",content:(0,y.buildDescriptionPrompt)(t,e,C)}],s=(0,b.getModel)();try{let e=(0,g.pickFastModel)(await (0,g.getClaudeAiModels)());e&&(s=e)}catch{}if(R.current===r)try{for await(let e of(0,f.claudeStream)(o,{signal:n.signal,model:s,max_tokens:2e3})){if(R.current!==r)return;N(t=>t+e)}}catch{R.current===r&&a.toast.error("Description generation failed. Check your API key in AI Settings.")}finally{R.current===r&&M(!1)}}let j=`${E} Channel Description${T?`: ${T}`:""}`;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>$(!0),"aria-label":`${E} channel description with ${v.AI_DISPLAY_NAME}`,title:`${E} a channel description with ${v.AI_DISPLAY_NAME}`,className:"absolute top-2 right-2 z-10 flex items-center justify-center w-8 h-8 rounded-full shadow border border-border bg-primary text-primary-foreground hover:opacity-90 transition-opacity",children:(0,t.jsx)(r.Bot,{size:16})}),(0,t.jsx)(i.Dialog,{open:w,onOpenChange:A,children:(0,t.jsxs)(i.DialogContent,{className:"sm:max-w-2xl",children:[(0,t.jsx)(i.DialogHeader,{children:(0,t.jsx)(i.DialogTitle,{children:j})}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 min-h-0 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(s.Input,{value:C,onChange:e=>k(e.target.value),placeholder:"Optional guidance, e.g. focus on the HL7 routing",disabled:I,onKeyDown:e=>{"Enter"!==e.key||I||(e.preventDefault(),L())}}),(0,t.jsx)(o.Button,{size:"sm",onClick:()=>void L(),disabled:I,children:I?"Generating…":E})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Generated from this channel's connectors, data types, and transformers."}),(D||I)&&(0,t.jsx)("div",{"aria-label":"Generated description preview",className:"max-h-72 min-w-0 max-w-full overflow-auto rounded border border-border bg-muted p-2 text-sm whitespace-pre-wrap break-words"+(I?" animate-pulse":""),children:(0,y.stripCodeFence)(D)||"Generating…"})]}),(0,t.jsxs)(i.DialogFooter,{children:[(0,t.jsx)(o.Button,{variant:"outline",size:"sm",onClick:()=>A(!1),children:"Cancel"}),(0,t.jsx)(o.Button,{size:"sm",onClick:function(){u((0,y.stripCodeFence)(D)),(0,a.toast)("Description replaced",{action:{label:"Undo",onClick:()=>u(e)}}),A(!1)},disabled:I||!D.trim(),children:"Apply"})]})]})})]})}],565352)},829168,e=>{e.v(t=>Promise.all(["static/chunks/1wqiwke9ww2l5.js","static/chunks/2cf671fk1yxx0.js"].map(t=>e.l(t))).then(()=>t(486609)))}]);