makecc 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -147,4 +147,4 @@ ${new Date().toISOString()}`;return n.onNodeProgress(e.id,100),n.onLog("success"
147
147
  `))+1))}const u="#".repeat(a),f=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
148
148
  `,...l.current()});return/^[\t ]/.test(h)&&(h=vl(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),d(),f(),h}C2.peek=BB;function C2(e){return e.value||""}function BB(){return"<"}T2.peek=HB;function T2(e,t,n,r){const a=Cg(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let f=n.enter("label");const d=n.createTracker(r);let h=d.move("![");return h+=d.move(n.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(f=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),f(),e.title&&(f=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),f()),h+=d.move(")"),u(),h}function HB(){return"!"}A2.peek=UB;function A2(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const f=n.createTracker(r);let d=f.move("![");const h=n.safe(e.alt,{before:d,after:"]",...f.current()});d+=f.move(h+"]["),u();const g=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...f.current()});return u(),n.stack=g,l(),a==="full"||!h||h!==m?d+=f.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=f.move("]"),d}function UB(){return"!"}M2.peek=IB;function M2(e,t,n){let r=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],f=n.compilePattern(u);let d;if(u.atBreak)for(;d=f.exec(r);){let h=d.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(d.index+1)}}return a+r+a}function IB(){return"`"}function j2(e,t){const n=xg(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}R2.peek=qB;function R2(e,t,n,r){const a=Cg(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let f,d;if(j2(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),f(),n.stack=g,m}f=n.enter("link"),d=n.enter("label");let h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=u.move(" "+a),h+=u.move(n.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),f(),h}function qB(e,t,n){return j2(e,n)?"<":"["}z2.peek=$B;function z2(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const f=n.createTracker(r);let d=f.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...f.current()});d+=f.move(h+"]["),u();const g=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...f.current()});return u(),n.stack=g,l(),a==="full"||!h||h!==m?d+=f.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=f.move("]"),d}function $B(){return"["}function Tg(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function PB(e){const t=Tg(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function VB(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function O2(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function FB(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?VB(n):Tg(n);const f=e.ordered?u==="."?")":".":PB(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),O2(n)===u&&g){let m=-1;for(;++m<e.children.length;){const x=e.children[m];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=f),n.bulletCurrent=u;const h=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),h}function YB(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function XB(e,t,n,r){const a=YB(n);let l=n.bulletCurrent||Tg(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const f=n.createTracker(r);f.move(l+" ".repeat(u-l.length)),f.shift(u);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return d(),h;function g(m,x,b){return x?(b?"":" ".repeat(u))+m:(b?l:l+" ".repeat(u-l.length))+m}}function GB(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),a(),u}const ZB=$f(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function QB(e,t,n,r){return(e.children.some(function(u){return ZB(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function KB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}D2.peek=JB;function D2(e,t,n,r){const a=KB(n),l=n.enter("strong"),u=n.createTracker(r),f=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:f,...u.current()}));const h=d.charCodeAt(0),g=hf(r.before.charCodeAt(r.before.length-1),h,a);g.inside&&(d=vl(h)+d.slice(1));const m=d.charCodeAt(d.length-1),x=hf(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+vl(m));const b=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:g.outside},f+d+b}function JB(e,t,n){return n.options.strong||"*"}function WB(e,t,n,r){return n.safe(e.value,r)}function e8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function t8(e,t,n){const r=(O2(n)+(n.options.ruleSpaces?" ":"")).repeat(e8(n));return n.options.ruleSpaces?r.slice(0,-1):r}const L2={blockquote:kB,break:Xv,code:MB,definition:RB,emphasis:N2,hardBreak:Xv,heading:LB,html:C2,image:T2,imageReference:A2,inlineCode:M2,link:R2,linkReference:z2,list:FB,listItem:XB,paragraph:GB,root:QB,strong:D2,text:WB,thematicBreak:t8};function n8(){return{enter:{table:i8,tableData:Gv,tableHeader:Gv,tableRow:s8},exit:{codeText:a8,table:r8,tableData:Gp,tableHeader:Gp,tableRow:Gp}}}function i8(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function r8(e){this.exit(e),this.data.inTable=void 0}function s8(e){this.enter({type:"tableRow",children:[]},e)}function Gp(e){this.exit(e)}function Gv(e){this.enter({type:"tableCell",children:[]},e)}function a8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,o8));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function o8(e,t){return t==="|"?t:e}function l8(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
149
149
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:f}};function u(b,w,k,N){return h(g(b,k,N),b.align)}function f(b,w,k,N){const _=m(b,k,N),z=h([_]);return z.slice(0,z.indexOf(`
150
- `))}function d(b,w,k,N){const _=k.enter("tableCell"),z=k.enter("phrasing"),E=k.containerPhrasing(b,{...N,before:l,after:l});return z(),_(),E}function h(b,w){return SB(b,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function g(b,w,k){const N=b.children;let _=-1;const z=[],E=w.enter("table");for(;++_<N.length;)z[_]=m(N[_],w,k);return E(),z}function m(b,w,k){const N=b.children;let _=-1;const z=[],E=w.enter("tableRow");for(;++_<N.length;)z[_]=d(N[_],b,w,k);return E(),z}function x(b,w,k){let N=L2.inlineCode(b,w,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function u8(){return{exit:{taskListCheckValueChecked:Zv,taskListCheckValueUnchecked:Zv,paragraph:f8}}}function c8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:d8}}}function Zv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function f8(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const f=a[l];if(f.type==="paragraph"){u=f;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function d8(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",f=n.createTracker(r);l&&f.move(u);let d=L2.listItem(e,t,n,{...r,...f.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(g){return g+u}}function h8(){return[FL(),dB(),gB(),n8(),u8()]}function p8(e){return{extensions:[YL(),hB(e),yB(),l8(e),c8()]}}const m8={tokenize:w8,partial:!0},B2={tokenize:S8,partial:!0},H2={tokenize:_8,partial:!0},U2={tokenize:k8,partial:!0},g8={tokenize:E8,partial:!0},I2={name:"wwwAutolink",tokenize:b8,previous:$2},q2={name:"protocolAutolink",tokenize:v8,previous:P2},Fi={name:"emailAutolink",tokenize:x8,previous:V2},hi={};function y8(){return{text:hi}}let ts=48;for(;ts<123;)hi[ts]=Fi,ts++,ts===58?ts=65:ts===91&&(ts=97);hi[43]=Fi;hi[45]=Fi;hi[46]=Fi;hi[95]=Fi;hi[72]=[Fi,q2];hi[104]=[Fi,q2];hi[87]=[Fi,I2];hi[119]=[Fi,I2];function x8(e,t,n){const r=this;let a,l;return u;function u(m){return!jm(m)||!V2.call(r,r.previous)||Ag(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(m))}function f(m){return jm(m)?(e.consume(m),f):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(g8,g,h)(m):m===45||m===95||$t(m)?(l=!0,e.consume(m),d):g(m)}function h(m){return e.consume(m),a=!0,d}function g(m){return l&&a&&Zt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function b8(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!$2.call(r,r.previous)||Ag(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(m8,e.attempt(B2,e.attempt(H2,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function v8(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&P2.call(r,r.previous)&&!Ag(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),f):n(m)}function f(m){if(Zt(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),f;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?h:(l=!0,d)):n(m)}function h(m){return m===null||cf(m)||st(m)||fs(m)||Uf(m)?n(m):e.attempt(B2,e.attempt(H2,g),n)(m)}function g(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function w8(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function S8(e,t,n){let r,a,l;return u;function u(h){return h===46||h===95?e.check(U2,d,f)(h):h===null||st(h)||fs(h)||h!==45&&Uf(h)?d(h):(l=!0,e.consume(h),u)}function f(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),u}function d(h){return a||r||!l?n(h):t(h)}}function _8(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(U2,t,l)(u):u===null||st(u)||fs(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function k8(e,t,n){return r;function r(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),r):f===38?(e.consume(f),l):f===93?(e.consume(f),a):f===60||f===null||st(f)||fs(f)?t(f):n(f)}function a(f){return f===null||f===40||f===91||st(f)||fs(f)?t(f):r(f)}function l(f){return Zt(f)?u(f):n(f)}function u(f){return f===59?(e.consume(f),r):Zt(f)?(e.consume(f),u):n(f)}}function E8(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return $t(l)?n(l):t(l)}}function $2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||st(e)}function P2(e){return!Zt(e)}function V2(e){return!(e===47||jm(e))}function jm(e){return e===43||e===45||e===46||e===95||$t(e)}function Ag(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const N8={tokenize:O8,partial:!0};function C8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:j8,continuation:{tokenize:R8},exit:z8}},text:{91:{name:"gfmFootnoteCall",tokenize:M8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:T8,resolveTo:A8}}}}function T8(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return f;function f(d){if(!u||!u._balanced)return n(d);const h=Zn(r.sliceSerialize({start:u.end,end:r.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function A8(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},f=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...f),e}function M8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return f;function f(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||st(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Zn(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return st(m)||(u=!0),l++,e.consume(m),m===92?g:h}function g(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function j8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,f;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(w)}function g(w){if(u>999||w===93&&!f||w===null||w===91||st(w))return n(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return l=Zn(r.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return st(w)||(f=!0),u++,e.consume(w),w===92?m:g}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,g):g(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),Fe(e,b,"gfmFootnoteDefinitionWhitespace")):n(w)}function b(w){return t(w)}}function R8(e,t,n){return e.check(zl,t,e.attempt(N8,t,n))}function z8(e){e.exit("gfmFootnoteDefinition")}function O8(e,t,n){const r=this;return Fe(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function D8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,f){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let h=d;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[d][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",g,f],["enter",u[h][1],f],["exit",u[h][1],f],["enter",m,f]],b=f.parser.constructs.insideSpan.null;b&&_n(x,x.length,0,If(b,u.slice(h+1,d),f)),_n(x,x.length,0,[["exit",m,f],["enter",u[d][1],f],["exit",u[d][1],f],["exit",g,f]]),_n(u,h-1,d-h+3,x),d=h+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,f,d){const h=this.previous,g=this.events;let m=0;return x;function x(w){return h===126&&g[g.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),b(w))}function b(w){const k=Ea(h);if(w===126)return m>1?d(w):(u.consume(w),m++,b);if(m<2&&!n)return d(w);const N=u.exit("strikethroughSequenceTemporary"),_=Ea(w);return N._open=!_||_===2&&!!k,N._close=!k||k===2&&!!_,f(w)}}}class L8{constructor(){this.map=[]}add(t,n,r){B8(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function B8(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function H8(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function U8(){return{flow:{null:{name:"table",tokenize:I8,resolveAll:q8}}}}function I8(e,t,n){const r=this;let a=0,l=0,u;return f;function f(H){let $=r.events.length-1;for(;$>-1;){const D=r.events[$][1].type;if(D==="lineEnding"||D==="linePrefix")$--;else break}const P=$>-1?r.events[$][1].type:null,te=P==="tableHead"||P==="tableRow"?A:d;return te===A&&r.parser.lazy[r.now().line]?n(H):te(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(u=!0,l+=1),g(H)}function g(H){return H===null?n(H):Se(H)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):n(H):He(H)?Fe(e,g,"whitespace")(H):(l+=1,u&&(u=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),m(H)))}function m(H){return H===null||H===124||st(H)?(e.exit("data"),g(H)):(e.consume(H),H===92?x:m)}function x(H){return H===92||H===124?(e.consume(H),m):m(H)}function b(H){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(H):(e.enter("tableDelimiterRow"),u=!1,He(H)?Fe(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?N(H):H===124?(u=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),k):L(H)}function k(H){return He(H)?Fe(e,N,"whitespace")(H):N(H)}function N(H){return H===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(l+=1,_(H)):H===null||Se(H)?C(H):L(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),z(H)):L(H)}function z(H){return H===45?(e.consume(H),z):H===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(H))}function E(H){return He(H)?Fe(e,C,"whitespace")(H):C(H)}function C(H){return H===124?w(H):H===null||Se(H)?!u||a!==l?L(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):L(H)}function L(H){return n(H)}function A(H){return e.enter("tableRow"),B(H)}function B(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),B):H===null||Se(H)?(e.exit("tableRow"),t(H)):He(H)?Fe(e,B,"whitespace")(H):(e.enter("data"),G(H))}function G(H){return H===null||H===124||st(H)?(e.exit("data"),B(H)):(e.consume(H),H===92?Z:G)}function Z(H){return H===92||H===124?(e.consume(H),G):G(H)}}function q8(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],f=!1,d=0,h,g,m;const x=new L8;for(;++n<e.length;){const b=e[n],w=b[1];b[0]==="enter"?w.type==="tableHead"?(f=!1,d!==0&&(Qv(x,t,d,h,g),g=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],f&&(f=!1,g={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",g,t]])),a=w.type==="tableDelimiterRow"?2:g?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=zc(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=zc(x,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(f=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=zc(x,t,l,a,n,m)):u[1]!==0&&(m=zc(x,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&Qv(x,t,d,h,g),x.consume(t.events),n=-1;++n<t.events.length;){const b=t.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=H8(t.events,n))}return e}function zc(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",f="tableContent";n[0]!==0&&(l.end=Object.assign({},oa(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=oa(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=oa(t.events,n[2]),g=oa(t.events,n[3]),m={type:f,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],b=t.events[n[3]];if(x[1].end=Object.assign({},b[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,k=n[3]-n[2]-1;e.add(w,k,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},oa(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function Qv(e,t,n,r,a){const l=[],u=oa(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function oa(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const $8={name:"tasklistCheck",tokenize:V8};function P8(){return{text:{91:$8}}}function V8(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return st(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(d)}function f(d){return Se(d)?t(d):He(d)?e.check({tokenize:F8},t,n)(d):n(d)}}function F8(e,t,n){return Fe(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function Y8(e){return t2([y8(),C8(),D8(e),U8(),P8()])}const X8={};function Kv(e){const t=this,n=e||X8,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(Y8(n)),l.push(h8()),u.push(p8(n))}function G8(){const{isRunning:e,results:t,workflowResults:n,logs:r}=Na(),{nodes:a,selectedNodeId:l,updateNode:u}=ci(),f=ci(WS),{execute:d,generatedFiles:h,downloadFile:g,downloadAllFiles:m}=D_(),[x,b]=X.useState("");X.useEffect(()=>{if(f?.type==="input"){const C=f.data;b(C.value||"")}},[l,f]);const w=a.filter(C=>C.type==="output"),k=w.length>0?t.get(w[0].id):null,N=f?.type==="input",_=N?f.data:null,z=C=>{b(C),l&&u(l,{value:C})},E=()=>{d()};return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ZS,{className:"w-5 h-5 text-gray-400"}),v.jsx("h3",{className:"text-lg font-semibold text-white",children:"Preview"})]}),e&&v.jsx("span",{className:"text-sm text-blue-400 animate-pulse",children:"Running..."})]}),e&&v.jsx("div",{className:"p-4 border-b border-border",children:v.jsx("div",{className:"space-y-3",children:a.map(C=>v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("div",{className:`w-2 h-2 rounded-full ${C.data.status==="completed"?"bg-green-500":C.data.status==="running"?"bg-blue-500 animate-pulse":C.data.status==="error"?"bg-red-500":"bg-gray-500"}`}),v.jsx("span",{className:"text-sm text-gray-300",children:C.data.label}),C.data.status==="running"&&C.data.progress!==void 0&&v.jsxs("span",{className:"text-xs text-gray-500",children:[C.data.progress,"%"]})]},C.id))})}),v.jsxs("div",{className:"p-4 border-b border-border",children:[v.jsxs("button",{onClick:E,disabled:e||a.length===0,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-amber-600 hover:bg-amber-700 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg font-medium transition-colors",children:[v.jsx(yl,{className:"w-4 h-4"}),e?"Running...":"Run Workflow"]}),a.length===0&&v.jsx("p",{className:"text-xs text-gray-500 text-center mt-2",children:"노드를 추가해주세요"})]}),v.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[N&&_&&v.jsxs("div",{className:"space-y-4 mb-4 p-4 bg-surface rounded-lg border border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(Af,{className:"w-5 h-5 text-amber-500"}),v.jsx("h4",{className:"text-md font-medium text-white",children:_.label})]}),_.inputType==="text"&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Enter your input"}),v.jsx("textarea",{className:"w-full h-32 px-3 py-2 text-sm bg-surface border border-border rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent resize-none",placeholder:_.placeholder||"Type your message here...",value:x||_.value||"",onChange:C=>z(C.target.value)})]}),_.inputType==="file"&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Upload a file"}),v.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-32 border-2 border-dashed border-gray-600 rounded-lg hover:border-amber-500 transition-colors cursor-pointer",children:[v.jsx(zj,{className:"w-8 h-8 text-gray-500 mb-2"}),v.jsx("p",{className:"text-sm text-gray-400",children:"Drop files here or click to upload"}),_.fileTypes&&v.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Supported: ",_.fileTypes.join(", ")]})]})]}),_.inputType==="select"&&_.options&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Select an option"}),v.jsxs("select",{className:"w-full px-3 py-2 text-sm bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-amber-500",value:x||_.value||"",onChange:C=>z(C.target.value),children:[v.jsx("option",{value:"",children:"Select..."}),_.options.map(C=>v.jsx("option",{value:C,children:C},C))]})]})]}),h.length>0&&v.jsxs("div",{className:"mb-4 p-4 bg-green-900/20 border border-green-700 rounded-lg",children:[v.jsxs("div",{className:"flex items-center justify-between mb-3",children:[v.jsx("h4",{className:"text-sm font-medium text-green-300",children:"생성된 파일"}),v.jsxs("button",{onClick:m,className:"flex items-center gap-1 px-2 py-1 text-xs bg-green-600 hover:bg-green-700 text-white rounded transition-colors",children:[v.jsx(da,{className:"w-3 h-3"}),"전체 다운로드"]})]}),v.jsx("div",{className:"space-y-2",children:h.map((C,L)=>v.jsxs("div",{className:"flex items-center justify-between p-2 bg-surface rounded",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ha,{className:"w-4 h-4 text-blue-400"}),v.jsx("span",{className:"text-sm text-white",children:C.name})]}),v.jsx("button",{onClick:()=>g(C.name,C.content),className:"p-1 hover:bg-surface-hover rounded transition-colors",children:v.jsx(da,{className:"w-4 h-4 text-gray-400"})})]},L))})]}),n.length>0?v.jsx("div",{className:"space-y-4",children:n.map(C=>v.jsxs("div",{className:`p-4 rounded-lg border ${C.success?"bg-surface border-border":"bg-red-900/20 border-red-700"}`,children:[v.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.success?v.jsx(Tf,{className:"w-5 h-5 text-green-500"}):v.jsx(ig,{className:"w-5 h-5 text-red-500"}),v.jsx("h5",{className:"text-sm font-medium text-white",children:C.label})]}),C.error&&v.jsx("p",{className:"text-sm text-red-400 mb-3",children:C.error}),C.files&&C.files.length>0&&v.jsxs("div",{className:"space-y-2 mb-3",children:[v.jsx("p",{className:"text-xs text-gray-400",children:"생성된 파일:"}),C.files.map((L,A)=>v.jsxs("div",{className:"flex items-center gap-2 p-2 bg-surface-hover rounded",children:[L.type==="image"?v.jsx(QS,{className:"w-4 h-4 text-purple-400"}):v.jsx(ha,{className:"w-4 h-4 text-blue-400"}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("p",{className:"text-sm text-white truncate",children:L.name}),v.jsx("p",{className:"text-xs text-gray-500 truncate",children:L.path})]})]},A))]}),C.result&&v.jsxs("details",{className:"group",open:!0,children:[v.jsx("summary",{className:"text-xs text-gray-400 cursor-pointer hover:text-gray-300",children:"결과 보기"}),v.jsx("div",{className:"mt-2 p-2 bg-black/30 rounded max-h-64 overflow-y-auto",children:v.jsx("div",{className:"markdown-content text-sm",children:v.jsx(Pv,{remarkPlugins:[Kv],children:C.result.length>2e3?C.result.substring(0,2e3)+"...":C.result})})})]})]},C.nodeId))}):k?v.jsx("div",{className:"markdown-content",children:v.jsx(Pv,{remarkPlugins:[Kv],children:typeof k=="string"?k:JSON.stringify(k,null,2)})}):r.length>0?v.jsxs("div",{className:"space-y-2",children:[v.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"실행 로그"}),r.slice(-20).map(C=>v.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[v.jsx("span",{className:"text-gray-500 shrink-0",children:new Date(C.timestamp).toLocaleTimeString("ko-KR")}),v.jsx("span",{className:C.level==="error"?"text-red-400":C.level==="warning"?"text-yellow-400":C.level==="success"?"text-green-400":"text-gray-300",children:C.message})]},C.id))]}):v.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[v.jsx(ha,{className:"w-12 h-12 mb-4 opacity-50"}),v.jsx("p",{className:"text-sm",children:"Run the workflow to see results"}),v.jsx("p",{className:"text-xs mt-2",children:"노드를 연결하고 Run Workflow 버튼을 클릭하세요"})]})]}),(k||h.length>0)&&v.jsx("div",{className:"flex items-center gap-2 p-4 border-t border-border",children:v.jsxs("button",{onClick:m,disabled:h.length===0,className:"flex items-center gap-2 px-3 py-2 bg-surface-hover rounded-lg text-sm hover:bg-border transition-colors disabled:opacity-50",children:[v.jsx(da,{className:"w-4 h-4"}),"Download .md"]})})]})}function F2({level:e}){switch(e){case"success":return v.jsx(Tf,{className:"w-4 h-4 text-green-400"});case"error":return v.jsx(ig,{className:"w-4 h-4 text-red-400"});case"warning":return v.jsx(jj,{className:"w-4 h-4 text-yellow-400"});default:return v.jsx(rj,{className:"w-4 h-4 text-blue-400"})}}function Y2(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Z8({isOpen:e,onClose:t}){const{logs:n,clearLogs:r,isRunning:a}=Na(),[l,u]=X.useState(!1),[f,d]=X.useState(250),h=X.useRef(null);X.useEffect(()=>{h.current&&!l&&h.current.scrollIntoView({behavior:"smooth"})},[n,l]);const g=m=>{m.preventDefault();const x=m.clientY,b=f,w=N=>{const _=x-N.clientY,z=Math.min(Math.max(b+_,100),500);d(z)},k=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)};return e?v.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[#1a1a1a] border-t border-gray-700 z-50 shadow-2xl",style:{height:l?40:f},children:[!l&&v.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-ns-resize hover:bg-amber-500 transition-colors",onMouseDown:g}),v.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#252525] border-b border-gray-700",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ds,{className:"w-4 h-4 text-amber-500"}),v.jsx("span",{className:"text-sm font-medium text-white",children:"Console"}),a&&v.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 rounded",children:[v.jsx("span",{className:"w-1.5 h-1.5 bg-blue-400 rounded-full animate-pulse"}),"Running"]}),v.jsxs("span",{className:"text-xs text-gray-500",children:["(",n.length," logs)"]})]}),v.jsxs("div",{className:"flex items-center gap-1",children:[v.jsx("button",{onClick:r,className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Clear logs",children:v.jsx(Mf,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:()=>u(!l),className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:l?"Expand":"Minimize",children:l?v.jsx(I5,{className:"w-4 h-4 text-gray-400"}):v.jsx(GS,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:()=>d(f===250?400:250),className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Toggle size",children:f>250?v.jsx(pj,{className:"w-4 h-4 text-gray-400"}):v.jsx(fj,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:t,className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Close",children:v.jsx(rg,{className:"w-4 h-4 text-gray-400"})})]})]}),!l&&v.jsx("div",{className:"overflow-y-auto font-mono text-sm p-3",style:{height:f-44},children:n.length===0?v.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:v.jsx("p",{children:"No logs yet. Run the workflow to see output."})}):v.jsxs("div",{className:"space-y-1",children:[n.map(m=>v.jsxs("div",{className:Gt("flex items-start gap-2 px-2 py-1 rounded hover:bg-gray-800/50",m.level==="error"&&"bg-red-500/10",m.level==="warning"&&"bg-yellow-500/10",m.level==="success"&&"bg-green-500/10"),children:[v.jsxs("span",{className:"text-gray-600 shrink-0 text-xs",children:["[",Y2(m.timestamp),"]"]}),v.jsx(F2,{level:m.level}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("span",{className:Gt("text-xs",m.level==="error"&&"text-red-400",m.level==="warning"&&"text-yellow-400",m.level==="success"&&"text-green-400",m.level==="info"&&"text-gray-300"),children:m.message}),m.nodeId&&v.jsxs("span",{className:"ml-2 text-purple-400 text-xs",children:["[",m.nodeId.slice(0,8),"]"]}),m.details&&v.jsx("pre",{className:"mt-1 p-2 bg-black/30 rounded text-xs text-gray-400 overflow-x-auto",children:typeof m.details=="string"?m.details:JSON.stringify(m.details,null,2)})]})]},m.id)),v.jsx("div",{ref:h})]})})]}):null}function Q8(){const{logs:e,clearLogs:t,isRunning:n}=Na(),r=X.useRef(null);return X.useEffect(()=>{r.current&&r.current.scrollIntoView({behavior:"smooth"})},[e]),v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ds,{className:"w-5 h-5 text-amber-500"}),v.jsx("h3",{className:"text-lg font-semibold text-white",children:"Console"}),n&&v.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 rounded",children:[v.jsx("span",{className:"w-1.5 h-1.5 bg-blue-400 rounded-full animate-pulse"}),"Running"]}),v.jsxs("span",{className:"text-xs text-gray-500",children:["(",e.length," logs)"]})]}),v.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-white hover:bg-surface-hover rounded-lg transition-colors",title:"Clear logs",children:v.jsx(Mf,{className:"w-4 h-4"})})]}),v.jsx("div",{className:"flex-1 overflow-y-auto p-4 font-mono text-sm",children:e.length===0?v.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:v.jsx("p",{children:"No logs yet. Run the workflow to see output."})}):v.jsxs("div",{className:"space-y-1",children:[e.map(a=>v.jsxs("div",{className:Gt("flex items-start gap-2 px-2 py-1 rounded hover:bg-surface-hover",a.level==="error"&&"bg-red-500/10",a.level==="warning"&&"bg-yellow-500/10",a.level==="success"&&"bg-green-500/10"),children:[v.jsxs("span",{className:"text-gray-600 shrink-0 text-xs",children:["[",Y2(a.timestamp),"]"]}),v.jsx(F2,{level:a.level}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("span",{className:Gt("text-xs",a.level==="error"&&"text-red-400",a.level==="warning"&&"text-yellow-400",a.level==="success"&&"text-green-400",a.level==="info"&&"text-gray-300"),children:a.message}),a.nodeId&&v.jsxs("span",{className:"ml-2 text-purple-400 text-xs",children:["[",a.nodeId.slice(0,8),"]"]}),a.details&&v.jsx("pre",{className:"mt-1 p-2 bg-black/30 rounded text-xs text-gray-400 overflow-x-auto",children:typeof a.details=="string"?a.details:JSON.stringify(a.details,null,2)})]})]},a.id)),v.jsx("div",{ref:r})]})})]})}const K8=["Read","Write","Edit","Bash","Glob","Grep","WebSearch","WebFetch","Task","TodoWrite"],J8=[{id:"image-gen-nanobanana",name:"Image Generator",description:"Google Gemini API를 사용한 AI 이미지 생성",keywords:["이미지","image","그림","사진","picture","illustration","graphic"]},{id:"ppt-generator",name:"PPT Generator",description:"한국어에 최적화된 미니멀 프레젠테이션 생성",keywords:["ppt","발표","presentation","slides","powerpoint","슬라이드"]},{id:"video-gen-veo3",name:"Video Generator",description:"Google Veo3 API를 사용한 AI 영상 생성",keywords:["영상","video","동영상","animation","애니메이션"]},{id:"pdf",name:"PDF",description:"PDF 텍스트 추출, 생성, 병합/분할, 폼 처리",keywords:["pdf","문서","document"]},{id:"docx",name:"Word Document",description:"Word 문서 생성, 편집, 변경 추적, 주석",keywords:["워드","docx","word","한글","문서"]},{id:"xlsx",name:"Excel",description:"스프레드시트 생성, 편집, 수식, 데이터 분석",keywords:["엑셀","xlsx","excel","스프레드시트","spreadsheet","표"]},{id:"pptx",name:"PowerPoint",description:"PPT 생성, 편집, 레이아웃, 스피커 노트",keywords:["pptx","powerpoint","presentation"]},{id:"git-commit-push",name:"Git Commit/Push",description:"Git 변경사항 분석, 커밋 메시지 작성, 푸시/PR 생성",keywords:["git","commit","push","pr","pull request","커밋","푸시"]}],W8=[{id:"sonnet",name:"Claude 4 Sonnet",description:"Fast, cost-efficient"},{id:"opus",name:"Claude 4.5 Opus",description:"Best for complex tasks"},{id:"haiku",name:"Claude 3.5 Haiku",description:"Fastest, for simple tasks"}];function e9(e){switch(e){case"input":return v.jsx(Af,{className:"w-5 h-5 text-yellow-400"});case"subagent":return v.jsx(Tl,{className:"w-5 h-5 text-purple-400"});case"skill":return v.jsx(jf,{className:"w-5 h-5 text-cyan-400"});case"command":return v.jsx(ds,{className:"w-5 h-5 text-orange-400"});case"hook":return v.jsx(ng,{className:"w-5 h-5 text-pink-400"});case"output":return v.jsx(Cf,{className:"w-5 h-5 text-emerald-400"});default:return null}}function t9(e){switch(e){case"input":return"User Input";case"subagent":return"Sub Agent";case"skill":return"Skill";case"command":return"Command";case"hook":return"Hook";case"output":return"Output";default:return"Node"}}function n9({node:e}){const{updateNode:t,removeNode:n}=ci(),r=X.useRef(null),a=X.useCallback(d=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{U_(d).catch(h=>{console.error("Failed to sync node to filesystem:",h)})},500)},[]);if(X.useEffect(()=>(e&&e.type!=="input"&&e.type!=="output"&&a(e),()=>{r.current&&clearTimeout(r.current)}),[e,a]),!e)return v.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500 p-8",children:[v.jsx(Ej,{className:"w-12 h-12 mb-4 opacity-50"}),v.jsx("p",{className:"text-center",children:"Select a node to configure its settings"})]});const l=()=>{I_(e).catch(d=>{console.error("Failed to delete node from filesystem:",d)}),n(e.id)},u=d=>{t(e.id,{label:d})},f=d=>{t(e.id,{description:d})};return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border bg-surface-hover/50",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("div",{className:"p-2 rounded-lg bg-surface",children:e9(e.type)}),v.jsxs("div",{children:[v.jsx("h3",{className:"text-base font-semibold text-white",children:e.data.label}),v.jsx("p",{className:"text-xs text-gray-500",children:t9(e.type)})]})]}),v.jsx("button",{onClick:l,className:"p-2 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded-lg transition-colors",title:"Delete node",children:v.jsx(Mf,{className:"w-4 h-4"})})]}),v.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5",children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Name"}),v.jsx("input",{type:"text",value:e.data.label,onChange:d=>u(d.target.value),className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent transition-all"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:e.type==="subagent"?"Prompt":"Description"}),v.jsx("textarea",{value:e.data.description||"",onChange:d=>f(d.target.value),rows:4,placeholder:e.type==="subagent"?"Enter instructions for this agent...":"Describe what this step does...",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent transition-all resize-none"})]}),e.type==="input"&&v.jsx(i9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="subagent"&&v.jsx(r9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="skill"&&v.jsx(s9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="command"&&v.jsx(a9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="hook"&&v.jsx(o9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="output"&&v.jsx(l9,{onUpdate:d=>t(e.id,d)})]})]})}function i9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Input Type"}),v.jsx("div",{className:"grid grid-cols-3 gap-2",children:["text","file","select"].map(n=>v.jsx("button",{onClick:()=>t({inputType:n}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.inputType===n?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:n.charAt(0).toUpperCase()+n.slice(1)},n))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Default Value"}),v.jsx("textarea",{value:e.value||"",onChange:n=>t({value:n.target.value}),rows:3,placeholder:"Enter default value...",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent resize-none"})]})]})}function r9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Model"}),v.jsx("div",{className:"space-y-2",children:W8.map(n=>v.jsxs("button",{onClick:()=>t({model:n.id}),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${e.model===n.id?"bg-accent/20 border-accent":"bg-surface-hover border-border hover:border-gray-500"}`,children:[v.jsx(Tl,{className:"w-5 h-5 text-purple-400"}),v.jsxs("div",{className:"text-left",children:[v.jsx("div",{className:"font-medium text-white",children:n.name}),v.jsx("div",{className:"text-xs text-gray-500",children:n.description})]})]},n.id))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Allowed Tools"}),v.jsx("div",{className:"grid grid-cols-2 gap-2",children:K8.map(n=>v.jsxs("label",{className:"flex items-center gap-2 p-2 bg-surface-hover rounded-lg cursor-pointer hover:bg-border transition-colors",children:[v.jsx("input",{type:"checkbox",checked:e.tools?.includes(n)??!1,onChange:r=>{const a=r.target.checked?[...e.tools||[],n]:(e.tools||[]).filter(l=>l!==n);t({tools:a})},className:"rounded border-gray-600 bg-surface text-accent focus:ring-accent"}),v.jsx("span",{className:"text-sm text-gray-300",children:n})]},n))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"System Prompt"}),v.jsx("textarea",{value:e.systemPrompt||"",onChange:n=>t({systemPrompt:n.target.value}),rows:4,placeholder:"Enter custom instructions for this agent...",className:"w-full px-3 py-2 bg-surface-hover border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent resize-none"})]})]})}function s9({data:e,onUpdate:t}){const[n,r]=X.useState([]),[a,l]=X.useState(!1),[u,f]=X.useState(null),[d,h]=X.useState(""),[g,m]=X.useState(!1),[x,b]=X.useState(null);X.useEffect(()=>{e.skillType==="generated"&&e.skillPath&&(l(!0),fetch(`/api/skill/files?path=${encodeURIComponent(e.skillPath)}`).then(k=>k.json()).then(k=>{r(k.files||[]),k.files?.length>0&&f(k.files[0].name)}).catch(k=>{console.error("Failed to load skill files:",k)}).finally(()=>l(!1)))},[e.skillPath,e.skillType]);const w=async()=>{if(e.skillPath){m(!0),b(null);try{const k=d.trim()?d.trim().split(/\s+/):[],_=await(await fetch("/api/skill/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:e.skillPath,args:k})})).json();b(_)}catch(k){b({success:!1,error:k instanceof Error?k.message:"Unknown error"})}finally{m(!1)}}};return e.skillType==="generated"&&e.skillPath?v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Skill Path"}),v.jsx("div",{className:"px-3 py-2 bg-surface border border-border rounded-lg text-gray-400 text-sm font-mono break-all",children:e.skillPath})]}),v.jsxs("div",{children:[v.jsxs("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:[v.jsx(K5,{className:"w-4 h-4 inline mr-1"}),"Files Preview"]}),a?v.jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500",children:[v.jsx(af,{className:"w-5 h-5 animate-spin mr-2"}),"파일 로딩 중..."]}):n.length===0?v.jsx("div",{className:"text-center py-4 text-gray-500 text-sm",children:"파일을 찾을 수 없습니다"}):v.jsx("div",{className:"space-y-2",children:n.map(k=>v.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[v.jsxs("button",{onClick:()=>f(u===k.name?null:k.name),className:"w-full flex items-center justify-between px-3 py-2 bg-surface-hover hover:bg-border transition-colors",children:[v.jsx("span",{className:"text-sm text-white font-medium",children:k.name}),u===k.name?v.jsx(GS,{className:"w-4 h-4 text-gray-400"}):v.jsx(H5,{className:"w-4 h-4 text-gray-400"})]}),u===k.name&&v.jsx("pre",{className:"p-3 bg-[#0d1117] text-xs text-gray-300 overflow-x-auto max-h-64 overflow-y-auto font-mono",children:k.content})]},k.name))})]}),v.jsxs("div",{children:[v.jsxs("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:[v.jsx(yl,{className:"w-4 h-4 inline mr-1"}),"Test Skill"]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{children:v.jsx("input",{type:"text",value:d,onChange:k=>h(k.target.value),placeholder:"Arguments (optional, space-separated)",className:"w-full px-3 py-2 bg-surface border border-border rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-accent"})}),v.jsx("button",{onClick:w,disabled:g,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${g?"bg-gray-600 text-gray-400 cursor-not-allowed":"bg-cyan-600 hover:bg-cyan-700 text-white"}`,children:g?v.jsxs(v.Fragment,{children:[v.jsx(af,{className:"w-4 h-4 animate-spin"}),"실행 중..."]}):v.jsxs(v.Fragment,{children:[v.jsx(yl,{className:"w-4 h-4"}),"테스트 실행"]})}),x&&v.jsxs("div",{className:`p-3 rounded-lg border ${x.success?"bg-green-500/10 border-green-500/30":"bg-red-500/10 border-red-500/30"}`,children:[v.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.success?v.jsx(Tf,{className:"w-4 h-4 text-green-400"}):v.jsx(ig,{className:"w-4 h-4 text-red-400"}),v.jsxs("span",{className:`text-sm font-medium ${x.success?"text-green-400":"text-red-400"}`,children:[x.success?"성공":"실패",x.exitCode!==void 0&&` (exit code: ${x.exitCode})`]})]}),x.stdout&&v.jsxs("div",{className:"mb-2",children:[v.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Output:"}),v.jsx("pre",{className:"p-2 bg-black/30 rounded text-xs text-gray-300 overflow-x-auto max-h-32 overflow-y-auto font-mono whitespace-pre-wrap",children:x.stdout})]}),x.stderr&&v.jsxs("div",{children:[v.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Error:"}),v.jsx("pre",{className:"p-2 bg-black/30 rounded text-xs text-red-400 overflow-x-auto max-h-32 overflow-y-auto font-mono whitespace-pre-wrap",children:x.stderr})]}),x.error&&v.jsx("div",{className:"text-sm text-red-400",children:x.error})]})]})]})]}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Skill Type"}),v.jsx("div",{className:"grid grid-cols-2 gap-2 mb-4",children:["official","custom"].map(k=>v.jsx("button",{onClick:()=>t({skillType:k}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.skillType===k?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:k.charAt(0).toUpperCase()+k.slice(1)},k))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Select Skill"}),v.jsx("div",{className:"space-y-2",children:J8.map(k=>v.jsxs("button",{onClick:()=>t({skillId:k.id,description:k.description}),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors text-left ${e.skillId===k.id?"bg-accent/20 border-accent":"bg-surface border-border hover:border-gray-500"}`,children:[v.jsx(jf,{className:"w-5 h-5 text-cyan-400"}),v.jsxs("div",{children:[v.jsx("div",{className:"font-medium text-white",children:k.name}),v.jsx("div",{className:"text-xs text-gray-500",children:k.description})]})]},k.id))})]})]})}function a9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Command Name"}),v.jsx("input",{type:"text",value:e.commandName||"",onChange:n=>t({commandName:n.target.value}),placeholder:"e.g., commit, review-pr",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Slash command to execute (without /)"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Command Path (optional)"}),v.jsx("input",{type:"text",value:e.commandPath||"",onChange:n=>t({commandPath:n.target.value}),placeholder:"e.g., .claude/commands/my-command.md",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"})]})]})}function o9({data:e,onUpdate:t}){const n=["PreToolUse","PostToolUse","Notification","Stop"];return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Hook Event"}),v.jsx("div",{className:"grid grid-cols-2 gap-2",children:n.map(r=>v.jsx("button",{onClick:()=>t({hookEvent:r}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.hookEvent===r?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:r},r))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Tool Matcher (optional)"}),v.jsx("input",{type:"text",value:e.hookMatcher||"",onChange:r=>t({hookMatcher:r.target.value}),placeholder:"e.g., Bash, Write, Edit",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Filter by tool name pattern"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Hook Command"}),v.jsx("input",{type:"text",value:e.hookCommand||"",onChange:r=>t({hookCommand:r.target.value}),placeholder:"e.g., npm run lint",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Shell command to execute"})]})]})}function l9({onUpdate:e}){const t=[{id:"auto",name:"Auto Format",description:"Automatically format output"},{id:"markdown",name:"Markdown",description:"Plain markdown text"},{id:"document",name:"Document",description:"Formatted document output"}];return v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Output Format"}),v.jsx("div",{className:"space-y-2",children:t.map(n=>v.jsxs("button",{onClick:()=>e({layoutType:n.id}),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-surface-hover border-border hover:border-gray-500 transition-colors text-left",children:[v.jsx(Cf,{className:"w-5 h-5 text-emerald-400"}),v.jsxs("div",{children:[v.jsx("div",{className:"font-medium text-white",children:n.name}),v.jsx("div",{className:"text-xs text-gray-500",children:n.description})]})]},n.id))})]})}const u9=[{id:"preview",label:"Preview"},{id:"console",label:"Console"},{id:"step",label:"Step"},{id:"theme",label:"Theme"}];function c9(){const{activeTab:e,setActiveTab:t}=Hf(),n=ci(WS);return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsx("div",{className:"flex items-center gap-1 p-2 border-b border-border",children:u9.map(r=>v.jsx("button",{onClick:()=>t(r.id),className:Gt("px-4 py-2 text-sm font-medium rounded-lg transition-colors",e===r.id?"bg-surface-hover text-white":"text-gray-400 hover:text-white hover:bg-surface-hover/50"),children:r.label},r.id))}),v.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e==="preview"&&v.jsx(G8,{}),e==="console"&&v.jsx(Q8,{}),e==="step"&&v.jsx(n9,{node:n}),e==="theme"&&v.jsx("div",{className:"p-4 text-gray-500",children:"Theme customization coming soon..."})]})]})}async function f9(e){let t;const{apiMode:n,apiKey:r,proxyUrl:a}=fg.getState(),l={"Content-Type":"application/json","X-API-Mode":n};n==="direct"&&r?l["X-API-Key"]=r:n==="proxy"&&a&&(l["X-Proxy-URL"]=a);try{t=await fetch("/api/generate/workflow",{method:"POST",headers:l,body:JSON.stringify({prompt:e})})}catch{throw new Error("서버에 연결할 수 없습니다. 서버가 실행 중인지 확인하세요.")}if(!t.ok){let d=`서버 오류 (${t.status})`;try{d=(await t.json()).message||d}catch{}throw new Error(d)}let u;try{u=await t.json()}catch{throw new Error("서버 응답을 파싱할 수 없습니다.")}return{workflow:h9(u),workflowName:u.workflowName}}function d9(e,t){if(e.length===0)return e;const n=300,r=150,a=100,l=100,u=new Map,f=new Map;e.forEach(w=>{u.set(w.id,[]),f.set(w.id,[])}),t.forEach(w=>{const k=u.get(w.target)||[];k.push(w.source),u.set(w.target,k);const N=f.get(w.source)||[];N.push(w.target),f.set(w.source,N)});const d=e.filter(w=>(u.get(w.id)||[]).length===0),h=new Map,g=[];for(d.forEach(w=>{h.set(w.id,0),g.push({id:w.id,depth:0})}),d.length===0&&e.length>0&&(h.set(e[0].id,0),g.push({id:e[0].id,depth:0}));g.length>0;){const w=g.shift();(f.get(w.id)||[]).forEach(N=>{const _=h.get(N),z=w.depth+1;(_===void 0||z>_)&&(h.set(N,z),g.push({id:N,depth:z}))})}const m=new Map;h.forEach((w,k)=>{const N=m.get(w)||[];N.push(k),m.set(w,N)});const x=Math.max(...Array.from(h.values()),0),b=new Map;for(let w=0;w<=x;w++){const k=m.get(w)||[],_=(k.length-1)*r,z=l+(300-_)/2;k.forEach((E,C)=>{b.set(E,{x:a+w*n,y:z+C*r})})}return e.map(w=>{const k=b.get(w.id)||w.position;return{...w,position:k}})}function h9(e){const t=[],n=new Map,r={x:0,y:0};e.nodes.forEach((u,f)=>{const d=ka();n.set(f,d);const h={label:u.label,description:u.description,status:"idle",usedInputs:[]};switch(u.type){case"input":t.push({id:d,type:"input",position:{...r},data:{...h,inputType:u.config.inputType||"text",placeholder:u.config.placeholder||u.description}});break;case"subagent":t.push({id:d,type:"subagent",position:{...r},data:{...h,role:u.config.role||"custom",tools:u.config.tools||["Read","Write"],model:u.config.model||"sonnet",systemPrompt:u.config.systemPrompt}});break;case"skill":t.push({id:d,type:"skill",position:{...r},data:{...h,skillType:u.config.skillType||"official",skillId:u.config.skillId,skillContent:u.config.skillContent}});break;case"command":t.push({id:d,type:"command",position:{...r},data:{...h,commandName:u.config.commandName||u.label,commandPath:u.config.commandPath}});break;case"hook":t.push({id:d,type:"hook",position:{...r},data:{...h,hookEvent:u.config.hookEvent||"PreToolUse",hookMatcher:u.config.hookMatcher,hookCommand:u.config.hookCommand}});break;case"output":t.push({id:d,type:"output",position:{...r},data:{...h,outputType:u.config.outputType||"auto"}});break}}),e.edges.forEach(u=>{const f=n.get(u.to),d=n.get(u.from);if(f&&d){const h=t.find(g=>g.id===f);h&&h.data.usedInputs&&h.data.usedInputs.push(d)}});const a=e.edges.map(u=>{const f=n.get(u.from),d=n.get(u.to);return!f||!d?null:{id:`e-${f}-${d}`,source:f,target:d,animated:!0}}).filter(u=>u!==null);return{nodes:d9(t,a),edges:a}}function p9(e){const t=e.toLowerCase();if(t.includes("스킬")||t.includes("skill"))return!0;const n=[/만들어\s*(줘|주세요|줘요)/,/작성해\s*(줘|주세요|줘요)/,/생성해\s*(줘|주세요|줘요)/];for(const r of n)if(r.test(e))return!0;return!1}const fi=Object.create(null);fi.open="0";fi.close="1";fi.ping="2";fi.pong="3";fi.message="4";fi.upgrade="5";fi.noop="6";const Vc=Object.create(null);Object.keys(fi).forEach(e=>{Vc[fi[e]]=e});const Rm={type:"error",data:"parser error"},X2=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",G2=typeof ArrayBuffer=="function",Z2=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Mg=({type:e,data:t},n,r)=>X2&&t instanceof Blob?n?r(t):Jv(t,r):G2&&(t instanceof ArrayBuffer||Z2(t))?n?r(t):Jv(new Blob([t]),r):r(fi[e]+(t||"")),Jv=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function Wv(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Zp;function m9(e,t){if(X2&&e.data instanceof Blob)return e.data.arrayBuffer().then(Wv).then(t);if(G2&&(e.data instanceof ArrayBuffer||Z2(e.data)))return t(Wv(e.data));Mg(e,!1,n=>{Zp||(Zp=new TextEncoder),t(Zp.encode(n))})}const ew="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nl=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<ew.length;e++)nl[ew.charCodeAt(e)]=e;const g9=e=>{let t=e.length*.75,n=e.length,r,a=0,l,u,f,d;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const h=new ArrayBuffer(t),g=new Uint8Array(h);for(r=0;r<n;r+=4)l=nl[e.charCodeAt(r)],u=nl[e.charCodeAt(r+1)],f=nl[e.charCodeAt(r+2)],d=nl[e.charCodeAt(r+3)],g[a++]=l<<2|u>>4,g[a++]=(u&15)<<4|f>>2,g[a++]=(f&3)<<6|d&63;return h},y9=typeof ArrayBuffer=="function",jg=(e,t)=>{if(typeof e!="string")return{type:"message",data:Q2(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:x9(e.substring(1),t)}:Vc[n]?e.length>1?{type:Vc[n],data:e.substring(1)}:{type:Vc[n]}:Rm},x9=(e,t)=>{if(y9){const n=g9(e);return Q2(n,t)}else return{base64:!0,data:e}},Q2=(e,t)=>t==="blob"?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,K2="",b9=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((l,u)=>{Mg(l,!1,f=>{r[u]=f,++a===n&&t(r.join(K2))})})},v9=(e,t)=>{const n=e.split(K2),r=[];for(let a=0;a<n.length;a++){const l=jg(n[a],t);if(r.push(l),l.type==="error")break}return r};function w9(){return new TransformStream({transform(e,t){m9(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const l=new DataView(a.buffer);l.setUint8(0,126),l.setUint16(1,r)}else{a=new Uint8Array(9);const l=new DataView(a.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let Qp;function Oc(e){return e.reduce((t,n)=>t+n.length,0)}function Dc(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function S9(e,t){Qp||(Qp=new TextDecoder);const n=[];let r=0,a=-1,l=!1;return new TransformStream({transform(u,f){for(n.push(u);;){if(r===0){if(Oc(n)<1)break;const d=Dc(n,1);l=(d[0]&128)===128,a=d[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(Oc(n)<2)break;const d=Dc(n,2);a=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),r=3}else if(r===2){if(Oc(n)<8)break;const d=Dc(n,8),h=new DataView(d.buffer,d.byteOffset,d.length),g=h.getUint32(0);if(g>Math.pow(2,21)-1){f.enqueue(Rm);break}a=g*Math.pow(2,32)+h.getUint32(4),r=3}else{if(Oc(n)<a)break;const d=Dc(n,a);f.enqueue(jg(l?d:Qp.decode(d),t)),r=0}if(a===0||a>e){f.enqueue(Rm);break}}}})}const J2=4;function kt(e){if(e)return _9(e)}function _9(e){for(var t in kt.prototype)e[t]=kt.prototype[t];return e}kt.prototype.on=kt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};kt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};kt.prototype.off=kt.prototype.removeListener=kt.prototype.removeAllListeners=kt.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};kt.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};kt.prototype.emitReserved=kt.prototype.emit;kt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};kt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Vf=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Ln=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),k9="arraybuffer";function W2(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const E9=Ln.setTimeout,N9=Ln.clearTimeout;function Ff(e,t){t.useNativeTimers?(e.setTimeoutFn=E9.bind(Ln),e.clearTimeoutFn=N9.bind(Ln)):(e.setTimeoutFn=Ln.setTimeout.bind(Ln),e.clearTimeoutFn=Ln.clearTimeout.bind(Ln))}const C9=1.33;function T9(e){return typeof e=="string"?A9(e):Math.ceil((e.byteLength||e.size)*C9)}function A9(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function ek(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function M9(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function j9(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let l=n[r].split("=");t[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return t}class R9 extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Rg extends kt{constructor(t){super(),this.writable=!1,Ff(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new R9(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=jg(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=M9(t);return n.length?"?"+n:""}}class z9 extends Rg{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};v9(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,b9(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=ek()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let tk=!1;try{tk=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const O9=tk;function D9(){}class L9 extends z9{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,l)=>{this.onError("xhr post error",a,l)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class li extends kt{constructor(t,n,r){super(),this.createRequest=t,Ff(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=W2(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=li.requestsCount++,li.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=D9,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete li.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}li.requestsCount=0;li.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",tw);else if(typeof addEventListener=="function"){const e="onpagehide"in Ln?"pagehide":"unload";addEventListener(e,tw,!1)}}function tw(){for(let e in li.requests)li.requests.hasOwnProperty(e)&&li.requests[e].abort()}const B9=(function(){const e=nk({xdomain:!1});return e&&e.responseType!==null})();class H9 extends L9{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=B9&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new li(nk,this.uri(),t)}}function nk(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||O9))return new XMLHttpRequest}catch{}if(!t)try{return new Ln[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ik=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class U9 extends Rg{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=ik?{}:W2(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;Mg(r,this.supportsBinary,l=>{try{this.doWrite(r,l)}catch{}a&&Vf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=ek()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Kp=Ln.WebSocket||Ln.MozWebSocket;class I9 extends U9{createSocket(t,n,r){return ik?new Kp(t,n,r):n?new Kp(t,n):new Kp(t)}doWrite(t,n){this.ws.send(n)}}class q9 extends Rg{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=S9(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=w9();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const l=()=>{r.read().then(({done:f,value:d})=>{f||(this.onPacket(d),l())}).catch(f=>{})};l();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&Vf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const $9={websocket:I9,webtransport:q9,polling:H9},P9=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,V9=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function zm(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=P9.exec(e||""),l={},u=14;for(;u--;)l[V9[u]]=a[u]||"";return n!=-1&&r!=-1&&(l.source=t,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=F9(l,l.path),l.queryKey=Y9(l,l.query),l}function F9(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Y9(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,l){a&&(n[a]=l)}),n}const Om=typeof addEventListener=="function"&&typeof removeEventListener=="function",Fc=[];Om&&addEventListener("offline",()=>{Fc.forEach(e=>e())},!1);class Ar extends kt{constructor(t,n){if(super(),this.binaryType=k9,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=zm(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=zm(n.host).host);Ff(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=j9(this.opts.query)),Om&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Fc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=J2,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Ar.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ar.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=T9(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Vf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const l={type:t,data:n,options:r};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Ar.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Om&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Fc.indexOf(this._offlineEventListener);r!==-1&&Fc.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ar.protocol=J2;class X9 extends Ar{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Ar.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",m=>{if(!r)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ar.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(g(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function l(){r||(r=!0,g(),n.close(),n=null)}const u=m=>{const x=new Error("probe error: "+m);x.transport=n.name,l(),this.emitReserved("upgradeError",x)};function f(){u("transport closed")}function d(){u("socket closed")}function h(m){n&&m.name!==n.name&&l()}const g=()=>{n.removeListener("open",a),n.removeListener("error",u),n.removeListener("close",f),this.off("close",d),this.off("upgrading",h)};n.once("open",a),n.once("error",u),n.once("close",f),this.once("close",d),this.once("upgrading",h),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let G9=class extends X9{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>$9[a]).filter(a=>!!a)),super(t,r)}};function Z9(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=zm(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const l=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+l+":"+r.port+t,r.href=r.protocol+"://"+l+(n&&n.port===r.port?"":":"+r.port),r}const Q9=typeof ArrayBuffer=="function",K9=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,rk=Object.prototype.toString,J9=typeof Blob=="function"||typeof Blob<"u"&&rk.call(Blob)==="[object BlobConstructor]",W9=typeof File=="function"||typeof File<"u"&&rk.call(File)==="[object FileConstructor]";function zg(e){return Q9&&(e instanceof ArrayBuffer||K9(e))||J9&&e instanceof Blob||W9&&e instanceof File}function Yc(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Yc(e[n]))return!0;return!1}if(zg(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Yc(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Yc(e[n]))return!0;return!1}function eH(e){const t=[],n=e.data,r=e;return r.data=Dm(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Dm(e,t){if(!e)return e;if(zg(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Dm(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Dm(e[r],t));return n}return e}function tH(e,t){return e.data=Lm(e.data,t),delete e.attachments,e}function Lm(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Lm(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Lm(e[n],t));return e}const nH=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var $e;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})($e||($e={}));class iH{constructor(t){this.replacer=t}encode(t){return(t.type===$e.EVENT||t.type===$e.ACK)&&Yc(t)?this.encodeAsBinary({type:t.type===$e.EVENT?$e.BINARY_EVENT:$e.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===$e.BINARY_EVENT||t.type===$e.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=eH(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class Og extends kt{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===$e.BINARY_EVENT;r||n.type===$e.BINARY_ACK?(n.type=r?$e.EVENT:$e.ACK,this.reconstructor=new rH(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(zg(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if($e[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===$e.BINARY_EVENT||r.type===$e.BINARY_ACK){const l=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const u=t.substring(l,n);if(u!=Number(u)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(u)}if(t.charAt(n+1)==="/"){const l=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(l,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const l=n+1;for(;++n;){const u=t.charAt(n);if(u==null||Number(u)!=u){--n;break}if(n===t.length)break}r.id=Number(t.substring(l,n+1))}if(t.charAt(++n)){const l=this.tryParse(t.substr(n));if(Og.isPayloadValid(r.type,l))r.data=l;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case $e.CONNECT:return nw(n);case $e.DISCONNECT:return n===void 0;case $e.CONNECT_ERROR:return typeof n=="string"||nw(n);case $e.EVENT:case $e.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&nH.indexOf(n[0])===-1);case $e.ACK:case $e.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class rH{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=tH(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function nw(e){return Object.prototype.toString.call(e)==="[object Object]"}const sH=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Og,Encoder:iH,get PacketType(){return $e}},Symbol.toStringTag,{value:"Module"}));function Vn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const aH=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sk extends kt{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Vn(t,"open",this.onopen.bind(this)),Vn(t,"packet",this.onpacket.bind(this)),Vn(t,"error",this.onerror.bind(this)),Vn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,l;if(aH.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const u={type:$e.EVENT,data:n};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const g=this.ids++,m=n.pop();this._registerAckCallback(g,m),u.id=g}const f=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,d=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!f||(d?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===t&&this.sendBuffer.splice(f,1);n.call(this,new Error("operation has timed out"))},a),u=(...f)=>{this.io.clearTimeoutFn(l),n.apply(this,f)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,a)=>{const l=(u,f)=>u?a(u):r(f);l.withError=!0,n.push(l),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...l)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...l)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:$e.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case $e.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case $e.EVENT:case $e.BINARY_EVENT:this.onevent(t);break;case $e.ACK:case $e.BINARY_ACK:this.onack(t);break;case $e.DISCONNECT:this.ondisconnect();break;case $e.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:$e.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:$e.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function Ra(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ra.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};Ra.prototype.reset=function(){this.attempts=0};Ra.prototype.setMin=function(e){this.ms=e};Ra.prototype.setMax=function(e){this.max=e};Ra.prototype.setJitter=function(e){this.jitter=e};class Bm extends kt{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Ff(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Ra({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||sH;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new G9(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Vn(n,"open",function(){r.onopen(),t&&t()}),l=f=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",f),t?t(f):this.maybeReconnectOnOpen()},u=Vn(n,"error",l);if(this._timeout!==!1){const f=this._timeout,d=this.setTimeoutFn(()=>{a(),l(new Error("timeout")),n.close()},f);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(a),this.subs.push(u),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Vn(t,"ping",this.onping.bind(this)),Vn(t,"data",this.ondata.bind(this)),Vn(t,"error",this.onerror.bind(this)),Vn(t,"close",this.onclose.bind(this)),Vn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Vf(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new sk(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Qo={};function Xc(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Z9(e,t.path||"/socket.io"),r=n.source,a=n.id,l=n.path,u=Qo[a]&&l in Qo[a].nsps,f=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let d;return f?d=new Bm(r,t):(Qo[a]||(Qo[a]=new Bm(r,t)),d=Qo[a]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(Xc,{Manager:Bm,Socket:sk,io:Xc,connect:Xc});const iw=window.location.origin;class oH{socket;constructor(){this.socket=Xc(iw,{autoConnect:!0,reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3}),this.socket.on("connect",()=>{console.log("[Socket] Connected to server:",iw)}),this.socket.on("disconnect",()=>{console.log("Disconnected from server")}),this.socket.on("connect_error",t=>{console.error("Socket connection error:",t.message)})}on(t,n){this.socket.on(t,n)}off(t,n){n?this.socket.off(t,n):this.socket.off(t)}emit(t,n){this.socket.connected||console.warn("Socket not connected, queuing emit:",t),this.socket.emit(t,n)}executeWorkflow(t){this.emit("execute:workflow",t)}cancelExecution(){this.emit("execute:cancel")}generateSkill(t){console.log("[Socket] Generating skill:",t.prompt.slice(0,50),"connected:",this.socket.connected),this.emit("generate:skill",t)}isConnected(){return this.socket.connected}disconnect(){this.socket.disconnect()}connect(){this.socket.connected||this.socket.connect()}}const Cr=new oH;function lH(){const[e,t]=X.useState(""),[n,r]=X.useState(!1),[a,l]=X.useState(null),[u,f]=X.useState(null),[d,h]=X.useState("workflow"),{loadWorkflow:g,addNode:m,setSelectedNode:x,nodes:b}=ci(),{openConsolePanel:w,openStepPanel:k}=Hf(),{addLog:N,clearLogs:_}=Na(),{apiMode:z,apiKey:E,proxyUrl:C}=fg(),L=X.useCallback(H=>{console.log("[PromptBar] Skill progress:",H.step,H.message);const $=H.step==="error"?"error":H.step==="completed"?"success":"info";N($,H.message,void 0,H.detail)},[N]),A=X.useCallback(H=>{r(!1),f(`스킬 "${H.skill.skillName}"이 ${H.savedPath}에 저장되었습니다!`),t(""),setTimeout(()=>f(null),5e3);const $=ka(),P=b.length,te={id:$,type:"skill",position:{x:100+P%3*300,y:100+Math.floor(P/3)*200},data:{label:H.skill.skillName,description:H.skill.description,status:"idle",skillType:"generated",skillId:H.skill.skillId,skillPath:H.savedPath}};m(te),x($),k()},[b,m,x,k]),B=X.useCallback(H=>{r(!1),l(H.error)},[]);X.useEffect(()=>(Cr.on("skill:progress",L),Cr.on("skill:completed",A),Cr.on("skill:error",B),()=>{Cr.off("skill:progress",L),Cr.off("skill:completed",A),Cr.off("skill:error",B)}),[L,A,B]);const G=async()=>{if(!e.trim()||n)return;r(!0),l(null),f(null);const H=p9(e);h(H?"skill":"workflow");try{if(H)_(),w(),N("info","✨ 스킬 생성을 시작합니다...",void 0,`요청: "${e.slice(0,50)}${e.length>50?"...":""}"`),Cr.isConnected()||N("warning","⚠️ 서버 연결 대기 중...",void 0,"잠시 후 자동으로 연결됩니다"),Cr.generateSkill({prompt:e,apiMode:z,apiKey:z==="direct"?E:void 0,proxyUrl:z==="proxy"?C:void 0}),N("info","🔍 요청을 분석하고 있어요...",void 0,"AI가 어떤 스킬이 필요한지 파악 중");else{const{workflow:$,workflowName:P}=await f9(e);g({nodes:$.nodes,edges:$.edges,name:P}),t(""),r(!1)}}catch($){console.error("Generation failed:",$);const P=$ instanceof Error?$.message:"생성에 실패했습니다.";l(P),r(!1)}},Z=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),G())};return v.jsxs("div",{className:"bg-surface border border-border rounded-2xl px-5 py-3 shadow-2xl flex items-center gap-3",children:[v.jsx(Tl,{className:"w-5 h-5 text-accent flex-shrink-0"}),v.jsx("input",{type:"text",value:e,onChange:H=>t(H.target.value),onKeyDown:Z,placeholder:"Describe your workflow... (e.g., 'Create an HTML page with images')",className:"flex-1 bg-transparent border-none outline-none text-white placeholder-gray-500 text-sm",disabled:n}),v.jsx("button",{onClick:G,disabled:!e.trim()||n,className:`p-2 rounded-full transition-all duration-200 ${e.trim()&&!n?"bg-accent text-white hover:bg-accent-hover hover:scale-105":"bg-surface-hover text-gray-500"}`,title:"Generate Workflow",children:n?v.jsx(af,{className:"w-5 h-5 animate-spin"}):v.jsx(wj,{className:"w-5 h-5"})}),v.jsx("div",{className:"absolute -bottom-6 left-1/2 -translate-x-1/2 text-xs whitespace-nowrap",children:a?v.jsx("span",{className:"text-red-400",children:a}):u?v.jsxs("span",{className:"text-green-400 flex items-center gap-1",children:[v.jsx(Tf,{className:"w-3 h-3"}),u]}):n?v.jsxs("span",{className:"text-accent",children:["AI가 ",d==="skill"?"스킬":"워크플로우","을 생성하고 있습니다..."]}):v.jsx("span",{className:"text-gray-600",children:'"스킬 만들어줘" 또는 워크플로우 설명을 입력하세요'})})]})}function uH(){const{isCollapsed:e,width:t}=Hf(),{isRunning:n,logs:r}=Na(),{mergeExistingConfig:a}=ci(),[l,u]=X.useState(!1),f=X.useRef(!1);return X.useEffect(()=>{f.current||(f.current=!0,L_().then(d=>{d.length>0&&(console.log(`Loaded ${d.length} nodes from .claude/`),a(d))}).catch(d=>{console.error("Failed to load initial config:",d)}))},[a]),X.useEffect(()=>{n&&u(!0)},[n]),v.jsx(PS,{children:v.jsxs("div",{className:"flex flex-col h-screen bg-canvas",children:[v.jsx(nz,{}),v.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[v.jsxs("div",{className:"flex-1 flex flex-col",children:[v.jsx(oz,{}),v.jsxs("div",{className:"flex-1 relative",children:[v.jsx(Ez,{}),v.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 w-full max-w-2xl px-4",children:v.jsx(lH,{})})]})]}),!e&&v.jsx("div",{className:"border-l border-border bg-surface",style:{width:`${t}px`},children:v.jsx(c9,{})})]}),v.jsxs("button",{onClick:()=>u(!l),className:`fixed bottom-4 left-4 z-40 flex items-center gap-2 px-3 py-2 rounded-lg shadow-lg transition-all ${l?"bg-amber-600 text-white":"bg-gray-800 text-gray-300 hover:bg-gray-700"} ${l?"opacity-0 pointer-events-none":"opacity-100"}`,children:[v.jsx(ds,{className:"w-4 h-4"}),v.jsx("span",{className:"text-sm font-medium",children:"Console"}),r.length>0&&!l&&v.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-amber-500 text-white rounded-full",children:r.length}),n&&v.jsx("span",{className:"w-2 h-2 bg-green-400 rounded-full animate-pulse"})]}),v.jsx(Z8,{isOpen:l,onClose:()=>u(!1)})]})})}bN.createRoot(document.getElementById("root")).render(v.jsx(X.StrictMode,{children:v.jsx(uH,{})}));
150
+ `))}function d(b,w,k,N){const _=k.enter("tableCell"),z=k.enter("phrasing"),E=k.containerPhrasing(b,{...N,before:l,after:l});return z(),_(),E}function h(b,w){return SB(b,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function g(b,w,k){const N=b.children;let _=-1;const z=[],E=w.enter("table");for(;++_<N.length;)z[_]=m(N[_],w,k);return E(),z}function m(b,w,k){const N=b.children;let _=-1;const z=[],E=w.enter("tableRow");for(;++_<N.length;)z[_]=d(N[_],b,w,k);return E(),z}function x(b,w,k){let N=L2.inlineCode(b,w,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function u8(){return{exit:{taskListCheckValueChecked:Zv,taskListCheckValueUnchecked:Zv,paragraph:f8}}}function c8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:d8}}}function Zv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function f8(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const f=a[l];if(f.type==="paragraph"){u=f;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function d8(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",f=n.createTracker(r);l&&f.move(u);let d=L2.listItem(e,t,n,{...r,...f.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(g){return g+u}}function h8(){return[FL(),dB(),gB(),n8(),u8()]}function p8(e){return{extensions:[YL(),hB(e),yB(),l8(e),c8()]}}const m8={tokenize:w8,partial:!0},B2={tokenize:S8,partial:!0},H2={tokenize:_8,partial:!0},U2={tokenize:k8,partial:!0},g8={tokenize:E8,partial:!0},I2={name:"wwwAutolink",tokenize:b8,previous:$2},q2={name:"protocolAutolink",tokenize:v8,previous:P2},Fi={name:"emailAutolink",tokenize:x8,previous:V2},hi={};function y8(){return{text:hi}}let ts=48;for(;ts<123;)hi[ts]=Fi,ts++,ts===58?ts=65:ts===91&&(ts=97);hi[43]=Fi;hi[45]=Fi;hi[46]=Fi;hi[95]=Fi;hi[72]=[Fi,q2];hi[104]=[Fi,q2];hi[87]=[Fi,I2];hi[119]=[Fi,I2];function x8(e,t,n){const r=this;let a,l;return u;function u(m){return!jm(m)||!V2.call(r,r.previous)||Ag(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(m))}function f(m){return jm(m)?(e.consume(m),f):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(g8,g,h)(m):m===45||m===95||$t(m)?(l=!0,e.consume(m),d):g(m)}function h(m){return e.consume(m),a=!0,d}function g(m){return l&&a&&Zt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function b8(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!$2.call(r,r.previous)||Ag(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(m8,e.attempt(B2,e.attempt(H2,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function v8(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&P2.call(r,r.previous)&&!Ag(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),f):n(m)}function f(m){if(Zt(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),f;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?h:(l=!0,d)):n(m)}function h(m){return m===null||cf(m)||st(m)||fs(m)||Uf(m)?n(m):e.attempt(B2,e.attempt(H2,g),n)(m)}function g(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function w8(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function S8(e,t,n){let r,a,l;return u;function u(h){return h===46||h===95?e.check(U2,d,f)(h):h===null||st(h)||fs(h)||h!==45&&Uf(h)?d(h):(l=!0,e.consume(h),u)}function f(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),u}function d(h){return a||r||!l?n(h):t(h)}}function _8(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(U2,t,l)(u):u===null||st(u)||fs(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function k8(e,t,n){return r;function r(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),r):f===38?(e.consume(f),l):f===93?(e.consume(f),a):f===60||f===null||st(f)||fs(f)?t(f):n(f)}function a(f){return f===null||f===40||f===91||st(f)||fs(f)?t(f):r(f)}function l(f){return Zt(f)?u(f):n(f)}function u(f){return f===59?(e.consume(f),r):Zt(f)?(e.consume(f),u):n(f)}}function E8(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return $t(l)?n(l):t(l)}}function $2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||st(e)}function P2(e){return!Zt(e)}function V2(e){return!(e===47||jm(e))}function jm(e){return e===43||e===45||e===46||e===95||$t(e)}function Ag(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const N8={tokenize:O8,partial:!0};function C8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:j8,continuation:{tokenize:R8},exit:z8}},text:{91:{name:"gfmFootnoteCall",tokenize:M8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:T8,resolveTo:A8}}}}function T8(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return f;function f(d){if(!u||!u._balanced)return n(d);const h=Zn(r.sliceSerialize({start:u.end,end:r.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function A8(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},f=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...f),e}function M8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return f;function f(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||st(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Zn(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return st(m)||(u=!0),l++,e.consume(m),m===92?g:h}function g(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function j8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,f;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(w)}function g(w){if(u>999||w===93&&!f||w===null||w===91||st(w))return n(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return l=Zn(r.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return st(w)||(f=!0),u++,e.consume(w),w===92?m:g}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,g):g(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),Fe(e,b,"gfmFootnoteDefinitionWhitespace")):n(w)}function b(w){return t(w)}}function R8(e,t,n){return e.check(zl,t,e.attempt(N8,t,n))}function z8(e){e.exit("gfmFootnoteDefinition")}function O8(e,t,n){const r=this;return Fe(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function D8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,f){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let h=d;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[d][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",g,f],["enter",u[h][1],f],["exit",u[h][1],f],["enter",m,f]],b=f.parser.constructs.insideSpan.null;b&&_n(x,x.length,0,If(b,u.slice(h+1,d),f)),_n(x,x.length,0,[["exit",m,f],["enter",u[d][1],f],["exit",u[d][1],f],["exit",g,f]]),_n(u,h-1,d-h+3,x),d=h+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,f,d){const h=this.previous,g=this.events;let m=0;return x;function x(w){return h===126&&g[g.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),b(w))}function b(w){const k=Ea(h);if(w===126)return m>1?d(w):(u.consume(w),m++,b);if(m<2&&!n)return d(w);const N=u.exit("strikethroughSequenceTemporary"),_=Ea(w);return N._open=!_||_===2&&!!k,N._close=!k||k===2&&!!_,f(w)}}}class L8{constructor(){this.map=[]}add(t,n,r){B8(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function B8(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function H8(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function U8(){return{flow:{null:{name:"table",tokenize:I8,resolveAll:q8}}}}function I8(e,t,n){const r=this;let a=0,l=0,u;return f;function f(H){let $=r.events.length-1;for(;$>-1;){const D=r.events[$][1].type;if(D==="lineEnding"||D==="linePrefix")$--;else break}const P=$>-1?r.events[$][1].type:null,te=P==="tableHead"||P==="tableRow"?A:d;return te===A&&r.parser.lazy[r.now().line]?n(H):te(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(u=!0,l+=1),g(H)}function g(H){return H===null?n(H):Se(H)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):n(H):He(H)?Fe(e,g,"whitespace")(H):(l+=1,u&&(u=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),m(H)))}function m(H){return H===null||H===124||st(H)?(e.exit("data"),g(H)):(e.consume(H),H===92?x:m)}function x(H){return H===92||H===124?(e.consume(H),m):m(H)}function b(H){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(H):(e.enter("tableDelimiterRow"),u=!1,He(H)?Fe(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?N(H):H===124?(u=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),k):L(H)}function k(H){return He(H)?Fe(e,N,"whitespace")(H):N(H)}function N(H){return H===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(l+=1,_(H)):H===null||Se(H)?C(H):L(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),z(H)):L(H)}function z(H){return H===45?(e.consume(H),z):H===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(H))}function E(H){return He(H)?Fe(e,C,"whitespace")(H):C(H)}function C(H){return H===124?w(H):H===null||Se(H)?!u||a!==l?L(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):L(H)}function L(H){return n(H)}function A(H){return e.enter("tableRow"),B(H)}function B(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),B):H===null||Se(H)?(e.exit("tableRow"),t(H)):He(H)?Fe(e,B,"whitespace")(H):(e.enter("data"),G(H))}function G(H){return H===null||H===124||st(H)?(e.exit("data"),B(H)):(e.consume(H),H===92?Z:G)}function Z(H){return H===92||H===124?(e.consume(H),G):G(H)}}function q8(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],f=!1,d=0,h,g,m;const x=new L8;for(;++n<e.length;){const b=e[n],w=b[1];b[0]==="enter"?w.type==="tableHead"?(f=!1,d!==0&&(Qv(x,t,d,h,g),g=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],f&&(f=!1,g={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",g,t]])),a=w.type==="tableDelimiterRow"?2:g?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=zc(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=zc(x,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(f=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=zc(x,t,l,a,n,m)):u[1]!==0&&(m=zc(x,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&Qv(x,t,d,h,g),x.consume(t.events),n=-1;++n<t.events.length;){const b=t.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=H8(t.events,n))}return e}function zc(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",f="tableContent";n[0]!==0&&(l.end=Object.assign({},oa(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=oa(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=oa(t.events,n[2]),g=oa(t.events,n[3]),m={type:f,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],b=t.events[n[3]];if(x[1].end=Object.assign({},b[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,k=n[3]-n[2]-1;e.add(w,k,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},oa(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function Qv(e,t,n,r,a){const l=[],u=oa(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function oa(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const $8={name:"tasklistCheck",tokenize:V8};function P8(){return{text:{91:$8}}}function V8(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return st(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(d)}function f(d){return Se(d)?t(d):He(d)?e.check({tokenize:F8},t,n)(d):n(d)}}function F8(e,t,n){return Fe(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function Y8(e){return t2([y8(),C8(),D8(e),U8(),P8()])}const X8={};function Kv(e){const t=this,n=e||X8,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(Y8(n)),l.push(h8()),u.push(p8(n))}function G8(){const{isRunning:e,results:t,workflowResults:n,logs:r}=Na(),{nodes:a,selectedNodeId:l,updateNode:u}=ci(),f=ci(WS),{execute:d,generatedFiles:h,downloadFile:g,downloadAllFiles:m}=D_(),[x,b]=X.useState("");X.useEffect(()=>{if(f?.type==="input"){const C=f.data;b(C.value||"")}},[l,f]);const w=a.filter(C=>C.type==="output"),k=w.length>0?t.get(w[0].id):null,N=f?.type==="input",_=N?f.data:null,z=C=>{b(C),l&&u(l,{value:C})},E=()=>{d()};return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ZS,{className:"w-5 h-5 text-gray-400"}),v.jsx("h3",{className:"text-lg font-semibold text-white",children:"Preview"})]}),e&&v.jsx("span",{className:"text-sm text-blue-400 animate-pulse",children:"Running..."})]}),e&&v.jsx("div",{className:"p-4 border-b border-border",children:v.jsx("div",{className:"space-y-3",children:a.map(C=>v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("div",{className:`w-2 h-2 rounded-full ${C.data.status==="completed"?"bg-green-500":C.data.status==="running"?"bg-blue-500 animate-pulse":C.data.status==="error"?"bg-red-500":"bg-gray-500"}`}),v.jsx("span",{className:"text-sm text-gray-300",children:C.data.label}),C.data.status==="running"&&C.data.progress!==void 0&&v.jsxs("span",{className:"text-xs text-gray-500",children:[C.data.progress,"%"]})]},C.id))})}),v.jsxs("div",{className:"p-4 border-b border-border",children:[v.jsxs("button",{onClick:E,disabled:e||a.length===0,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-amber-600 hover:bg-amber-700 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg font-medium transition-colors",children:[v.jsx(yl,{className:"w-4 h-4"}),e?"Running...":"Run Workflow"]}),a.length===0&&v.jsx("p",{className:"text-xs text-gray-500 text-center mt-2",children:"노드를 추가해주세요"})]}),v.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[N&&_&&v.jsxs("div",{className:"space-y-4 mb-4 p-4 bg-surface rounded-lg border border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(Af,{className:"w-5 h-5 text-amber-500"}),v.jsx("h4",{className:"text-md font-medium text-white",children:_.label})]}),_.inputType==="text"&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Enter your input"}),v.jsx("textarea",{className:"w-full h-32 px-3 py-2 text-sm bg-surface border border-border rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent resize-none",placeholder:_.placeholder||"Type your message here...",value:x||_.value||"",onChange:C=>z(C.target.value)})]}),_.inputType==="file"&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Upload a file"}),v.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-32 border-2 border-dashed border-gray-600 rounded-lg hover:border-amber-500 transition-colors cursor-pointer",children:[v.jsx(zj,{className:"w-8 h-8 text-gray-500 mb-2"}),v.jsx("p",{className:"text-sm text-gray-400",children:"Drop files here or click to upload"}),_.fileTypes&&v.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Supported: ",_.fileTypes.join(", ")]})]})]}),_.inputType==="select"&&_.options&&v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"text-sm text-gray-400",children:_.description||"Select an option"}),v.jsxs("select",{className:"w-full px-3 py-2 text-sm bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-amber-500",value:x||_.value||"",onChange:C=>z(C.target.value),children:[v.jsx("option",{value:"",children:"Select..."}),_.options.map(C=>v.jsx("option",{value:C,children:C},C))]})]})]}),h.length>0&&v.jsxs("div",{className:"mb-4 p-4 bg-green-900/20 border border-green-700 rounded-lg",children:[v.jsxs("div",{className:"flex items-center justify-between mb-3",children:[v.jsx("h4",{className:"text-sm font-medium text-green-300",children:"생성된 파일"}),v.jsxs("button",{onClick:m,className:"flex items-center gap-1 px-2 py-1 text-xs bg-green-600 hover:bg-green-700 text-white rounded transition-colors",children:[v.jsx(da,{className:"w-3 h-3"}),"전체 다운로드"]})]}),v.jsx("div",{className:"space-y-2",children:h.map((C,L)=>v.jsxs("div",{className:"flex items-center justify-between p-2 bg-surface rounded",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ha,{className:"w-4 h-4 text-blue-400"}),v.jsx("span",{className:"text-sm text-white",children:C.name})]}),v.jsx("button",{onClick:()=>g(C.name,C.content),className:"p-1 hover:bg-surface-hover rounded transition-colors",children:v.jsx(da,{className:"w-4 h-4 text-gray-400"})})]},L))})]}),n.length>0?v.jsx("div",{className:"space-y-4",children:n.map(C=>v.jsxs("div",{className:`p-4 rounded-lg border ${C.success?"bg-surface border-border":"bg-red-900/20 border-red-700"}`,children:[v.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.success?v.jsx(Tf,{className:"w-5 h-5 text-green-500"}):v.jsx(ig,{className:"w-5 h-5 text-red-500"}),v.jsx("h5",{className:"text-sm font-medium text-white",children:C.label})]}),C.error&&v.jsx("p",{className:"text-sm text-red-400 mb-3",children:C.error}),C.files&&C.files.length>0&&v.jsxs("div",{className:"space-y-2 mb-3",children:[v.jsx("p",{className:"text-xs text-gray-400",children:"생성된 파일:"}),C.files.map((L,A)=>v.jsxs("div",{className:"flex items-center gap-2 p-2 bg-surface-hover rounded",children:[L.type==="image"?v.jsx(QS,{className:"w-4 h-4 text-purple-400"}):v.jsx(ha,{className:"w-4 h-4 text-blue-400"}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("p",{className:"text-sm text-white truncate",children:L.name}),v.jsx("p",{className:"text-xs text-gray-500 truncate",children:L.path})]})]},A))]}),C.result&&v.jsxs("details",{className:"group",open:!0,children:[v.jsx("summary",{className:"text-xs text-gray-400 cursor-pointer hover:text-gray-300",children:"결과 보기"}),v.jsx("div",{className:"mt-2 p-2 bg-black/30 rounded max-h-64 overflow-y-auto",children:v.jsx("div",{className:"markdown-content text-sm",children:v.jsx(Pv,{remarkPlugins:[Kv],children:C.result.length>2e3?C.result.substring(0,2e3)+"...":C.result})})})]})]},C.nodeId))}):k?v.jsx("div",{className:"markdown-content",children:v.jsx(Pv,{remarkPlugins:[Kv],children:typeof k=="string"?k:JSON.stringify(k,null,2)})}):r.length>0?v.jsxs("div",{className:"space-y-2",children:[v.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"실행 로그"}),r.slice(-20).map(C=>v.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[v.jsx("span",{className:"text-gray-500 shrink-0",children:new Date(C.timestamp).toLocaleTimeString("ko-KR")}),v.jsx("span",{className:C.level==="error"?"text-red-400":C.level==="warning"?"text-yellow-400":C.level==="success"?"text-green-400":"text-gray-300",children:C.message})]},C.id))]}):v.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[v.jsx(ha,{className:"w-12 h-12 mb-4 opacity-50"}),v.jsx("p",{className:"text-sm",children:"Run the workflow to see results"}),v.jsx("p",{className:"text-xs mt-2",children:"노드를 연결하고 Run Workflow 버튼을 클릭하세요"})]})]}),(k||h.length>0)&&v.jsx("div",{className:"flex items-center gap-2 p-4 border-t border-border",children:v.jsxs("button",{onClick:m,disabled:h.length===0,className:"flex items-center gap-2 px-3 py-2 bg-surface-hover rounded-lg text-sm hover:bg-border transition-colors disabled:opacity-50",children:[v.jsx(da,{className:"w-4 h-4"}),"Download .md"]})})]})}function F2({level:e}){switch(e){case"success":return v.jsx(Tf,{className:"w-4 h-4 text-green-400"});case"error":return v.jsx(ig,{className:"w-4 h-4 text-red-400"});case"warning":return v.jsx(jj,{className:"w-4 h-4 text-yellow-400"});default:return v.jsx(rj,{className:"w-4 h-4 text-blue-400"})}}function Y2(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Z8({isOpen:e,onClose:t}){const{logs:n,clearLogs:r,isRunning:a}=Na(),[l,u]=X.useState(!1),[f,d]=X.useState(250),h=X.useRef(null);X.useEffect(()=>{h.current&&!l&&h.current.scrollIntoView({behavior:"smooth"})},[n,l]);const g=m=>{m.preventDefault();const x=m.clientY,b=f,w=N=>{const _=x-N.clientY,z=Math.min(Math.max(b+_,100),500);d(z)},k=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)};return e?v.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[#1a1a1a] border-t border-gray-700 z-50 shadow-2xl",style:{height:l?40:f},children:[!l&&v.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-ns-resize hover:bg-amber-500 transition-colors",onMouseDown:g}),v.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#252525] border-b border-gray-700",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ds,{className:"w-4 h-4 text-amber-500"}),v.jsx("span",{className:"text-sm font-medium text-white",children:"Console"}),a&&v.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 rounded",children:[v.jsx("span",{className:"w-1.5 h-1.5 bg-blue-400 rounded-full animate-pulse"}),"Running"]}),v.jsxs("span",{className:"text-xs text-gray-500",children:["(",n.length," logs)"]})]}),v.jsxs("div",{className:"flex items-center gap-1",children:[v.jsx("button",{onClick:r,className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Clear logs",children:v.jsx(Mf,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:()=>u(!l),className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:l?"Expand":"Minimize",children:l?v.jsx(I5,{className:"w-4 h-4 text-gray-400"}):v.jsx(GS,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:()=>d(f===250?400:250),className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Toggle size",children:f>250?v.jsx(pj,{className:"w-4 h-4 text-gray-400"}):v.jsx(fj,{className:"w-4 h-4 text-gray-400"})}),v.jsx("button",{onClick:t,className:"p-1.5 hover:bg-gray-700 rounded transition-colors",title:"Close",children:v.jsx(rg,{className:"w-4 h-4 text-gray-400"})})]})]}),!l&&v.jsx("div",{className:"overflow-y-auto font-mono text-sm p-3",style:{height:f-44},children:n.length===0?v.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:v.jsx("p",{children:"No logs yet. Run the workflow to see output."})}):v.jsxs("div",{className:"space-y-1",children:[n.map(m=>v.jsxs("div",{className:Gt("flex items-start gap-2 px-2 py-1 rounded hover:bg-gray-800/50",m.level==="error"&&"bg-red-500/10",m.level==="warning"&&"bg-yellow-500/10",m.level==="success"&&"bg-green-500/10"),children:[v.jsxs("span",{className:"text-gray-600 shrink-0 text-xs",children:["[",Y2(m.timestamp),"]"]}),v.jsx(F2,{level:m.level}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("span",{className:Gt("text-xs",m.level==="error"&&"text-red-400",m.level==="warning"&&"text-yellow-400",m.level==="success"&&"text-green-400",m.level==="info"&&"text-gray-300"),children:m.message}),m.nodeId&&v.jsxs("span",{className:"ml-2 text-purple-400 text-xs",children:["[",m.nodeId.slice(0,8),"]"]}),m.details&&v.jsx("pre",{className:"mt-1 p-2 bg-black/30 rounded text-xs text-gray-400 overflow-x-auto",children:typeof m.details=="string"?m.details:JSON.stringify(m.details,null,2)})]})]},m.id)),v.jsx("div",{ref:h})]})})]}):null}function Q8(){const{logs:e,clearLogs:t,isRunning:n}=Na(),r=X.useRef(null);return X.useEffect(()=>{r.current&&r.current.scrollIntoView({behavior:"smooth"})},[e]),v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(ds,{className:"w-5 h-5 text-amber-500"}),v.jsx("h3",{className:"text-lg font-semibold text-white",children:"Console"}),n&&v.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 rounded",children:[v.jsx("span",{className:"w-1.5 h-1.5 bg-blue-400 rounded-full animate-pulse"}),"Running"]}),v.jsxs("span",{className:"text-xs text-gray-500",children:["(",e.length," logs)"]})]}),v.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-white hover:bg-surface-hover rounded-lg transition-colors",title:"Clear logs",children:v.jsx(Mf,{className:"w-4 h-4"})})]}),v.jsx("div",{className:"flex-1 overflow-y-auto p-4 font-mono text-sm",children:e.length===0?v.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:v.jsx("p",{children:"No logs yet. Run the workflow to see output."})}):v.jsxs("div",{className:"space-y-1",children:[e.map(a=>v.jsxs("div",{className:Gt("flex items-start gap-2 px-2 py-1 rounded hover:bg-surface-hover",a.level==="error"&&"bg-red-500/10",a.level==="warning"&&"bg-yellow-500/10",a.level==="success"&&"bg-green-500/10"),children:[v.jsxs("span",{className:"text-gray-600 shrink-0 text-xs",children:["[",Y2(a.timestamp),"]"]}),v.jsx(F2,{level:a.level}),v.jsxs("div",{className:"flex-1 min-w-0",children:[v.jsx("span",{className:Gt("text-xs",a.level==="error"&&"text-red-400",a.level==="warning"&&"text-yellow-400",a.level==="success"&&"text-green-400",a.level==="info"&&"text-gray-300"),children:a.message}),a.nodeId&&v.jsxs("span",{className:"ml-2 text-purple-400 text-xs",children:["[",a.nodeId.slice(0,8),"]"]}),a.details&&v.jsx("pre",{className:"mt-1 p-2 bg-black/30 rounded text-xs text-gray-400 overflow-x-auto",children:typeof a.details=="string"?a.details:JSON.stringify(a.details,null,2)})]})]},a.id)),v.jsx("div",{ref:r})]})})]})}const K8=["Read","Write","Edit","Bash","Glob","Grep","WebSearch","WebFetch","Task","TodoWrite"],J8=[{id:"image-gen-nanobanana",name:"Image Generator",description:"Google Gemini API를 사용한 AI 이미지 생성",keywords:["이미지","image","그림","사진","picture","illustration","graphic"]},{id:"ppt-generator",name:"PPT Generator",description:"한국어에 최적화된 미니멀 프레젠테이션 생성",keywords:["ppt","발표","presentation","slides","powerpoint","슬라이드"]},{id:"video-gen-veo3",name:"Video Generator",description:"Google Veo3 API를 사용한 AI 영상 생성",keywords:["영상","video","동영상","animation","애니메이션"]},{id:"pdf",name:"PDF",description:"PDF 텍스트 추출, 생성, 병합/분할, 폼 처리",keywords:["pdf","문서","document"]},{id:"docx",name:"Word Document",description:"Word 문서 생성, 편집, 변경 추적, 주석",keywords:["워드","docx","word","한글","문서"]},{id:"xlsx",name:"Excel",description:"스프레드시트 생성, 편집, 수식, 데이터 분석",keywords:["엑셀","xlsx","excel","스프레드시트","spreadsheet","표"]},{id:"pptx",name:"PowerPoint",description:"PPT 생성, 편집, 레이아웃, 스피커 노트",keywords:["pptx","powerpoint","presentation"]},{id:"git-commit-push",name:"Git Commit/Push",description:"Git 변경사항 분석, 커밋 메시지 작성, 푸시/PR 생성",keywords:["git","commit","push","pr","pull request","커밋","푸시"]}],W8=[{id:"sonnet",name:"Claude 4 Sonnet",description:"Fast, cost-efficient"},{id:"opus",name:"Claude 4.5 Opus",description:"Best for complex tasks"},{id:"haiku",name:"Claude 3.5 Haiku",description:"Fastest, for simple tasks"}];function e9(e){switch(e){case"input":return v.jsx(Af,{className:"w-5 h-5 text-yellow-400"});case"subagent":return v.jsx(Tl,{className:"w-5 h-5 text-purple-400"});case"skill":return v.jsx(jf,{className:"w-5 h-5 text-cyan-400"});case"command":return v.jsx(ds,{className:"w-5 h-5 text-orange-400"});case"hook":return v.jsx(ng,{className:"w-5 h-5 text-pink-400"});case"output":return v.jsx(Cf,{className:"w-5 h-5 text-emerald-400"});default:return null}}function t9(e){switch(e){case"input":return"User Input";case"subagent":return"Sub Agent";case"skill":return"Skill";case"command":return"Command";case"hook":return"Hook";case"output":return"Output";default:return"Node"}}function n9({node:e}){const{updateNode:t,removeNode:n}=ci(),r=X.useRef(null),a=X.useCallback(d=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{U_(d).catch(h=>{console.error("Failed to sync node to filesystem:",h)})},500)},[]);if(X.useEffect(()=>(e&&e.type!=="input"&&e.type!=="output"&&a(e),()=>{r.current&&clearTimeout(r.current)}),[e,a]),!e)return v.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500 p-8",children:[v.jsx(Ej,{className:"w-12 h-12 mb-4 opacity-50"}),v.jsx("p",{className:"text-center",children:"Select a node to configure its settings"})]});const l=()=>{I_(e).catch(d=>{console.error("Failed to delete node from filesystem:",d)}),n(e.id)},u=d=>{t(e.id,{label:d})},f=d=>{t(e.id,{description:d})};return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border bg-surface-hover/50",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("div",{className:"p-2 rounded-lg bg-surface",children:e9(e.type)}),v.jsxs("div",{children:[v.jsx("h3",{className:"text-base font-semibold text-white",children:e.data.label}),v.jsx("p",{className:"text-xs text-gray-500",children:t9(e.type)})]})]}),v.jsx("button",{onClick:l,className:"p-2 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded-lg transition-colors",title:"Delete node",children:v.jsx(Mf,{className:"w-4 h-4"})})]}),v.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5",children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Name"}),v.jsx("input",{type:"text",value:e.data.label,onChange:d=>u(d.target.value),className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent transition-all"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:e.type==="subagent"?"Prompt":"Description"}),v.jsx("textarea",{value:e.data.description||"",onChange:d=>f(d.target.value),rows:4,placeholder:e.type==="subagent"?"Enter instructions for this agent...":"Describe what this step does...",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent transition-all resize-none"})]}),e.type==="input"&&v.jsx(i9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="subagent"&&v.jsx(r9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="skill"&&v.jsx(s9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="command"&&v.jsx(a9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="hook"&&v.jsx(o9,{data:e.data,onUpdate:d=>t(e.id,d)}),e.type==="output"&&v.jsx(l9,{onUpdate:d=>t(e.id,d)})]})]})}function i9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Input Type"}),v.jsx("div",{className:"grid grid-cols-3 gap-2",children:["text","file","select"].map(n=>v.jsx("button",{onClick:()=>t({inputType:n}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.inputType===n?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:n.charAt(0).toUpperCase()+n.slice(1)},n))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Default Value"}),v.jsx("textarea",{value:e.value||"",onChange:n=>t({value:n.target.value}),rows:3,placeholder:"Enter default value...",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent resize-none"})]})]})}function r9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Model"}),v.jsx("div",{className:"space-y-2",children:W8.map(n=>v.jsxs("button",{onClick:()=>t({model:n.id}),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${e.model===n.id?"bg-accent/20 border-accent":"bg-surface-hover border-border hover:border-gray-500"}`,children:[v.jsx(Tl,{className:"w-5 h-5 text-purple-400"}),v.jsxs("div",{className:"text-left",children:[v.jsx("div",{className:"font-medium text-white",children:n.name}),v.jsx("div",{className:"text-xs text-gray-500",children:n.description})]})]},n.id))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Allowed Tools"}),v.jsx("div",{className:"grid grid-cols-2 gap-2",children:K8.map(n=>v.jsxs("label",{className:"flex items-center gap-2 p-2 bg-surface-hover rounded-lg cursor-pointer hover:bg-border transition-colors",children:[v.jsx("input",{type:"checkbox",checked:e.tools?.includes(n)??!1,onChange:r=>{const a=r.target.checked?[...e.tools||[],n]:(e.tools||[]).filter(l=>l!==n);t({tools:a})},className:"rounded border-gray-600 bg-surface text-accent focus:ring-accent"}),v.jsx("span",{className:"text-sm text-gray-300",children:n})]},n))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"System Prompt"}),v.jsx("textarea",{value:e.systemPrompt||"",onChange:n=>t({systemPrompt:n.target.value}),rows:4,placeholder:"Enter custom instructions for this agent...",className:"w-full px-3 py-2 bg-surface-hover border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent resize-none"})]})]})}function s9({data:e,onUpdate:t}){const[n,r]=X.useState([]),[a,l]=X.useState(!1),[u,f]=X.useState(null),[d,h]=X.useState(""),[g,m]=X.useState(!1),[x,b]=X.useState(null);X.useEffect(()=>{e.skillType==="generated"&&e.skillPath&&(l(!0),fetch(`/api/skill/files?path=${encodeURIComponent(e.skillPath)}`).then(k=>k.json()).then(k=>{r(k.files||[]),k.files?.length>0&&f(k.files[0].name)}).catch(k=>{console.error("Failed to load skill files:",k)}).finally(()=>l(!1)))},[e.skillPath,e.skillType]);const w=async()=>{if(e.skillPath){m(!0),b(null);try{const k=d.trim()?d.trim().split(/\s+/):[],_=await(await fetch("/api/skill/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:e.skillPath,args:k})})).json();b(_)}catch(k){b({success:!1,error:k instanceof Error?k.message:"Unknown error"})}finally{m(!1)}}};return e.skillType==="generated"&&e.skillPath?v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Skill Path"}),v.jsx("div",{className:"px-3 py-2 bg-surface border border-border rounded-lg text-gray-400 text-sm font-mono break-all",children:e.skillPath})]}),v.jsxs("div",{children:[v.jsxs("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:[v.jsx(K5,{className:"w-4 h-4 inline mr-1"}),"Files Preview"]}),a?v.jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500",children:[v.jsx(af,{className:"w-5 h-5 animate-spin mr-2"}),"파일 로딩 중..."]}):n.length===0?v.jsx("div",{className:"text-center py-4 text-gray-500 text-sm",children:"파일을 찾을 수 없습니다"}):v.jsx("div",{className:"space-y-2",children:n.map(k=>v.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[v.jsxs("button",{onClick:()=>f(u===k.name?null:k.name),className:"w-full flex items-center justify-between px-3 py-2 bg-surface-hover hover:bg-border transition-colors",children:[v.jsx("span",{className:"text-sm text-white font-medium",children:k.name}),u===k.name?v.jsx(GS,{className:"w-4 h-4 text-gray-400"}):v.jsx(H5,{className:"w-4 h-4 text-gray-400"})]}),u===k.name&&v.jsx("pre",{className:"p-3 bg-[#0d1117] text-xs text-gray-300 overflow-x-auto max-h-64 overflow-y-auto font-mono",children:k.content})]},k.name))})]}),v.jsxs("div",{children:[v.jsxs("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:[v.jsx(yl,{className:"w-4 h-4 inline mr-1"}),"Test Skill"]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{children:v.jsx("input",{type:"text",value:d,onChange:k=>h(k.target.value),placeholder:"Arguments (optional, space-separated)",className:"w-full px-3 py-2 bg-surface border border-border rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-accent"})}),v.jsx("button",{onClick:w,disabled:g,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${g?"bg-gray-600 text-gray-400 cursor-not-allowed":"bg-cyan-600 hover:bg-cyan-700 text-white"}`,children:g?v.jsxs(v.Fragment,{children:[v.jsx(af,{className:"w-4 h-4 animate-spin"}),"실행 중..."]}):v.jsxs(v.Fragment,{children:[v.jsx(yl,{className:"w-4 h-4"}),"테스트 실행"]})}),x&&v.jsxs("div",{className:`p-3 rounded-lg border ${x.success?"bg-green-500/10 border-green-500/30":"bg-red-500/10 border-red-500/30"}`,children:[v.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.success?v.jsx(Tf,{className:"w-4 h-4 text-green-400"}):v.jsx(ig,{className:"w-4 h-4 text-red-400"}),v.jsxs("span",{className:`text-sm font-medium ${x.success?"text-green-400":"text-red-400"}`,children:[x.success?"성공":"실패",x.exitCode!==void 0&&` (exit code: ${x.exitCode})`]})]}),x.stdout&&v.jsxs("div",{className:"mb-2",children:[v.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Output:"}),v.jsx("pre",{className:"p-2 bg-black/30 rounded text-xs text-gray-300 overflow-x-auto max-h-32 overflow-y-auto font-mono whitespace-pre-wrap",children:x.stdout})]}),x.stderr&&v.jsxs("div",{children:[v.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Error:"}),v.jsx("pre",{className:"p-2 bg-black/30 rounded text-xs text-red-400 overflow-x-auto max-h-32 overflow-y-auto font-mono whitespace-pre-wrap",children:x.stderr})]}),x.error&&v.jsx("div",{className:"text-sm text-red-400",children:x.error})]})]})]})]}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Skill Type"}),v.jsx("div",{className:"grid grid-cols-2 gap-2 mb-4",children:["official","custom"].map(k=>v.jsx("button",{onClick:()=>t({skillType:k}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.skillType===k?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:k.charAt(0).toUpperCase()+k.slice(1)},k))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Select Skill"}),v.jsx("div",{className:"space-y-2",children:J8.map(k=>v.jsxs("button",{onClick:()=>t({skillId:k.id,description:k.description}),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors text-left ${e.skillId===k.id?"bg-accent/20 border-accent":"bg-surface border-border hover:border-gray-500"}`,children:[v.jsx(jf,{className:"w-5 h-5 text-cyan-400"}),v.jsxs("div",{children:[v.jsx("div",{className:"font-medium text-white",children:k.name}),v.jsx("div",{className:"text-xs text-gray-500",children:k.description})]})]},k.id))})]})]})}function a9({data:e,onUpdate:t}){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Command Name"}),v.jsx("input",{type:"text",value:e.commandName||"",onChange:n=>t({commandName:n.target.value}),placeholder:"e.g., commit, review-pr",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Slash command to execute (without /)"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Command Path (optional)"}),v.jsx("input",{type:"text",value:e.commandPath||"",onChange:n=>t({commandPath:n.target.value}),placeholder:"e.g., .claude/commands/my-command.md",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"})]})]})}function o9({data:e,onUpdate:t}){const n=["PreToolUse","PostToolUse","Notification","Stop"];return v.jsxs(v.Fragment,{children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Hook Event"}),v.jsx("div",{className:"grid grid-cols-2 gap-2",children:n.map(r=>v.jsx("button",{onClick:()=>t({hookEvent:r}),className:`px-3 py-2 text-sm rounded-lg border transition-colors ${e.hookEvent===r?"bg-accent/20 border-accent text-white":"bg-surface border-border text-gray-400 hover:border-gray-500"}`,children:r},r))})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Tool Matcher (optional)"}),v.jsx("input",{type:"text",value:e.hookMatcher||"",onChange:r=>t({hookMatcher:r.target.value}),placeholder:"e.g., Bash, Write, Edit",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Filter by tool name pattern"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Hook Command"}),v.jsx("input",{type:"text",value:e.hookCommand||"",onChange:r=>t({hookCommand:r.target.value}),placeholder:"e.g., npm run lint",className:"w-full px-3 py-2.5 bg-surface border border-border rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-accent"}),v.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Shell command to execute"})]})]})}function l9({onUpdate:e}){const t=[{id:"auto",name:"Auto Format",description:"Automatically format output"},{id:"markdown",name:"Markdown",description:"Plain markdown text"},{id:"document",name:"Document",description:"Formatted document output"}];return v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Output Format"}),v.jsx("div",{className:"space-y-2",children:t.map(n=>v.jsxs("button",{onClick:()=>e({layoutType:n.id}),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-surface-hover border-border hover:border-gray-500 transition-colors text-left",children:[v.jsx(Cf,{className:"w-5 h-5 text-emerald-400"}),v.jsxs("div",{children:[v.jsx("div",{className:"font-medium text-white",children:n.name}),v.jsx("div",{className:"text-xs text-gray-500",children:n.description})]})]},n.id))})]})}const u9=[{id:"preview",label:"Preview"},{id:"console",label:"Console"},{id:"step",label:"Step"},{id:"theme",label:"Theme"}];function c9(){const{activeTab:e,setActiveTab:t}=Hf(),n=ci(WS);return v.jsxs("div",{className:"flex flex-col h-full",children:[v.jsx("div",{className:"flex items-center gap-1 p-2 border-b border-border",children:u9.map(r=>v.jsx("button",{onClick:()=>t(r.id),className:Gt("px-4 py-2 text-sm font-medium rounded-lg transition-colors",e===r.id?"bg-surface-hover text-white":"text-gray-400 hover:text-white hover:bg-surface-hover/50"),children:r.label},r.id))}),v.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e==="preview"&&v.jsx(G8,{}),e==="console"&&v.jsx(Q8,{}),e==="step"&&v.jsx(n9,{node:n}),e==="theme"&&v.jsx("div",{className:"p-4 text-gray-500",children:"Theme customization coming soon..."})]})]})}async function f9(e){let t;const{apiMode:n,apiKey:r,proxyUrl:a}=fg.getState(),l={"Content-Type":"application/json","X-API-Mode":n};n==="direct"&&r?l["X-API-Key"]=r:n==="proxy"&&a&&(l["X-Proxy-URL"]=a);try{t=await fetch("/api/generate/workflow",{method:"POST",headers:l,body:JSON.stringify({prompt:e})})}catch{throw new Error("서버에 연결할 수 없습니다. 서버가 실행 중인지 확인하세요.")}if(!t.ok){let d=`서버 오류 (${t.status})`;try{d=(await t.json()).message||d}catch{}throw new Error(d)}let u;try{u=await t.json()}catch{throw new Error("서버 응답을 파싱할 수 없습니다.")}return{workflow:h9(u),workflowName:u.workflowName}}function d9(e,t){if(e.length===0)return e;const n=300,r=150,a=100,l=100,u=new Map,f=new Map;e.forEach(w=>{u.set(w.id,[]),f.set(w.id,[])}),t.forEach(w=>{const k=u.get(w.target)||[];k.push(w.source),u.set(w.target,k);const N=f.get(w.source)||[];N.push(w.target),f.set(w.source,N)});const d=e.filter(w=>(u.get(w.id)||[]).length===0),h=new Map,g=[];for(d.forEach(w=>{h.set(w.id,0),g.push({id:w.id,depth:0})}),d.length===0&&e.length>0&&(h.set(e[0].id,0),g.push({id:e[0].id,depth:0}));g.length>0;){const w=g.shift();(f.get(w.id)||[]).forEach(N=>{const _=h.get(N),z=w.depth+1;(_===void 0||z>_)&&(h.set(N,z),g.push({id:N,depth:z}))})}const m=new Map;h.forEach((w,k)=>{const N=m.get(w)||[];N.push(k),m.set(w,N)});const x=Math.max(...Array.from(h.values()),0),b=new Map;for(let w=0;w<=x;w++){const k=m.get(w)||[],_=(k.length-1)*r,z=l+(300-_)/2;k.forEach((E,C)=>{b.set(E,{x:a+w*n,y:z+C*r})})}return e.map(w=>{const k=b.get(w.id)||w.position;return{...w,position:k}})}function h9(e){const t=[],n=new Map,r={x:0,y:0};e.nodes.forEach((u,f)=>{const d=ka();n.set(f,d);const h={label:u.label,description:u.description,status:"idle",usedInputs:[]};switch(u.type){case"input":t.push({id:d,type:"input",position:{...r},data:{...h,inputType:u.config.inputType||"text",placeholder:u.config.placeholder||u.description}});break;case"subagent":t.push({id:d,type:"subagent",position:{...r},data:{...h,role:u.config.role||"custom",tools:u.config.tools||["Read","Write"],model:u.config.model||"sonnet",systemPrompt:u.config.systemPrompt}});break;case"skill":t.push({id:d,type:"skill",position:{...r},data:{...h,skillType:u.config.skillType||"official",skillId:u.config.skillId,skillContent:u.config.skillContent}});break;case"command":t.push({id:d,type:"command",position:{...r},data:{...h,commandName:u.config.commandName||u.label,commandPath:u.config.commandPath}});break;case"hook":t.push({id:d,type:"hook",position:{...r},data:{...h,hookEvent:u.config.hookEvent||"PreToolUse",hookMatcher:u.config.hookMatcher,hookCommand:u.config.hookCommand}});break;case"output":t.push({id:d,type:"output",position:{...r},data:{...h,outputType:u.config.outputType||"auto"}});break}}),e.edges.forEach(u=>{const f=n.get(u.to),d=n.get(u.from);if(f&&d){const h=t.find(g=>g.id===f);h&&h.data.usedInputs&&h.data.usedInputs.push(d)}});const a=e.edges.map(u=>{const f=n.get(u.from),d=n.get(u.to);return!f||!d?null:{id:`e-${f}-${d}`,source:f,target:d,animated:!0}}).filter(u=>u!==null);return{nodes:d9(t,a),edges:a}}function p9(e){const t=e.toLowerCase();if(t.includes("스킬")||t.includes("skill"))return!0;const n=[/만들어\s*(줘|주세요|줘요)/,/작성해\s*(줘|주세요|줘요)/,/생성해\s*(줘|주세요|줘요)/];for(const r of n)if(r.test(e))return!0;return!1}const fi=Object.create(null);fi.open="0";fi.close="1";fi.ping="2";fi.pong="3";fi.message="4";fi.upgrade="5";fi.noop="6";const Vc=Object.create(null);Object.keys(fi).forEach(e=>{Vc[fi[e]]=e});const Rm={type:"error",data:"parser error"},X2=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",G2=typeof ArrayBuffer=="function",Z2=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Mg=({type:e,data:t},n,r)=>X2&&t instanceof Blob?n?r(t):Jv(t,r):G2&&(t instanceof ArrayBuffer||Z2(t))?n?r(t):Jv(new Blob([t]),r):r(fi[e]+(t||"")),Jv=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function Wv(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Zp;function m9(e,t){if(X2&&e.data instanceof Blob)return e.data.arrayBuffer().then(Wv).then(t);if(G2&&(e.data instanceof ArrayBuffer||Z2(e.data)))return t(Wv(e.data));Mg(e,!1,n=>{Zp||(Zp=new TextEncoder),t(Zp.encode(n))})}const ew="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nl=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<ew.length;e++)nl[ew.charCodeAt(e)]=e;const g9=e=>{let t=e.length*.75,n=e.length,r,a=0,l,u,f,d;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const h=new ArrayBuffer(t),g=new Uint8Array(h);for(r=0;r<n;r+=4)l=nl[e.charCodeAt(r)],u=nl[e.charCodeAt(r+1)],f=nl[e.charCodeAt(r+2)],d=nl[e.charCodeAt(r+3)],g[a++]=l<<2|u>>4,g[a++]=(u&15)<<4|f>>2,g[a++]=(f&3)<<6|d&63;return h},y9=typeof ArrayBuffer=="function",jg=(e,t)=>{if(typeof e!="string")return{type:"message",data:Q2(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:x9(e.substring(1),t)}:Vc[n]?e.length>1?{type:Vc[n],data:e.substring(1)}:{type:Vc[n]}:Rm},x9=(e,t)=>{if(y9){const n=g9(e);return Q2(n,t)}else return{base64:!0,data:e}},Q2=(e,t)=>t==="blob"?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,K2="",b9=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((l,u)=>{Mg(l,!1,f=>{r[u]=f,++a===n&&t(r.join(K2))})})},v9=(e,t)=>{const n=e.split(K2),r=[];for(let a=0;a<n.length;a++){const l=jg(n[a],t);if(r.push(l),l.type==="error")break}return r};function w9(){return new TransformStream({transform(e,t){m9(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const l=new DataView(a.buffer);l.setUint8(0,126),l.setUint16(1,r)}else{a=new Uint8Array(9);const l=new DataView(a.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let Qp;function Oc(e){return e.reduce((t,n)=>t+n.length,0)}function Dc(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function S9(e,t){Qp||(Qp=new TextDecoder);const n=[];let r=0,a=-1,l=!1;return new TransformStream({transform(u,f){for(n.push(u);;){if(r===0){if(Oc(n)<1)break;const d=Dc(n,1);l=(d[0]&128)===128,a=d[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(Oc(n)<2)break;const d=Dc(n,2);a=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),r=3}else if(r===2){if(Oc(n)<8)break;const d=Dc(n,8),h=new DataView(d.buffer,d.byteOffset,d.length),g=h.getUint32(0);if(g>Math.pow(2,21)-1){f.enqueue(Rm);break}a=g*Math.pow(2,32)+h.getUint32(4),r=3}else{if(Oc(n)<a)break;const d=Dc(n,a);f.enqueue(jg(l?d:Qp.decode(d),t)),r=0}if(a===0||a>e){f.enqueue(Rm);break}}}})}const J2=4;function kt(e){if(e)return _9(e)}function _9(e){for(var t in kt.prototype)e[t]=kt.prototype[t];return e}kt.prototype.on=kt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};kt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};kt.prototype.off=kt.prototype.removeListener=kt.prototype.removeAllListeners=kt.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};kt.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};kt.prototype.emitReserved=kt.prototype.emit;kt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};kt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Vf=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Ln=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),k9="arraybuffer";function W2(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const E9=Ln.setTimeout,N9=Ln.clearTimeout;function Ff(e,t){t.useNativeTimers?(e.setTimeoutFn=E9.bind(Ln),e.clearTimeoutFn=N9.bind(Ln)):(e.setTimeoutFn=Ln.setTimeout.bind(Ln),e.clearTimeoutFn=Ln.clearTimeout.bind(Ln))}const C9=1.33;function T9(e){return typeof e=="string"?A9(e):Math.ceil((e.byteLength||e.size)*C9)}function A9(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function ek(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function M9(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function j9(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let l=n[r].split("=");t[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return t}class R9 extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Rg extends kt{constructor(t){super(),this.writable=!1,Ff(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new R9(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=jg(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=M9(t);return n.length?"?"+n:""}}class z9 extends Rg{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};v9(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,b9(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=ek()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let tk=!1;try{tk=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const O9=tk;function D9(){}class L9 extends z9{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,l)=>{this.onError("xhr post error",a,l)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class li extends kt{constructor(t,n,r){super(),this.createRequest=t,Ff(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=W2(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=li.requestsCount++,li.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=D9,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete li.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}li.requestsCount=0;li.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",tw);else if(typeof addEventListener=="function"){const e="onpagehide"in Ln?"pagehide":"unload";addEventListener(e,tw,!1)}}function tw(){for(let e in li.requests)li.requests.hasOwnProperty(e)&&li.requests[e].abort()}const B9=(function(){const e=nk({xdomain:!1});return e&&e.responseType!==null})();class H9 extends L9{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=B9&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new li(nk,this.uri(),t)}}function nk(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||O9))return new XMLHttpRequest}catch{}if(!t)try{return new Ln[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ik=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class U9 extends Rg{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=ik?{}:W2(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;Mg(r,this.supportsBinary,l=>{try{this.doWrite(r,l)}catch{}a&&Vf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=ek()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Kp=Ln.WebSocket||Ln.MozWebSocket;class I9 extends U9{createSocket(t,n,r){return ik?new Kp(t,n,r):n?new Kp(t,n):new Kp(t)}doWrite(t,n){this.ws.send(n)}}class q9 extends Rg{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=S9(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=w9();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const l=()=>{r.read().then(({done:f,value:d})=>{f||(this.onPacket(d),l())}).catch(f=>{})};l();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&Vf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const $9={websocket:I9,webtransport:q9,polling:H9},P9=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,V9=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function zm(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=P9.exec(e||""),l={},u=14;for(;u--;)l[V9[u]]=a[u]||"";return n!=-1&&r!=-1&&(l.source=t,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=F9(l,l.path),l.queryKey=Y9(l,l.query),l}function F9(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Y9(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,l){a&&(n[a]=l)}),n}const Om=typeof addEventListener=="function"&&typeof removeEventListener=="function",Fc=[];Om&&addEventListener("offline",()=>{Fc.forEach(e=>e())},!1);class Ar extends kt{constructor(t,n){if(super(),this.binaryType=k9,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=zm(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=zm(n.host).host);Ff(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=j9(this.opts.query)),Om&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Fc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=J2,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Ar.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ar.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=T9(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Vf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const l={type:t,data:n,options:r};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Ar.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Om&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Fc.indexOf(this._offlineEventListener);r!==-1&&Fc.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ar.protocol=J2;class X9 extends Ar{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Ar.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",m=>{if(!r)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ar.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(g(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function l(){r||(r=!0,g(),n.close(),n=null)}const u=m=>{const x=new Error("probe error: "+m);x.transport=n.name,l(),this.emitReserved("upgradeError",x)};function f(){u("transport closed")}function d(){u("socket closed")}function h(m){n&&m.name!==n.name&&l()}const g=()=>{n.removeListener("open",a),n.removeListener("error",u),n.removeListener("close",f),this.off("close",d),this.off("upgrading",h)};n.once("open",a),n.once("error",u),n.once("close",f),this.once("close",d),this.once("upgrading",h),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let G9=class extends X9{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>$9[a]).filter(a=>!!a)),super(t,r)}};function Z9(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=zm(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const l=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+l+":"+r.port+t,r.href=r.protocol+"://"+l+(n&&n.port===r.port?"":":"+r.port),r}const Q9=typeof ArrayBuffer=="function",K9=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,rk=Object.prototype.toString,J9=typeof Blob=="function"||typeof Blob<"u"&&rk.call(Blob)==="[object BlobConstructor]",W9=typeof File=="function"||typeof File<"u"&&rk.call(File)==="[object FileConstructor]";function zg(e){return Q9&&(e instanceof ArrayBuffer||K9(e))||J9&&e instanceof Blob||W9&&e instanceof File}function Yc(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Yc(e[n]))return!0;return!1}if(zg(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Yc(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Yc(e[n]))return!0;return!1}function eH(e){const t=[],n=e.data,r=e;return r.data=Dm(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Dm(e,t){if(!e)return e;if(zg(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Dm(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Dm(e[r],t));return n}return e}function tH(e,t){return e.data=Lm(e.data,t),delete e.attachments,e}function Lm(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Lm(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Lm(e[n],t));return e}const nH=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var $e;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})($e||($e={}));class iH{constructor(t){this.replacer=t}encode(t){return(t.type===$e.EVENT||t.type===$e.ACK)&&Yc(t)?this.encodeAsBinary({type:t.type===$e.EVENT?$e.BINARY_EVENT:$e.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===$e.BINARY_EVENT||t.type===$e.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=eH(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class Og extends kt{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===$e.BINARY_EVENT;r||n.type===$e.BINARY_ACK?(n.type=r?$e.EVENT:$e.ACK,this.reconstructor=new rH(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(zg(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if($e[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===$e.BINARY_EVENT||r.type===$e.BINARY_ACK){const l=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const u=t.substring(l,n);if(u!=Number(u)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(u)}if(t.charAt(n+1)==="/"){const l=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(l,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const l=n+1;for(;++n;){const u=t.charAt(n);if(u==null||Number(u)!=u){--n;break}if(n===t.length)break}r.id=Number(t.substring(l,n+1))}if(t.charAt(++n)){const l=this.tryParse(t.substr(n));if(Og.isPayloadValid(r.type,l))r.data=l;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case $e.CONNECT:return nw(n);case $e.DISCONNECT:return n===void 0;case $e.CONNECT_ERROR:return typeof n=="string"||nw(n);case $e.EVENT:case $e.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&nH.indexOf(n[0])===-1);case $e.ACK:case $e.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class rH{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=tH(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function nw(e){return Object.prototype.toString.call(e)==="[object Object]"}const sH=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Og,Encoder:iH,get PacketType(){return $e}},Symbol.toStringTag,{value:"Module"}));function Vn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const aH=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sk extends kt{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Vn(t,"open",this.onopen.bind(this)),Vn(t,"packet",this.onpacket.bind(this)),Vn(t,"error",this.onerror.bind(this)),Vn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,l;if(aH.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const u={type:$e.EVENT,data:n};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const g=this.ids++,m=n.pop();this._registerAckCallback(g,m),u.id=g}const f=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,d=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!f||(d?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===t&&this.sendBuffer.splice(f,1);n.call(this,new Error("operation has timed out"))},a),u=(...f)=>{this.io.clearTimeoutFn(l),n.apply(this,f)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,a)=>{const l=(u,f)=>u?a(u):r(f);l.withError=!0,n.push(l),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...l)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...l)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:$e.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case $e.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case $e.EVENT:case $e.BINARY_EVENT:this.onevent(t);break;case $e.ACK:case $e.BINARY_ACK:this.onack(t);break;case $e.DISCONNECT:this.ondisconnect();break;case $e.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:$e.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:$e.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function Ra(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ra.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};Ra.prototype.reset=function(){this.attempts=0};Ra.prototype.setMin=function(e){this.ms=e};Ra.prototype.setMax=function(e){this.max=e};Ra.prototype.setJitter=function(e){this.jitter=e};class Bm extends kt{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Ff(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Ra({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||sH;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new G9(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Vn(n,"open",function(){r.onopen(),t&&t()}),l=f=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",f),t?t(f):this.maybeReconnectOnOpen()},u=Vn(n,"error",l);if(this._timeout!==!1){const f=this._timeout,d=this.setTimeoutFn(()=>{a(),l(new Error("timeout")),n.close()},f);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(a),this.subs.push(u),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Vn(t,"ping",this.onping.bind(this)),Vn(t,"data",this.ondata.bind(this)),Vn(t,"error",this.onerror.bind(this)),Vn(t,"close",this.onclose.bind(this)),Vn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Vf(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new sk(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Qo={};function Xc(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Z9(e,t.path||"/socket.io"),r=n.source,a=n.id,l=n.path,u=Qo[a]&&l in Qo[a].nsps,f=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let d;return f?d=new Bm(r,t):(Qo[a]||(Qo[a]=new Bm(r,t)),d=Qo[a]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(Xc,{Manager:Bm,Socket:sk,io:Xc,connect:Xc});const iw=window.location.origin;class oH{socket;constructor(){this.socket=Xc(iw,{autoConnect:!0,reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3}),this.socket.on("connect",()=>{console.log("[Socket] Connected to server:",iw)}),this.socket.on("disconnect",()=>{console.log("Disconnected from server")}),this.socket.on("connect_error",t=>{console.error("Socket connection error:",t.message)})}on(t,n){this.socket.on(t,n)}off(t,n){n?this.socket.off(t,n):this.socket.off(t)}emit(t,n){this.socket.connected||console.warn("Socket not connected, queuing emit:",t),this.socket.emit(t,n)}executeWorkflow(t){this.emit("execute:workflow",t)}cancelExecution(){this.emit("execute:cancel")}generateSkill(t){console.log("[Socket] Generating skill:",t.prompt.slice(0,50),"connected:",this.socket.connected),this.emit("generate:skill",t)}isConnected(){return this.socket.connected}disconnect(){this.socket.disconnect()}connect(){this.socket.connected||this.socket.connect()}}const Cr=new oH;function lH(){const[e,t]=X.useState(""),[n,r]=X.useState(!1),[a,l]=X.useState(null),[u,f]=X.useState(null),[d,h]=X.useState("workflow"),{loadWorkflow:g,addNode:m,setSelectedNode:x,nodes:b}=ci(),{openConsolePanel:w,openStepPanel:k}=Hf(),{addLog:N,clearLogs:_}=Na(),{apiMode:z,apiKey:E,proxyUrl:C}=fg(),L=X.useCallback(H=>{console.log("[PromptBar] Skill progress:",H.step,H.message);const $=H.step==="error"?"error":H.step==="completed"?"success":"info";N($,H.message,void 0,H.detail)},[N]),A=X.useCallback(H=>{r(!1),f(`스킬 "${H.skill.skillName}"이 ${H.savedPath}에 저장되었습니다!`),t(""),setTimeout(()=>f(null),5e3);const $=ka(),P=b.length,te={id:$,type:"skill",position:{x:100+P%3*300,y:100+Math.floor(P/3)*200},data:{label:H.skill.skillName,description:H.skill.description,status:"idle",skillType:"generated",skillId:H.skill.skillId,skillPath:H.savedPath}};m(te),x($),k()},[b,m,x,k]),B=X.useCallback(H=>{r(!1),l(H.error)},[]);X.useEffect(()=>(Cr.on("skill:progress",L),Cr.on("skill:completed",A),Cr.on("skill:error",B),()=>{Cr.off("skill:progress",L),Cr.off("skill:completed",A),Cr.off("skill:error",B)}),[L,A,B]);const G=async()=>{if(!e.trim()||n)return;r(!0),l(null),f(null);const H=p9(e);h(H?"skill":"workflow");try{if(H)_(),w(),Cr.isConnected()||N("warning","⚠️ 서버 연결 대기 중...",void 0,"잠시 후 자동으로 연결됩니다"),Cr.generateSkill({prompt:e,apiMode:z,apiKey:z==="direct"?E:void 0,proxyUrl:z==="proxy"?C:void 0});else{const{workflow:$,workflowName:P}=await f9(e);g({nodes:$.nodes,edges:$.edges,name:P}),t(""),r(!1)}}catch($){console.error("Generation failed:",$);const P=$ instanceof Error?$.message:"생성에 실패했습니다.";l(P),r(!1)}},Z=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),G())};return v.jsxs("div",{className:"bg-surface border border-border rounded-2xl px-5 py-3 shadow-2xl flex items-center gap-3",children:[v.jsx(Tl,{className:"w-5 h-5 text-accent flex-shrink-0"}),v.jsx("input",{type:"text",value:e,onChange:H=>t(H.target.value),onKeyDown:Z,placeholder:"Describe your workflow... (e.g., 'Create an HTML page with images')",className:"flex-1 bg-transparent border-none outline-none text-white placeholder-gray-500 text-sm",disabled:n}),v.jsx("button",{onClick:G,disabled:!e.trim()||n,className:`p-2 rounded-full transition-all duration-200 ${e.trim()&&!n?"bg-accent text-white hover:bg-accent-hover hover:scale-105":"bg-surface-hover text-gray-500"}`,title:"Generate Workflow",children:n?v.jsx(af,{className:"w-5 h-5 animate-spin"}):v.jsx(wj,{className:"w-5 h-5"})}),v.jsx("div",{className:"absolute -bottom-6 left-1/2 -translate-x-1/2 text-xs whitespace-nowrap",children:a?v.jsx("span",{className:"text-red-400",children:a}):u?v.jsxs("span",{className:"text-green-400 flex items-center gap-1",children:[v.jsx(Tf,{className:"w-3 h-3"}),u]}):n?v.jsxs("span",{className:"text-accent",children:["AI가 ",d==="skill"?"스킬":"워크플로우","을 생성하고 있습니다..."]}):v.jsx("span",{className:"text-gray-600",children:'"스킬 만들어줘" 또는 워크플로우 설명을 입력하세요'})})]})}function uH(){const{isCollapsed:e,width:t}=Hf(),{isRunning:n,logs:r}=Na(),{mergeExistingConfig:a}=ci(),[l,u]=X.useState(!1),f=X.useRef(!1);return X.useEffect(()=>{f.current||(f.current=!0,L_().then(d=>{d.length>0&&(console.log(`Loaded ${d.length} nodes from .claude/`),a(d))}).catch(d=>{console.error("Failed to load initial config:",d)}))},[a]),X.useEffect(()=>{n&&u(!0)},[n]),v.jsx(PS,{children:v.jsxs("div",{className:"flex flex-col h-screen bg-canvas",children:[v.jsx(nz,{}),v.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[v.jsxs("div",{className:"flex-1 flex flex-col",children:[v.jsx(oz,{}),v.jsxs("div",{className:"flex-1 relative",children:[v.jsx(Ez,{}),v.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 w-full max-w-2xl px-4",children:v.jsx(lH,{})})]})]}),!e&&v.jsx("div",{className:"border-l border-border bg-surface",style:{width:`${t}px`},children:v.jsx(c9,{})})]}),v.jsxs("button",{onClick:()=>u(!l),className:`fixed bottom-4 left-4 z-40 flex items-center gap-2 px-3 py-2 rounded-lg shadow-lg transition-all ${l?"bg-amber-600 text-white":"bg-gray-800 text-gray-300 hover:bg-gray-700"} ${l?"opacity-0 pointer-events-none":"opacity-100"}`,children:[v.jsx(ds,{className:"w-4 h-4"}),v.jsx("span",{className:"text-sm font-medium",children:"Console"}),r.length>0&&!l&&v.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-amber-500 text-white rounded-full",children:r.length}),n&&v.jsx("span",{className:"w-2 h-2 bg-green-400 rounded-full animate-pulse"})]}),v.jsx(Z8,{isOpen:l,onClose:()=>u(!1)})]})})}bN.createRoot(document.getElementById("root")).render(v.jsx(X.StrictMode,{children:v.jsx(uH,{})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>vite-temp</title>
8
- <script type="module" crossorigin src="/assets/index-lpZin4sA.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-oO8rpFoq.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-v9IFpWkA.css">
10
10
  </head>
11
11
  <body>