1import{p as le,e as Ve,i as C,d as ce,f as He,b as Q,k as ve,u as pe}from"./i18n-BlwlR3g4.js";import{R as Re,aa as ze,a1 as I,G as We,M as $,w as e,a2 as Be,t as W,z as b,Z as k,a as p,T as De,a3 as g,x as r,U as ue,V as l,X as u,W as _,Y as d,a6 as Le,S as Ue,ak as $e,a0 as te,a7 as fe}from"./index-B5CnGmTK.js";import{b as Pe}from"./input-2DWUN4z0.js";import"./StreamingBar.svelte_svelte_type_style_lang-lroHh1Vk.js";import"./ScrollFade.svelte_svelte_type_style_lang-3SfI1hia.js";import{C as Te}from"./Code-DsrZEN77.js";/* empty css */import{M as Ze}from"./Index.svelte_svelte_type_style_lang-BaIYGPu-.js";import"./MarkdownCode-CCjfggqx.js";import"./index-B_pwUImq.js";/* empty css */import"./html-Dw1CmxWF.js";import"./snippet-qnvrkjTU.js";import"./actions-B4qJajJp.js";import"./utils.svelte-Cn7aBojF.js";import"./clone-CePNcxlk.js";import"./Check-CLEdriM2.js";import"./Copy-DUUXwOFO.js";import"./IconButtonWrapper-D8MDVsLy.js";import"./prism-python-Zujh3v0-.js";var qe=_('<span class="added svelte-1s2fnws"> </span>'),Qe=_('<span class="removed svelte-1s2fnws"> </span>'),Ie=_('<span class="diff-stats svelte-1s2fnws"><!> <!></span>'),je=_('<button class="undo-button svelte-1s2fnws" title="Undo this change">Undo</button>'),Ge=_('<div><div class="message-content svelte-1s2fnws"><span class="message-text svelte-1s2fnws"><!></span> <!></div></div>'),Xe=_('<div class="no-messages svelte-1s2fnws">No messages yet</div>'),Ye=_('<button class="starter-query-button svelte-1s2fnws"> </button>'),Ae=_('<div class="starter-queries-container svelte-1s2fnws"><div class="starter-queries svelte-1s2fnws"></div></div>'),Ke=_('<div class="message-history svelte-1s2fnws"><!> <!> <!></div>'),Ne=_('<div class="code-content svelte-1s2fnws"><div class="code-editor-container svelte-1s2fnws"><!></div> <button><!></button> <button class="deploy-to-spaces-button svelte-1s2fnws"><span class="button-content svelte-1s2fnws">Deploy to <svg class="spaces-logo svelte-1s2fnws" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" preserveAspectRatio="xMidYMid meet" viewBox="0 0 39 40"><path d="M6.3712 2.04427C3.7183 2.04427 1.56771 4.19486 1.56771 6.84776V18.3546V18.6544V32.7341C1.56771 35.3868 3.71818 37.5377 6.3712 37.5377H17.878H20.7507H32.2575C34.9104 37.5377 37.0612 35.387 37.0612 32.7341V21.6204C37.0612 20.177 36.4252 18.8839 35.4189 18.004C36.4576 16.3895 37.0612 14.4666 37.0612 12.4046C37.0612 6.68274 32.4225 2.04427 26.7007 2.04427C24.6388 2.04427 22.7159 2.64776 21.1014 3.68647C20.2214 2.6802 18.9282 2.04427 17.4849 2.04427H6.3712Z" fill="black" class="stroke-white dark:stroke-white/10" stroke-width="3.07552"></path><path d="M9.56855 23.5001C8.8406 23.5001 8.25047 24.0902 8.25047 24.8182V29.5361C8.25047 30.2641 8.8406 30.8542 9.56855 30.8542H14.2864C15.0144 30.8542 15.6045 30.2641 15.6045 29.5361V24.8182C15.6045 24.0902 15.0143 23.5001 14.2864 23.5001H9.56855Z" fill="#FF3270"></path><path d="M24.3409 23.5001C23.613 23.5001 23.0228 24.0902 23.0228 24.8182V29.5361C23.0228 30.2641 23.613 30.8542 24.3409 30.8542H29.0588C29.7868 30.8542 30.3769 30.2641 30.3769 29.5361V24.8182C30.3769 24.0902 29.7868 23.5001 29.0588 23.5001H24.3409Z" fill="#861FFF"></path><path d="M9.56855 8.72815C8.8406 8.72815 8.25047 9.31827 8.25047 10.0462V14.7641C8.25047 15.4921 8.8406 16.0822 9.56855 16.0822H14.2864C15.0144 16.0822 15.6045 15.4921 15.6045 14.7641V10.0462C15.6045 9.31827 15.0143 8.72815 14.2864 8.72815H9.56855Z" fill="#097EFF"></path><path d="M26.6999 8.72815C24.6692 8.72815 23.0228 10.3744 23.0228 12.4052C23.0228 14.4359 24.6692 16.0822 26.6999 16.0822C28.7306 16.0822 30.3769 14.4359 30.3769 12.4052C30.3769 10.3744 28.7306 8.72815 26.6999 8.72815Z" fill="#FFD702"></path></svg> <span style="font-weight: 600;">Spaces</span></span></button></div>'),Je=_('<div class="vibe-editor svelte-1s2fnws"><button class="resize-handle svelte-1s2fnws" aria-label="Resize sidebar"></button> <div class="tab-header svelte-1s2fnws"><button>
1Chat</button> <button>Code <!></button></div> <div class="tab-content svelte-1s2fnws"><!></div> <div class="input-section svelte-1s2fnws"><div class="powered-by svelte-1s2fnws">Powered by: <code>gpt-oss</code></div> <textarea placeholder="What can I add or change?" class="prompt-input svelte-1s2fnws"></textarea> <button class="submit-button svelte-1s2fnws">Send</button></div></div>');function gt(me,j){Re(j,!1);let E=le(j,"app",12),F=le(j,"root",12),V=g(""),G=g(350),X=!1,se=g(),M=g("chat"),B=g(""),v=g(null),n=g([]),D=g();const P=(t="smooth")=>{e(D)&&e(D).scrollTo({top:e(D).scrollHeight,behavior:t})};let T=g([]);(async()=>E().post_data(`${F()}/gradio_api/vibe-starter-queries/`,{}).then(async([a,i])=>{if(i!==200)throw new Error(`Error: ${i}`);r(T,a.starter_queries)}).catch(async a=>{console.error("Failed to fetch starter queries:",a)}))();const Y=async t=>{const a=t||e(V);if(a.trim()==="")return;r(v,null);const i=e(n).length;r(n,[...e(n),{text:a,isBot:!1}]);const f=e(n).length;r(n,[...e(n),{text:"Working...",isBot:!0,isPending:!0}]),await $(),P();const y=a;t||r(V,""),E().post_data(`${F()}/gradio_api/vibe-edit/`,{prompt:y}).then(async([c,o])=>{if(o!==200)throw new Error(`Error: ${o}`);const s=c;r(v,s.diff_stats),r(n,e(n).map((m,h)=>h===i?{...m,hash:s.hash}:m)),r(n,e(n).map((m,h)=>h===f?{text:s.reasoning?s.reasoning:"Done.",isBot:!0,isPending:!1}:m)),await $(),P()}).catch(async c=>{r(n,e(n).map((o,s)=>s===f?{text:"Error occurred.",isBot:!0,isPending:!1}:o)),await $(),P()})},he=async t=>{await Y(t)},_e=async(t,a)=>{try{await E().post_data(`${F()}/gradio_api/undo-vibe-edit/`,{hash:t}),r(v,null);const i=e(n)[a];r(V,i.text),r(n,e(n).slice(0,a))}catch(i){console.error("Failed to undo:",i)}},we=t=>{t.preventDefault(),X=!0,document.addEventListener("mousemove",A),document.addEventListener("mouseup",K),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},A=t=>{if(!X)return;const a=250,i=Math.min(800,window.innerWidth*.5),f=window.innerWidth-t.clientX;r(G,Math.max(a,Math.min(i,f))),window.dispatchEvent(new CustomEvent("vibeEditorResize",{detail:{width:e(G)}}))},K=()=>{X=!1,document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",K),document.body.style.cursor="",document.body.style.userSelect=""},be=async()=>{try{const t=await fetch(`${F()}/gradio_api/vibe-code/`,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.ok){const a=await t.json();r(B,a.code)}}catch(t){console.error("Failed to fetch code:",t)}};let z=g(!1);const ge=async()=>{try{await E().post_data(`${F()}/gradio_api/vibe-code/`,{code:e(B)}),r(z,!0),setTimeout(()=>{r(z,!1)},1e3)}catch(t){console.error("Failed to update code:",t)}};function ye(){const t="https://huggingface.co/new-space",a=new URLSearchParams({name:"new-space",sdk:"gradio"}),i=e(B).trimStart();a.append("files[0][path]","app.py"),a.append("files[0][content]",i),window.open(`${t}?${a.toString()}`,"_blank")?.focus()}ze(()=>()=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",K)}),I(()=>We(E()),()=>{E(),be()}),I(()=>(e(M),$),()=>{e(M)==="chat"&&$().then(()=>P("auto"))}),I(()=>e(z),()=>{e(z)}),I(()=>e(T),()=>{e(T)}),Be();var xe={get app(){return E()},set app(t){E(t),ue()},get root(){return F()},set root(t){F(t),ue()}};Ve();var L=Je(),ae=l(L),N=u(ae,2),J=l(N);let oe;var Z=u(J,2);let re;var Ce=u(l(Z));{var ke=t=>{var a=Ie(),i=l(a);{var f=c=>{var o=qe(),s=l(o);d(o),W(()=>te(s,`+${e(v),b(()=>e(v).lines_added)??""}`)),p(c,o)};C(i,c=>{e(v),b(()=>e(v).lines_added>0)&&c(f)})}var y=u(i,2);{var S=c=>{var o=Qe(),s=l(o);d(o),W(()=>te(s,`-${e(v),b(()=>e(v).lines_removed)??""}`)),p(c,o)};C(y,c=>{e(v),b(()=>e(v).lines_removed>0)&&c(S)})}d(a),p(t,a)};C(Ce,t=>{e(v),b(()=>e(v)&&(e(v).lines_added>0||e(v).lines_removed>0))&&t(ke)})}d(Z),d(N);var O=u(N,2),Ee=l(O);{var Me=t=>{var a=Ke(),i=l(a);ve(i,1,()=>e(n),pe,(o,s,m)=>{var h=Ge();let H;var x=l(h),R=l(x),w=l(R);Ze(w,{get value(){return e(s),b(()=>e(s).text)},latex_delimiters:[],theme_mode:"system"}),d(R);var U=u(R,2);{var Fe=ee=>{var de=je();k("click",de,()=>_e(e(s).hash||"",m)),p(ee,de)};C(U,ee=>{e(s),b(()=>!e(s).isBot&&e(s).hash&&!e(s).isPending)&&ee(Fe)})}
1d(x),d(h),W(()=>H=Q(h,1,"message-item svelte-1s2fnws",null,H,{"bot-message":e(s).isBot,"user-message":!e(s).isBot})),p(o,h)});var f=u(i,2);{var y=o=>{var s=Xe();p(o,s)};C(f,o=>{e(n),b(()=>e(n).length===0)&&o(y)})}var S=u(f,2);{var c=o=>{var s=Ae(),m=l(s);ve(m,5,()=>e(T),pe,(h,H)=>{var x=Ye(),R=l(x,!0);d(x),W(()=>te(R,e(H))),k("click",x,()=>he(e(H))),p(h,x)}),d(m),d(s),p(o,s)};C(S,o=>{e(n),b(()=>e(n).length===0)&&o(c)})}d(a),ce(a,o=>r(D,o),()=>e(D)),p(t,a)},Se=t=>{var a=Le(),i=Ue(a);{var f=y=>{var S=Ne(),c=l(S),o=l(c);Te(o,{language:"python",lines:10,dark_mode:!1,basic:!0,readonly:!1,placeholder:"Enter your code here...",wrap_lines:!0,get value(){return e(B)},set value(w){r(B,w)},$$legacy:!0}),d(c);var s=u(c,2);let m;var h=l(s);{var H=w=>{var U=fe("Updated!");p(w,U)},x=w=>{var U=fe("Update Code");p(w,U)};C(h,w=>{e(z)?w(H):w(x,!1)})}d(s);var R=u(s,2);d(S),W(()=>m=Q(s,1,"update-code-button svelte-1s2fnws",null,m,{updating:e(z)})),k("click",s,ge),k("click",R,()=>ye()),p(y,S)};C(i,y=>{e(M)==="code"&&y(f)},!0)}p(t,a)};C(Ee,t=>{e(M)==="chat"?t(Me):t(Se,!1)})}d(O);var ne=u(O,2),q=u(l(ne),2);$e(q);var ie=u(q,2);return d(ne),d(L),ce(L,t=>r(se,t),()=>e(se)),W(t=>{He(L,`width: ${e(G)??""}px;`),oe=Q(J,1,"tab-button svelte-1s2fnws",null,oe,{active:e(M)==="chat"}),re=Q(Z,1,"tab-button svelte-1s2fnws",null,re,{active:e(M)==="code"}),ie.disabled=t},[()=>(e(V),b(()=>e(V).trim()===""))]),k("mousedown",ae,we),k("click",J,()=>r(M,"chat")),k("click",Z,()=>r(M,"code")),k("keydown",q,t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),Y())}),Pe(q,()=>e(V),t=>r(V,t)),k("click",ie,()=>Y()),p(me,L),De(xe)}export{gt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.