import"./svelte/svelte_internal_flags_async.js";import*as a from"./svelte/svelte_internal_client.js";import"./i18n-BldJSFLV.js";import{G as H}from"./utils.svelte-Ceck75cM.js";import{S as j}from"./StreamingBar-b2qVLPYU.js";import{onMount as z,tick as C}from"./svelte/svelte_svelte.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_store.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./IconButtonWrapper-Cljb5D-5.js";import"./MarkdownCode-C2b9iIxl.js";import"./prism-python-CpYAgONt.js";var N=a.from_html('<div role="region" aria-label="Draggable items container"><!> <!></div>');function gt(A,m){a.push(m,!0);const S=a.rest_props(m,["$$slots","$$events","$$legacy"]),s=new H(S);let n,i=null,g=[],d=null;const u=[{event:"dragstart",handler:$},{event:"dragend",handler:D}],h=[{event:"dragover",handler:M},{event:"drop",handler:k},{event:"dragenter",handler:P}];function w(t){u.forEach(({event:r,handler:e})=>{t.addEventListener(r,e)})}function v(t){u.forEach(({event:r,handler:e})=>{t.removeEventListener(r,e)})}function x(t){h.forEach(({event:r,handler:e})=>{t.addEventListener(r,e)})}function b(t){h.forEach(({event:r,handler:e})=>{t.removeEventListener(r,e)})}function E(t,r){t.classList.add("draggable-item"),t.setAttribute("data-index",r.toString()),t.style.position="relative";const e=document.createElement("div");e.className="drag-handle",e.setAttribute("draggable","true"),e.setAttribute("aria-grabbed","false"),e.setAttribute("data-index",r.toString()),e.innerHTML="⋮⋮",t.appendChild(e),w(e),x(t)}function _(){if(!n)return;g.forEach(e=>{const o=e.querySelector(".drag-handle");o&&(v(o),o.remove()),b(e)}),g=[];const t=Array.from(n.children);let r=0;t.forEach(e=>{e.classList.contains("status-tracker")||(e.classList.contains("form")&&e.children.length>0?Array.from(e.children).forEach(c=>{g.push(c),E(c,r),r++}):(g.push(e),E(e,r),r++))})}function $(t){t.stopPropagation?.();const r=t.currentTarget,e=r.parentElement;i=e,parseInt(r.dataset.index||"-1"),r.setAttribute("aria-grabbed","true"),e.classList.add("dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/html",e.outerHTML),t.dataTransfer.setDragImage(e,10,10))}function D(t){t.stopPropagation?.();const r=t.currentTarget;r.parentElement.classList.remove("dragging"),r.setAttribute("aria-grabbed","false"),d&&(d.classList.remove("drop-target"),d=null),i=null}function M(t){return t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!1}function P(t){t.stopPropagation?.();const r=t.currentTarget;if(r===i||!i||!n)return;const e=i.parentElement,o=r.parentElement,c=e?.classList.contains("form")&&e.parentElement===n,f=o?.classList.contains("form")&&o.parentElement===n;(c||e===n)&&(f||o===n)&&(d&&d!==r&&d.classList.remove("drop-target"),r.classList.add("drop-target"),d=r)}async function k(t){t.stopPropagation?.();const r=t.currentTarget;if(r.classList.remove("drop-target"),d&&(d.classList.remove("drop-target"),d=null),i&&i!==r&&n){const e=i.parentElement,o=r.parentElement,c=e?.classList.contains("form")&&e.parentElement===n,f=o?.classList.contains("form")&&o.parentElement===n;if(!((c||e===n)&&(f||o===n)))return!1;const p=document.createElement("div");p.style.display="none",e.insertBefore(p,i),o.insertBefore(i,r),e.insertBefore(r,p),p.remove(),i?.classList.remove("dragging");const y=i?.querySelector(".drag-handle");y&&y.setAttribute("aria-grabbed","false"),await C(),_()}return!1}z(()=>{_();const t=new MutationObserver(_);return n&&t.observe(n,{childList:!0,subtree:!1}),()=>{t.disconnect(),g.forEach(r=>{const e=r.querySelector(".drag-handle");e&&v(e),b(r)})}});var l=N();let L;var T=a.child(l);{var q=t=>{{let r=a.derived(()=>s.shared.loading_status?s.shared.loading_status.status=="pending"?"generating":s.shared.loading_status.status:null);j(t,a.spread_props({get autoscroll(){return s.shared.autoscroll},get i18n(){return s.i18n}},()=>s.shared.loading_status,{get status(){return a.get(r)}}))}};a.if(T,t=>{s.shared.loading_status&&s.props.show_progress&&t(q)})}var B=a.sibling(T,2);a.slot(B,m,"default",{},null),a.reset(l),a.bind_this(l,t=>n=t,()=>n),a.template_effect(t=>{a.set_attribute(l,"id",s.shared.elem_id),L=a.set_class(l,1,`draggable ${t??""}`,"svelte-1kr8imm",L,{hide:!s.shared.visible,horizontal:s.props.orientation==="row",vertical:s.props.orientation==="column"})},[()=>(s.shared.elem_classes||[]).join(" ")]),a.append(A,l),a.pop()}export{gt as default};
