1import{c as J,r as a,j as t,d as Et,t as A}from"./index-p3KznPWj.js";import{u as kt}from"./useQuery-D63ZgA1E.js";import{u as oe}from"./useMutation-DZ_BYECa.js";import{c as X,r as Y,u as U}from"./auth-middleware-BCtjZ7dl.js";import{a as At,c as le,u as Qe,B as $}from"./button-ByNz47lc.js";import{B as be}from"./badge-rW4MHkXq.js";import{I as Ot}from"./input-Dp-Vy5kA.js";import{L as je}from"./label-BJTGq5Hw.js";import{C as Se,a as Ne,b as Pe,c as Re}from"./card-V4vl9HTm.js";import{R as _t,A as Ze,e as Je,C as It,f as Ft,S as Me,a as Te,b as De,c as Le,d as ze}from"./select-Db7VH0Xa.js";import{T as Ve,a as qe,b as ye,c as O,d as Ke,e as _}from"./table-hFaWZ4iM.js";import{R as $t,P as Mt,O as Tt,C as Dt}from"./index-B5izRL_9.js";import{a as Q}from"./index-Bmi9gmvs.js";import{c as ee}from"./utils-BQHNewu7.js";import"./dialog-CFad9u4c.js";import{S as Xe}from"./search-Bwx9wizL.js";import{u as Lt,P as Ye,a as fe,c as zt}from"./index-CVY7gzEC.js";import{P as Vt,h as qt,R as Kt,u as Bt,F as Ht,D as Gt}from"./Combination-sRnVkKB_.js";import{P as et}from"./index-BOlwJzzV.js";import{P as Wt}from"./page-header-C5U8gEk7.js";import{c as Ie}from"./createLucideIcon-BRnsEs_G.js";import{C as Ut}from"./check-BUCgiivG.js";import{R as Be}from"./refresh-cw-BcccIQ9_.js";import{P as Qt}from"./pencil-BoPCCL4p.js";import{T as Zt}from"./trash-2-Z_T2Lsd3.js";import"./index-LHNt3CwB.js";import"./index-D5Og5Nnm.js";import"./index-D7UgSzHv.js";import"./x-np6399jh.js";const Jt=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Xt=Ie("arrow-up-down",Jt);const Yt=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],er=Ie("chevrons-up-down",Yt);const tr=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],rr=Ie("wand-sparkles",tr),nr=X({method:"GET"}).middleware([Y]).handler(J("82ce8cd4d77aaf43571e4b0174feb91f69138bb86d5fce3dca3c06de1fa4bc0b")),or=X({method:"POST"}).middleware([Y]).handler(J("9f7bcf460591fee28501fb7a9a600fe18ba4ae9465297c99a1661270a3422ae8")),ar=X({method:"POST"}).middleware([Y]).handler(J("0f2a58069c4ca8430b5941dbf986168bb8cc0118acbb852364892b4361f05523")),sr=X({method:"POST"}).middleware([Y]).handler(J("4b78a7419b51a10ae078fcfd641565d82ade7d28c45ce1181511dbd42ee9b479")),lr=X({method:"POST"}).middleware([Y]).handler(J("60384a6c82a5dd5f53bdc9665d0b1d112ec26a33fe3a9c78fe1ade0f85b4e0b1")),ir=X({method:"POST"}).middleware([Y]).handler(J("c24c31b09a4836dc00811d8b945868d31f879cba830035bf2badd5c4cd8f874b")),cr=X({method:"POST"}).middleware([Y]).handler(J("f3b7cd9573659d8340955d8387862a3799d90e08f8933e8f14e0f038b3e7278d"));var He=1,dr=.9,ur=.8,pr=.17,Ee=.1,ke=.999,mr=.9999,fr=.99,hr=/[\\\/_+.#"@\[\(\{&]/,vr=/[\\\/_+.#"@\[\(\{&]/g,gr=/[\s-]/,tt=/[\s-]/g;function Oe(e,n,r,c,l,i,d){if(i===n.length)return l===e.length?He:fr;var u=`${l},${i}`;if(d[u]!==void 0)return d[u];for(var h=c.charAt(i),p=r.indexOf(h,l),g=0,x,b,y,E;p>=0;)x=Oe(e,n,r,c,p+1,i+1,d),x>g&&(p===l?x*=He:hr.test(e.charAt(p-1))?(x*=ur,y=e.slice(l,p-1).match(vr),y&&l>0&&(x*=Math.pow(ke,y.length))):gr.test(e.charAt(p-1))?(x*=dr,E=e.slice(l,p-1).match(tt),E&&l>0&&(x*=Math.pow(ke,E.length))):(x*=pr,l>0&&(x*=Math.pow(ke,p-l))),e.charAt(p)!==n.charAt(i)&&(x*=mr)),(x<Ee&&r.charAt(p-1)===c.charAt(i+1)||c.charAt(i+1)===c.charAt(i)&&r.charAt(p-1)!==c.charAt(i))&&(b=Oe(e,n,r,c,p+1,i+2,d),b*Ee>x&&(x=b*Ee)),x>g&&(g=x),p=r.indexOf(h,p+1);return d[u]=g,g}function Ge(e){return e.toLowerCase().replace(tt," ")}function xr(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,Oe(e,n,Ge(e),Ge(n),0,0,{})}var br=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],K=br.reduce((e,n)=>{const r=At(`Primitive.${n}`),c=a.forwardRef((l,i)=>{const{asChild:d,...u}=l,h=d?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(h,{...u,ref:i})});return c.displayName=`Primitive.${n}`,{...e,[n]:c}},{}),me='[cmdk-group=""]',Ae='[cmdk-group-items=""]',jr='[cmdk-group-heading=""]',rt='[cmdk-item=""]',We=`${rt}:not([aria-disabled="true"])`,_e="cmdk-item-select",ae="data-value",yr=(e,n,r)=>xr(e,n,r),nt=a.createContext(void 0),he=()=>a.useContext(nt),ot=a.createContext(void 0),Fe=()=>a.useContext(ot),at=a.createContext(void 0),st=a.forwardRef((e,n
vendor: 9,930 bytes, line 1
1)=>{let r=se(()=>{var s,f;return{search:"",value:(f=(s=e.value)!=null?s:e.defaultValue)!=null?f:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),c=se(()=>new Set),l=se(()=>new Map),i=se(()=>new Map),d=se(()=>new Set),u=lt(e),{label:h,children:p,value:g,onValueChange:x,filter:b,shouldFilter:y,loop:E,disablePointerSelection:te=!1,vimBindings:M=!0,...H}=e,G=Q(),ce=Q(),de=Q(),k=a.useRef(null),w=_r();Z(()=>{if(g!==void 0){let s=g.trim();r.current.value=s,N.emit()}},[g]),Z(()=>{w(6,F)},[]);let N=a.useMemo(()=>({subscribe:s=>(d.current.add(s),()=>d.current.delete(s)),snapshot:()=>r.current,setState:(s,f,v)=>{var m,j,o,C;if(!Object.is(r.current[s],f)){if(r.current[s]=f,s==="search")W(),T(),w(1,D);else if(s==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let P=document.getElementById(de);P?P.focus():(m=document.getElementById(G))==null||m.focus()}if(w(7,()=>{var P;r.current.selectedItemId=(P=L())==null?void 0:P.id,N.emit()}),v||w(5,F),((j=u.current)==null?void 0:j.value)!==void 0){let P=f??"";(C=(o=u.current).onValueChange)==null||C.call(o,P);return}}N.emit()}},emit:()=>{d.current.forEach(s=>s())}}),[]),re=a.useMemo(()=>({value:(s,f,v)=>{var m;f!==((m=i.current.get(s))==null?void 0:m.value)&&(i.current.set(s,{value:f,keywords:v}),r.current.filtered.items.set(s,ge(f,v)),w(2,()=>{T(),N.emit()}))},item:(s,f)=>(c.current.add(s),f&&(l.current.has(f)?l.current.get(f).add(s):l.current.set(f,new Set([s]))),w(3,()=>{W(),T(),r.current.value||D(),N.emit()}),()=>{i.current.delete(s),c.current.delete(s),r.current.filtered.items.delete(s);let v=L();w(4,()=>{W(),v?.getAttribute("id")===s&&D(),N.emit()})}),group:s=>(l.current.has(s)||l.current.set(s,new Set),()=>{i.current.delete(s),l.current.delete(s)}),filter:()=>u.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>u.current.disablePointerSelection,listId:G,inputId:de,labelId:ce,listInnerRef:k}),[]);function ge(s,f){var v,m;let j=(m=(v=u.current)==null?void 0:v.filter)!=null?m:yr;return s?j(s,r.current.search,f):0}function T(){if(!r.current.search||u.current.shouldFilter===!1)return;let s=r.current.filtered.items,f=[];r.current.filtered.groups.forEach(m=>{let j=l.current.get(m),o=0;j.forEach(C=>{let P=s.get(C);o=Math.max(P,o)}),f.push([m,o])});let v=k.current;S().sort((m,j)=>{var o,C;let P=m.getAttribute("id"),xe=j.getAttribute("id");return((o=s.get(xe))!=null?o:0)-((C=s.get(P))!=null?C:0)}).forEach(m=>{let j=m.closest(Ae);j?j.appendChild(m.parentElement===j?m:m.closest(`${Ae} > *`)):v.appendChild(m.parentElement===v?m:m.closest(`${Ae} > *`))}),f.sort((m,j)=>j[1]-m[1]).forEach(m=>{var j;let o=(j=k.current)==null?void 0:j.querySelector(`${me}[${ae}="${encodeURIComponent(m[0])}"]`);o?.parentElement.appendChild(o)})}function D(){let s=S().find(v=>v.getAttribute("aria-disabled")!=="true"),f=s?.getAttribute(ae);N.setState("value",f||void 0)}function W(){var s,f,v,m;if(!r.current.search||u.current.shouldFilter===!1){r.current.filtered.count=c.current.size;return}r.current.filtered.groups=new Set;let j=0;for(let o of c.current){let C=(f=(s=i.current.get(o))==null?void 0:s.value)!=null?f:"",P=(m=(v=i.current.get(o))==null?void 0:v.keywords)!=null?m:[],xe=ge(C,P);r.current.filtered.items.set(o,xe),xe>0&&j++}for(let[o,C]of l.current)for(let P of C)if(r.current.filtered.items.get(P)>0){r.current.filtered.groups.add(o);break}r.current.filtered.count=j}function F(){var s,f,v;let m=L();m&&(((s=m.parentElement)==null?void 0:s.firstChild)===m&&((v=(f=m.closest(me))==null?void 0:f.querySelector(jr))==null||v.scrollIntoView({block:"nearest"})),m.scrollIntoView({block:"nearest"}))}function L(){var s;return(s=k.current)==null?void 0:s.querySelector(`${rt}[aria-selected="true"]`)}function S(){var s;return Array.from(((s=k.current)==null?void 0:s.querySelectorAll(We))||[])}function ne(s){let f=S()[s];f&&N.setState("value",f.getAttribute(ae))}function z(s){var f;let v=L(),m=S(),j=m.findIndex(C=>C===v),o=m[j+s];(f=u.current)!=null&&f.loop&&(o=j+s<0?m[m.length-1]:j+s===m.length?m[0]:m[j+s]),o&&N.setState("value",o.getAttribute(ae))}function V(s){let f=L(),v=f?.closest(me),m;for(;v&&!m;)v=s>0?Ar(v,me):Or(v,me),m=v?.querySelector(We);m?N.setState("value",m.getAttribute(ae)):z(s)}let I=()=>ne(S().length-1),ue=s=>{s.preventDefault(),s.metaKey?I():s.altKey?V(1):z(1)},pe=s=>{s.preventDefault(),s.metaKey?ne(0):s.altKey?V(-1):z(-1)};return a.createElement(K.div,{ref:n,tabIndex:-1,...H,"cmdk-root":"",onKeyDown:s=>{var f;(f=H.onKeyDown)==null||f.call(H,s);let v=s.nativeEvent.isComposing||s.keyCode===229;if(!(s.defaultPrevented||v))switch(s.key){case"n":case"j":{M&&s.ctrlKey&&ue(s);break}case"ArrowDown":{ue(s);break}case"p":case"k":{M&&s.ctrlKey&&pe(s);break}case"ArrowUp":{pe(s);break}case"Home":{s.preventDefault(),ne(0);break}case"End":{s.preventDefault(),I();break}case"Enter":{s.preventDefault();let m=L();if(m){let j=new Event(_e);m.dispatchEvent(j)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:re.inputId,id:re.labelId,style:Fr},h),we(e,s=>a.createElement(ot.Provider,{value:N},a.createElement(nt.Provider,{value:re},s))))}),wr=a.forwardRef((e,n)=>{var r,c;let l=Q(),i=a.useRef(null),d=a.useContext(at),u=he(),h=lt(e),p=(c=(r=h.current)==null?void 0:r.forceMount)!=null?c:d?.forceMount;Z(()=>{if(!p)return u.item(l,d?.id)},[p]);let g=it(l,i,[e.value,e.children,i],e.keywords),x=Fe(),b=q(w=>w.value&&w.value===g.current),y=q(w=>p||u.filter()===!1?!0:w.search?w.filtered.items.get(l)>0:!0);a.useEffect(()=>{let w=i.current;if(!(!w||e.disabled))return w.addEventListener(_e,E),()=>w.removeEventListener(_e,E)},[y,e.onSelect,e.disabled]);function E(){var w,N;te(),(N=(w=h.current).onSelect)==null||N.call(w,g.current)}function te(){x.setState("value",g.current,!0)}if(!y)return null;let{disabled:M,value:H,onSelect:G,forceMount:ce,keywords:de,...k}=e;return a.createElement(K.div,{ref:le(i,n),...k,id:l,"cmdk-item":"",role:"option","aria-disabled":!!M,"aria-selected":!!b,"data-disabled":!!M,"data-selected":!!b,onPointerMove:M||u.getDisablePointerSelection()?void 0:te,onClick:M?void 0:E},e.children)}),Cr=a.forwardRef((e,n)=>{let{heading:r,children:c,forceMount:l,...i}=e,d=Q(),u=a.useRef(null),h=a.useRef(null),p=Q(),g=he(),x=q(y=>l||g.filter()===!1?!0:y.search?y.filtered.groups.has(d):!0);Z(()=>g.group(d),[]),it(d,u,[e.value,e.heading,h]);let b=a.useMemo(()=>({id:d,forceMount:l}),[l]);return a.createElement(K.div,{ref:le(u,n),...i,"cmdk-group":"",role:"presentation",hidden:x?void 0:!0},r&&a.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:p},r),we(e,y=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?p:void 0},a.createElement(at.Provider,{value:b},y))))}),Sr=a.forwardRef((e,n)=>{let{alwaysRender:r,...c}=e,l=a.useRef(null),i=q(d=>!d.search);return!r&&!i?null:a.createElement(K.div,{ref:le(l,n),...c,"cmdk-separator":"",role:"separator"})}),Nr=a.forwardRef((e,n)=>{let{onValueChange:r,...c}=e,l=e.value!=null,i=Fe(),d=q(p=>p.search),u=q(p=>p.selectedItemId),h=he();return a.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),a.createElement(K.input,{ref:n,...c,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":u,id:h.inputId,type:"text",value:l?e.value:d,onChange:p=>{l||i.setState("search",p.target.value),r?.(p.target.value)}})}),Pr=a.forwardRef((e,n)=>{let{children:r,label:c="Suggestions",...l}=e,i=a.useRef(null),d=a.useRef(null),u=q(p=>p.selectedItemId),h=he();return a.useEffect(()=>{if(d.current&&i.current){let p=d.current,g=i.current,x,b=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let y=p.offsetHeight;g.style.setProperty("--cmdk-list-height",y.toFixed(1)+"px")})});return b.observe(p),()=>{cancelAnimationFrame(x),b.unobserve(p)}}},[]),a.createElement(K.div,{ref:le(i,n),...l,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":u,"aria-label":c,id:h.listId},we(e,p=>a.createElement("div",{ref:le(d,h.listInnerRef),"cmdk-list-sizer":""},p)))}),Rr=a.forwardRef((e,n)=>{let{open:r,onOpenChange:c,overlayClassName:l,contentClassName:i,container:d,...u}=e;return a.createElement($t,{open:r,onOpenChange:c},a.createElement(Mt,{container:d},a.createElement(Tt,{"cmdk-overlay":"",className:l}),a.createElement(Dt,{"aria-label":e.label,"cmdk-dialog":"",className:i},a.createElement(st,{ref:n,...u}))))}),Er=a.forwardRef((e,n)=>q(r=>r.filtered.count===0)?a.createElement(K.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),kr=a.forwardRef((e,n)=>{let{progress:r,children:c,label:l="Loading...",...i}=e;return a.createElement(K.div,{ref:n,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l},we(e,d=>a.createElement("div",{"aria-hidden":!0},d)))}),R=Object.assign(st,{List:Pr,Item:wr,Input:Nr,Group:Cr,Separator:Sr,Dialog:Rr,Empty:Er,Loading:kr});function Ar(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function Or(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function lt(e){let n=a.useRef(e);return Z(()=>{n.current=e}),n}var Z=typeof window>"u"?a.useEffect:a.useLayoutEffect;function se(e){let n=a.useRef();return n.current===void 0&&(n.current=e()),n}function q(e){let n=Fe(),r=()=>e(n.snapshot());return a.useSyncExternalStore(n.subscribe,r,r)}function it(e,n,r,c=[]){let l=a.useRef(),i=he();return Z(()=>{var d;let u=(()=>{var p;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(p=g.current.textContent)==null?void 0:p.trim():l.current}})(),h=c.map(p=>p.trim());i.value(e,u,h),(d=n.current)==null||d.setAttribute(ae,u),l.current=u}),l}var _r=()=>{let[e,n]=a.useState(),r=se(()=>new Map);return Z(()=>{r.current.forEach(c=>
1c()),r.current=new Map},[e]),(c,l)=>{r.current.set(c,l),n({})}};function Ir(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function we({asChild:e,children:n},r){return e&&a.isValidElement(n)?a.cloneElement(Ir(n),{ref:n.ref},r(n.props.children)):r(n)}var Fr={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ct=a.forwardRef(({className:e,...n},r)=>t.jsx(R,{ref:r,className:ee("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...n}));ct.displayName=R.displayName;const dt=a.forwardRef(({className:e,...n},r)=>t.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[t.jsx(Xe,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),t.jsx(R.Input,{ref:r,className:ee("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]}));dt.displayName=R.Input.displayName;const ut=a.forwardRef(({className:e,...n},r)=>t.jsx(R.List,{ref:r,className:ee("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...n}));ut.displayName=R.List.displayName;const pt=a.forwardRef((e,n)=>t.jsx(R.Empty,{ref:n,className:"py-6 text-center text-sm",...e}));pt.displayName=R.Empty.displayName;const mt=a.forwardRef(({className:e,...n},r)=>t.jsx(R.Group,{ref:r,className:ee("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...n}));mt.displayName=R.Group.displayName;const $r=a.forwardRef(({className:e,...n},r)=>t.jsx(R.Separator,{ref:r,className:ee("-mx-1 h-px bg-border",e),...n}));$r.displayName=R.Separator.displayName;const ft=a.forwardRef(({className:e,...n},r)=>t.jsx(R.Item,{ref:r,className:ee("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...n}));ft.displayName=R.Item.displayName;function Mr(e){const n=Tr(e),r=a.forwardRef((c,l)=>{const{children:i,...d}=c,u=a.Children.toArray(i),h=u.find(Lr);if(h){const p=h.props.children,g=u.map(x=>x===h?a.Children.count(p)>1?a.Children.only(null):a.isValidElement(p)?p.props.children:null:x);return t.jsx(n,{...d,ref:l,children:a.isValidElement(p)?a.cloneElement(p,void 0,g):null})}return t.jsx(n,{...d,ref:l,children:i})});return r.displayName=`${e}.Slot`,r}function Tr(e){const n=a.forwardRef((r,c)=>{const{children:l,...i}=r;if(a.isValidElement(l)){const d=Vr(l),u=zr(i,l.props);return l.type!==a.Fragment&&(u.ref=c?le(c,d):d),a.cloneElement(l,u)}return a.Children.count(l)>1?a.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var Dr=Symbol("radix.slottable");function Lr(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Dr}function zr(e,n){const r={...n};for(const c in n){const l=e[c],i=n[c];/^on[A-Z]/.test(c)?l&&i?r[c]=(...u)=>{const h=i(...u);return l(...u),h}:l&&(r[c]=l):c==="style"?r[c]={...l,...i}:c==="className"&&(r[c]=[l,i].filter(Boolean).join(" "))}return{...e,...r}}function Vr(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ce="Popover",[ht]=zt(Ce,[Je]),ve=Je(),[qr,B]=ht(Ce),vt=e=>{const{__scopePopover:n,children:r,open:c,defaultOpen:l,onOpenChange:i,modal:d=!1}=e,u=ve(n),h=a.useRef(null),[p,g]=a.useState(!1),[x,b]=Lt({prop:c,defaultProp:l??!1,onChange:i,caller:Ce});return t.jsx(_t,{...u,children:t.jsx(qr,{scope:n,contentId:Q(),triggerRef:h,open:x,onOpenChange:b,onOpenToggle:a.useCallback(()=>b(y=>!y),[b]),hasCustomAnchor:p,onCustomAnchorAdd:a.useCallback(()=>g(!0),[]),onCustomAnchorRemove:a.useCallback(()=>g(!1),[]),modal:d,children:r})})};vt.displayName=Ce;
vendor: 4,385 bytes, line 1
1var gt="PopoverAnchor",Kr=a.forwardRef((e,n)=>{const{__scopePopover:r,...c}=e,l=B(gt,r),i=ve(r),{onCustomAnchorAdd:d,onCustomAnchorRemove:u}=l;return a.useEffect(()=>(d(),()=>u()),[d,u]),t.jsx(Ze,{...i,...c,ref:n})});Kr.displayName=gt;var xt="PopoverTrigger",bt=a.forwardRef((e,n)=>{const{__scopePopover:r,...c}=e,l=B(xt,r),i=ve(r),d=Qe(n,l.triggerRef),u=t.jsx(Ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":St(l.open),...c,ref:d,onClick:fe(e.onClick,l.onOpenToggle)});return l.hasCustomAnchor?u:t.jsx(Ze,{asChild:!0,...i,children:u})});bt.displayName=xt;var $e="PopoverPortal",[Br,Hr]=ht($e,{forceMount:void 0}),jt=e=>{const{__scopePopover:n,forceMount:r,children:c,container:l}=e,i=B($e,n);return t.jsx(Br,{scope:n,forceMount:r,children:t.jsx(et,{present:r||i.open,children:t.jsx(Vt,{asChild:!0,container:l,children:c})})})};jt.displayName=$e;var ie="PopoverContent",yt=a.forwardRef((e,n)=>{const r=Hr(ie,e.__scopePopover),{forceMount:c=r.forceMount,...l}=e,i=B(ie,e.__scopePopover);return t.jsx(et,{present:c||i.open,children:i.modal?t.jsx(Wr,{...l,ref:n}):t.jsx(Ur,{...l,ref:n})})});yt.displayName=ie;var Gr=Mr("PopoverContent.RemoveScroll"),Wr=a.forwardRef((e,n)=>{const r=B(ie,e.__scopePopover),c=a.useRef(null),l=Qe(n,c),i=a.useRef(!1);return a.useEffect(()=>{const d=c.current;if(d)return qt(d)},[]),t.jsx(Kt,{as:Gr,allowPinchZoom:!0,children:t.jsx(wt,{...e,ref:l,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,d=>{d.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,d=>{const u=d.detail.originalEvent,h=u.button===0&&u.ctrlKey===!0,p=u.button===2||h;i.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:fe(e.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ur=a.forwardRef((e,n)=>{const r=B(ie,e.__scopePopover),c=a.useRef(!1),l=a.useRef(!1);return t.jsx(wt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(c.current||r.triggerRef.current?.focus(),i.preventDefault()),c.current=!1,l.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(c.current=!0,i.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const d=i.target;r.triggerRef.current?.contains(d)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&l.current&&i.preventDefault()}})}),wt=a.forwardRef((e,n)=>{const{__scopePopover:r,trapFocus:c,onOpenAutoFocus:l,onCloseAutoFocus:i,disableOutsidePointerEvents:d,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:g,...x}=e,b=B(ie,r),y=ve(r);return Bt(),t.jsx(Ht,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:l,onUnmountAutoFocus:i,children:t.jsx(Gt,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:g,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:p,onDismiss:()=>b.onOpenChange(!1),children:t.jsx(It,{"data-state":St(b.open),role:"dialog",id:b.contentId,...y,...x,ref:n,style:{...x.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Ct="PopoverClose",Qr=a.forwardRef((e,n)=>{const{__scopePopover:r,...c}=e,l=B(Ct,r);return t.jsx(Ye.button,{type:"button",...c,ref:n,onClick:fe(e.onClick,()=>l.onOpenChange(!1))})});Qr.displayName=Ct;var Zr="PopoverArrow",Jr=a.forwardRef((e,n)=>{const{__scopePopover:r,...c}=e,l=ve(r);return t.jsx(Ft,{...l,...c,ref:n})});Jr.displayName=Zr;function St(e){return e?"open":"closed"}var Xr=vt,Yr=bt,en=jt,Nt=yt;const tn=Xr,rn=Yr,Pt=a.forwardRef(({className:e,align:n="center",sideOffset:r=4,...c},l)=>t.jsx(en,{children:t.jsx(Nt,{ref:l,align:n,sideOffset:r,className:ee("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
1de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin)",e),...c})}));Pt.displayName=Nt.displayName;const Rt=[{value:"newest",label:"Más nuevo a más viejo"},{value:"oldest",label:"Más viejo a más nuevo"},{value:"price_desc",label:"Mayor precio a menor precio"},{value:"price_asc",label:"Menor precio a mayor precio"},{value:"sizes_desc",label:"Más tallas disponibles primero"},{value:"stock_desc",label:"Mayor stock disponible primero"}],Ue=Object.fromEntries(Rt.map(e=>[e.value,e.label]));function nn(e){return new Intl.NumberFormat("es-CO",{maximumFractionDigits:0}).format(e)}function Fn(){const e=Et(),n=U(nr),r=U(lr),c=U(ir),l=U(cr),i=U(sr),d=U(or),u=U(ar),[h,p]=a.useState(""),[g,x]=a.useState(""),[b,y]=a.useState(""),[E,te]=a.useState("newest"),[M,H]=a.useState(!1),[G,ce]=a.useState(""),[de,k]=a.useState(0),[w,N]=a.useState(""),{data:re}=kt({queryKey:["collection-order-base"],queryFn:()=>n()}),ge=re?.stores??[],T=re?.runs??[],D=15,W=Math.max(1,Math.ceil(T.length/D)),F=Math.min(de,W-1),L=T.slice(F*D,F*D+D),S=oe({mutationFn:o=>r({data:{store_id:o?.store_id??h,search:o?.search??g}}),onSuccess:o=>{if(G){o.collections.some(P=>P.gid===G)?(y(G),f.reset()):A.error("La colección de esa ejecución ya no está disponible en Shopify."),ce("");return}b&&!o.collections.some(C=>C.gid===b)&&(y(""),f.reset())},onError:o=>A.error(o.message)}),ne=oe({mutationFn:o=>i({data:{id:o}}),onSuccess:()=>{A.success("Ejecución eliminada"),k(0),e.invalidateQueries({queryKey:["collection-order-base"]})},onError:o=>A.error(o.message)}),z=oe({mutationFn:o=>d({data:{run_id:o}}),onSuccess:o=>{A.success(`Regla actualizada: ${o.productsOrdered} productos reordenados`),k(0),e.invalidateQueries({queryKey:["collection-order-base"]})},onError:o=>A.error(o.message),onSettled:()=>N("")}),V=oe({mutationFn:()=>u(),onSuccess:o=>{o.failed===0?A.success(`${o.ok} colecciones reorganizadas`):A.warning(`${o.ok} colecciones reorganizadas, ${o.failed} con error: ${o.errors.slice(0,3).map(C=>C.collection_title).join(", ")}`),k(0),e.invalidateQueries({queryKey:["collection-order-base"]})},onError:o=>A.error(o.message)}),I=S.data?.collections??[],ue=S.data?.totalScanned??0,pe=S.data?.search??"",s=I.find(o=>o.gid===b),f=oe({mutationFn:()=>c({data:{store_id:h,collection_gid:b,rule:E}}),onError:o=>A.error(o.message)}),v=oe({mutationFn:()=>l({data:{store_id:h,collection_gid:b,collection_title:s?.title??"",rule:E}}),onSuccess:o=>{A.success(`Colección reordenada: ${o.productsOrdered} productos`),e.invalidateQueries({queryKey:["collection-order-base"]})},onError:o=>A.error(o.message)}),m=f.data?.products??[];function j(o){const C=o.collection_title??"";p(o.store_id),te(o.rule),x(C),y(""),ce(o.collection_gid),f.reset(),S.mutate({store_id:o.store_id,search:C}),window.scrollTo({top:0,behavior:"smooth"})}return t.jsx("div",{className:"p-8",children:t.jsxs("div",{className:"mx-auto max-w-6xl space-y-6",children:[t.jsx(Wt,{title:"Collections order",description:"Reorganiza los productos dentro de una colección de Shopify según la regla que elijas."}),t.jsxs(Se,{children:[t.jsx(Ne,{children:t.jsx(Pe,{className:"text-base",children:"Configuración"})}),t.jsxs(Re,{className:"space-y-5",children:[t.jsxs("div",{className:"grid gap-5 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(je,{children:"Tienda"}),t.jsxs(Me,{value:h,onValueChange:o=>{p(o),y(""),S.reset(),f.reset()},children:[t.jsx(Te,{children:t.jsx(De,{placeholder:"Selecciona una tienda"})}),t.jsx(Le,{children:ge.map(o=>t.jsx(ze,{value:o.id,children:o.shop_name??o.shop_domain},o.id))})]})]}),t.jsxs("div",{className:"space-y-2 md:col-span-2",children:[t.jsx(je,{children:"Buscar colección"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ot,{value:g,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&h&&S.mutate(void 0)},placeholder:"Nombre de la colección (vacÃo = todas)",disabled:!h}),t.jsxs($,{variant:"secondary",className:"shrink-0",disabled:!h||S.isPending,onClick:()=>S.mutate(void 0),children:[t.jsx(Xe,{className:"h-4 w-4 mr-1.5"}),S.isPending?"Buscandoâ¦":"Buscar"]})]})]})]}),t.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(je,{children:"Colección"}),t.jsxs(tn,{open:M,onOpenChange:H,children:[t.jsx(rn,{asChild:!0,children:t.jsxs($,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",disabled:I.length===0,children:[t.jsx("span",{className:"truncate",children:s?`${s.title} (${s.productsCount})`:I.length===0?"Busca colecciones primero":`Selecciona entre ${I.length}`}),t.jsx(er,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(Pt,{className:"w-[min(28rem,90vw)] p-0",align:"start",children:t.jsxs(ct,{children:[t.jsx(dt,{placeholder:"Filtrar coleccionesâ¦"}),t.jsxs(ut,{children:[t.jsx(pt,{children:"Sin coincidencias."}),t.jsx(mt,{children:I.map(o=>t.jsxs(ft,{value:`${o.title} ${o.handle}`,onSelect:()=>{y(o.gid),H(!1),f.reset()},children:[t.jsx(Ut,{className:"mr-2 h-4 w-4 "+(o.gid===b?"opacity-100":"opacity-0")}),t.jsx("span",{className:"truncate",children:o.title}),t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:o.productsCount})]},o.gid))})]})]})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(je,{children:"Regla de orden"}),t.jsxs(Me,{value:E,onValueChange:o=>{te(o),f.reset()},children:[t.jsx(Te,{children:t.jsx(De,{})}),t.jsx(Le,{children:Rt.map(o=>t.jsx(ze,{value:o.value,children:o.label},o.value))})]})]})]}),S.isSuccess&&I.length===0?t.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["No se encontró â",pe,"â después de revisar ",ue," colecciones de esta tienda en Shopify. No requiere resincronización; verifica que el nombre o handle coincida."]}):S.isSuccess?t.jsx("p",{className:"text-sm text-muted-foreground",children:pe?`Se encontraron ${I.length} coincidencias al revisar ${ue} colecciones en Shopify.`:`Se cargaron ${I.length} colecciones desde Shopify.`}):null,s?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[t.jsx(be,{variant:"secondary",children:s.title}),t.jsxs(be,{variant:"outline",children:[s.productsCount," productos"]}),t.jsxs(be,{variant:"outline",children:["Orden actual: ",s.sortOrder]}),t.jsx("span",{className:"text-muted-foreground",children:"Al aplicar, la colección queda en orden manual con el nuevo orden."})]}):null,t.jsxs("div",{className:"flex flex-wrap justify-end gap-2 border-t border-border pt-4",children:[t.jsxs($,{variant:"secondary",disabled:!b||f.isPending,onClick:()=>f.mutate(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1.5"}),f.isPending?"Calculandoâ¦":"Ver vista previa"]}),t.jsxs($,{disabled:!b||m.length===0||v.isPending,onClick:()=>{window.confirm(`Se cambiará el orden de "${s?.title??""}" en Shopify a orden manual con ${m.length} productos. ¿Continuar?`)&&v.mutate()},children:[t.jsx(rr,{className:"h-4 w-4 mr-1.5"}),v.isPending?"Reordenandoâ¦":"Reordenar en Shopify"]})]})]})]}),t.jsxs(Se,{children:[t.jsx(Ne,{children:t.jsx(Pe,{className:"text-base",children:m.length>0?`Vista previa · ${m.length} productos · ${Ue[E]}`:"Vista previa"})}),t.jsx(Re,{className:"p-0",children:m.length===0?t.jsx("p",{className:"px-6 pb-6 text-sm text-muted-foreground",children:"Selecciona tienda y colección, luego pulsa âVer vista previaâ."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(Ve,{children:[t.jsx(qe,{className:"bg-muted/50",children:t.jsxs(ye,{children:[t.jsx(O,{className:"w-14 pl-6",children:"#"}),t.jsx(O,{className:"w-16"}),t.jsx(O,{children:"Producto"}),t.jsx(O,{className:"text-right",children:"Precio"}),t.jsx(O,{className:"text-right",children:"Tallas disp."}),t.jsx(O,{className:"text-right pr-6",children:"Stock"})]})}),t.jsx(Ke,{children:m.map((o,C)=>t.jsxs(ye,{className:"h-16",children:[t.jsx(_,{className:"pl-6 text-muted-foreground",children:C+1}),t.jsx(_,{children:o.image?t.jsx("img",{src:o.image,alt:o.title,className:"h-10 w-10 rounded-md border border-border object-cover",loading:"lazy"}):t.jsx("div",{className:"h-10 w-10 rounded-md border border-dashed border-border"})}),t.jsx(_,{className:"font-medium",children:o.title}),t.jsxs(_,{className:"text-right",children:["$",nn(o.price)]}),t.jsx(_,{className:"text-right",children:o.sizesAvailable}),t.jsx(_,{className:"text-right pr-6",children:o.totalStock})]},o.gid))})]})})})]}),t.jsxs(Se,{children:[t.jsxs(Ne,{className:"flex flex-row items-center justify-between gap-3",children:[t.jsx(Pe,{className:"text-base",children:"Historial"}),t.jsxs($,{variant:"secondary",size:"sm",disabled:T.length===0||V.isPending,onClick:()=>{window.confirm("Se volverá a aplicar la regla guardada de cada colección en Shopify, incluyendo los productos nuevos. ¿Continuar?")&&V.mutate()},children:[t.jsx(Be,{className:"h-4 w-4 mr-1.5 "+(V.isPending?"animate-spin":"")}),V.isPending?"Reorganizandoâ¦":"Reorganizar todas"]})]}),t.jsx(Re,{className:"p-0",children:T.length===0?t.jsx("p",{className:"px-6 pb-6 text-sm text-muted-foreground",children:"Aún no hay ejecuciones."}):t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs(Ve,{children:[t.jsx(qe,{className:"bg-muted/50",children:t.jsxs(ye,{children:[t.jsx(O,{className:"pl-6",children:"Fecha"}),t.jsx(O,{children:"Colección"}),t.jsx(O,{children:"Regla"}),t.jsx(O,{className:"text-right",children:"Productos"}),t.jsx(O,{children:"Estado"}),t.jsx(O,{className:"pr-6 text-right",children:"Acciones"})]})}),t.jsx(Ke,{children:L.map(o=>t.jsxs(ye,{className:"h-14",children:[t.jsx(_,{className:"pl-6 text-xs text-muted-foreground",children:new Date(o.created_at).toLocaleStr
1ing("es-CO")}),t.jsx(_,{children:o.collection_title??o.collection_gid}),t.jsx(_,{className:"text-xs",children:Ue[o.rule]??o.rule}),t.jsx(_,{className:"text-right",children:o.products_ordered}),t.jsxs(_,{children:[t.jsx(be,{variant:o.status==="success"?"default":o.status==="error"?"destructive":"secondary",children:o.status}),o.error?t.jsx("div",{className:"mt-1 max-w-[320px] text-xs text-destructive",children:o.error}):null]}),t.jsx(_,{className:"pr-6",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsxs($,{variant:"outline",size:"sm",disabled:z.isPending||V.isPending,onClick:()=>{N(o.id),z.mutate(o.id)},children:[t.jsx(Be,{className:"h-3.5 w-3.5 mr-1.5 "+(w===o.id&&z.isPending?"animate-spin":"")}),w===o.id&&z.isPending?"Actualizandoâ¦":"Actualizar"]}),t.jsxs($,{variant:"outline",size:"sm",disabled:S.isPending,onClick:()=>j(o),children:[t.jsx(Qt,{className:"h-3.5 w-3.5 mr-1.5"}),"Editar"]}),t.jsxs($,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",disabled:ne.isPending,onClick:()=>{window.confirm("¿Eliminar esta ejecución del historial? No cambia el orden en Shopify.")&&ne.mutate(o.id)},children:[t.jsx(Zt,{className:"h-3.5 w-3.5 mr-1.5"}),"Eliminar"]})]})})]},o.id))})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-border px-6 py-4",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Página ",F+1," de ",W," · ",T.length," ejecuciones"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx($,{variant:"outline",size:"sm",disabled:F===0,onClick:()=>k(F-1),children:"Anterior"}),t.jsx($,{variant:"outline",size:"sm",disabled:F>=W-1,onClick:()=>k(F+1),children:"Siguiente"})]})]})]})})]})]})})}export{Fn as component};
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.