@gcoredev/fastedge-test 0.1.0 → 0.1.3
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.
- package/dist/frontend/assets/{index-CEFjsU8e.js → index-CjNwdWIi.js} +2 -2
- package/dist/frontend/index.html +1 -1
- package/dist/lib/index.cjs +172 -86
- package/dist/lib/index.js +170 -86
- package/dist/lib/runner/HttpWasmRunner.d.ts +2 -0
- package/dist/lib/runner/ProxyWasmRunner.d.ts +5 -0
- package/dist/lib/runner/index.d.ts +1 -1
- package/dist/lib/schemas/api.d.ts +1 -1
- package/dist/lib/test-framework/assertions.d.ts +39 -0
- package/dist/lib/test-framework/index.cjs +295 -95
- package/dist/lib/test-framework/index.d.ts +3 -3
- package/dist/lib/test-framework/index.js +285 -95
- package/dist/lib/test-framework/suite-runner.d.ts +11 -2
- package/dist/lib/test-framework/types.d.ts +10 -0
- package/dist/lib/utils/legacy-wasm-detect.d.ts +25 -0
- package/dist/lib/utils/wasmTypeDetector.d.ts +3 -2
- package/dist/server.js +26 -26
- package/docs/API.md +52 -55
- package/docs/DEBUGGER.md +15 -14
- package/docs/INDEX.md +68 -55
- package/docs/RUNNER.md +101 -42
- package/docs/TEST_CONFIG.md +32 -32
- package/docs/TEST_FRAMEWORK.md +139 -16
- package/docs/WEBSOCKET.md +13 -13
- package/llms.txt +12 -225
- package/package.json +10 -4
- package/schemas/api-send.schema.json +10 -2
|
@@ -11,7 +11,7 @@ Error generating stack: `+n.message+`
|
|
|
11
11
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
12
12
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
13
13
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
14
|
-
`);const X=M.state[b];if(X==null)return;JSON.stringify(m.getState())!==JSON.stringify(X)&&R(X);return}Kh(m)&&m.dispatch(M)});case"DISPATCH":switch(D.payload.type){case"RESET":return R(j),b===void 0?T?.init(m.getState()):T?.init(Ei(x.name));case"COMMIT":if(b===void 0){T?.init(m.getState());return}return T?.init(Ei(x.name));case"ROLLBACK":return mo(D.state,M=>{if(b===void 0){R(M),T?.init(m.getState());return}R(M[b]),T?.init(Ei(x.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return mo(D.state,M=>{if(b===void 0){R(M);return}JSON.stringify(m.getState())!==JSON.stringify(M[b])&&R(M[b])});case"IMPORT_STATE":{const{nextLiftedState:M}=D.payload,X=(E=M.computedStates.slice(-1)[0])==null?void 0:E.state;if(!X)return;R(b===void 0?X:X[b]),T?.send(null,M);return}case"PAUSE_RECORDING":return U=!U}return}}),j},Av=xv,mo=(i,s)=>{let c;try{c=JSON.parse(i)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}c!==void 0&&s(c)};function fm(i,s){let c;try{c=i()}catch{return}return{getItem:m=>{var h;const _=x=>x===null?null:JSON.parse(x,s?.reviver),b=(h=c.getItem(m))!=null?h:null;return b instanceof Promise?b.then(_):_(b)},setItem:(m,h)=>c.setItem(m,JSON.stringify(h,s?.replacer)),removeItem:m=>c.removeItem(m)}}const bo=i=>s=>{try{const c=i(s);return c instanceof Promise?c:{then(r){return bo(r)(c)},catch(r){return this}}}catch(c){return{then(r){return this},catch(r){return bo(r)(c)}}}},zv=(i,s)=>(c,r,m)=>{let h={storage:fm(()=>window.localStorage),partialize:E=>E,version:0,merge:(E,M)=>({...M,...E}),...s},_=!1,b=0;const x=new Set,p=new Set;let T=h.storage;if(!T)return i((...E)=>{console.warn(`[zustand persist middleware] Unable to update item '${h.name}', the given storage is currently unavailable.`),c(...E)},r,m);const z=()=>{const E=h.partialize({...r()});return T.setItem(h.name,{state:E,version:h.version})},U=m.setState;m.setState=(E,M)=>(U(E,M),z());const R=i((...E)=>(c(...E),z()),r,m);m.getInitialState=()=>R;let j;const D=()=>{var E,M;if(!T)return;const X=++b;_=!1,x.forEach(V=>{var F;return V((F=r())!=null?F:R)});const G=((M=h.onRehydrateStorage)==null?void 0:M.call(h,(E=r())!=null?E:R))||void 0;return bo(T.getItem.bind(T))(h.name).then(V=>{if(V)if(typeof V.version=="number"&&V.version!==h.version){if(h.migrate){const F=h.migrate(V.state,V.version);return F instanceof Promise?F.then(P=>[!0,P]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,V.state];return[!1,void 0]}).then(V=>{var F;if(X!==b)return;const[P,Q]=V;if(j=h.merge(Q,(F=r())!=null?F:R),c(j,!0),P)return z()}).then(()=>{X===b&&(G?.(j,void 0),j=r(),_=!0,p.forEach(V=>V(j)))}).catch(V=>{X===b&&G?.(void 0,V)})};return m.persist={setOptions:E=>{h={...h,...E},E.storage&&(T=E.storage)},clearStorage:()=>{T?.removeItem(h.name)},getOptions:()=>h,rehydrate:()=>D(),hasHydrated:()=>_,onHydrate:E=>(x.add(E),()=>{x.delete(E)}),onFinishHydration:E=>(p.add(E),()=>{p.delete(E)})},h.skipHydration||D(),j||R},Nv=zv;var dm=Symbol.for("immer-nothing"),$h=Symbol.for("immer-draftable"),nt=Symbol.for("immer-state");function Lt(i,...s){throw new Error(`[Immer] minified error nr: ${i}. Full error at: https://bit.ly/3cXEKWf`)}var Et=Object,ea=Et.getPrototypeOf,ji="constructor",wi="prototype",So="configurable",Oi="enumerable",Ai="writable",Ia="value",Vl=i=>!!i&&!!i[nt];function hl(i){return i?hm(i)||Bi(i)||!!i[$h]||!!i[ji]?.[$h]||Li(i)||Yi(i):!1}var jv=Et[wi][ji].toString(),kh=new WeakMap;function hm(i){if(!i||!Ro(i))return!1;const s=ea(i);if(s===null||s===Et[wi])return!0;const c=Et.hasOwnProperty.call(s,ji)&&s[ji];if(c===Object)return!0;if(!Pn(c))return!1;let r=kh.get(c);return r===void 0&&(r=Function.toString.call(c),kh.set(c,r)),r===jv}function Ui(i,s,c=!0){tu(i)===0?(c?Reflect.ownKeys(i):Et.keys(i)).forEach(m=>{s(m,i[m],i)}):i.forEach((r,m)=>s(m,r,i))}function tu(i){const s=i[nt];return s?s.type_:Bi(i)?1:Li(i)?2:Yi(i)?3:0}var Wh=(i,s,c=tu(i))=>c===2?i.has(s):Et[wi].hasOwnProperty.call(i,s),To=(i,s,c=tu(i))=>c===2?i.get(s):i[s],Ri=(i,s,c,r=tu(i))=>{r===2?i.set(s,c):r===3?i.add(c):i[s]=c};function Ov(i,s){return i===s?i!==0||1/i===1/s:i!==i&&s!==s}var Bi=Array.isArray,Li=i=>i instanceof Map,Yi=i=>i instanceof Set,Ro=i=>typeof i=="object",Pn=i=>typeof i=="function",yo=i=>typeof i=="boolean";function Rv(i){const s=+i;return Number.isInteger(s)&&String(s)===i}var dl=i=>i.copy_||i.base_,Co=i=>i.modified_?i.copy_:i.base_;function Eo(i,s){if(Li(i))return new Map(i);if(Yi(i))return new Set(i);if(Bi(i))return Array[wi].slice.call(i);const c=hm(i);if(s===!0||s==="class_only"&&!c){const r=Et.getOwnPropertyDescriptors(i);delete r[nt];let m=Reflect.ownKeys(r);for(let h=0;h<m.length;h++){const _=m[h],b=r[_];b[Ai]===!1&&(b[Ai]=!0,b[So]=!0),(b.get||b.set)&&(r[_]={[So]:!0,[Ai]:!0,[Oi]:b[Oi],[Ia]:i[_]})}return Et.create(ea(i),r)}else{const r=ea(i);if(r!==null&&c)return{...i};const m=Et.create(r);return Et.assign(m,i)}}function Mo(i,s=!1){return Gi(i)||Vl(i)||!hl(i)||(tu(i)>1&&Et.defineProperties(i,{set:xi,add:xi,clear:xi,delete:xi}),Et.freeze(i),s&&Ui(i,(c,r)=>{Mo(r,!0)},!1)),i}function Cv(){Lt(2)}var xi={[Ia]:Cv};function Gi(i){return i===null||!Ro(i)?!0:Et.isFrozen(i)}var Ci="MapSet",xo="Patches",Fh="ArrayMethods",mm={};function hn(i){const s=mm[i];return s||Lt(0,i),s}var Ih=i=>!!mm[i],Pa,ym=()=>Pa,Mv=(i,s)=>({drafts_:[],parent_:i,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ih(Ci)?hn(Ci):void 0,arrayMethodsPlugin_:Ih(Fh)?hn(Fh):void 0});function Ph(i,s){s&&(i.patchPlugin_=hn(xo),i.patches_=[],i.inversePatches_=[],i.patchListener_=s)}function Ao(i){zo(i),i.drafts_.forEach(Dv),i.drafts_=null}function zo(i){i===Pa&&(Pa=i.parent_)}var em=i=>Pa=Mv(Pa,i);function Dv(i){const s=i[nt];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function tm(i,s){s.unfinalizedDrafts_=s.drafts_.length;const c=s.drafts_[0];if(i!==void 0&&i!==c){c[nt].modified_&&(Ao(s),Lt(4)),hl(i)&&(i=lm(s,i));const{patchPlugin_:m}=s;m&&m.generateReplacementPatches_(c[nt].base_,i,s)}else i=lm(s,c);return qv(s,i,!0),Ao(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),i!==dm?i:void 0}function lm(i,s){if(Gi(s))return s;const c=s[nt];if(!c)return Mi(s,i.handledSet_,i);if(!Vi(c,i))return s;if(!c.modified_)return c.base_;if(!c.finalized_){const{callbacks_:r}=c;if(r)for(;r.length>0;)r.pop()(i);gm(c,i)}return c.copy_}function qv(i,s,c=!1){!i.parent_&&i.immer_.autoFreeze_&&i.canAutoFreeze_&&Mo(s,c)}function pm(i){i.finalized_=!0,i.scope_.unfinalizedDrafts_--}var Vi=(i,s)=>i.scope_===s,Hv=[];function vm(i,s,c,r){const m=dl(i),h=i.type_;if(r!==void 0&&To(m,r,h)===s){Ri(m,r,c,h);return}if(!i.draftLocations_){const b=i.draftLocations_=new Map;Ui(m,(x,p)=>{if(Vl(p)){const T=b.get(p)||[];T.push(x),b.set(p,T)}})}const _=i.draftLocations_.get(s)??Hv;for(const b of _)Ri(m,b,c,h)}function wv(i,s,c){i.callbacks_.push(function(m){const h=s;if(!h||!Vi(h,m))return;m.mapSetPlugin_?.fixSetContents(h);const _=Co(h);vm(i,h.draft_??h,_,c),gm(h,m)})}function gm(i,s){if(i.modified_&&!i.finalized_&&(i.type_===3||i.type_===1&&i.allIndicesReassigned_||(i.assigned_?.size??0)>0)){const{patchPlugin_:r}=s;if(r){const m=r.getPath(i);m&&r.generatePatches_(i,m,s)}pm(i)}}function Uv(i,s,c){const{scope_:r}=i;if(Vl(c)){const m=c[nt];Vi(m,r)&&m.callbacks_.push(function(){zi(i);const _=Co(m);vm(i,c,_,s)})}else hl(c)&&i.callbacks_.push(function(){const h=dl(i);i.type_===3?h.has(c)&&Mi(c,r.handledSet_,r):To(h,s,i.type_)===c&&r.drafts_.length>1&&(i.assigned_.get(s)??!1)===!0&&i.copy_&&Mi(To(i.copy_,s,i.type_),r.handledSet_,r)})}function Mi(i,s,c){return!c.immer_.autoFreeze_&&c.unfinalizedDrafts_<1||Vl(i)||s.has(i)||!hl(i)||Gi(i)||(s.add(i),Ui(i,(r,m)=>{if(Vl(m)){const h=m[nt];if(Vi(h,c)){const _=Co(h);Ri(i,r,_,i.type_),pm(h)}}else hl(m)&&Mi(m,s,c)})),i}function Bv(i,s){const c=Bi(i),r={type_:c?1:0,scope_:s?s.scope_:ym(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:i,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let m=r,h=Di;c&&(m=[r],h=eu);const{revoke:_,proxy:b}=Proxy.revocable(m,h);return r.draft_=b,r.revoke_=_,[b,r]}var Di={get(i,s){if(s===nt)return i;let c=i.scope_.arrayMethodsPlugin_;const r=i.type_===1&&typeof s=="string";if(r&&c?.isArrayOperationMethod(s))return c.createMethodInterceptor(i,s);const m=dl(i);if(!Wh(m,s,i.type_))return Lv(i,m,s);const h=m[s];if(i.finalized_||!hl(h)||r&&i.operationMethod&&c?.isMutatingArrayMethod(i.operationMethod)&&Rv(s))return h;if(h===po(i.base_,s)){zi(i);const _=i.type_===1?+s:s,b=jo(i.scope_,h,i,_);return i.copy_[_]=b}return h},has(i,s){return s in dl(i)},ownKeys(i){return Reflect.ownKeys(dl(i))},set(i,s,c){const r=_m(dl(i),s);if(r?.set)return r.set.call(i.draft_,c),!0;if(!i.modified_){const m=po(dl(i),s),h=m?.[nt];if(h&&h.base_===c)return i.copy_[s]=c,i.assigned_.set(s,!1),!0;if(Ov(c,m)&&(c!==void 0||Wh(i.base_,s,i.type_)))return!0;zi(i),No(i)}return i.copy_[s]===c&&(c!==void 0||s in i.copy_)||Number.isNaN(c)&&Number.isNaN(i.copy_[s])||(i.copy_[s]=c,i.assigned_.set(s,!0),Uv(i,s,c)),!0},deleteProperty(i,s){return zi(i),po(i.base_,s)!==void 0||s in i.base_?(i.assigned_.set(s,!1),No(i)):i.assigned_.delete(s),i.copy_&&delete i.copy_[s],!0},getOwnPropertyDescriptor(i,s){const c=dl(i),r=Reflect.getOwnPropertyDescriptor(c,s);return r&&{[Ai]:!0,[So]:i.type_!==1||s!=="length",[Oi]:r[Oi],[Ia]:c[s]}},defineProperty(){Lt(11)},getPrototypeOf(i){return ea(i.base_)},setPrototypeOf(){Lt(12)}},eu={};for(let i in Di){let s=Di[i];eu[i]=function(){const c=arguments;return c[0]=c[0][0],s.apply(this,c)}}eu.deleteProperty=function(i,s){return eu.set.call(this,i,s,void 0)};eu.set=function(i,s,c){return Di.set.call(this,i[0],s,c,i[0])};function po(i,s){const c=i[nt];return(c?dl(c):i)[s]}function Lv(i,s,c){const r=_m(s,c);return r?Ia in r?r[Ia]:r.get?.call(i.draft_):void 0}function _m(i,s){if(!(s in i))return;let c=ea(i);for(;c;){const r=Object.getOwnPropertyDescriptor(c,s);if(r)return r;c=ea(c)}}function No(i){i.modified_||(i.modified_=!0,i.parent_&&No(i.parent_))}function zi(i){i.copy_||(i.assigned_=new Map,i.copy_=Eo(i.base_,i.scope_.immer_.useStrictShallowCopy_))}var Yv=class{constructor(i){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,c,r)=>{if(Pn(s)&&!Pn(c)){const h=c;c=s;const _=this;return function(x=h,...p){return _.produce(x,T=>c.call(this,T,...p))}}Pn(c)||Lt(6),r!==void 0&&!Pn(r)&&Lt(7);let m;if(hl(s)){const h=em(this),_=jo(h,s,void 0);let b=!0;try{m=c(_),b=!1}finally{b?Ao(h):zo(h)}return Ph(h,r),tm(m,h)}else if(!s||!Ro(s)){if(m=c(s),m===void 0&&(m=s),m===dm&&(m=void 0),this.autoFreeze_&&Mo(m,!0),r){const h=[],_=[];hn(xo).generateReplacementPatches_(s,m,{patches_:h,inversePatches_:_}),r(h,_)}return m}else Lt(1,s)},this.produceWithPatches=(s,c)=>{if(Pn(s))return(_,...b)=>this.produceWithPatches(_,x=>s(x,...b));let r,m;return[this.produce(s,c,(_,b)=>{r=_,m=b}),r,m]},yo(i?.autoFreeze)&&this.setAutoFreeze(i.autoFreeze),yo(i?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(i.useStrictShallowCopy),yo(i?.useStrictIteration)&&this.setUseStrictIteration(i.useStrictIteration)}createDraft(i){hl(i)||Lt(8),Vl(i)&&(i=Gv(i));const s=em(this),c=jo(s,i,void 0);return c[nt].isManual_=!0,zo(s),c}finishDraft(i,s){const c=i&&i[nt];(!c||!c.isManual_)&&Lt(9);const{scope_:r}=c;return Ph(r,s),tm(void 0,r)}setAutoFreeze(i){this.autoFreeze_=i}setUseStrictShallowCopy(i){this.useStrictShallowCopy_=i}setUseStrictIteration(i){this.useStrictIteration_=i}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(i,s){let c;for(c=s.length-1;c>=0;c--){const m=s[c];if(m.path.length===0&&m.op==="replace"){i=m.value;break}}c>-1&&(s=s.slice(c+1));const r=hn(xo).applyPatches_;return Vl(i)?r(i,s):this.produce(i,m=>r(m,s))}};function jo(i,s,c,r){const[m,h]=Li(s)?hn(Ci).proxyMap_(s,c):Yi(s)?hn(Ci).proxySet_(s,c):Bv(s,c);return(c?.scope_??ym()).drafts_.push(m),h.callbacks_=c?.callbacks_??[],h.key_=r,c&&r!==void 0?wv(c,h,r):h.callbacks_.push(function(x){x.mapSetPlugin_?.fixSetContents(h);const{patchPlugin_:p}=x;h.modified_&&p&&p.generatePatches_(h,[],x)}),m}function Gv(i){return Vl(i)||Lt(10,i),bm(i)}function bm(i){if(!hl(i)||Gi(i))return i;const s=i[nt];let c,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,c=Eo(i,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else c=Eo(i,!0);return Ui(c,(m,h)=>{Ri(c,m,bm(h))},r),s&&(s.finalized_=!1),c}var Vv=new Yv,Xv=Vv.produce;const Qv=i=>(s,c,r)=>(r.setState=(m,h,..._)=>{const b=typeof m=="function"?Xv(m):m;return s(b,h,..._)},i(r.setState,c,r)),Zv=Qv;var Jv=Object.defineProperty,Kv=(i,s,c)=>s in i?Jv(i,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):i[s]=c,dn=(i,s,c)=>Kv(i,typeof s!="symbol"?s+"":s,c),$v=class{constructor(i,s){this.storageApi=i,this.pluginManager=s}async getItem(i){let s=await this.storageApi.getItem(i);return this.pluginManager?this.pluginManager.applyAfterGetItem(s):s}async setItem(i,s){if(!this.pluginManager)return this.storageApi.setItem(i,s);let c=this.pluginManager.applyBeforeSetItem(s);return this.storageApi.setItem(i,c)}async removeItem(i){return this.storageApi.removeItem(i)}},lu=class{constructor(i){this.wrappedStorage=i}async getItem(i){return this.wrappedStorage.getItem(i)}async setItem(i,s){await this.wrappedStorage.setItem(i,s)}async removeItem(i){await this.wrappedStorage.removeItem(i)}async flush(){this.wrappedStorage.flush&&await this.wrappedStorage.flush()}},kv=class extends lu{constructor(i,s){super(i),dn(this,"eventEmitter"),this.eventEmitter=s}on(i,s){this.eventEmitter.on(i,s)}async setItem(i,s){this.eventEmitter.emit("write",i,s),await this.wrappedStorage.setItem(i,s)}async getItem(i){let s=await this.wrappedStorage.getItem(i);return this.eventEmitter.emit("get",i,s),s}async removeItem(i){await this.wrappedStorage.removeItem(i),this.eventEmitter.emit("remove",i)}},Wv=class extends lu{constructor(i,s={},c){super(i),this.options=s,this.eventEmitter=c}async setItem(i,s){let{maxRetries:c=3,retryDelay:r=1e3,backoffMultiplier:m=1}=this.options,h=0;for(;h<c;)try{await this.wrappedStorage.setItem(i,s);return}catch(_){if(h++,h>=c)throw this.eventEmitter&&this.eventEmitter.emit("error",i,_),_;let b=r*m**(h-1);this.eventEmitter&&this.eventEmitter.emit("retry",i,h,_,b),await new Promise(x=>setTimeout(x,b))}}},Fv=class extends lu{constructor(i,s){super(i),this.options=s}async setItem(i,s){let c=this.options.serialize(s);await this.wrappedStorage.setItem(i,c)}async getItem(i){let s=await this.wrappedStorage.getItem(i);return s?this.options.deserialize(s):null}},Iv=class extends lu{constructor(i,s,c){super(i),this.options=s,dn(this,"timeoutId"),dn(this,"pendingValue",null),dn(this,"lastExecutionTime",0),dn(this,"eventEmitter"),this.eventEmitter=c}async setItem(i,s){let{debounceTime:c=0,throttleTime:r=0,immediately:m=!1}=this.options;if(m){await this.wrappedStorage.setItem(i,s),this.eventEmitter.emit("save",i,s);return}let h=Date.now();r&&h-this.lastExecutionTime<r||(this.pendingValue={key:i,value:s},this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{if(this.pendingValue!==null){let{key:_,value:b}=this.pendingValue;this.wrappedStorage.setItem(_,b).then(()=>{this.lastExecutionTime=Date.now(),this.eventEmitter.emit("save",_,b),this.pendingValue=null})}},c))}async flush(){if(this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.pendingValue!==null){let{key:i,value:s}=this.pendingValue;await this.wrappedStorage.setItem(i,s),this.eventEmitter.emit("save",i,s),this.eventEmitter.emit("flush",i,s),this.pendingValue=null}await this.wrappedStorage.flush?.()}},Pv=class extends lu{constructor(i,s){super(i),this.options=s}async setItem(i,s){let c=Date.now()+this.options.ttl,r=JSON.stringify({value:s,expiresAt:c});await this.wrappedStorage.setItem(i,r)}async getItem(i){let s=await this.wrappedStorage.getItem(i);if(!s)return null;try{let{value:c,expiresAt:r}=JSON.parse(s);return Date.now()>r?(await this.removeItem(i),null):c}catch{return null}}},eg=class{constructor(){dn(this,"events",{})}on(i,s){this.events[i]||(this.events[i]=[]),this.events[i].push(s)}emit(i,...s){if(this.events[i])for(let c of this.events[i])c(...s)}},tg=class{constructor(){dn(this,"plugins",[])}register(i){for(let s of i){if(!s.name||typeof s.name!="string")throw new Error("Plugin must have a valid name property");this.plugins.push(s)}}applyBeforeSetItem(i){let s=i;for(let c of this.plugins)if(c.beforeSetItem)try{let r=c.beforeSetItem(s);r!==void 0&&(s=r)}catch(r){console.error(`[zustand-debounce] Plugin "${c.name}" beforeSetItem hook failed:`,r)}return s}applyAfterGetItem(i){let s=i;for(let c of this.plugins)if(c.afterGetItem)try{let r=c.afterGetItem(s);r!==void 0&&(s=r)}catch(r){return console.error(`[zustand-debounce] Plugin "${c.name}" afterGetItem hook failed:`,r),null}return s}getPlugins(){return[...this.plugins]}};function lg(){let i={};return{getItem:async s=>i[s]||null,setItem:async(s,c)=>{i[s]=c},removeItem:async s=>{delete i[s]}}}function ng(i){if(typeof i=="object"&&i!==null&&typeof i.getItem=="function")return i;if(i==="localStorage"){if(typeof window<"u"&&window.localStorage)return{getItem:async s=>window.localStorage.getItem(s),setItem:async(s,c)=>window.localStorage.setItem(s,c),removeItem:async s=>window.localStorage.removeItem(s)};throw new Error("localStorage no está disponible.")}if(i==="sessionStorage"){if(typeof window<"u"&&window.sessionStorage)return{getItem:async s=>window.sessionStorage.getItem(s),setItem:async(s,c)=>window.sessionStorage.setItem(s,c),removeItem:async s=>window.sessionStorage.removeItem(s)};throw new Error("sessionStorage no está disponible.")}if(i==="memoryStorage")return lg();throw new Error(`Adaptador de almacenamiento no soportado: ${i}`)}function ag(i,s={}){let c=new eg,{debounceTime:r,throttleTime:m,immediately:h,maxRetries:_,retryDelay:b,onWrite:x,onSave:p,serialize:T,deserialize:z,ttl:U,plugins:R=[],...j}=s,D;R.length>0&&(D=new tg,D.register(R));let E=new $v(ng(i),D);T&&z&&(E=new Fv(E,{serialize:T,deserialize:z})),typeof U=="number"&&(E=new Pv(E,{ttl:U})),(_||b)&&(E=new Wv(E,{maxRetries:_,retryDelay:b})),(r||m||h!==void 0)&&(E=new Iv(E,{debounceTime:r,throttleTime:m,immediately:h},c));let M=new kv(E,c);x&&M.on("write",x),p&&M.on("save",p),E=M;let X={getItem:async V=>await E.getItem(V),setItem:async(V,F)=>{await E.setItem(V,F)},removeItem:async V=>{await E.removeItem(V)}},G=fm(()=>X,j);if(G===void 0)throw new Error("createJSONStorage returned undefined");return G}const nm={method:"POST",url:"https://cdn-origin-4732724.fastedge.cdn.gc.onl/",requestHeaders:{},requestBody:'{"message": "Hello"}',responseHeaders:{"content-type":"application/json"},responseBody:'{"response": "OK"}'},ug=i=>({...nm,setMethod:s=>i(c=>{c.method=s}),setUrl:s=>i(c=>{c.url=s}),setRequestHeaders:s=>i(c=>{c.requestHeaders=s}),setRequestBody:s=>i(c=>{c.requestBody=s}),setResponseHeaders:s=>i(c=>{c.responseHeaders=s}),setResponseBody:s=>i(c=>{c.responseBody=s}),updateRequestHeader:(s,c)=>i(r=>{r.requestHeaders[s]=c}),removeRequestHeader:s=>i(c=>{delete c.requestHeaders[s]}),updateResponseHeader:(s,c)=>i(r=>{r.responseHeaders[s]=c}),removeResponseHeader:s=>i(c=>{delete c.responseHeaders[s]}),resetRequest:()=>i(s=>{Object.assign(s,nm)})});function ig(){return typeof window<"u"&&(window.vscodeApi!==void 0||typeof window.acquireVsCodeApi=="function"||window.vscode!==void 0)}function cg(){return!!(typeof window<"u"&&(navigator.userAgent.toLowerCase().includes("electron")||navigator.userAgent.toLowerCase().includes("vscode")||window.process?.type==="renderer"||window.process?.type==="worker"))}function sg(){if(ig()||cg()||typeof window.process<"u")return!0;try{if("path"in new File(["test"],"test.txt"))return!0}catch{}return!1}function Sm(i){return typeof i.path=="string"&&i.path.length>0}function og(i){return i&&Sm(i)?i.path:null}function qi(i){if(i===0)return"0 Bytes";const s=1024,c=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(i)/Math.log(s));return`${(i/Math.pow(s,r)).toFixed(1)} ${c[r]}`}const ml="/api";async function Tm(){const i=await fetch(`${ml}/environment`,{method:"GET",headers:{"Content-Type":"application/json"}});return i.ok?await i.json():(console.warn("Failed to fetch environment info, defaulting to node"),{environment:"node",supportsPathLoading:!0})}async function Em(i,s=!0,c){const r=performance.now(),m=i.size;if(sg()&&Sm(i)){const T=og(i);if(T){console.log(`📁 Using path-based loading (${qi(m)}): ${T}`);try{const z=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmPath:T,dotenv:{enabled:s,...c?{path:c}:{}}})});if(z.ok){const U=performance.now()-r,R=await z.json();return console.log(`✅ Path-based loading succeeded in ${U.toFixed(1)}ms`),{path:i.name,wasmType:R.wasmType,loadingMode:"path",loadTime:U,fileSize:m}}else{const U=await z.json();console.warn("⚠️ Path-based loading failed, falling back to buffer mode:",U.error)}}catch(z){console.warn("⚠️ Path-based loading error, falling back to buffer mode:",z)}}}console.log(`💾 Using buffer-based loading (${qi(m)})...`);const h=await i.arrayBuffer(),_=btoa(new Uint8Array(h).reduce((T,z)=>T+String.fromCharCode(z),"")),b=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmBase64:_,dotenv:{enabled:s,...c?{path:c}:{}}})});if(!b.ok){const T=await b.json();throw new Error(T.error||"Failed to load WASM file")}const x=performance.now()-r,p=await b.json();return console.log(`✅ Buffer-based loading succeeded in ${x.toFixed(1)}ms`),{path:i.name,wasmType:p.wasmType,loadingMode:"buffer",loadTime:x,fileSize:m}}async function xm(i,s=!0,c){const r=performance.now();console.log(`📁 Loading WASM from path: ${i}`);const m=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmPath:i,dotenv:{enabled:s,...c?{path:c}:{}}})});if(!m.ok){const b=await m.json();throw new Error(b.error||"Failed to load WASM from path")}const h=performance.now()-r,_=await m.json();return console.log(`✅ Path-based loading succeeded in ${h.toFixed(1)}ms`),{path:_.resolvedPath||i,wasmType:_.wasmType,loadingMode:"path",loadTime:h,fileSize:0}}async function rg(i,s,c){const r={url:i,request:{headers:c.request_headers||{},body:c.request_body||"",method:s||"GET"},response:{headers:c.response_headers||{},body:c.response_body||""},properties:c.properties||{}},m=await fetch(`${ml}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!m.ok){const b=await m.json();throw new Error(b.error||"Failed to execute full flow")}const h=await m.json(),_={};for(const[b,x]of Object.entries(h.hookResults||{})){const p=x,T=p?.logs||[];_[b]={logs:T,returnValue:p?.returnCode,error:p?.error,input:p?.input,output:p?.output,properties:p?.properties}}return{hookResults:_,finalResponse:h.finalResponse,calculatedProperties:h.calculatedProperties}}async function Am(i){return await(await fetch(`${ml}/config/show-save-dialog`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suggestedName:i})})).json()}async function Ni(i,s){const c=await fetch(`${ml}/config/save-as`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:i,filePath:s})});if(!c.ok){const r=await c.json();throw new Error(r.error||"Failed to save config")}return c.json()}async function zm(i,s="GET",c={},r=""){const m={url:i,method:s,headers:c,body:r},h=await fetch(`${ml}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!h.ok){const b=await h.json();throw new Error(b.error||"Failed to execute HTTP WASM")}return(await h.json()).result}async function fg(i,s){const c=await fetch(`${ml}/dotenv`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({dotenv:{enabled:i,...s?{path:s}:{}}})});if(!c.ok){const r=await c.json();throw new Error(r.error||"Failed to apply dotenv setting")}}const Nm=Object.freeze(Object.defineProperty({__proto__:null,applyDotenv:fg,executeHttpWasm:zm,getEnvironment:Tm,saveConfigAs:Ni,sendFullFlow:rg,showSaveDialog:Am,uploadWasm:Em,uploadWasmFromPath:xm},Symbol.toStringTag,{value:"Module"})),dg={wasmPath:null,wasmBuffer:null,wasmFile:null,wasmType:null,loading:!1,error:null,loadingMode:null,loadTime:null,fileSize:null},hg=(i,s)=>({...dg,loadWasm:async(c,r,m)=>{i(h=>{h.loading=!0,h.error=null,h.hookResults={},h.finalResponse=null,h.isExecuting=!1,h.httpResponse=null,h.httpLogs=[]});try{let h,_=null;const b=(m!==void 0?m:s().dotenv.path)??void 0;typeof c=="string"?h=await xm(c,r,b):(_=c,h=await Em(_,r,b));const{path:x,wasmType:p,loadingMode:T,loadTime:z,fileSize:U}=h;let R=null;_&&T==="buffer"&&(R=await _.arrayBuffer()),i(j=>{j.wasmPath=x,j.wasmBuffer=R,j.wasmFile=_,j.wasmType=p,j.loadingMode=T,j.loadTime=z,j.fileSize=U,j.loading=!1,j.error=null})}catch(h){const _=h instanceof Error?h.message:"Failed to load WASM";i(b=>{b.error=_,b.loading=!1})}},reloadWasm:async(c,r)=>{const{wasmFile:m,wasmPath:h,loadWasm:_}=s();m?await _(m,c,r):h?await _(h,c,r):i(b=>{b.error="No WASM loaded to reload"})},clearWasm:()=>{i(c=>{c.wasmPath=null,c.wasmBuffer=null,c.wasmFile=null,c.wasmType=null,c.loading=!1,c.error=null,c.loadingMode=null,c.loadTime=null,c.fileSize=null})},setWasmLoaded:(c,r,m)=>{i(h=>{h.wasmPath=c,h.wasmType=r,h.fileSize=m,h.loading=!1,h.error=null,h.loadingMode="path",h.hookResults={},h.finalResponse=null,h.isExecuting=!1,h.httpResponse=null,h.httpLogs=[]})},setLoading:c=>{i(r=>{r.loading=c})},setError:c=>{i(r=>{r.error=c})}}),mg={hookResults:{},finalResponse:null,isExecuting:!1},yg=i=>({...mg,setHookResult:(s,c)=>i(r=>{r.hookResults[s]=c}),setHookResults:s=>i(c=>{c.hookResults=s}),setFinalResponse:s=>i(c=>{c.finalResponse=s}),setIsExecuting:s=>i(c=>{c.isExecuting=s}),clearResults:()=>i(s=>{s.hookResults={},s.finalResponse=null,s.isExecuting=!1})}),pg="modulepreload",vg=function(i){return"/"+i},am={},jm=function(s,c,r){let m=Promise.resolve();if(c&&c.length>0){let p=function(T){return Promise.all(T.map(z=>Promise.resolve(z).then(U=>({status:"fulfilled",value:U}),U=>({status:"rejected",reason:U}))))};var _=p;document.getElementsByTagName("link");const b=document.querySelector("meta[property=csp-nonce]"),x=b?.nonce||b?.getAttribute("nonce");m=p(c.map(T=>{if(T=vg(T),T in am)return;am[T]=!0;const z=T.endsWith(".css"),U=z?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${T}"]${U}`))return;const R=document.createElement("link");if(R.rel=z?"stylesheet":pg,z||(R.as="script"),R.crossOrigin="",R.href=T,x&&R.setAttribute("nonce",x),document.head.appendChild(R),z)return new Promise((j,D)=>{R.addEventListener("load",j),R.addEventListener("error",()=>D(new Error(`Unable to preload CSS for ${T}`)))})}))}function h(b){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=b,window.dispatchEvent(x),!x.defaultPrevented)throw b}return m.then(b=>{for(const x of b||[])x.status==="rejected"&&h(x.reason);return s().catch(h)})},um={properties:{},dotenv:{enabled:!1,path:null},logLevel:2},gg=(i,s)=>({...um,setProperties:c=>i(r=>{r.properties=c}),updateProperty:(c,r)=>i(m=>{m.properties[c]=r}),removeProperty:c=>i(r=>{delete r.properties[c]}),mergeProperties:c=>i(r=>{Object.assign(r.properties,c)}),setDotenvEnabled:c=>{i(r=>{r.dotenv.enabled=c,c?r.expandedPanels.dotenv=!0:delete r.expandedPanels.dotenv})},setDotenvPath:async c=>{i(h=>{h.dotenv.path=c});const{wasmPath:r,dotenv:m}=s();if(r!==null&&m.enabled){const{applyDotenv:h}=await jm(async()=>{const{applyDotenv:_}=await Promise.resolve().then(()=>Nm);return{applyDotenv:_}},void 0);await h(m.enabled,c)}},setLogLevel:c=>i(r=>{r.logLevel=c}),loadFromConfig:c=>i(r=>{r.properties={...c.properties},r.logLevel=c.logLevel,r.dotenv={enabled:c.dotenv?.enabled??!1,path:c.dotenv?.path??null},c.appType==="http-wasm"?(r.httpMethod=c.request.method,r.httpUrl=c.request.url,r.httpRequestHeaders={...c.request.headers},r.httpRequestBody=c.request.body):(r.method=c.request.method,r.url=c.request.url,r.requestHeaders={...c.request.headers},r.requestBody=c.request.body,c.response&&(r.responseHeaders={...c.response.headers},r.responseBody=c.response.body))}),exportConfig:()=>{const c=s(),r=c.wasmType==="http-wasm",m={appType:c.wasmType??"proxy-wasm",request:{method:r?c.httpMethod:c.method,url:r?c.httpUrl:c.url,headers:r?{...c.httpRequestHeaders}:{...c.requestHeaders},body:r?c.httpRequestBody:c.requestBody},properties:{...c.properties},logLevel:c.logLevel,dotenv:{enabled:c.dotenv.enabled,...c.dotenv.path?{path:c.dotenv.path}:{}}};return r||(m.response={headers:{...c.responseHeaders},body:c.responseBody}),c.wasmPath&&(m.wasm={path:c.wasmPath,description:"Current loaded WASM binary"}),m},resetConfig:()=>i(c=>{Object.assign(c,um)})}),_g={activeHookTab:"request_headers",activeSubView:"logs",expandedPanels:{},wsStatus:{connected:!1,reconnecting:!1,clientCount:0,error:null}},bg=i=>({..._g,setActiveHookTab:s=>i(c=>{c.activeHookTab=s}),setActiveSubView:s=>i(c=>{c.activeSubView=s}),togglePanel:s=>i(c=>{c.expandedPanels[s]=!c.expandedPanels[s]}),setPanelExpanded:(s,c)=>i(r=>{r.expandedPanels[s]=c}),setWsStatus:s=>i(c=>{c.wsStatus=s})}),Hi="http://test.localhost/",im={httpMethod:"GET",httpUrl:"http://test.localhost/",httpRequestHeaders:{},httpRequestBody:"",httpResponse:null,httpLogs:[],httpIsExecuting:!1,httpRunnerPort:null},Sg=(i,s)=>({...im,setHttpMethod:c=>{i(r=>{r.httpMethod=c})},setHttpUrl:c=>{c.startsWith(Hi)||(c=Hi),i(r=>{r.httpUrl=c})},setHttpRequestHeaders:c=>{i(r=>{r.httpRequestHeaders=c})},setHttpRequestBody:c=>{i(r=>{r.httpRequestBody=c})},setHttpResponse:c=>{i(r=>{r.httpResponse=c})},setHttpLogs:c=>{i(r=>{r.httpLogs=c})},appendHttpLogs:c=>{i(r=>{r.httpLogs.push(...c)})},setHttpRunnerPort:c=>{i(r=>{r.httpRunnerPort=c})},setHttpIsExecuting:c=>{i(r=>{r.httpIsExecuting=c})},executeHttpRequest:async()=>{const c=s();i(r=>{r.httpIsExecuting=!0,r.httpLogs=[]});try{const r=await zm(c.httpUrl,c.httpMethod,c.httpRequestHeaders,c.httpRequestBody);i(m=>{m.httpResponse={status:r.status,statusText:r.statusText,headers:r.headers,body:r.body,contentType:r.contentType,isBase64:r.isBase64},m.httpLogs=r.logs,m.httpIsExecuting=!1})}catch(r){const m=r instanceof Error?r.message:"Failed to execute HTTP WASM";i(h=>{h.httpResponse={status:0,statusText:"Error",headers:{},body:m,contentType:"text/plain"},h.httpLogs=[{level:4,message:`Error: ${m}`}],h.httpIsExecuting=!1})}},clearHttpResponse:()=>{i(c=>{c.httpResponse=null,c.httpLogs=[]})},resetHttpWasm:()=>{i(c=>{Object.assign(c,im)})}}),Tg=ag(localStorage,{debounceTime:500}),nu=bv()(Av(Zv(Nv((...i)=>({...ug(...i),...hg(...i),...yg(...i),...gg(...i),...bg(...i),...Sg(...i)}),{name:"proxy-runner-config",storage:Tg,partialize:i=>({request:{method:i.method,url:i.url,requestHeaders:i.requestHeaders,requestBody:i.requestBody,responseHeaders:i.responseHeaders,responseBody:i.responseBody},config:{properties:i.properties,dotenv:i.dotenv,logLevel:i.logLevel},ui:{expandedPanels:i.expandedPanels}}),version:1})),{name:"ProxyRunnerStore",enabled:!1}));function Eg(i={}){const s=(()=>{const P=window.location.protocol==="https:"?"wss:":"ws:",Q=window.location.hostname==="localhost"?"127.0.0.1":window.location.hostname,te=window.location.port?`:${window.location.port}`:"";return`${P}//${Q}${te}/ws`})(),{url:c=s,autoConnect:r=!0,reconnectInterval:m=200,maxReconnectAttempts:h=15,onEvent:_,debug:b=!1}=i,[x,p]=W.useState({connected:!1,reconnecting:!1,clientCount:0,error:null}),[T,z]=W.useState(null),U=W.useRef(null),R=W.useRef(0),j=W.useRef(null),D=W.useRef(!1),E=W.useCallback((P,...Q)=>{b&&console.log(`[useWebSocket] ${P}`,...Q)},[b]),M=W.useCallback(P=>{try{const Q=JSON.parse(P.data);E(`Received event: ${Q.type} from ${Q.source}`),z(Q),Q.type==="connection_status"&&p(te=>({...te,clientCount:Q.data.clientCount})),_&&_(Q)}catch(Q){console.error("[useWebSocket] Failed to parse message:",Q)}},[_,E]),X=W.useCallback(()=>{if(D.current){E("Skipping reconnect - intentional disconnect");return}if(R.current>=h){E(`Max reconnect attempts (${h}) reached`),p(Q=>({...Q,connected:!1,reconnecting:!1,error:"Failed to reconnect after multiple attempts"}));return}R.current++,E(`Reconnect attempt ${R.current}/${h}`),p(Q=>({...Q,reconnecting:!0,error:`Reconnecting... (attempt ${R.current})`}));const P=Math.min(m*Math.pow(1.5,R.current-1),3e3);j.current=setTimeout(()=>{G()},P)},[m,h,E]),G=W.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),U.current&&(U.current.close(),U.current=null);try{const P=performance.now();E(`Connecting to ${c}`);const Q=new WebSocket(c);Q.onopen=()=>{const te=performance.now()-P;E(`Connected (took ${te.toFixed(0)}ms)`),R.current=0,D.current=!1,p({connected:!0,reconnecting:!1,clientCount:0,error:null})},Q.onmessage=M,Q.onerror=te=>{console.error("[useWebSocket] WebSocket error:",te),p(Ce=>({...Ce,error:"WebSocket error occurred"}))},Q.onclose=te=>{E(`Disconnected (code: ${te.code}, reason: ${te.reason})`),p(Ce=>({...Ce,connected:!1,error:te.reason||"Connection closed"})),U.current=null,D.current||X()},U.current=Q}catch(P){console.error("[useWebSocket] Failed to create WebSocket:",P),p(Q=>({...Q,connected:!1,error:P instanceof Error?P.message:"Failed to connect"})),X()}},[c,M,X,E]),V=W.useCallback(()=>{E("Intentional disconnect"),D.current=!0,j.current&&(clearTimeout(j.current),j.current=null),U.current&&(U.current.close(1e3,"Client disconnect"),U.current=null),p({connected:!1,reconnecting:!1,clientCount:0,error:null})},[E]),F=W.useCallback(P=>{if(!U.current||U.current.readyState!==WebSocket.OPEN){console.warn("[useWebSocket] Cannot send - not connected");return}try{const Q=typeof P=="string"?P:JSON.stringify(P);U.current.send(Q),E("Sent message:",P)}catch(Q){console.error("[useWebSocket] Failed to send message:",Q)}},[E]);return W.useEffect(()=>(r&&G(),()=>{D.current=!0,j.current&&clearTimeout(j.current),U.current&&U.current.close()}),[r]),{status:x,lastEvent:T,connect:G,disconnect:V,send:F}}const xg="_wasmLoader_3gv9a_1",Ag="_header_3gv9a_7",zg="_loadingIndicator_3gv9a_41",Ng="_pathInputGroup_3gv9a_46",jg="_pathInput_3gv9a_46",Og="_pathButton_3gv9a_78",Rg="_tabs_3gv9a_101",Cg="_tabButtons_3gv9a_110",Mg="_tab_3gv9a_101",Dg="_tabActive_3gv9a_138",qg="_tabIcon_3gv9a_154",Hg="_tabContent_3gv9a_158",wg="_pathPanel_3gv9a_162",Ug="_uploadPanel_3gv9a_163",Bg="_panelDescription_3gv9a_170",Lg="_fileInputWrapper_3gv9a_178",Yg="_chooseFileButton_3gv9a_189",Gg="_hiddenFileInput_3gv9a_212",Vg="_noFileChosen_3gv9a_217",Xg="_selectedFile_3gv9a_224",Qg="_selectedFileIcon_3gv9a_231",Zg="_selectedFileName_3gv9a_237",Jg="_selectedFileSize_3gv9a_243",Kg="_tabInfo_3gv9a_249",$g="_tabInfoIcon_3gv9a_260",kg="_tabInfoText_3gv9a_264",Wg="_tabInfoTime_3gv9a_269",Fg="_tabInfoSize_3gv9a_273",ve={wasmLoader:xg,header:Ag,loadingIndicator:zg,pathInputGroup:Ng,pathInput:jg,pathButton:Og,tabs:Rg,tabButtons:Cg,tab:Mg,tabActive:Dg,tabIcon:qg,tabContent:Hg,pathPanel:wg,uploadPanel:Ug,panelDescription:Bg,fileInputWrapper:Lg,chooseFileButton:Yg,hiddenFileInput:Gg,noFileChosen:Vg,selectedFile:Xg,selectedFileIcon:Qg,selectedFileName:Zg,selectedFileSize:Jg,tabInfo:Kg,tabInfoIcon:$g,tabInfoText:kg,tabInfoTime:Wg,tabInfoSize:Fg};function Ig({onFileLoad:i,onPathLoad:s,loading:c,loadingMode:r,loadTime:m,fileSize:h,fileName:_,defaultTab:b="upload",wasmPath:x}){const[p,T]=W.useState(""),[z,U]=W.useState(b),R=W.useRef(null);W.useEffect(()=>{U(b)},[b]),W.useEffect(()=>{r==="buffer"?U("upload"):r==="path"&&U("path")},[r]),W.useEffect(()=>{r==="path"&&x&&x!==p?T(x):r==="buffer"&&T("")},[x,r]);const j=V=>{const F=V.target.files?.[0];F&&i(F)},D=()=>{p.trim()&&s&&s(p.trim())},E=V=>{V.key==="Enter"&&p.trim()&&s&&D()},M=()=>r?r==="path"?"📁":"💾":null,X=()=>r?r==="path"?"Path-based":"Buffer-based":null,G=()=>r?r==="path"?"Optimized path-based loading (70-95% faster)":"Standard buffer-based loading":"";return d.jsxs("section",{className:ve.wasmLoader,children:[d.jsx("div",{className:ve.header,children:d.jsx("h2",{children:"Load WASM Binary"})}),s&&d.jsxs("div",{className:ve.tabs,children:[d.jsxs("div",{className:ve.tabButtons,children:[d.jsxs("button",{className:`${ve.tab} ${z==="path"?ve.tabActive:""}`,onClick:()=>U("path"),disabled:c,children:[d.jsx("span",{className:ve.tabIcon,children:"📁"}),d.jsx("span",{children:"File Path"})]}),d.jsxs("button",{className:`${ve.tab} ${z==="upload"?ve.tabActive:""}`,onClick:()=>U("upload"),disabled:c,children:[d.jsx("span",{className:ve.tabIcon,children:"📤"}),d.jsx("span",{children:"Upload File"})]})]}),!c&&_&&r&&d.jsxs("div",{className:ve.tabInfo,title:G(),children:[d.jsx("span",{className:ve.tabInfoIcon,children:M()}),d.jsx("span",{className:ve.tabInfoText,children:X()}),m!=null&&d.jsxs("span",{className:ve.tabInfoTime,children:["• ",m.toFixed(1),"ms"]}),h&&d.jsxs("span",{className:ve.tabInfoSize,children:["• (",qi(h),")"]})]})]}),d.jsxs("div",{className:ve.tabContent,children:[s&&z==="path"&&d.jsxs("div",{className:ve.pathPanel,children:[d.jsx("div",{className:ve.panelDescription,children:"Load WASM directly from filesystem path (faster, no upload needed)"}),d.jsxs("div",{className:ve.pathInputGroup,children:[d.jsx("input",{type:"text",className:ve.pathInput,placeholder:"<workspace>/.fastedge/bin/debugger.wasm",value:p,onChange:V=>T(V.target.value),onKeyDown:E,disabled:c}),d.jsx("button",{onClick:D,disabled:c||!p.trim(),className:ve.pathButton,children:"Load from Path"})]})]}),z==="upload"&&d.jsxs("div",{className:ve.uploadPanel,children:[d.jsx("div",{className:ve.panelDescription,children:"Upload a WASM binary file from your computer"}),d.jsxs("div",{className:ve.fileInputWrapper,children:[d.jsx("button",{onClick:()=>R.current?.click(),disabled:c,className:ve.chooseFileButton,children:"Choose File"}),d.jsx("input",{ref:R,type:"file",accept:".wasm",onChange:j,disabled:c,className:ve.hiddenFileInput}),!c&&r==="buffer"&&_?d.jsxs("div",{className:ve.selectedFile,children:[d.jsx("span",{className:ve.selectedFileIcon,children:"✓"}),d.jsx("span",{className:ve.selectedFileName,children:_}),h&&d.jsxs("span",{className:ve.selectedFileSize,children:["(",qi(h),")"]})]}):d.jsx("span",{className:ve.noFileChosen,children:"No file chosen"})]})]})]}),c&&d.jsx("span",{className:ve.loadingIndicator,children:" Loading..."})]})}const Pg="_container_1g2xx_1",e0="_indicator_1g2xx_9",t0="_indicatorConnected_1g2xx_16",l0="_indicatorReconnecting_1g2xx_20",n0="_indicatorError_1g2xx_24",a0="_indicatorDisconnected_1g2xx_28",u0="_text_1g2xx_32",on={container:Pg,indicator:e0,indicatorConnected:t0,indicatorReconnecting:l0,indicatorError:n0,indicatorDisconnected:a0,text:u0};function i0({status:i}){const s=()=>i.connected?on.indicatorConnected:i.reconnecting?on.indicatorReconnecting:i.error?on.indicatorError:on.indicatorDisconnected,c=()=>i.connected?i.clientCount>1?`Connected (${i.clientCount} clients)`:"Connected":i.reconnecting?"Reconnecting...":i.error?"Disconnected":"Not connected";return d.jsxs("div",{className:on.container,children:[d.jsx("div",{className:`${on.indicator} ${s()}`,title:i.error||c()}),d.jsx("span",{className:on.text,children:c()})]})}const c0="_container_qhpt2_1",s0="_spinner_qhpt2_11",o0="_message_qhpt2_26",vo={container:c0,spinner:s0,message:o0};function r0({message:i="Loading..."}){return d.jsxs("div",{className:vo.container,children:[d.jsx("div",{className:vo.spinner}),d.jsx("p",{className:vo.message,children:i})]})}const f0="_container_iyt3w_1",d0="_editor_iyt3w_7",cm={container:f0,editor:d0};function h0({config:i}){const s=JSON.stringify(i,null,2);return d.jsx("div",{className:cm.container,children:d.jsx("textarea",{className:cm.editor,value:s,readOnly:!0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})})}const m0="_backdrop_8umbd_1",y0="_modal_8umbd_15",p0="_header_8umbd_27",v0="_closeButton_8umbd_41",g0="_content_8umbd_57",_0="_footer_8umbd_64",In={backdrop:m0,modal:y0,header:p0,closeButton:v0,content:g0,footer:_0};function b0({initialConfig:i,onClose:s}){const[c,r]=W.useState(!1);W.useEffect(()=>{const _=b=>{b.key==="Escape"&&s()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[s]);const m=async()=>{try{r(!0);const _="fastedge-config.test.json";if(window!==window.top){const T=await new Promise(U=>{const R=j=>{j.source===window.parent&&j.data?.command==="savePickerResult"&&(window.removeEventListener("message",R),U(j.data.canceled?null:j.data.filePath))};window.addEventListener("message",R),window.parent.postMessage({command:"openSavePicker",suggestedName:_},"*")});if(!T){r(!1);return}const z=await Ni(i,T);alert(`✅ Config saved to: ${z.savedPath}`),s();return}if("showSaveFilePicker"in window)try{const T=await window.showSaveFilePicker({suggestedName:_,types:[{description:"JSON Config File",accept:{"application/json":[".json"]}}]}),z=await T.createWritable();await z.write(JSON.stringify(i,null,2)),await z.close(),alert(`✅ Config saved to: ${T.name}`),s();return}catch(T){if(T.name==="AbortError"){r(!1);return}}try{const T=await Am(_);if(T.canceled){r(!1);return}if(T.filePath){const z=await Ni(i,T.filePath);alert(`✅ Config saved to: ${z.savedPath}`),s();return}}catch{}const x=prompt(`Enter the file path to save (relative to project root or absolute):
|
|
14
|
+
`);const X=M.state[b];if(X==null)return;JSON.stringify(m.getState())!==JSON.stringify(X)&&R(X);return}Kh(m)&&m.dispatch(M)});case"DISPATCH":switch(D.payload.type){case"RESET":return R(j),b===void 0?T?.init(m.getState()):T?.init(Ei(x.name));case"COMMIT":if(b===void 0){T?.init(m.getState());return}return T?.init(Ei(x.name));case"ROLLBACK":return mo(D.state,M=>{if(b===void 0){R(M),T?.init(m.getState());return}R(M[b]),T?.init(Ei(x.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return mo(D.state,M=>{if(b===void 0){R(M);return}JSON.stringify(m.getState())!==JSON.stringify(M[b])&&R(M[b])});case"IMPORT_STATE":{const{nextLiftedState:M}=D.payload,X=(E=M.computedStates.slice(-1)[0])==null?void 0:E.state;if(!X)return;R(b===void 0?X:X[b]),T?.send(null,M);return}case"PAUSE_RECORDING":return U=!U}return}}),j},Av=xv,mo=(i,s)=>{let c;try{c=JSON.parse(i)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}c!==void 0&&s(c)};function fm(i,s){let c;try{c=i()}catch{return}return{getItem:m=>{var h;const _=x=>x===null?null:JSON.parse(x,s?.reviver),b=(h=c.getItem(m))!=null?h:null;return b instanceof Promise?b.then(_):_(b)},setItem:(m,h)=>c.setItem(m,JSON.stringify(h,s?.replacer)),removeItem:m=>c.removeItem(m)}}const bo=i=>s=>{try{const c=i(s);return c instanceof Promise?c:{then(r){return bo(r)(c)},catch(r){return this}}}catch(c){return{then(r){return this},catch(r){return bo(r)(c)}}}},zv=(i,s)=>(c,r,m)=>{let h={storage:fm(()=>window.localStorage),partialize:E=>E,version:0,merge:(E,M)=>({...M,...E}),...s},_=!1,b=0;const x=new Set,p=new Set;let T=h.storage;if(!T)return i((...E)=>{console.warn(`[zustand persist middleware] Unable to update item '${h.name}', the given storage is currently unavailable.`),c(...E)},r,m);const z=()=>{const E=h.partialize({...r()});return T.setItem(h.name,{state:E,version:h.version})},U=m.setState;m.setState=(E,M)=>(U(E,M),z());const R=i((...E)=>(c(...E),z()),r,m);m.getInitialState=()=>R;let j;const D=()=>{var E,M;if(!T)return;const X=++b;_=!1,x.forEach(V=>{var F;return V((F=r())!=null?F:R)});const G=((M=h.onRehydrateStorage)==null?void 0:M.call(h,(E=r())!=null?E:R))||void 0;return bo(T.getItem.bind(T))(h.name).then(V=>{if(V)if(typeof V.version=="number"&&V.version!==h.version){if(h.migrate){const F=h.migrate(V.state,V.version);return F instanceof Promise?F.then(P=>[!0,P]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,V.state];return[!1,void 0]}).then(V=>{var F;if(X!==b)return;const[P,Q]=V;if(j=h.merge(Q,(F=r())!=null?F:R),c(j,!0),P)return z()}).then(()=>{X===b&&(G?.(j,void 0),j=r(),_=!0,p.forEach(V=>V(j)))}).catch(V=>{X===b&&G?.(void 0,V)})};return m.persist={setOptions:E=>{h={...h,...E},E.storage&&(T=E.storage)},clearStorage:()=>{T?.removeItem(h.name)},getOptions:()=>h,rehydrate:()=>D(),hasHydrated:()=>_,onHydrate:E=>(x.add(E),()=>{x.delete(E)}),onFinishHydration:E=>(p.add(E),()=>{p.delete(E)})},h.skipHydration||D(),j||R},Nv=zv;var dm=Symbol.for("immer-nothing"),$h=Symbol.for("immer-draftable"),nt=Symbol.for("immer-state");function Lt(i,...s){throw new Error(`[Immer] minified error nr: ${i}. Full error at: https://bit.ly/3cXEKWf`)}var Et=Object,ea=Et.getPrototypeOf,ji="constructor",wi="prototype",So="configurable",Oi="enumerable",Ai="writable",Ia="value",Vl=i=>!!i&&!!i[nt];function hl(i){return i?hm(i)||Bi(i)||!!i[$h]||!!i[ji]?.[$h]||Li(i)||Yi(i):!1}var jv=Et[wi][ji].toString(),kh=new WeakMap;function hm(i){if(!i||!Ro(i))return!1;const s=ea(i);if(s===null||s===Et[wi])return!0;const c=Et.hasOwnProperty.call(s,ji)&&s[ji];if(c===Object)return!0;if(!Pn(c))return!1;let r=kh.get(c);return r===void 0&&(r=Function.toString.call(c),kh.set(c,r)),r===jv}function Ui(i,s,c=!0){tu(i)===0?(c?Reflect.ownKeys(i):Et.keys(i)).forEach(m=>{s(m,i[m],i)}):i.forEach((r,m)=>s(m,r,i))}function tu(i){const s=i[nt];return s?s.type_:Bi(i)?1:Li(i)?2:Yi(i)?3:0}var Wh=(i,s,c=tu(i))=>c===2?i.has(s):Et[wi].hasOwnProperty.call(i,s),To=(i,s,c=tu(i))=>c===2?i.get(s):i[s],Ri=(i,s,c,r=tu(i))=>{r===2?i.set(s,c):r===3?i.add(c):i[s]=c};function Ov(i,s){return i===s?i!==0||1/i===1/s:i!==i&&s!==s}var Bi=Array.isArray,Li=i=>i instanceof Map,Yi=i=>i instanceof Set,Ro=i=>typeof i=="object",Pn=i=>typeof i=="function",yo=i=>typeof i=="boolean";function Rv(i){const s=+i;return Number.isInteger(s)&&String(s)===i}var dl=i=>i.copy_||i.base_,Co=i=>i.modified_?i.copy_:i.base_;function Eo(i,s){if(Li(i))return new Map(i);if(Yi(i))return new Set(i);if(Bi(i))return Array[wi].slice.call(i);const c=hm(i);if(s===!0||s==="class_only"&&!c){const r=Et.getOwnPropertyDescriptors(i);delete r[nt];let m=Reflect.ownKeys(r);for(let h=0;h<m.length;h++){const _=m[h],b=r[_];b[Ai]===!1&&(b[Ai]=!0,b[So]=!0),(b.get||b.set)&&(r[_]={[So]:!0,[Ai]:!0,[Oi]:b[Oi],[Ia]:i[_]})}return Et.create(ea(i),r)}else{const r=ea(i);if(r!==null&&c)return{...i};const m=Et.create(r);return Et.assign(m,i)}}function Mo(i,s=!1){return Gi(i)||Vl(i)||!hl(i)||(tu(i)>1&&Et.defineProperties(i,{set:xi,add:xi,clear:xi,delete:xi}),Et.freeze(i),s&&Ui(i,(c,r)=>{Mo(r,!0)},!1)),i}function Cv(){Lt(2)}var xi={[Ia]:Cv};function Gi(i){return i===null||!Ro(i)?!0:Et.isFrozen(i)}var Ci="MapSet",xo="Patches",Fh="ArrayMethods",mm={};function hn(i){const s=mm[i];return s||Lt(0,i),s}var Ih=i=>!!mm[i],Pa,ym=()=>Pa,Mv=(i,s)=>({drafts_:[],parent_:i,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ih(Ci)?hn(Ci):void 0,arrayMethodsPlugin_:Ih(Fh)?hn(Fh):void 0});function Ph(i,s){s&&(i.patchPlugin_=hn(xo),i.patches_=[],i.inversePatches_=[],i.patchListener_=s)}function Ao(i){zo(i),i.drafts_.forEach(Dv),i.drafts_=null}function zo(i){i===Pa&&(Pa=i.parent_)}var em=i=>Pa=Mv(Pa,i);function Dv(i){const s=i[nt];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function tm(i,s){s.unfinalizedDrafts_=s.drafts_.length;const c=s.drafts_[0];if(i!==void 0&&i!==c){c[nt].modified_&&(Ao(s),Lt(4)),hl(i)&&(i=lm(s,i));const{patchPlugin_:m}=s;m&&m.generateReplacementPatches_(c[nt].base_,i,s)}else i=lm(s,c);return qv(s,i,!0),Ao(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),i!==dm?i:void 0}function lm(i,s){if(Gi(s))return s;const c=s[nt];if(!c)return Mi(s,i.handledSet_,i);if(!Vi(c,i))return s;if(!c.modified_)return c.base_;if(!c.finalized_){const{callbacks_:r}=c;if(r)for(;r.length>0;)r.pop()(i);gm(c,i)}return c.copy_}function qv(i,s,c=!1){!i.parent_&&i.immer_.autoFreeze_&&i.canAutoFreeze_&&Mo(s,c)}function pm(i){i.finalized_=!0,i.scope_.unfinalizedDrafts_--}var Vi=(i,s)=>i.scope_===s,Hv=[];function vm(i,s,c,r){const m=dl(i),h=i.type_;if(r!==void 0&&To(m,r,h)===s){Ri(m,r,c,h);return}if(!i.draftLocations_){const b=i.draftLocations_=new Map;Ui(m,(x,p)=>{if(Vl(p)){const T=b.get(p)||[];T.push(x),b.set(p,T)}})}const _=i.draftLocations_.get(s)??Hv;for(const b of _)Ri(m,b,c,h)}function wv(i,s,c){i.callbacks_.push(function(m){const h=s;if(!h||!Vi(h,m))return;m.mapSetPlugin_?.fixSetContents(h);const _=Co(h);vm(i,h.draft_??h,_,c),gm(h,m)})}function gm(i,s){if(i.modified_&&!i.finalized_&&(i.type_===3||i.type_===1&&i.allIndicesReassigned_||(i.assigned_?.size??0)>0)){const{patchPlugin_:r}=s;if(r){const m=r.getPath(i);m&&r.generatePatches_(i,m,s)}pm(i)}}function Uv(i,s,c){const{scope_:r}=i;if(Vl(c)){const m=c[nt];Vi(m,r)&&m.callbacks_.push(function(){zi(i);const _=Co(m);vm(i,c,_,s)})}else hl(c)&&i.callbacks_.push(function(){const h=dl(i);i.type_===3?h.has(c)&&Mi(c,r.handledSet_,r):To(h,s,i.type_)===c&&r.drafts_.length>1&&(i.assigned_.get(s)??!1)===!0&&i.copy_&&Mi(To(i.copy_,s,i.type_),r.handledSet_,r)})}function Mi(i,s,c){return!c.immer_.autoFreeze_&&c.unfinalizedDrafts_<1||Vl(i)||s.has(i)||!hl(i)||Gi(i)||(s.add(i),Ui(i,(r,m)=>{if(Vl(m)){const h=m[nt];if(Vi(h,c)){const _=Co(h);Ri(i,r,_,i.type_),pm(h)}}else hl(m)&&Mi(m,s,c)})),i}function Bv(i,s){const c=Bi(i),r={type_:c?1:0,scope_:s?s.scope_:ym(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:i,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let m=r,h=Di;c&&(m=[r],h=eu);const{revoke:_,proxy:b}=Proxy.revocable(m,h);return r.draft_=b,r.revoke_=_,[b,r]}var Di={get(i,s){if(s===nt)return i;let c=i.scope_.arrayMethodsPlugin_;const r=i.type_===1&&typeof s=="string";if(r&&c?.isArrayOperationMethod(s))return c.createMethodInterceptor(i,s);const m=dl(i);if(!Wh(m,s,i.type_))return Lv(i,m,s);const h=m[s];if(i.finalized_||!hl(h)||r&&i.operationMethod&&c?.isMutatingArrayMethod(i.operationMethod)&&Rv(s))return h;if(h===po(i.base_,s)){zi(i);const _=i.type_===1?+s:s,b=jo(i.scope_,h,i,_);return i.copy_[_]=b}return h},has(i,s){return s in dl(i)},ownKeys(i){return Reflect.ownKeys(dl(i))},set(i,s,c){const r=_m(dl(i),s);if(r?.set)return r.set.call(i.draft_,c),!0;if(!i.modified_){const m=po(dl(i),s),h=m?.[nt];if(h&&h.base_===c)return i.copy_[s]=c,i.assigned_.set(s,!1),!0;if(Ov(c,m)&&(c!==void 0||Wh(i.base_,s,i.type_)))return!0;zi(i),No(i)}return i.copy_[s]===c&&(c!==void 0||s in i.copy_)||Number.isNaN(c)&&Number.isNaN(i.copy_[s])||(i.copy_[s]=c,i.assigned_.set(s,!0),Uv(i,s,c)),!0},deleteProperty(i,s){return zi(i),po(i.base_,s)!==void 0||s in i.base_?(i.assigned_.set(s,!1),No(i)):i.assigned_.delete(s),i.copy_&&delete i.copy_[s],!0},getOwnPropertyDescriptor(i,s){const c=dl(i),r=Reflect.getOwnPropertyDescriptor(c,s);return r&&{[Ai]:!0,[So]:i.type_!==1||s!=="length",[Oi]:r[Oi],[Ia]:c[s]}},defineProperty(){Lt(11)},getPrototypeOf(i){return ea(i.base_)},setPrototypeOf(){Lt(12)}},eu={};for(let i in Di){let s=Di[i];eu[i]=function(){const c=arguments;return c[0]=c[0][0],s.apply(this,c)}}eu.deleteProperty=function(i,s){return eu.set.call(this,i,s,void 0)};eu.set=function(i,s,c){return Di.set.call(this,i[0],s,c,i[0])};function po(i,s){const c=i[nt];return(c?dl(c):i)[s]}function Lv(i,s,c){const r=_m(s,c);return r?Ia in r?r[Ia]:r.get?.call(i.draft_):void 0}function _m(i,s){if(!(s in i))return;let c=ea(i);for(;c;){const r=Object.getOwnPropertyDescriptor(c,s);if(r)return r;c=ea(c)}}function No(i){i.modified_||(i.modified_=!0,i.parent_&&No(i.parent_))}function zi(i){i.copy_||(i.assigned_=new Map,i.copy_=Eo(i.base_,i.scope_.immer_.useStrictShallowCopy_))}var Yv=class{constructor(i){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,c,r)=>{if(Pn(s)&&!Pn(c)){const h=c;c=s;const _=this;return function(x=h,...p){return _.produce(x,T=>c.call(this,T,...p))}}Pn(c)||Lt(6),r!==void 0&&!Pn(r)&&Lt(7);let m;if(hl(s)){const h=em(this),_=jo(h,s,void 0);let b=!0;try{m=c(_),b=!1}finally{b?Ao(h):zo(h)}return Ph(h,r),tm(m,h)}else if(!s||!Ro(s)){if(m=c(s),m===void 0&&(m=s),m===dm&&(m=void 0),this.autoFreeze_&&Mo(m,!0),r){const h=[],_=[];hn(xo).generateReplacementPatches_(s,m,{patches_:h,inversePatches_:_}),r(h,_)}return m}else Lt(1,s)},this.produceWithPatches=(s,c)=>{if(Pn(s))return(_,...b)=>this.produceWithPatches(_,x=>s(x,...b));let r,m;return[this.produce(s,c,(_,b)=>{r=_,m=b}),r,m]},yo(i?.autoFreeze)&&this.setAutoFreeze(i.autoFreeze),yo(i?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(i.useStrictShallowCopy),yo(i?.useStrictIteration)&&this.setUseStrictIteration(i.useStrictIteration)}createDraft(i){hl(i)||Lt(8),Vl(i)&&(i=Gv(i));const s=em(this),c=jo(s,i,void 0);return c[nt].isManual_=!0,zo(s),c}finishDraft(i,s){const c=i&&i[nt];(!c||!c.isManual_)&&Lt(9);const{scope_:r}=c;return Ph(r,s),tm(void 0,r)}setAutoFreeze(i){this.autoFreeze_=i}setUseStrictShallowCopy(i){this.useStrictShallowCopy_=i}setUseStrictIteration(i){this.useStrictIteration_=i}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(i,s){let c;for(c=s.length-1;c>=0;c--){const m=s[c];if(m.path.length===0&&m.op==="replace"){i=m.value;break}}c>-1&&(s=s.slice(c+1));const r=hn(xo).applyPatches_;return Vl(i)?r(i,s):this.produce(i,m=>r(m,s))}};function jo(i,s,c,r){const[m,h]=Li(s)?hn(Ci).proxyMap_(s,c):Yi(s)?hn(Ci).proxySet_(s,c):Bv(s,c);return(c?.scope_??ym()).drafts_.push(m),h.callbacks_=c?.callbacks_??[],h.key_=r,c&&r!==void 0?wv(c,h,r):h.callbacks_.push(function(x){x.mapSetPlugin_?.fixSetContents(h);const{patchPlugin_:p}=x;h.modified_&&p&&p.generatePatches_(h,[],x)}),m}function Gv(i){return Vl(i)||Lt(10,i),bm(i)}function bm(i){if(!hl(i)||Gi(i))return i;const s=i[nt];let c,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,c=Eo(i,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else c=Eo(i,!0);return Ui(c,(m,h)=>{Ri(c,m,bm(h))},r),s&&(s.finalized_=!1),c}var Vv=new Yv,Xv=Vv.produce;const Qv=i=>(s,c,r)=>(r.setState=(m,h,..._)=>{const b=typeof m=="function"?Xv(m):m;return s(b,h,..._)},i(r.setState,c,r)),Zv=Qv;var Jv=Object.defineProperty,Kv=(i,s,c)=>s in i?Jv(i,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):i[s]=c,dn=(i,s,c)=>Kv(i,typeof s!="symbol"?s+"":s,c),$v=class{constructor(i,s){this.storageApi=i,this.pluginManager=s}async getItem(i){let s=await this.storageApi.getItem(i);return this.pluginManager?this.pluginManager.applyAfterGetItem(s):s}async setItem(i,s){if(!this.pluginManager)return this.storageApi.setItem(i,s);let c=this.pluginManager.applyBeforeSetItem(s);return this.storageApi.setItem(i,c)}async removeItem(i){return this.storageApi.removeItem(i)}},lu=class{constructor(i){this.wrappedStorage=i}async getItem(i){return this.wrappedStorage.getItem(i)}async setItem(i,s){await this.wrappedStorage.setItem(i,s)}async removeItem(i){await this.wrappedStorage.removeItem(i)}async flush(){this.wrappedStorage.flush&&await this.wrappedStorage.flush()}},kv=class extends lu{constructor(i,s){super(i),dn(this,"eventEmitter"),this.eventEmitter=s}on(i,s){this.eventEmitter.on(i,s)}async setItem(i,s){this.eventEmitter.emit("write",i,s),await this.wrappedStorage.setItem(i,s)}async getItem(i){let s=await this.wrappedStorage.getItem(i);return this.eventEmitter.emit("get",i,s),s}async removeItem(i){await this.wrappedStorage.removeItem(i),this.eventEmitter.emit("remove",i)}},Wv=class extends lu{constructor(i,s={},c){super(i),this.options=s,this.eventEmitter=c}async setItem(i,s){let{maxRetries:c=3,retryDelay:r=1e3,backoffMultiplier:m=1}=this.options,h=0;for(;h<c;)try{await this.wrappedStorage.setItem(i,s);return}catch(_){if(h++,h>=c)throw this.eventEmitter&&this.eventEmitter.emit("error",i,_),_;let b=r*m**(h-1);this.eventEmitter&&this.eventEmitter.emit("retry",i,h,_,b),await new Promise(x=>setTimeout(x,b))}}},Fv=class extends lu{constructor(i,s){super(i),this.options=s}async setItem(i,s){let c=this.options.serialize(s);await this.wrappedStorage.setItem(i,c)}async getItem(i){let s=await this.wrappedStorage.getItem(i);return s?this.options.deserialize(s):null}},Iv=class extends lu{constructor(i,s,c){super(i),this.options=s,dn(this,"timeoutId"),dn(this,"pendingValue",null),dn(this,"lastExecutionTime",0),dn(this,"eventEmitter"),this.eventEmitter=c}async setItem(i,s){let{debounceTime:c=0,throttleTime:r=0,immediately:m=!1}=this.options;if(m){await this.wrappedStorage.setItem(i,s),this.eventEmitter.emit("save",i,s);return}let h=Date.now();r&&h-this.lastExecutionTime<r||(this.pendingValue={key:i,value:s},this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{if(this.pendingValue!==null){let{key:_,value:b}=this.pendingValue;this.wrappedStorage.setItem(_,b).then(()=>{this.lastExecutionTime=Date.now(),this.eventEmitter.emit("save",_,b),this.pendingValue=null})}},c))}async flush(){if(this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.pendingValue!==null){let{key:i,value:s}=this.pendingValue;await this.wrappedStorage.setItem(i,s),this.eventEmitter.emit("save",i,s),this.eventEmitter.emit("flush",i,s),this.pendingValue=null}await this.wrappedStorage.flush?.()}},Pv=class extends lu{constructor(i,s){super(i),this.options=s}async setItem(i,s){let c=Date.now()+this.options.ttl,r=JSON.stringify({value:s,expiresAt:c});await this.wrappedStorage.setItem(i,r)}async getItem(i){let s=await this.wrappedStorage.getItem(i);if(!s)return null;try{let{value:c,expiresAt:r}=JSON.parse(s);return Date.now()>r?(await this.removeItem(i),null):c}catch{return null}}},eg=class{constructor(){dn(this,"events",{})}on(i,s){this.events[i]||(this.events[i]=[]),this.events[i].push(s)}emit(i,...s){if(this.events[i])for(let c of this.events[i])c(...s)}},tg=class{constructor(){dn(this,"plugins",[])}register(i){for(let s of i){if(!s.name||typeof s.name!="string")throw new Error("Plugin must have a valid name property");this.plugins.push(s)}}applyBeforeSetItem(i){let s=i;for(let c of this.plugins)if(c.beforeSetItem)try{let r=c.beforeSetItem(s);r!==void 0&&(s=r)}catch(r){console.error(`[zustand-debounce] Plugin "${c.name}" beforeSetItem hook failed:`,r)}return s}applyAfterGetItem(i){let s=i;for(let c of this.plugins)if(c.afterGetItem)try{let r=c.afterGetItem(s);r!==void 0&&(s=r)}catch(r){return console.error(`[zustand-debounce] Plugin "${c.name}" afterGetItem hook failed:`,r),null}return s}getPlugins(){return[...this.plugins]}};function lg(){let i={};return{getItem:async s=>i[s]||null,setItem:async(s,c)=>{i[s]=c},removeItem:async s=>{delete i[s]}}}function ng(i){if(typeof i=="object"&&i!==null&&typeof i.getItem=="function")return i;if(i==="localStorage"){if(typeof window<"u"&&window.localStorage)return{getItem:async s=>window.localStorage.getItem(s),setItem:async(s,c)=>window.localStorage.setItem(s,c),removeItem:async s=>window.localStorage.removeItem(s)};throw new Error("localStorage no está disponible.")}if(i==="sessionStorage"){if(typeof window<"u"&&window.sessionStorage)return{getItem:async s=>window.sessionStorage.getItem(s),setItem:async(s,c)=>window.sessionStorage.setItem(s,c),removeItem:async s=>window.sessionStorage.removeItem(s)};throw new Error("sessionStorage no está disponible.")}if(i==="memoryStorage")return lg();throw new Error(`Adaptador de almacenamiento no soportado: ${i}`)}function ag(i,s={}){let c=new eg,{debounceTime:r,throttleTime:m,immediately:h,maxRetries:_,retryDelay:b,onWrite:x,onSave:p,serialize:T,deserialize:z,ttl:U,plugins:R=[],...j}=s,D;R.length>0&&(D=new tg,D.register(R));let E=new $v(ng(i),D);T&&z&&(E=new Fv(E,{serialize:T,deserialize:z})),typeof U=="number"&&(E=new Pv(E,{ttl:U})),(_||b)&&(E=new Wv(E,{maxRetries:_,retryDelay:b})),(r||m||h!==void 0)&&(E=new Iv(E,{debounceTime:r,throttleTime:m,immediately:h},c));let M=new kv(E,c);x&&M.on("write",x),p&&M.on("save",p),E=M;let X={getItem:async V=>await E.getItem(V),setItem:async(V,F)=>{await E.setItem(V,F)},removeItem:async V=>{await E.removeItem(V)}},G=fm(()=>X,j);if(G===void 0)throw new Error("createJSONStorage returned undefined");return G}const nm={method:"POST",url:"http://fastedge-builtin.debug",requestHeaders:{},requestBody:'{"message": "Hello"}',responseHeaders:{"content-type":"application/json"},responseBody:'{"response": "OK"}'},ug=i=>({...nm,setMethod:s=>i(c=>{c.method=s}),setUrl:s=>i(c=>{c.url=s}),setRequestHeaders:s=>i(c=>{c.requestHeaders=s}),setRequestBody:s=>i(c=>{c.requestBody=s}),setResponseHeaders:s=>i(c=>{c.responseHeaders=s}),setResponseBody:s=>i(c=>{c.responseBody=s}),updateRequestHeader:(s,c)=>i(r=>{r.requestHeaders[s]=c}),removeRequestHeader:s=>i(c=>{delete c.requestHeaders[s]}),updateResponseHeader:(s,c)=>i(r=>{r.responseHeaders[s]=c}),removeResponseHeader:s=>i(c=>{delete c.responseHeaders[s]}),resetRequest:()=>i(s=>{Object.assign(s,nm)})});function ig(){return typeof window<"u"&&(window.vscodeApi!==void 0||typeof window.acquireVsCodeApi=="function"||window.vscode!==void 0)}function cg(){return!!(typeof window<"u"&&(navigator.userAgent.toLowerCase().includes("electron")||navigator.userAgent.toLowerCase().includes("vscode")||window.process?.type==="renderer"||window.process?.type==="worker"))}function sg(){if(ig()||cg()||typeof window.process<"u")return!0;try{if("path"in new File(["test"],"test.txt"))return!0}catch{}return!1}function Sm(i){return typeof i.path=="string"&&i.path.length>0}function og(i){return i&&Sm(i)?i.path:null}function qi(i){if(i===0)return"0 Bytes";const s=1024,c=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(i)/Math.log(s));return`${(i/Math.pow(s,r)).toFixed(1)} ${c[r]}`}const ml="/api";async function Tm(){const i=await fetch(`${ml}/environment`,{method:"GET",headers:{"Content-Type":"application/json"}});return i.ok?await i.json():(console.warn("Failed to fetch environment info, defaulting to node"),{environment:"node",supportsPathLoading:!0})}async function Em(i,s=!0,c){const r=performance.now(),m=i.size;if(sg()&&Sm(i)){const T=og(i);if(T){console.log(`📁 Using path-based loading (${qi(m)}): ${T}`);try{const z=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmPath:T,dotenv:{enabled:s,...c?{path:c}:{}}})});if(z.ok){const U=performance.now()-r,R=await z.json();return console.log(`✅ Path-based loading succeeded in ${U.toFixed(1)}ms`),{path:i.name,wasmType:R.wasmType,loadingMode:"path",loadTime:U,fileSize:m}}else{const U=await z.json();console.warn("⚠️ Path-based loading failed, falling back to buffer mode:",U.error)}}catch(z){console.warn("⚠️ Path-based loading error, falling back to buffer mode:",z)}}}console.log(`💾 Using buffer-based loading (${qi(m)})...`);const h=await i.arrayBuffer(),_=btoa(new Uint8Array(h).reduce((T,z)=>T+String.fromCharCode(z),"")),b=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmBase64:_,dotenv:{enabled:s,...c?{path:c}:{}}})});if(!b.ok){const T=await b.json();throw new Error(T.error||"Failed to load WASM file")}const x=performance.now()-r,p=await b.json();return console.log(`✅ Buffer-based loading succeeded in ${x.toFixed(1)}ms`),{path:i.name,wasmType:p.wasmType,loadingMode:"buffer",loadTime:x,fileSize:m}}async function xm(i,s=!0,c){const r=performance.now();console.log(`📁 Loading WASM from path: ${i}`);const m=await fetch(`${ml}/load`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wasmPath:i,dotenv:{enabled:s,...c?{path:c}:{}}})});if(!m.ok){const b=await m.json();throw new Error(b.error||"Failed to load WASM from path")}const h=performance.now()-r,_=await m.json();return console.log(`✅ Path-based loading succeeded in ${h.toFixed(1)}ms`),{path:_.resolvedPath||i,wasmType:_.wasmType,loadingMode:"path",loadTime:h,fileSize:0}}async function rg(i,s,c){const r={url:i,request:{headers:c.request_headers||{},body:c.request_body||"",method:s||"GET"},response:{headers:c.response_headers||{},body:c.response_body||""},properties:c.properties||{}},m=await fetch(`${ml}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!m.ok){const b=await m.json();throw new Error(b.error||"Failed to execute full flow")}const h=await m.json(),_={};for(const[b,x]of Object.entries(h.hookResults||{})){const p=x,T=p?.logs||[];_[b]={logs:T,returnValue:p?.returnCode,error:p?.error,input:p?.input,output:p?.output,properties:p?.properties}}return{hookResults:_,finalResponse:h.finalResponse,calculatedProperties:h.calculatedProperties}}async function Am(i){return await(await fetch(`${ml}/config/show-save-dialog`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suggestedName:i})})).json()}async function Ni(i,s){const c=await fetch(`${ml}/config/save-as`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:i,filePath:s})});if(!c.ok){const r=await c.json();throw new Error(r.error||"Failed to save config")}return c.json()}async function zm(i,s="GET",c={},r=""){const m={url:i,method:s,headers:c,body:r},h=await fetch(`${ml}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!h.ok){const b=await h.json();throw new Error(b.error||"Failed to execute HTTP WASM")}return(await h.json()).result}async function fg(i,s){const c=await fetch(`${ml}/dotenv`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({dotenv:{enabled:i,...s?{path:s}:{}}})});if(!c.ok){const r=await c.json();throw new Error(r.error||"Failed to apply dotenv setting")}}const Nm=Object.freeze(Object.defineProperty({__proto__:null,applyDotenv:fg,executeHttpWasm:zm,getEnvironment:Tm,saveConfigAs:Ni,sendFullFlow:rg,showSaveDialog:Am,uploadWasm:Em,uploadWasmFromPath:xm},Symbol.toStringTag,{value:"Module"})),dg={wasmPath:null,wasmBuffer:null,wasmFile:null,wasmType:null,loading:!1,error:null,loadingMode:null,loadTime:null,fileSize:null},hg=(i,s)=>({...dg,loadWasm:async(c,r,m)=>{i(h=>{h.loading=!0,h.error=null,h.hookResults={},h.finalResponse=null,h.isExecuting=!1,h.httpResponse=null,h.httpLogs=[]});try{let h,_=null;const b=(m!==void 0?m:s().dotenv.path)??void 0;typeof c=="string"?h=await xm(c,r,b):(_=c,h=await Em(_,r,b));const{path:x,wasmType:p,loadingMode:T,loadTime:z,fileSize:U}=h;let R=null;_&&T==="buffer"&&(R=await _.arrayBuffer()),i(j=>{j.wasmPath=x,j.wasmBuffer=R,j.wasmFile=_,j.wasmType=p,j.loadingMode=T,j.loadTime=z,j.fileSize=U,j.loading=!1,j.error=null})}catch(h){const _=h instanceof Error?h.message:"Failed to load WASM";i(b=>{b.error=_,b.loading=!1})}},reloadWasm:async(c,r)=>{const{wasmFile:m,wasmPath:h,loadWasm:_}=s();m?await _(m,c,r):h?await _(h,c,r):i(b=>{b.error="No WASM loaded to reload"})},clearWasm:()=>{i(c=>{c.wasmPath=null,c.wasmBuffer=null,c.wasmFile=null,c.wasmType=null,c.loading=!1,c.error=null,c.loadingMode=null,c.loadTime=null,c.fileSize=null})},setWasmLoaded:(c,r,m)=>{i(h=>{h.wasmPath=c,h.wasmType=r,h.fileSize=m,h.loading=!1,h.error=null,h.loadingMode="path",h.hookResults={},h.finalResponse=null,h.isExecuting=!1,h.httpResponse=null,h.httpLogs=[]})},setLoading:c=>{i(r=>{r.loading=c})},setError:c=>{i(r=>{r.error=c})}}),mg={hookResults:{},finalResponse:null,isExecuting:!1},yg=i=>({...mg,setHookResult:(s,c)=>i(r=>{r.hookResults[s]=c}),setHookResults:s=>i(c=>{c.hookResults=s}),setFinalResponse:s=>i(c=>{c.finalResponse=s}),setIsExecuting:s=>i(c=>{c.isExecuting=s}),clearResults:()=>i(s=>{s.hookResults={},s.finalResponse=null,s.isExecuting=!1})}),pg="modulepreload",vg=function(i){return"/"+i},am={},jm=function(s,c,r){let m=Promise.resolve();if(c&&c.length>0){let p=function(T){return Promise.all(T.map(z=>Promise.resolve(z).then(U=>({status:"fulfilled",value:U}),U=>({status:"rejected",reason:U}))))};var _=p;document.getElementsByTagName("link");const b=document.querySelector("meta[property=csp-nonce]"),x=b?.nonce||b?.getAttribute("nonce");m=p(c.map(T=>{if(T=vg(T),T in am)return;am[T]=!0;const z=T.endsWith(".css"),U=z?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${T}"]${U}`))return;const R=document.createElement("link");if(R.rel=z?"stylesheet":pg,z||(R.as="script"),R.crossOrigin="",R.href=T,x&&R.setAttribute("nonce",x),document.head.appendChild(R),z)return new Promise((j,D)=>{R.addEventListener("load",j),R.addEventListener("error",()=>D(new Error(`Unable to preload CSS for ${T}`)))})}))}function h(b){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=b,window.dispatchEvent(x),!x.defaultPrevented)throw b}return m.then(b=>{for(const x of b||[])x.status==="rejected"&&h(x.reason);return s().catch(h)})},um={properties:{},dotenv:{enabled:!1,path:null},logLevel:2},gg=(i,s)=>({...um,setProperties:c=>i(r=>{r.properties=c}),updateProperty:(c,r)=>i(m=>{m.properties[c]=r}),removeProperty:c=>i(r=>{delete r.properties[c]}),mergeProperties:c=>i(r=>{Object.assign(r.properties,c)}),setDotenvEnabled:c=>{i(r=>{r.dotenv.enabled=c,c?r.expandedPanels.dotenv=!0:delete r.expandedPanels.dotenv})},setDotenvPath:async c=>{i(h=>{h.dotenv.path=c});const{wasmPath:r,dotenv:m}=s();if(r!==null&&m.enabled){const{applyDotenv:h}=await jm(async()=>{const{applyDotenv:_}=await Promise.resolve().then(()=>Nm);return{applyDotenv:_}},void 0);await h(m.enabled,c)}},setLogLevel:c=>i(r=>{r.logLevel=c}),loadFromConfig:c=>i(r=>{r.properties={...c.properties},r.logLevel=c.logLevel,r.dotenv={enabled:c.dotenv?.enabled??!1,path:c.dotenv?.path??null},c.appType==="http-wasm"?(r.httpMethod=c.request.method,r.httpUrl=c.request.url,r.httpRequestHeaders={...c.request.headers},r.httpRequestBody=c.request.body):(r.method=c.request.method,r.url=c.request.url,r.requestHeaders={...c.request.headers},r.requestBody=c.request.body,c.response&&(r.responseHeaders={...c.response.headers},r.responseBody=c.response.body))}),exportConfig:()=>{const c=s(),r=c.wasmType==="http-wasm",m={appType:c.wasmType??"proxy-wasm",request:{method:r?c.httpMethod:c.method,url:r?c.httpUrl:c.url,headers:r?{...c.httpRequestHeaders}:{...c.requestHeaders},body:r?c.httpRequestBody:c.requestBody},properties:{...c.properties},logLevel:c.logLevel,dotenv:{enabled:c.dotenv.enabled,...c.dotenv.path?{path:c.dotenv.path}:{}}};return r||(m.response={headers:{...c.responseHeaders},body:c.responseBody}),c.wasmPath&&(m.wasm={path:c.wasmPath,description:"Current loaded WASM binary"}),m},resetConfig:()=>i(c=>{Object.assign(c,um)})}),_g={activeHookTab:"request_headers",activeSubView:"logs",expandedPanels:{},wsStatus:{connected:!1,reconnecting:!1,clientCount:0,error:null}},bg=i=>({..._g,setActiveHookTab:s=>i(c=>{c.activeHookTab=s}),setActiveSubView:s=>i(c=>{c.activeSubView=s}),togglePanel:s=>i(c=>{c.expandedPanels[s]=!c.expandedPanels[s]}),setPanelExpanded:(s,c)=>i(r=>{r.expandedPanels[s]=c}),setWsStatus:s=>i(c=>{c.wsStatus=s})}),Hi="http://test.localhost/",im={httpMethod:"GET",httpUrl:"http://test.localhost/",httpRequestHeaders:{},httpRequestBody:"",httpResponse:null,httpLogs:[],httpIsExecuting:!1,httpRunnerPort:null},Sg=(i,s)=>({...im,setHttpMethod:c=>{i(r=>{r.httpMethod=c})},setHttpUrl:c=>{c.startsWith(Hi)||(c=Hi),i(r=>{r.httpUrl=c})},setHttpRequestHeaders:c=>{i(r=>{r.httpRequestHeaders=c})},setHttpRequestBody:c=>{i(r=>{r.httpRequestBody=c})},setHttpResponse:c=>{i(r=>{r.httpResponse=c})},setHttpLogs:c=>{i(r=>{r.httpLogs=c})},appendHttpLogs:c=>{i(r=>{r.httpLogs.push(...c)})},setHttpRunnerPort:c=>{i(r=>{r.httpRunnerPort=c})},setHttpIsExecuting:c=>{i(r=>{r.httpIsExecuting=c})},executeHttpRequest:async()=>{const c=s();i(r=>{r.httpIsExecuting=!0,r.httpLogs=[]});try{const r=await zm(c.httpUrl,c.httpMethod,c.httpRequestHeaders,c.httpRequestBody);i(m=>{m.httpResponse={status:r.status,statusText:r.statusText,headers:r.headers,body:r.body,contentType:r.contentType,isBase64:r.isBase64},m.httpLogs=r.logs,m.httpIsExecuting=!1})}catch(r){const m=r instanceof Error?r.message:"Failed to execute HTTP WASM";i(h=>{h.httpResponse={status:0,statusText:"Error",headers:{},body:m,contentType:"text/plain"},h.httpLogs=[{level:4,message:`Error: ${m}`}],h.httpIsExecuting=!1})}},clearHttpResponse:()=>{i(c=>{c.httpResponse=null,c.httpLogs=[]})},resetHttpWasm:()=>{i(c=>{Object.assign(c,im)})}}),Tg=ag(localStorage,{debounceTime:500}),nu=bv()(Av(Zv(Nv((...i)=>({...ug(...i),...hg(...i),...yg(...i),...gg(...i),...bg(...i),...Sg(...i)}),{name:"proxy-runner-config",storage:Tg,partialize:i=>({request:{method:i.method,url:i.url,requestHeaders:i.requestHeaders,requestBody:i.requestBody,responseHeaders:i.responseHeaders,responseBody:i.responseBody},config:{properties:i.properties,dotenv:i.dotenv,logLevel:i.logLevel},ui:{expandedPanels:i.expandedPanels}}),version:1})),{name:"ProxyRunnerStore",enabled:!1}));function Eg(i={}){const s=(()=>{const P=window.location.protocol==="https:"?"wss:":"ws:",Q=window.location.hostname==="localhost"?"127.0.0.1":window.location.hostname,te=window.location.port?`:${window.location.port}`:"";return`${P}//${Q}${te}/ws`})(),{url:c=s,autoConnect:r=!0,reconnectInterval:m=200,maxReconnectAttempts:h=15,onEvent:_,debug:b=!1}=i,[x,p]=W.useState({connected:!1,reconnecting:!1,clientCount:0,error:null}),[T,z]=W.useState(null),U=W.useRef(null),R=W.useRef(0),j=W.useRef(null),D=W.useRef(!1),E=W.useCallback((P,...Q)=>{b&&console.log(`[useWebSocket] ${P}`,...Q)},[b]),M=W.useCallback(P=>{try{const Q=JSON.parse(P.data);E(`Received event: ${Q.type} from ${Q.source}`),z(Q),Q.type==="connection_status"&&p(te=>({...te,clientCount:Q.data.clientCount})),_&&_(Q)}catch(Q){console.error("[useWebSocket] Failed to parse message:",Q)}},[_,E]),X=W.useCallback(()=>{if(D.current){E("Skipping reconnect - intentional disconnect");return}if(R.current>=h){E(`Max reconnect attempts (${h}) reached`),p(Q=>({...Q,connected:!1,reconnecting:!1,error:"Failed to reconnect after multiple attempts"}));return}R.current++,E(`Reconnect attempt ${R.current}/${h}`),p(Q=>({...Q,reconnecting:!0,error:`Reconnecting... (attempt ${R.current})`}));const P=Math.min(m*Math.pow(1.5,R.current-1),3e3);j.current=setTimeout(()=>{G()},P)},[m,h,E]),G=W.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),U.current&&(U.current.close(),U.current=null);try{const P=performance.now();E(`Connecting to ${c}`);const Q=new WebSocket(c);Q.onopen=()=>{const te=performance.now()-P;E(`Connected (took ${te.toFixed(0)}ms)`),R.current=0,D.current=!1,p({connected:!0,reconnecting:!1,clientCount:0,error:null})},Q.onmessage=M,Q.onerror=te=>{console.error("[useWebSocket] WebSocket error:",te),p(Ce=>({...Ce,error:"WebSocket error occurred"}))},Q.onclose=te=>{E(`Disconnected (code: ${te.code}, reason: ${te.reason})`),p(Ce=>({...Ce,connected:!1,error:te.reason||"Connection closed"})),U.current=null,D.current||X()},U.current=Q}catch(P){console.error("[useWebSocket] Failed to create WebSocket:",P),p(Q=>({...Q,connected:!1,error:P instanceof Error?P.message:"Failed to connect"})),X()}},[c,M,X,E]),V=W.useCallback(()=>{E("Intentional disconnect"),D.current=!0,j.current&&(clearTimeout(j.current),j.current=null),U.current&&(U.current.close(1e3,"Client disconnect"),U.current=null),p({connected:!1,reconnecting:!1,clientCount:0,error:null})},[E]),F=W.useCallback(P=>{if(!U.current||U.current.readyState!==WebSocket.OPEN){console.warn("[useWebSocket] Cannot send - not connected");return}try{const Q=typeof P=="string"?P:JSON.stringify(P);U.current.send(Q),E("Sent message:",P)}catch(Q){console.error("[useWebSocket] Failed to send message:",Q)}},[E]);return W.useEffect(()=>(r&&G(),()=>{D.current=!0,j.current&&clearTimeout(j.current),U.current&&U.current.close()}),[r]),{status:x,lastEvent:T,connect:G,disconnect:V,send:F}}const xg="_wasmLoader_3gv9a_1",Ag="_header_3gv9a_7",zg="_loadingIndicator_3gv9a_41",Ng="_pathInputGroup_3gv9a_46",jg="_pathInput_3gv9a_46",Og="_pathButton_3gv9a_78",Rg="_tabs_3gv9a_101",Cg="_tabButtons_3gv9a_110",Mg="_tab_3gv9a_101",Dg="_tabActive_3gv9a_138",qg="_tabIcon_3gv9a_154",Hg="_tabContent_3gv9a_158",wg="_pathPanel_3gv9a_162",Ug="_uploadPanel_3gv9a_163",Bg="_panelDescription_3gv9a_170",Lg="_fileInputWrapper_3gv9a_178",Yg="_chooseFileButton_3gv9a_189",Gg="_hiddenFileInput_3gv9a_212",Vg="_noFileChosen_3gv9a_217",Xg="_selectedFile_3gv9a_224",Qg="_selectedFileIcon_3gv9a_231",Zg="_selectedFileName_3gv9a_237",Jg="_selectedFileSize_3gv9a_243",Kg="_tabInfo_3gv9a_249",$g="_tabInfoIcon_3gv9a_260",kg="_tabInfoText_3gv9a_264",Wg="_tabInfoTime_3gv9a_269",Fg="_tabInfoSize_3gv9a_273",ve={wasmLoader:xg,header:Ag,loadingIndicator:zg,pathInputGroup:Ng,pathInput:jg,pathButton:Og,tabs:Rg,tabButtons:Cg,tab:Mg,tabActive:Dg,tabIcon:qg,tabContent:Hg,pathPanel:wg,uploadPanel:Ug,panelDescription:Bg,fileInputWrapper:Lg,chooseFileButton:Yg,hiddenFileInput:Gg,noFileChosen:Vg,selectedFile:Xg,selectedFileIcon:Qg,selectedFileName:Zg,selectedFileSize:Jg,tabInfo:Kg,tabInfoIcon:$g,tabInfoText:kg,tabInfoTime:Wg,tabInfoSize:Fg};function Ig({onFileLoad:i,onPathLoad:s,loading:c,loadingMode:r,loadTime:m,fileSize:h,fileName:_,defaultTab:b="upload",wasmPath:x}){const[p,T]=W.useState(""),[z,U]=W.useState(b),R=W.useRef(null);W.useEffect(()=>{U(b)},[b]),W.useEffect(()=>{r==="buffer"?U("upload"):r==="path"&&U("path")},[r]),W.useEffect(()=>{r==="path"&&x&&x!==p?T(x):r==="buffer"&&T("")},[x,r]);const j=V=>{const F=V.target.files?.[0];F&&i(F)},D=()=>{p.trim()&&s&&s(p.trim())},E=V=>{V.key==="Enter"&&p.trim()&&s&&D()},M=()=>r?r==="path"?"📁":"💾":null,X=()=>r?r==="path"?"Path-based":"Buffer-based":null,G=()=>r?r==="path"?"Optimized path-based loading (70-95% faster)":"Standard buffer-based loading":"";return d.jsxs("section",{className:ve.wasmLoader,children:[d.jsx("div",{className:ve.header,children:d.jsx("h2",{children:"Load WASM Binary"})}),s&&d.jsxs("div",{className:ve.tabs,children:[d.jsxs("div",{className:ve.tabButtons,children:[d.jsxs("button",{className:`${ve.tab} ${z==="path"?ve.tabActive:""}`,onClick:()=>U("path"),disabled:c,children:[d.jsx("span",{className:ve.tabIcon,children:"📁"}),d.jsx("span",{children:"File Path"})]}),d.jsxs("button",{className:`${ve.tab} ${z==="upload"?ve.tabActive:""}`,onClick:()=>U("upload"),disabled:c,children:[d.jsx("span",{className:ve.tabIcon,children:"📤"}),d.jsx("span",{children:"Upload File"})]})]}),!c&&_&&r&&d.jsxs("div",{className:ve.tabInfo,title:G(),children:[d.jsx("span",{className:ve.tabInfoIcon,children:M()}),d.jsx("span",{className:ve.tabInfoText,children:X()}),m!=null&&d.jsxs("span",{className:ve.tabInfoTime,children:["• ",m.toFixed(1),"ms"]}),h&&d.jsxs("span",{className:ve.tabInfoSize,children:["• (",qi(h),")"]})]})]}),d.jsxs("div",{className:ve.tabContent,children:[s&&z==="path"&&d.jsxs("div",{className:ve.pathPanel,children:[d.jsx("div",{className:ve.panelDescription,children:"Load WASM directly from filesystem path (faster, no upload needed)"}),d.jsxs("div",{className:ve.pathInputGroup,children:[d.jsx("input",{type:"text",className:ve.pathInput,placeholder:"<workspace>/.fastedge-debug/app.wasm",value:p,onChange:V=>T(V.target.value),onKeyDown:E,disabled:c}),d.jsx("button",{onClick:D,disabled:c||!p.trim(),className:ve.pathButton,children:"Load from Path"})]})]}),z==="upload"&&d.jsxs("div",{className:ve.uploadPanel,children:[d.jsx("div",{className:ve.panelDescription,children:"Upload a WASM binary file from your computer"}),d.jsxs("div",{className:ve.fileInputWrapper,children:[d.jsx("button",{onClick:()=>R.current?.click(),disabled:c,className:ve.chooseFileButton,children:"Choose File"}),d.jsx("input",{ref:R,type:"file",accept:".wasm",onChange:j,disabled:c,className:ve.hiddenFileInput}),!c&&r==="buffer"&&_?d.jsxs("div",{className:ve.selectedFile,children:[d.jsx("span",{className:ve.selectedFileIcon,children:"✓"}),d.jsx("span",{className:ve.selectedFileName,children:_}),h&&d.jsxs("span",{className:ve.selectedFileSize,children:["(",qi(h),")"]})]}):d.jsx("span",{className:ve.noFileChosen,children:"No file chosen"})]})]})]}),c&&d.jsx("span",{className:ve.loadingIndicator,children:" Loading..."})]})}const Pg="_container_1g2xx_1",e0="_indicator_1g2xx_9",t0="_indicatorConnected_1g2xx_16",l0="_indicatorReconnecting_1g2xx_20",n0="_indicatorError_1g2xx_24",a0="_indicatorDisconnected_1g2xx_28",u0="_text_1g2xx_32",on={container:Pg,indicator:e0,indicatorConnected:t0,indicatorReconnecting:l0,indicatorError:n0,indicatorDisconnected:a0,text:u0};function i0({status:i}){const s=()=>i.connected?on.indicatorConnected:i.reconnecting?on.indicatorReconnecting:i.error?on.indicatorError:on.indicatorDisconnected,c=()=>i.connected?i.clientCount>1?`Connected (${i.clientCount} clients)`:"Connected":i.reconnecting?"Reconnecting...":i.error?"Disconnected":"Not connected";return d.jsxs("div",{className:on.container,children:[d.jsx("div",{className:`${on.indicator} ${s()}`,title:i.error||c()}),d.jsx("span",{className:on.text,children:c()})]})}const c0="_container_qhpt2_1",s0="_spinner_qhpt2_11",o0="_message_qhpt2_26",vo={container:c0,spinner:s0,message:o0};function r0({message:i="Loading..."}){return d.jsxs("div",{className:vo.container,children:[d.jsx("div",{className:vo.spinner}),d.jsx("p",{className:vo.message,children:i})]})}const f0="_container_iyt3w_1",d0="_editor_iyt3w_7",cm={container:f0,editor:d0};function h0({config:i}){const s=JSON.stringify(i,null,2);return d.jsx("div",{className:cm.container,children:d.jsx("textarea",{className:cm.editor,value:s,readOnly:!0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})})}const m0="_backdrop_8umbd_1",y0="_modal_8umbd_15",p0="_header_8umbd_27",v0="_closeButton_8umbd_41",g0="_content_8umbd_57",_0="_footer_8umbd_64",In={backdrop:m0,modal:y0,header:p0,closeButton:v0,content:g0,footer:_0};function b0({initialConfig:i,onClose:s}){const[c,r]=W.useState(!1);W.useEffect(()=>{const _=b=>{b.key==="Escape"&&s()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[s]);const m=async()=>{try{r(!0);const _="fastedge-config.test.json";if(window!==window.top){const T=await new Promise(U=>{const R=j=>{j.source===window.parent&&j.data?.command==="savePickerResult"&&(window.removeEventListener("message",R),U(j.data.canceled?null:j.data.filePath))};window.addEventListener("message",R),window.parent.postMessage({command:"openSavePicker",suggestedName:_},"*")});if(!T){r(!1);return}const z=await Ni(i,T);alert(`✅ Config saved to: ${z.savedPath}`),s();return}if("showSaveFilePicker"in window)try{const T=await window.showSaveFilePicker({suggestedName:_,types:[{description:"JSON Config File",accept:{"application/json":[".json"]}}]}),z=await T.createWritable();await z.write(JSON.stringify(i,null,2)),await z.close(),alert(`✅ Config saved to: ${T.name}`),s();return}catch(T){if(T.name==="AbortError"){r(!1);return}}try{const T=await Am(_);if(T.canceled){r(!1);return}if(T.filePath){const z=await Ni(i,T.filePath);alert(`✅ Config saved to: ${z.savedPath}`),s();return}}catch{}const x=prompt(`Enter the file path to save (relative to project root or absolute):
|
|
15
15
|
|
|
16
16
|
Examples:
|
|
17
17
|
configs/my-test.json
|
|
@@ -30,6 +30,6 @@ Examples:
|
|
|
30
30
|
`)}catch{return G}},D=G=>{try{let V=G,F=0;const P=" ";V=V.replace(/>\s*</g,`>
|
|
31
31
|
<`);const Q=V.split(`
|
|
32
32
|
`),te=[];for(const Ce of Q){const Se=Ce.trim();Se&&(Se.startsWith("</")&&(F=Math.max(0,F-1)),te.push(P.repeat(F)+Se),Se.startsWith("<")&&!Se.startsWith("</")&&!Se.endsWith("/>")&&!Se.startsWith("<?")&&!Se.startsWith("<!")&&(Se.includes("</")||F++))}return te.join(`
|
|
33
|
-
`)}catch{return G}},E=()=>{if(z)try{const G=JSON.parse(i.body);return d.jsx(Jt,{data:G,style:{margin:0}})}catch{return d.jsx("pre",{style:{margin:0},children:i.body})}if(p){const G=j(i.body);return d.jsx("pre",{style:{margin:0},children:G})}if(T){const G=D(i.body);return d.jsx("pre",{style:{margin:0},children:G})}return d.jsx("pre",{style:{margin:0},children:i.body})},M=()=>{if(x)return d.jsx("div",{className:_e.imagePreview,children:d.jsx("img",{src:`data:${i.contentType};base64,${i.body}`,alt:"Response preview",className:_e.previewImage,onError:G=>{const F=G.target.parentElement;F&&(F.innerHTML=`<p style="color: #666;">Unable to display image. Content-Type: ${i.contentType}</p><p style="color: #999; font-size: 12px;">The image data may be corrupted or in an unsupported format.</p>`)}})});if(p){if(r&&h){const G=(()=>{try{return new URL(_).pathname||"/"}catch{return"/"}})();return d.jsx("iframe",{src:`http://localhost:${h}${G}`,title:"Live preview",className:_e.htmlPreview})}return d.jsx("iframe",{srcDoc:i.body,title:"Response preview",className:_e.htmlPreview,sandbox:"allow-same-origin"})}return U&&!x?d.jsxs("div",{className:_e.binaryNotice,children:[d.jsxs("p",{children:["Binary content: ",i.contentType]}),d.jsx("p",{style:{fontSize:"12px",marginTop:"8px"},children:'Preview not available for binary content. Check the "Headers" tab for response metadata.'})]}):d.jsxs("div",{className:_e.binaryNotice,children:[d.jsxs("p",{children:["Preview not available for content type: ",i.contentType]}),d.jsx("p",{style:{fontSize:"12px",marginTop:"8px"},children:'Switch to "Body" tab to view raw content.'})]})},X=()=>{const G=Object.entries(i.headers);return G.length===0?d.jsx("div",{className:_e.noHeaders,children:"No headers received"}):d.jsx("div",{className:_e.headersList,children:G.map(([V,F])=>d.jsxs("div",{className:_e.headerItem,children:[d.jsxs("span",{className:_e.headerKey,children:[V,":"]}),d.jsx("span",{className:_e.headerValue,children:F})]},V))})};return d.jsx("div",{className:_e.responsePanel,children:d.jsxs(ta,{title:"Response",defaultExpanded:!0,headerExtra:d.jsxs("div",{className:_e.responseStatus,children:[d.jsx("span",{style:{color:b(i.status),fontWeight:600,fontSize:"13px"},children:i.status===0?"ERROR":`${i.status} ${i.statusText}`}),d.jsx("span",{style:{color:"#666",marginLeft:"12px",fontSize:"12px"},children:i.contentType})]}),children:[d.jsxs("div",{className:_e.tabs,children:[d.jsxs("div",{className:_e.tabButtons,children:[!U&&d.jsx("button",{className:`${_e.tab} ${s==="body"?_e.active:""}`,onClick:()=>c("body"),children:"Body"}),R&&d.jsx("button",{className:`${_e.tab} ${s==="preview"?_e.active:""}`,onClick:()=>c("preview"),children:"Preview"}),d.jsx("button",{className:`${_e.tab} ${s==="headers"?_e.active:""}`,onClick:()=>c("headers"),children:"Headers"})]}),p&&d.jsxs("div",{className:_e.previewToolbar,children:[d.jsx("button",{className:`${_e.toolbarButton} ${r?_e.toolbarButtonActive:""}`,onClick:()=>m(G=>!G),disabled:!h,title:h?"Toggle live preview (loads assets from running WASM)":"No HTTP WASM runner active",children:"● Live"}),d.jsx("button",{className:_e.toolbarButton,onClick:()=>{const G=`http://localhost:${h}/`;window!==window.top?window.parent.postMessage({command:"openExternal",url:G},"*"):window.open(G,"_blank")},disabled:!h,title:h?"Open in system browser":"No HTTP WASM runner active",children:"↗ Open in Browser"})]})]}),d.jsxs("div",{className:_e.responseContent,children:[s==="body"&&!U&&d.jsx("div",{className:_e.responseBody,children:E()}),s==="preview"&&R&&d.jsx("div",{className:_e.responsePreview,children:M()}),s==="headers"&&d.jsx("div",{className:_e.responseHeaders,children:X()})]})]})})}const __="_logsViewer_1lb7i_1",b_="_logsContainer_1lb7i_46",S_="_logEntry_1lb7i_59",T_="_logLevel_1lb7i_65",E_="_logMessage_1lb7i_70",x_="_trace_1lb7i_78",A_="_debug_1lb7i_82",z_="_info_1lb7i_86",N_="_warn_1lb7i_90",j_="_error_1lb7i_94",O_="_critical_1lb7i_98",R_="_emptyState_1lb7i_103",C_="_noLogs_1lb7i_117",ft={logsViewer:__,logsContainer:b_,logEntry:S_,logLevel:T_,logMessage:E_,trace:x_,debug:A_,info:z_,warn:N_,error:j_,critical:O_,emptyState:R_,noLogs:C_},M_=["TRACE","DEBUG","INFO","WARN","ERROR","CRITICAL"],D_={0:ft.trace,1:ft.debug,2:ft.info,3:ft.warn,4:ft.error,5:ft.critical};function q_({logs:i,logLevel:s}){const c=(h,_)=>h.filter(b=>b.level>=_),r=h=>M_[h]||"UNKNOWN",m=c(i,s);return i.length===0?d.jsx("div",{className:ft.emptyState,children:d.jsx("p",{children:"No logs captured"})}):d.jsx("div",{className:ft.logsViewer,children:d.jsx("pre",{className:ft.logsContainer,children:m.length>0?m.map((h,_)=>{const b=D_[h.level]||ft.trace;return d.jsxs("div",{className:ft.logEntry,children:[d.jsxs("span",{className:`${ft.logLevel} ${b}`,children:["[",r(h.level),"]"]}),d.jsx("span",{className:ft.logMessage,children:h.message})]},_)}):d.jsx("div",{className:ft.noLogs,children:"No logs at this level. Lower the log level to see more output."})})})}const H_="_logLevelSelector_1dmmk_1",w_={logLevelSelector:H_};function Dm({logLevel:i,onLogLevelChange:s}){const c=r=>{s(parseInt(r.target.value,10))};return d.jsxs("div",{className:w_.logLevelSelector,children:[d.jsx("label",{children:"Log Level:"}),d.jsxs("select",{value:i,onChange:c,children:[d.jsx("option",{value:"0",children:"Trace (0)"}),d.jsx("option",{value:"1",children:"Debug (1)"}),d.jsx("option",{value:"2",children:"Info (2)"}),d.jsx("option",{value:"3",children:"Warn (3)"}),d.jsx("option",{value:"4",children:"Error (4)"}),d.jsx("option",{value:"5",children:"Critical (5)"})]})]})}const U_="_httpWasmView_12ui9_1",B_="_panels_12ui9_9",L_="_hint_12ui9_35",Y_="_loggingContent_12ui9_44",G_="_loggingHeader_12ui9_50",V_="_logTab_12ui9_58",X_="_tabLabel_12ui9_66",Q_="_loggingControls_12ui9_71",Z_="_clearLogsButton_12ui9_77",fl={httpWasmView:U_,panels:B_,hint:L_,loggingContent:Y_,loggingHeader:G_,logTab:V_,tabLabel:X_,loggingControls:Q_,clearLogsButton:Z_},J_=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"];function K_(){const i=W.useRef(null),[s,c]=W.useState(0),{httpMethod:r,httpUrl:m,httpRequestHeaders:h,httpRequestBody:_,httpIsExecuting:b,httpResponse:x,httpLogs:p,wasmPath:T,dotenv:z,setHttpMethod:U,setHttpUrl:R,setHttpRequestHeaders:j,setHttpRequestBody:D,setHttpLogs:E,setDotenvEnabled:M,setDotenvPath:X,executeHttpRequest:G,expandedPanels:V,setPanelExpanded:F}=nu(),P=te=>{R(Hi+te)},Q=()=>{G()};return d.jsx("div",{className:fl.httpWasmView,children:d.jsxs("div",{className:fl.panels,children:[d.jsx(Cm,{method:r,url:m,wasmLoaded:T!==null,onMethodChange:U,onUrlChange:P,onSend:Q,methods:J_,urlPrefix:Hi,urlPlaceholder:"",isExecuting:b,executingText:"Executing...",urlInputRef:i,headers:h,body:_,onHeadersChange:j,onBodyChange:D,headersLabel:"Request Headers",bodyLabel:"Request Body",bodyRows:10,headerKeyPlaceholder:"Header name (e.g., Content-Type)",headerValuePlaceholder:"Header value (e.g., application/json)",additionalContent:T?void 0:d.jsx("div",{className:fl.hint,children:"Load a WASM file first"})}),d.jsx(Om,{enabled:z.enabled,onToggle:M,path:z.path,onPathChange:X,isExpanded:V.dotenv??!1,onExpandedChange:te=>F("dotenv",te)}),d.jsx(ta,{title:"Logging",defaultExpanded:p.length>0,children:d.jsxs("div",{className:fl.loggingContent,children:[d.jsxs("div",{className:fl.loggingHeader,children:[d.jsxs("div",{className:fl.logTab,children:[d.jsx("span",{className:fl.tabLabel,children:"Logs"}),p.length>0&&d.jsx("button",{className:fl.clearLogsButton,onClick:()=>E([]),title:"Clear logs",children:"🧹"})]}),d.jsx("div",{className:fl.loggingControls,children:d.jsx(Dm,{logLevel:s,onLogLevelChange:c})})]}),d.jsx(q_,{logs:p,logLevel:s})]})}),d.jsx(Mm,{response:x})]})})}const $_="_countryPresets_1xq35_1",k_="_countryLabel_1xq35_7",W_="_flag_1xq35_14",_o={countryPresets:$_,countryLabel:k_,flag:W_},qm={luxembourg:{code:"LU",name:"Luxembourg",city:"Luxembourg",geoLat:"49.6116",geoLong:"6.1319",region:"Luxembourg",continent:"Europe",flag:"🇱🇺"},germany:{code:"DE",name:"Germany",city:"Frankfurt",geoLat:"50.1109",geoLong:"8.6821",region:"Hesse",continent:"Europe",flag:"🇩🇪"}},Hm=i=>{const s=qm[i];return{"request.country":{value:s.code,placeholder:s.code},"request.city":{value:s.city,placeholder:s.city},"request.geo.lat":{value:s.geoLat,placeholder:s.geoLat},"request.geo.long":{value:s.geoLong,placeholder:s.geoLong},"request.region":{value:s.region,placeholder:s.region},"request.continent":{value:s.continent,placeholder:s.continent},"request.country.name":{value:s.name,placeholder:s.name},"request.url":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.host":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.path":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.scheme":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.extension":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.query":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.x_real_ip":{value:"203.0.113.42",placeholder:"Client IP address",enabled:!1},"request.asn":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.var":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0}}},om=i=>{const s=Hm(i),c={};for(const[r,m]of Object.entries(s))if(typeof m=="string")c[r]=m;else{const h=m.enabled??!0,_=m.readOnly??!1;h&&!_&&m.value&&(c[r]=m.value)}return c};function F_({value:i,onChange:s}){const[c,r]=W.useState("luxembourg");W.useEffect(()=>{Object.keys(i).length===0&&s(om(c))},[]);const m=h=>{r(h),s(om(h))};return d.jsxs("div",{children:[d.jsx("div",{className:_o.countryPresets,children:Object.entries(qm).map(([h,_])=>d.jsxs("label",{className:_o.countryLabel,children:[d.jsx("input",{type:"radio",name:"country",value:h,checked:c===h,onChange:()=>m(h)}),d.jsx("span",{className:_o.flag,children:_.flag}),d.jsx("span",{children:_.name})]},h))}),d.jsx(Rm,{value:i,onChange:s,keyPlaceholder:"Property path",valuePlaceholder:"Property value",disableDelete:!0,defaultValues:Hm(c)},c)]})}function I_({properties:i,onPropertiesChange:s}){return d.jsx(ta,{title:"Server Properties",defaultExpanded:!1,children:d.jsx(F_,{value:i,onChange:s})})}const P_="_hookStagesPanel_12u1g_1",eb="_stagesHeader_12u1g_9",tb="_tabs_12u1g_18",lb="_tab_12u1g_18",nb="_active_12u1g_43",ab="_subViewTabs_12u1g_70",ub="_subTab_12u1g_78",ib="_stageContent_12u1g_101",cb="_hookInputs_12u1g_107",sb="_hookLogs_12u1g_108",ob="_hookOutputs_12u1g_109",rb="_metadata_12u1g_113",fb="_section_12u1g_119",db="_noData_12u1g_123",hb="_error_12u1g_129",mb="_returnValue_12u1g_139",yb="_outputHeader_12u1g_145",pb="_outputTitle_12u1g_152",vb="_filterInfo_12u1g_158",gb="_logsContainer_12u1g_163",_b="_logEntry_12u1g_172",bb="_logLevel_12u1g_53",Sb="_noLogs_12u1g_181",Tb="_accessViolation_12u1g_187",Eb="_violationIcon_12u1g_203",ce={hookStagesPanel:P_,stagesHeader:eb,tabs:tb,tab:lb,active:nb,subViewTabs:ab,subTab:ub,stageContent:ib,hookInputs:cb,hookLogs:sb,hookOutputs:ob,metadata:rb,section:fb,noData:db,error:hb,returnValue:mb,outputHeader:yb,outputTitle:pb,filterInfo:vb,logsContainer:gb,logEntry:_b,logLevel:bb,noLogs:Sb,accessViolation:Tb,violationIcon:Eb},xb=["onRequestHeaders","onRequestBody","onResponseHeaders","onResponseBody"];function Ab({results:i,hookCall:s,logLevel:c,onLogLevelChange:r}){const[m,h]=W.useState("onRequestHeaders"),[_,b]=W.useState("logs"),x=E=>(Object.entries(E).find(([X])=>X.toLowerCase()==="content-type")?.[1]||"").includes("application/json"),p=(E,M)=>{if(x(M))try{return JSON.parse(E)}catch{return E}return E},T=E=>{const M=i[E];if(M?.input)switch(E){case"onRequestHeaders":return{headers:M.input.request.headers,metadata:"Request headers as received by this hook on the server (BEFORE modification)"};case"onRequestBody":return{body:M.input.request.body,headers:M.input.request.headers,metadata:"Request body and headers as received by this hook on the server (BEFORE modification)"};case"onResponseHeaders":return{headers:M.input.response.headers,requestHeaders:M.input.request.headers,metadata:"Response headers as received by this hook (with modified request headers from previous hooks)"};case"onResponseBody":return{body:M.input.response.body,headers:M.input.response.headers,requestHeaders:M.input.request.headers,metadata:"Response body and headers as received by this hook on the server"};default:return{metadata:"No input data"}}switch(E){case"onRequestHeaders":return{headers:s.request_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onRequestBody":return{body:s.request_body||"",headers:s.request_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onResponseHeaders":return{headers:s.response_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onResponseBody":return{body:s.response_body||"",headers:s.response_headers||{},metadata:"(Not yet executed - showing initial state)"};default:return{metadata:"No input data"}}},z=E=>{const M=T(E),X=i[E];return d.jsxs("div",{className:ce.hookInputs,children:[d.jsx("p",{className:ce.metadata,children:M.metadata}),"requestHeaders"in M&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.requestHeaders,title:"Request Headers (Modified by Previous Hooks)"})}),"headers"in M&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.headers,title:E.includes("Response")?"Response Headers":"Request Headers"})}),"body"in M&&M.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(M.body,M.headers||{}),title:E.includes("Response")?"Response Body":"Request Body"})}),X?.input?.properties&&Object.keys(X.input.properties).length>0&&d.jsx("div",{children:d.jsx(Jt,{data:X.input.properties,title:"Properties (Before Hook Execution)"})})]})},U=E=>{const M=i[E];if(!M?.output)return d.jsx("div",{className:ce.noData,children:'No output yet. Click "Send" to execute this hook.'});const X=M.output,G=M.input;return d.jsxs("div",{className:ce.hookOutputs,children:[d.jsx("p",{className:ce.metadata,children:"Data produced by this hook AFTER execution (modifications made by WASM)"}),E.includes("Request")&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:X.request.headers,compareWith:G?.request.headers,title:"Request Headers (Modified)"})}),E==="onRequestBody"&&X.request.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(X.request.body,X.request.headers),compareWith:G?.request.body?p(G.request.body,G.request.headers):void 0,title:"Request Body (Modified)"})}),E.includes("Response")&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:X.response.headers,compareWith:G?.response.headers,title:"Response Headers (Modified)"})}),E==="onResponseBody"&&X.response.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(X.response.body,X.response.headers),compareWith:G?.response.body?p(G.response.body,G.response.headers):void 0,title:"Response Body (Modified)"})})]}),M?.output?.properties&&Object.keys(M.output.properties).length>0&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.output.properties,compareWith:M.input?.properties,title:"Properties (After Hook Execution)"})})]})},R=(E,M)=>E.filter(X=>X.level>=M),j=E=>["TRACE","DEBUG","INFO","WARN","ERROR","CRITICAL"][E]||"UNKNOWN",D=E=>{const M=i[E];if(!M)return d.jsx("div",{className:ce.noData,children:'No logs yet. Click "Send" to execute this hook.'});const X=M.logs&&M.logs.length>0?R(M.logs,c):[],G=M.logs?.length||0,V=X.length;return d.jsxs("div",{className:ce.hookLogs,children:[M.error&&d.jsxs("div",{className:ce.error,children:["Error: ",M.error]}),M.returnValue!==void 0&&d.jsxs("div",{className:ce.returnValue,children:[d.jsx("strong",{children:"Return Code:"})," ",M.returnValue]}),G>0?d.jsxs("div",{children:[d.jsxs("div",{className:ce.outputHeader,children:[d.jsx("h4",{className:ce.outputTitle,children:"Output"}),V<G&&d.jsxs("span",{className:ce.filterInfo,children:["Showing ",V," of ",G," logs (filtered by level)"]})]}),d.jsx("pre",{className:ce.logsContainer,children:X.length>0?X.map((F,P)=>{const Q=F.message.includes("[property access denied]"),te=Q?`${ce.logEntry} ${ce.accessViolation}`:ce.logEntry;return d.jsxs("div",{className:te,children:[Q&&d.jsx("span",{className:ce.violationIcon,title:"Property Access Violation",children:"🚫"}),d.jsxs("span",{className:ce.logLevel,children:["[",j(F.level),"]"]}),F.message]},P)}):d.jsx("div",{className:ce.noLogs,children:"No logs at this level. Lower the log level to see more output."})})]}):d.jsx("div",{className:ce.noLogs,children:"No logs produced by this hook."})]})};return d.jsx("div",{className:ce.hookStagesPanel,children:d.jsxs(ta,{title:"Logging",defaultExpanded:!1,children:[d.jsxs("div",{className:ce.stagesHeader,children:[d.jsx("div",{className:ce.tabs,children:xb.map(E=>d.jsx("button",{className:`${ce.tab} ${m===E?ce.active:""}`,onClick:()=>h(E),children:E},E))}),d.jsx(Dm,{logLevel:c,onLogLevelChange:r})]}),d.jsxs("div",{className:ce.subViewTabs,children:[d.jsx("button",{className:`${ce.subTab} ${_==="logs"?ce.active:""}`,onClick:()=>b("logs"),children:"Logs"}),d.jsx("button",{className:`${ce.subTab} ${_==="inputs"?ce.active:""}`,onClick:()=>b("inputs"),children:"Inputs"}),d.jsx("button",{className:`${ce.subTab} ${_==="outputs"?ce.active:""}`,onClick:()=>b("outputs"),children:"Outputs"})]}),d.jsxs("div",{className:ce.stageContent,children:[_==="logs"&&D(m),_==="inputs"&&z(m),_==="outputs"&&U(m)]})]})})}function zb(i,s){const c={...i};if(!c["content-type"]&&s.trim()){const r=s.trim(),m=r.toLowerCase();r.startsWith("{")||r.startsWith("[")?c["content-type"]="application/json":m.startsWith("<!doctype html")||m.startsWith("<html")?c["content-type"]="text/html":r.startsWith("<?xml")?c["content-type"]="application/xml":r.startsWith("<")?c["content-type"]="text/html":c["content-type"]="text/plain"}return c}const Nb="_proxyWasmView_jh16a_1",jb={proxyWasmView:Nb};function Ob(){const{method:i,url:s,requestHeaders:c,requestBody:r,responseHeaders:m,responseBody:h,setMethod:_,setUrl:b,setRequestHeaders:x,setRequestBody:p,hookResults:T,finalResponse:z,setHookResults:U,setFinalResponse:R,properties:j,dotenv:D,logLevel:E,setProperties:M,mergeProperties:X,setDotenvEnabled:G,setDotenvPath:V,setLogLevel:F,expandedPanels:P,setPanelExpanded:Q,wasmPath:te}=nu(),Ce={request_headers:c,request_body:r,request_trailers:{},response_headers:m,response_body:h,response_trailers:{},properties:j},Se=async()=>{try{const Be=zb(c,r),{sendFullFlow:qe}=await jm(async()=>{const{sendFullFlow:q}=await Promise.resolve().then(()=>Nm);return{sendFullFlow:q}},void 0),{hookResults:Je,finalResponse:dt,calculatedProperties:Ke}=await qe(s,i,{...Ce,request_headers:Be,logLevel:E});if(U(Je),R(dt),console.log("[API] Received calculatedProperties:",Ke),Ke){console.log("[API] Updating properties. Previous:",j);const q={};for(const[w,J]of Object.entries(Ke))q[w]=String(J);console.log("[API] Merging properties:",q),X(q)}}catch(Be){const qe=Be instanceof Error?Be.message:"Unknown error",Je={logs:[],returnValue:void 0,error:qe};U({onRequestHeaders:Je,onRequestBody:Je,onResponseHeaders:Je,onResponseBody:Je}),R(null)}};return d.jsxs("div",{className:jb.proxyWasmView,children:[d.jsx(Cm,{method:i,url:s,wasmLoaded:te!==null,onMethodChange:_,onUrlChange:b,onSend:Se,headers:c,body:r,onHeadersChange:x,onBodyChange:p,defaultHeaders:{"user-agent":{value:"Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0",enabled:!1,placeholder:"Browser user agent"},accept:{value:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",enabled:!1,placeholder:"Browser accept types"},"accept-language":{value:"en-US,en;q=0.9",enabled:!1,placeholder:"Browser languages"},"accept-encoding":{value:"gzip, deflate, br, zstd",enabled:!1,placeholder:"Browser encodings"},host:{value:"",enabled:!1,placeholder:"<Calculated from URL>"},"content-type":{value:"",enabled:!1,placeholder:"<Calculated from body>"},Authorization:{value:"",enabled:!1,placeholder:"Bearer <token>"}},headersLabel:"Request Headers",bodyLabel:"Request Body",headerKeyPlaceholder:"Header name",headerValuePlaceholder:"Header value"}),d.jsx(Om,{enabled:D.enabled,onToggle:G,path:D.path,onPathChange:V,isExpanded:P.dotenv??!1,onExpandedChange:Be=>Q("dotenv",Be)}),d.jsx(I_,{properties:j,onPropertiesChange:M}),d.jsx(Ab,{results:T,hookCall:Ce,logLevel:E,onLogLevelChange:F}),d.jsx(Mm,{response:z})]})}function Rb(){const[i,s]=W.useState(null),{wasmPath:c,wasmFile:r,wasmType:m,loading:h,error:_,loadWasm:b,reloadWasm:x,setWasmLoaded:p,loadingMode:T,loadTime:z,fileSize:U,setUrl:R,setMethod:j,setRequestHeaders:D,setHookResults:E,setFinalResponse:M,hookResults:X,properties:G,mergeProperties:V,setHttpResponse:F,appendHttpLogs:P,setHttpRunnerPort:Q,dotenv:te,loadFromConfig:Ce,wsStatus:Se,setWsStatus:Be}=nu(),{status:qe}=Eg({autoConnect:!0,debug:!0,onEvent:dt});W.useEffect(()=>{Be(qe)},[qe,Be]);const Je=W.useRef(!0);W.useEffect(()=>{(async()=>{try{const J=await Tm();s(J),console.log(`[App] Detected environment: ${J.environment}`)}catch(J){console.error("[App] Failed to initialize environment:",J),s({environment:"node",supportsPathLoading:!0})}})()},[]),W.useEffect(()=>{if(Je.current){Je.current=!1;return}(r||c)&&(console.log(`[App] Dotenv toggle changed to ${te.enabled}, reloading WASM...`),x(te.enabled))},[te.enabled,r,c,x]);function dt(w){switch(console.log(`[App] Received ${w.type} from ${w.source}`),w.type){case"wasm_loaded":console.log(`WASM loaded: ${w.data.filename} (${w.data.size} bytes)`),Q(w.data.runnerPort??null),w.source!=="ui"&&p(w.data.resolvedPath??w.data.filename,w.data.wasmType,w.data.size);break;case"request_started":R(w.data.url),j(w.data.method),D(w.data.headers),E({}),M(null);break;case"hook_executed":const J=w.data.hook;E({...X,[J]:{logs:[],returnValue:w.data.returnCode??void 0,input:w.data.input,output:w.data.output}});break;case"request_completed":if(E(w.data.hookResults),M(w.data.finalResponse),console.log("[WebSocket] request_completed calculatedProperties:",w.data.calculatedProperties),w.data.calculatedProperties){console.log("[WebSocket] Updating properties. Previous:",G);const me={};for(const[g,Y]of Object.entries(w.data.calculatedProperties))me[g]=String(Y);console.log("[WebSocket] Merging properties:",me),V(me)}break;case"request_failed":const le={logs:[],returnValue:void 0,error:w.data.error};E({onRequestHeaders:le,onRequestBody:le,onResponseHeaders:le,onResponseBody:le}),M(null);break;case"http_wasm_request_completed":F(w.data.response);break;case"http_wasm_log":P([w.data]);break;case"properties_updated":V(w.data.properties);break;case"reload_workspace_wasm":console.log(`[App] Reloading workspace WASM: ${w.data.path}`),b(w.data.path,te.enabled);break}}const Ke=async w=>{try{await b(w,te.enabled);const J=typeof w=="string"?w.split("/").pop()||w:w.name;console.log(`✅ WASM loaded via drag & drop: ${J}`)}catch(J){const le=J instanceof Error?J.message:"Unknown error";alert(`❌ Failed to load WASM: ${le}`)}},q=async w=>{try{const J=await w.text(),le=JSON.parse(J);if(!le.request||!le.properties||le.logLevel===void 0)throw new Error("Invalid config file structure");if(Ce(le),le.wasm?.path)try{await b(le.wasm.path,te.enabled),alert(`✅ Configuration loaded from ${w.name}
|
|
33
|
+
`)}catch{return G}},E=()=>{if(z)try{const G=JSON.parse(i.body);return d.jsx(Jt,{data:G,style:{margin:0}})}catch{return d.jsx("pre",{style:{margin:0},children:i.body})}if(p){const G=j(i.body);return d.jsx("pre",{style:{margin:0},children:G})}if(T){const G=D(i.body);return d.jsx("pre",{style:{margin:0},children:G})}return d.jsx("pre",{style:{margin:0},children:i.body})},M=()=>{if(x)return d.jsx("div",{className:_e.imagePreview,children:d.jsx("img",{src:`data:${i.contentType};base64,${i.body}`,alt:"Response preview",className:_e.previewImage,onError:G=>{const F=G.target.parentElement;F&&(F.innerHTML=`<p style="color: #666;">Unable to display image. Content-Type: ${i.contentType}</p><p style="color: #999; font-size: 12px;">The image data may be corrupted or in an unsupported format.</p>`)}})});if(p){if(r&&h){const G=(()=>{try{return new URL(_).pathname||"/"}catch{return"/"}})();return d.jsx("iframe",{src:`http://localhost:${h}${G}`,title:"Live preview",className:_e.htmlPreview})}return d.jsx("iframe",{srcDoc:i.body,title:"Response preview",className:_e.htmlPreview,sandbox:"allow-same-origin"})}return U&&!x?d.jsxs("div",{className:_e.binaryNotice,children:[d.jsxs("p",{children:["Binary content: ",i.contentType]}),d.jsx("p",{style:{fontSize:"12px",marginTop:"8px"},children:'Preview not available for binary content. Check the "Headers" tab for response metadata.'})]}):d.jsxs("div",{className:_e.binaryNotice,children:[d.jsxs("p",{children:["Preview not available for content type: ",i.contentType]}),d.jsx("p",{style:{fontSize:"12px",marginTop:"8px"},children:'Switch to "Body" tab to view raw content.'})]})},X=()=>{const G=Object.entries(i.headers);return G.length===0?d.jsx("div",{className:_e.noHeaders,children:"No headers received"}):d.jsx("div",{className:_e.headersList,children:G.map(([V,F])=>d.jsxs("div",{className:_e.headerItem,children:[d.jsxs("span",{className:_e.headerKey,children:[V,":"]}),d.jsx("span",{className:_e.headerValue,children:F})]},V))})};return d.jsx("div",{className:_e.responsePanel,children:d.jsxs(ta,{title:"Response",defaultExpanded:!0,headerExtra:d.jsxs("div",{className:_e.responseStatus,children:[d.jsx("span",{style:{color:b(i.status),fontWeight:600,fontSize:"13px"},children:i.status===0?"ERROR":`${i.status} ${i.statusText}`}),d.jsx("span",{style:{color:"#666",marginLeft:"12px",fontSize:"12px"},children:i.contentType})]}),children:[d.jsxs("div",{className:_e.tabs,children:[d.jsxs("div",{className:_e.tabButtons,children:[!U&&d.jsx("button",{className:`${_e.tab} ${s==="body"?_e.active:""}`,onClick:()=>c("body"),children:"Body"}),R&&d.jsx("button",{className:`${_e.tab} ${s==="preview"?_e.active:""}`,onClick:()=>c("preview"),children:"Preview"}),d.jsx("button",{className:`${_e.tab} ${s==="headers"?_e.active:""}`,onClick:()=>c("headers"),children:"Headers"})]}),p&&d.jsxs("div",{className:_e.previewToolbar,children:[d.jsx("button",{className:`${_e.toolbarButton} ${r?_e.toolbarButtonActive:""}`,onClick:()=>m(G=>!G),disabled:!h,title:h?"Toggle live preview (loads assets from running WASM)":"No HTTP WASM runner active",children:"● Live"}),d.jsx("button",{className:_e.toolbarButton,onClick:()=>{const G=`http://localhost:${h}/`;window!==window.top?window.parent.postMessage({command:"openExternal",url:G},"*"):window.open(G,"_blank")},disabled:!h,title:h?"Open in system browser":"No HTTP WASM runner active",children:"↗ Open in Browser"})]})]}),d.jsxs("div",{className:_e.responseContent,children:[s==="body"&&!U&&d.jsx("div",{className:_e.responseBody,children:E()}),s==="preview"&&R&&d.jsx("div",{className:_e.responsePreview,children:M()}),s==="headers"&&d.jsx("div",{className:_e.responseHeaders,children:X()})]})]})})}const __="_logsViewer_1lb7i_1",b_="_logsContainer_1lb7i_46",S_="_logEntry_1lb7i_59",T_="_logLevel_1lb7i_65",E_="_logMessage_1lb7i_70",x_="_trace_1lb7i_78",A_="_debug_1lb7i_82",z_="_info_1lb7i_86",N_="_warn_1lb7i_90",j_="_error_1lb7i_94",O_="_critical_1lb7i_98",R_="_emptyState_1lb7i_103",C_="_noLogs_1lb7i_117",ft={logsViewer:__,logsContainer:b_,logEntry:S_,logLevel:T_,logMessage:E_,trace:x_,debug:A_,info:z_,warn:N_,error:j_,critical:O_,emptyState:R_,noLogs:C_},M_=["TRACE","DEBUG","INFO","WARN","ERROR","CRITICAL"],D_={0:ft.trace,1:ft.debug,2:ft.info,3:ft.warn,4:ft.error,5:ft.critical};function q_({logs:i,logLevel:s}){const c=(h,_)=>h.filter(b=>b.level>=_),r=h=>M_[h]||"UNKNOWN",m=c(i,s);return i.length===0?d.jsx("div",{className:ft.emptyState,children:d.jsx("p",{children:"No logs captured"})}):d.jsx("div",{className:ft.logsViewer,children:d.jsx("pre",{className:ft.logsContainer,children:m.length>0?m.map((h,_)=>{const b=D_[h.level]||ft.trace;return d.jsxs("div",{className:ft.logEntry,children:[d.jsxs("span",{className:`${ft.logLevel} ${b}`,children:["[",r(h.level),"]"]}),d.jsx("span",{className:ft.logMessage,children:h.message})]},_)}):d.jsx("div",{className:ft.noLogs,children:"No logs at this level. Lower the log level to see more output."})})})}const H_="_logLevelSelector_1dmmk_1",w_={logLevelSelector:H_};function Dm({logLevel:i,onLogLevelChange:s}){const c=r=>{s(parseInt(r.target.value,10))};return d.jsxs("div",{className:w_.logLevelSelector,children:[d.jsx("label",{children:"Log Level:"}),d.jsxs("select",{value:i,onChange:c,children:[d.jsx("option",{value:"0",children:"Trace (0)"}),d.jsx("option",{value:"1",children:"Debug (1)"}),d.jsx("option",{value:"2",children:"Info (2)"}),d.jsx("option",{value:"3",children:"Warn (3)"}),d.jsx("option",{value:"4",children:"Error (4)"}),d.jsx("option",{value:"5",children:"Critical (5)"})]})]})}const U_="_httpWasmView_12ui9_1",B_="_panels_12ui9_9",L_="_hint_12ui9_35",Y_="_loggingContent_12ui9_44",G_="_loggingHeader_12ui9_50",V_="_logTab_12ui9_58",X_="_tabLabel_12ui9_66",Q_="_loggingControls_12ui9_71",Z_="_clearLogsButton_12ui9_77",fl={httpWasmView:U_,panels:B_,hint:L_,loggingContent:Y_,loggingHeader:G_,logTab:V_,tabLabel:X_,loggingControls:Q_,clearLogsButton:Z_},J_=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"];function K_(){const i=W.useRef(null),[s,c]=W.useState(0),{httpMethod:r,httpUrl:m,httpRequestHeaders:h,httpRequestBody:_,httpIsExecuting:b,httpResponse:x,httpLogs:p,wasmPath:T,dotenv:z,setHttpMethod:U,setHttpUrl:R,setHttpRequestHeaders:j,setHttpRequestBody:D,setHttpLogs:E,setDotenvEnabled:M,setDotenvPath:X,executeHttpRequest:G,expandedPanels:V,setPanelExpanded:F}=nu(),P=te=>{R(Hi+te)},Q=()=>{G()};return d.jsx("div",{className:fl.httpWasmView,children:d.jsxs("div",{className:fl.panels,children:[d.jsx(Cm,{method:r,url:m,wasmLoaded:T!==null,onMethodChange:U,onUrlChange:P,onSend:Q,methods:J_,urlPrefix:Hi,urlPlaceholder:"",isExecuting:b,executingText:"Executing...",urlInputRef:i,headers:h,body:_,onHeadersChange:j,onBodyChange:D,headersLabel:"Request Headers",bodyLabel:"Request Body",bodyRows:10,headerKeyPlaceholder:"Header name (e.g., Content-Type)",headerValuePlaceholder:"Header value (e.g., application/json)",additionalContent:T?void 0:d.jsx("div",{className:fl.hint,children:"Load a WASM file first"})}),d.jsx(Om,{enabled:z.enabled,onToggle:M,path:z.path,onPathChange:X,isExpanded:V.dotenv??!1,onExpandedChange:te=>F("dotenv",te)}),d.jsx(ta,{title:"Logging",defaultExpanded:p.length>0,children:d.jsxs("div",{className:fl.loggingContent,children:[d.jsxs("div",{className:fl.loggingHeader,children:[d.jsxs("div",{className:fl.logTab,children:[d.jsx("span",{className:fl.tabLabel,children:"Logs"}),p.length>0&&d.jsx("button",{className:fl.clearLogsButton,onClick:()=>E([]),title:"Clear logs",children:"🧹"})]}),d.jsx("div",{className:fl.loggingControls,children:d.jsx(Dm,{logLevel:s,onLogLevelChange:c})})]}),d.jsx(q_,{logs:p,logLevel:s})]})}),d.jsx(Mm,{response:x})]})})}const $_="_countryPresets_1xq35_1",k_="_countryLabel_1xq35_7",W_="_flag_1xq35_14",_o={countryPresets:$_,countryLabel:k_,flag:W_},qm={luxembourg:{code:"LU",name:"Luxembourg",city:"Luxembourg",geoLat:"49.6116",geoLong:"6.1319",region:"Luxembourg",continent:"Europe",flag:"🇱🇺"},germany:{code:"DE",name:"Germany",city:"Frankfurt",geoLat:"50.1109",geoLong:"8.6821",region:"Hesse",continent:"Europe",flag:"🇩🇪"}},Hm=i=>{const s=qm[i];return{"request.country":{value:s.code,placeholder:s.code},"request.city":{value:s.city,placeholder:s.city},"request.geo.lat":{value:s.geoLat,placeholder:s.geoLat},"request.geo.long":{value:s.geoLong,placeholder:s.geoLong},"request.region":{value:s.region,placeholder:s.region},"request.continent":{value:s.continent,placeholder:s.continent},"request.country.name":{value:s.name,placeholder:s.name},"request.url":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.host":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.path":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.scheme":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.extension":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.query":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.x_real_ip":{value:"203.0.113.42",placeholder:"Client IP address",enabled:!1},"request.asn":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0},"request.var":{value:"",placeholder:"<Calculated>",enabled:!0,readOnly:!0}}},om=i=>{const s=Hm(i),c={};for(const[r,m]of Object.entries(s))if(typeof m=="string")c[r]=m;else{const h=m.enabled??!0,_=m.readOnly??!1;h&&!_&&m.value&&(c[r]=m.value)}return c};function F_({value:i,onChange:s}){const[c,r]=W.useState("luxembourg");W.useEffect(()=>{Object.keys(i).length===0&&s(om(c))},[]);const m=h=>{r(h),s(om(h))};return d.jsxs("div",{children:[d.jsx("div",{className:_o.countryPresets,children:Object.entries(qm).map(([h,_])=>d.jsxs("label",{className:_o.countryLabel,children:[d.jsx("input",{type:"radio",name:"country",value:h,checked:c===h,onChange:()=>m(h)}),d.jsx("span",{className:_o.flag,children:_.flag}),d.jsx("span",{children:_.name})]},h))}),d.jsx(Rm,{value:i,onChange:s,keyPlaceholder:"Property path",valuePlaceholder:"Property value",disableDelete:!0,defaultValues:Hm(c)},c)]})}function I_({properties:i,onPropertiesChange:s}){return d.jsx(ta,{title:"Server Properties",defaultExpanded:!1,children:d.jsx(F_,{value:i,onChange:s})})}const P_="_hookStagesPanel_12u1g_1",eb="_stagesHeader_12u1g_9",tb="_tabs_12u1g_18",lb="_tab_12u1g_18",nb="_active_12u1g_43",ab="_subViewTabs_12u1g_70",ub="_subTab_12u1g_78",ib="_stageContent_12u1g_101",cb="_hookInputs_12u1g_107",sb="_hookLogs_12u1g_108",ob="_hookOutputs_12u1g_109",rb="_metadata_12u1g_113",fb="_section_12u1g_119",db="_noData_12u1g_123",hb="_error_12u1g_129",mb="_returnValue_12u1g_139",yb="_outputHeader_12u1g_145",pb="_outputTitle_12u1g_152",vb="_filterInfo_12u1g_158",gb="_logsContainer_12u1g_163",_b="_logEntry_12u1g_172",bb="_logLevel_12u1g_53",Sb="_noLogs_12u1g_181",Tb="_accessViolation_12u1g_187",Eb="_violationIcon_12u1g_203",ce={hookStagesPanel:P_,stagesHeader:eb,tabs:tb,tab:lb,active:nb,subViewTabs:ab,subTab:ub,stageContent:ib,hookInputs:cb,hookLogs:sb,hookOutputs:ob,metadata:rb,section:fb,noData:db,error:hb,returnValue:mb,outputHeader:yb,outputTitle:pb,filterInfo:vb,logsContainer:gb,logEntry:_b,logLevel:bb,noLogs:Sb,accessViolation:Tb,violationIcon:Eb},xb=["onRequestHeaders","onRequestBody","onResponseHeaders","onResponseBody"];function Ab({results:i,hookCall:s,logLevel:c,onLogLevelChange:r}){const[m,h]=W.useState("onRequestHeaders"),[_,b]=W.useState("logs"),x=E=>(Object.entries(E).find(([X])=>X.toLowerCase()==="content-type")?.[1]||"").includes("application/json"),p=(E,M)=>{if(x(M))try{return JSON.parse(E)}catch{return E}return E},T=E=>{const M=i[E];if(M?.input)switch(E){case"onRequestHeaders":return{headers:M.input.request.headers,metadata:"Request headers as received by this hook on the server (BEFORE modification)"};case"onRequestBody":return{body:M.input.request.body,headers:M.input.request.headers,metadata:"Request body and headers as received by this hook on the server (BEFORE modification)"};case"onResponseHeaders":return{headers:M.input.response.headers,requestHeaders:M.input.request.headers,metadata:"Response headers as received by this hook (with modified request headers from previous hooks)"};case"onResponseBody":return{body:M.input.response.body,headers:M.input.response.headers,requestHeaders:M.input.request.headers,metadata:"Response body and headers as received by this hook on the server"};default:return{metadata:"No input data"}}switch(E){case"onRequestHeaders":return{headers:s.request_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onRequestBody":return{body:s.request_body||"",headers:s.request_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onResponseHeaders":return{headers:s.response_headers||{},metadata:"(Not yet executed - showing initial state)"};case"onResponseBody":return{body:s.response_body||"",headers:s.response_headers||{},metadata:"(Not yet executed - showing initial state)"};default:return{metadata:"No input data"}}},z=E=>{const M=T(E),X=i[E];return d.jsxs("div",{className:ce.hookInputs,children:[d.jsx("p",{className:ce.metadata,children:M.metadata}),"requestHeaders"in M&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.requestHeaders,title:"Request Headers (Modified by Previous Hooks)"})}),"headers"in M&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.headers,title:E.includes("Response")?"Response Headers":"Request Headers"})}),"body"in M&&M.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(M.body,M.headers||{}),title:E.includes("Response")?"Response Body":"Request Body"})}),X?.input?.properties&&Object.keys(X.input.properties).length>0&&d.jsx("div",{children:d.jsx(Jt,{data:X.input.properties,title:"Properties (Before Hook Execution)"})})]})},U=E=>{const M=i[E];if(!M?.output)return d.jsx("div",{className:ce.noData,children:'No output yet. Click "Send" to execute this hook.'});const X=M.output,G=M.input;return d.jsxs("div",{className:ce.hookOutputs,children:[d.jsx("p",{className:ce.metadata,children:"Data produced by this hook AFTER execution (modifications made by WASM)"}),E.includes("Request")&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:X.request.headers,compareWith:G?.request.headers,title:"Request Headers (Modified)"})}),E==="onRequestBody"&&X.request.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(X.request.body,X.request.headers),compareWith:G?.request.body?p(G.request.body,G.request.headers):void 0,title:"Request Body (Modified)"})}),E.includes("Response")&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:X.response.headers,compareWith:G?.response.headers,title:"Response Headers (Modified)"})}),E==="onResponseBody"&&X.response.body&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:p(X.response.body,X.response.headers),compareWith:G?.response.body?p(G.response.body,G.response.headers):void 0,title:"Response Body (Modified)"})})]}),M?.output?.properties&&Object.keys(M.output.properties).length>0&&d.jsx("div",{className:ce.section,children:d.jsx(Jt,{data:M.output.properties,compareWith:M.input?.properties,title:"Properties (After Hook Execution)"})})]})},R=(E,M)=>E.filter(X=>X.level>=M),j=E=>["TRACE","DEBUG","INFO","WARN","ERROR","CRITICAL"][E]||"UNKNOWN",D=E=>{const M=i[E];if(!M)return d.jsx("div",{className:ce.noData,children:'No logs yet. Click "Send" to execute this hook.'});const X=M.logs&&M.logs.length>0?R(M.logs,c):[],G=M.logs?.length||0,V=X.length;return d.jsxs("div",{className:ce.hookLogs,children:[M.error&&d.jsxs("div",{className:ce.error,children:["Error: ",M.error]}),M.returnValue!==void 0&&d.jsxs("div",{className:ce.returnValue,children:[d.jsx("strong",{children:"Return Code:"})," ",M.returnValue]}),G>0?d.jsxs("div",{children:[d.jsxs("div",{className:ce.outputHeader,children:[d.jsx("h4",{className:ce.outputTitle,children:"Output"}),V<G&&d.jsxs("span",{className:ce.filterInfo,children:["Showing ",V," of ",G," logs (filtered by level)"]})]}),d.jsx("pre",{className:ce.logsContainer,children:X.length>0?X.map((F,P)=>{const Q=F.message.includes("[property access denied]"),te=Q?`${ce.logEntry} ${ce.accessViolation}`:ce.logEntry;return d.jsxs("div",{className:te,children:[Q&&d.jsx("span",{className:ce.violationIcon,title:"Property Access Violation",children:"🚫"}),d.jsxs("span",{className:ce.logLevel,children:["[",j(F.level),"]"]}),F.message]},P)}):d.jsx("div",{className:ce.noLogs,children:"No logs at this level. Lower the log level to see more output."})})]}):d.jsx("div",{className:ce.noLogs,children:"No logs produced by this hook."})]})};return d.jsx("div",{className:ce.hookStagesPanel,children:d.jsxs(ta,{title:"Logging",defaultExpanded:!1,children:[d.jsxs("div",{className:ce.stagesHeader,children:[d.jsx("div",{className:ce.tabs,children:xb.map(E=>d.jsx("button",{className:`${ce.tab} ${m===E?ce.active:""}`,onClick:()=>h(E),children:E},E))}),d.jsx(Dm,{logLevel:c,onLogLevelChange:r})]}),d.jsxs("div",{className:ce.subViewTabs,children:[d.jsx("button",{className:`${ce.subTab} ${_==="logs"?ce.active:""}`,onClick:()=>b("logs"),children:"Logs"}),d.jsx("button",{className:`${ce.subTab} ${_==="inputs"?ce.active:""}`,onClick:()=>b("inputs"),children:"Inputs"}),d.jsx("button",{className:`${ce.subTab} ${_==="outputs"?ce.active:""}`,onClick:()=>b("outputs"),children:"Outputs"})]}),d.jsxs("div",{className:ce.stageContent,children:[_==="logs"&&D(m),_==="inputs"&&z(m),_==="outputs"&&U(m)]})]})})}function zb(i,s){const c={...i};if(!c["content-type"]&&s.trim()){const r=s.trim(),m=r.toLowerCase();r.startsWith("{")||r.startsWith("[")?c["content-type"]="application/json":m.startsWith("<!doctype html")||m.startsWith("<html")?c["content-type"]="text/html":r.startsWith("<?xml")?c["content-type"]="application/xml":r.startsWith("<")?c["content-type"]="text/html":c["content-type"]="text/plain"}return c}const Nb="_proxyWasmView_jh16a_1",jb={proxyWasmView:Nb};function Ob(){const{method:i,url:s,requestHeaders:c,requestBody:r,responseHeaders:m,responseBody:h,setMethod:_,setUrl:b,setRequestHeaders:x,setRequestBody:p,hookResults:T,finalResponse:z,setHookResults:U,setFinalResponse:R,properties:j,dotenv:D,logLevel:E,setProperties:M,mergeProperties:X,setDotenvEnabled:G,setDotenvPath:V,setLogLevel:F,expandedPanels:P,setPanelExpanded:Q,wasmPath:te}=nu(),Ce={request_headers:c,request_body:r,request_trailers:{},response_headers:m,response_body:h,response_trailers:{},properties:j},Se=async()=>{try{const Be=zb(c,r),{sendFullFlow:qe}=await jm(async()=>{const{sendFullFlow:q}=await Promise.resolve().then(()=>Nm);return{sendFullFlow:q}},void 0),{hookResults:Je,finalResponse:dt,calculatedProperties:Ke}=await qe(s,i,{...Ce,request_headers:Be,logLevel:E});if(U(Je),R(dt),console.log("[API] Received calculatedProperties:",Ke),Ke){console.log("[API] Updating properties. Previous:",j);const q={};for(const[w,J]of Object.entries(Ke))q[w]=String(J);console.log("[API] Merging properties:",q),X(q)}}catch(Be){const qe=Be instanceof Error?Be.message:"Unknown error",Je={logs:[],returnValue:void 0,error:qe};U({onRequestHeaders:Je,onRequestBody:Je,onResponseHeaders:Je,onResponseBody:Je}),R(null)}};return d.jsxs("div",{className:jb.proxyWasmView,children:[d.jsx(Cm,{method:i,url:s,wasmLoaded:te!==null,onMethodChange:_,onUrlChange:b,onSend:Se,headers:c,body:r,onHeadersChange:x,onBodyChange:p,defaultHeaders:{"user-agent":{value:"Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0",enabled:!1,placeholder:"Browser user agent"},accept:{value:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",enabled:!1,placeholder:"Browser accept types"},"accept-language":{value:"en-US,en;q=0.9",enabled:!1,placeholder:"Browser languages"},"accept-encoding":{value:"gzip, deflate, br, zstd",enabled:!1,placeholder:"Browser encodings"},host:{value:"",enabled:!1,placeholder:"<Calculated from URL>"},"content-type":{value:"",enabled:!1,placeholder:"<Calculated from body>"},Authorization:{value:"",enabled:!1,placeholder:"Bearer <token>"},"x-debugger-status":{value:"",enabled:!1,placeholder:"HTTP status code for built-in responder"},"x-debugger-content":{value:"",enabled:!1,placeholder:"body-only | status-only for built-in responder"}},headersLabel:"Request Headers",bodyLabel:"Request Body",headerKeyPlaceholder:"Header name",headerValuePlaceholder:"Header value"}),d.jsx(Om,{enabled:D.enabled,onToggle:G,path:D.path,onPathChange:V,isExpanded:P.dotenv??!1,onExpandedChange:Be=>Q("dotenv",Be)}),d.jsx(I_,{properties:j,onPropertiesChange:M}),d.jsx(Ab,{results:T,hookCall:Ce,logLevel:E,onLogLevelChange:F}),d.jsx(Mm,{response:z})]})}function Rb(){const[i,s]=W.useState(null),{wasmPath:c,wasmFile:r,wasmType:m,loading:h,error:_,loadWasm:b,reloadWasm:x,setWasmLoaded:p,loadingMode:T,loadTime:z,fileSize:U,setUrl:R,setMethod:j,setRequestHeaders:D,setHookResults:E,setFinalResponse:M,hookResults:X,properties:G,mergeProperties:V,setHttpResponse:F,appendHttpLogs:P,setHttpRunnerPort:Q,dotenv:te,loadFromConfig:Ce,wsStatus:Se,setWsStatus:Be}=nu(),{status:qe}=Eg({autoConnect:!0,debug:!0,onEvent:dt});W.useEffect(()=>{Be(qe)},[qe,Be]);const Je=W.useRef(!0);W.useEffect(()=>{(async()=>{try{const J=await Tm();s(J),console.log(`[App] Detected environment: ${J.environment}`)}catch(J){console.error("[App] Failed to initialize environment:",J),s({environment:"node",supportsPathLoading:!0})}})()},[]),W.useEffect(()=>{if(Je.current){Je.current=!1;return}(r||c)&&(console.log(`[App] Dotenv toggle changed to ${te.enabled}, reloading WASM...`),x(te.enabled))},[te.enabled,r,c,x]);function dt(w){switch(console.log(`[App] Received ${w.type} from ${w.source}`),w.type){case"wasm_loaded":console.log(`WASM loaded: ${w.data.filename} (${w.data.size} bytes)`),Q(w.data.runnerPort??null),w.source!=="ui"&&p(w.data.resolvedPath??w.data.filename,w.data.wasmType,w.data.size);break;case"request_started":R(w.data.url),j(w.data.method),D(w.data.headers),E({}),M(null);break;case"hook_executed":const J=w.data.hook;E({...X,[J]:{logs:[],returnValue:w.data.returnCode??void 0,input:w.data.input,output:w.data.output}});break;case"request_completed":if(E(w.data.hookResults),M(w.data.finalResponse),console.log("[WebSocket] request_completed calculatedProperties:",w.data.calculatedProperties),w.data.calculatedProperties){console.log("[WebSocket] Updating properties. Previous:",G);const me={};for(const[g,Y]of Object.entries(w.data.calculatedProperties))me[g]=String(Y);console.log("[WebSocket] Merging properties:",me),V(me)}break;case"request_failed":const le={logs:[],returnValue:void 0,error:w.data.error};E({onRequestHeaders:le,onRequestBody:le,onResponseHeaders:le,onResponseBody:le}),M(null);break;case"http_wasm_request_completed":F(w.data.response);break;case"http_wasm_log":P([w.data]);break;case"properties_updated":V(w.data.properties);break;case"reload_workspace_wasm":console.log(`[App] Reloading workspace WASM: ${w.data.path}`),b(w.data.path,te.enabled);break}}const Ke=async w=>{try{await b(w,te.enabled);const J=typeof w=="string"?w.split("/").pop()||w:w.name;console.log(`✅ WASM loaded via drag & drop: ${J}`)}catch(J){const le=J instanceof Error?J.message:"Unknown error";alert(`❌ Failed to load WASM: ${le}`)}},q=async w=>{try{const J=await w.text(),le=JSON.parse(J);if(!le.request||!le.properties||le.logLevel===void 0)throw new Error("Invalid config file structure");if(Ce(le),le.wasm?.path)try{await b(le.wasm.path,te.enabled),alert(`✅ Configuration loaded from ${w.name}
|
|
34
34
|
🚀 WASM auto-loaded: ${le.wasm.path}`)}catch{alert(`✅ Configuration loaded from ${w.name}
|
|
35
35
|
⚠️ WASM path not found. Please load WASM manually.`)}else alert(`✅ Configuration loaded from ${w.name}!`)}catch(J){const le=J instanceof Error?J.message:"Unknown error";alert(`❌ Failed to load config: ${le}`)}};return d.jsx(C0,{onWasmDrop:Ke,onConfigDrop:q,children:d.jsxs("div",{className:"container",children:[d.jsxs("header",{children:[d.jsx("h1",{children:m==="http-wasm"?"HTTP WASM Debugger":m==="proxy-wasm"?"Proxy-WASM Test Runner":"FastEdge WASM Debugger"}),d.jsx(i0,{status:Se})]}),_&&d.jsx("div",{className:"error",children:_}),d.jsx(Ig,{onFileLoad:w=>b(w,te.enabled),onPathLoad:w=>b(w,te.enabled),loading:h,wasmPath:c,loadingMode:T,loadTime:z,fileSize:U,fileName:c,defaultTab:"path"}),d.jsx(E0,{}),h&&d.jsx(r0,{message:"Loading and detecting WASM type..."}),!h&&!c&&d.jsx("div",{className:"empty-state",children:d.jsx("p",{children:"👆 Load a WASM binary to get started"})}),!h&&c&&m==="http-wasm"&&d.jsx(K_,{}),!h&&c&&m==="proxy-wasm"&&d.jsx(Ob,{})]})})}yv.createRoot(document.getElementById("root")).render(d.jsx(Rb,{}));
|
package/dist/frontend/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Proxy Runner</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-CjNwdWIi.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-DdlINQc_.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|