1import{B as C,q as f,s as y,d as U,w as j,j as N,c as x,b as s,h as M,t as S,n as D,g as l,l as h,A as B,p as k,i as w,X as E,v as F,m as Y,V as q,o as m}from"./uv7Rk5x0.js";const A=()=>{const u=C(),c=f([]),r=f(!1),b=f(null);async function I(){r.value=!0,b.value=null;try{const{data:o,error:n}=await u.rpc("get_my_pending_owned_listings");if(n){const{data:p,error:_}=await u.from("space_course_listing").select("id, space_id, course_id, created_at, space:community_space(name, slug), course:lms_course(title, slug, cover_image_url)").eq("listing_kind","owned").eq("publish_status","draft");if(_)throw _;c.value=(p??[]).map(a=>({id:a.id,space_id:a.space_id,space_name:a.space?.name??null,space_slug:a.space?.slug??null,course_id:a.course_id,course_title:a.course?.title??null,course_slug:a.course?.slug??null,course_cover_image_url:a.course?.cover_image_url??null,allows_free:!0,allows_resell:!0,created_at:a.created_at}))}else c.value=o??[]}catch(o){b.value=o?.message??"Failed to load pending listings",c.value=[]}finally{r.value=!1}}async function t(o){const{error:n}=await u.rpc("publish_owned_course_listing",{p_space_id:o.spaceId,p_course_id:o.courseId,p_mode:o.mode,p_resell_price_currency:o.currency??null,p_resell_price_amount:o.amount??null});return n?{error:n.message}:(c.value=c.value.filter(p=>!(p.space_id===o.spaceId&&p.course_id===o.courseId)),{ok:!0})}const d=y(()=>c.value.length),v=y(()=>d.value>0);return{items:c,count:d,hasPending:v,loading:r,error:b,fetch:I,publish:t}},T={class:"bg-surface-container-lowest w-full max-w-md rounded-2xl shadow-2xl border border-outline-variant/20 overflow-hidden"},z={class:"px-6 pt-6 pb-2"},O={class:"text-sm text-on-surface-variant mt-1"},L={class:"font-semibold text-on-surface"},X={class:"font-semibold text-on-surface"},G={class:"px-6 py-4 space-y-3"},H=["disabled"],J={class:"min-w-0"},K={key:0,class:"text-[11px] text-error mt-1"},Q=["disabled"],W={class:"min-w-0 flex-1"},Z={key:0,class:"mt-3 flex items-center gap-2"},$={key:1,class:"text-[11px] text-error mt-1"},ee={key:0,class:"px-6 -mt-2 text-xs text-error"},se={class:"px-6 py-4 flex items-center justify-end gap-2 bg-surface-container-low/40"},te=["disabled"],le={key:0},oe={key:1},re=U({__name:"BuyerPublishModeModal",props:{open:{type:Boolean},listing:{}},emits:["close","published"],setup(u,{emit:c}){const r=u,b=c,{publish:I}=A(),t=f("free"),d=f("IDR"),v=f(""),o=f(!1),n=f(null);j(()=>r.listing?.id,()=>{t.value=r.listing?.allows_free===!1?"resell":"free",v.value="",n.value=null,d.value="IDR"});const p=y(()=>r.listing?.allows_free!==!1),_=y(()=>r.listing?.allows_resell!==!1),a=y(()=>{const i=Number(v.value.replace(/[^\d.]/g,""));return!Number.isFinite(i)||i<=0?null:d.value==="IDR"?Math.round(i):Math.round(i*100)}),R=y(()=>o.value?!1:t.value==="free"?p.value:t.value==="resell"?_.value&&a.value!==null:!1);async function V(){if(r.listing){n.value=null,o.value=!0;try{const i=await I({spaceId:r.listing.space_id,courseId:r.listing.course_id,mode:t.value,currency:t.value==="resell"?d.value:void 0,amount:t.value==="resell"?a.value??void 0:void 0});i?.error?n.value=String(i.error):(b("published",r.listing.id),b("close"))}catch(i){n.value=i?.message??"Publish failed"}finally{o.value=!1}}}function P(){b("close")}return(i,e)=>(m(),N(q,{to:"body"},[u.open&&u.listing?(m(),x("div",{key:0,class:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-labelledby":"buyer-publish-title",onClick:Y(P,["self"])},[s("div",T,[s("div",z,[e[7]||(e[7]=s("h2",{id:"buyer-publish-title",class:"text-lg font-bold text-on-surface"}," Publish in your space ",-1)),s("p",O,[e[4]||(e[4]=M(" You now own ",-1)),s("span",L,S(u.listing.course_title||"this course"),1),e[5]||(e[5]=M(". Pick how to surface it in ",-1)),s("span",X,S(u.listing.space_name||"your space"),1),e[6]||(e[6]=M(". ",-1))])]),s("div",G,[s("label",{class:D(["flex items-start gap-3 p-3 rounded-xl border cursor-pointer transition-colors",[l(t)==="free"?"border-primary bg-primary/5":"border-outline-variant/40 hover:bg-surface-container-low",!l(p)&&"opacity-50 cursor-not-allowed"]])},[h(s("input",{"onUpdate:modelValue":e[0]||(e[0]=g=>k(t)?t.value=g:null),type:"radio",value:"free",disabled:!l(p),class:"mt-1 accent-primary"},null,8,H),[[B,l(t)]]),s("div",J,[e[8]||(e[8]=s("p",{class:"font-semibold text-on-surface text-sm"},"Free for my members",-1)),e[9]||(e[9]=s("p",{class:"text-xs text-on-surface-variant mt-0.5"}," Anyone in your space can enrol without paying. ",-1)),l(p)?w("",!0):(m(),x("p",K," Your license does not permit free reuse. "))])],2),s("label",{class:D(["flex items-start gap-3 p-3 rounded-xl border cursor-pointer transition-colors",[l(t)==="resell"?"border-primary bg-primary/5":"border-outline-variant/40 hover:bg-surface-container-low",!l(_)&&"opacity-50 cursor-not-allowed"]])},[h(s("input",{"onUpdate:modelValue":e[1]||(e[1]=g=>k(t)?t.value=g:null),type:"radio",value:"resell",disabled:!l(_),class:"mt-1 accent-primary"}
1,null,8,Q),[[B,l(t)]]),s("div",W,[e[11]||(e[11]=s("p",{class:"font-semibold text-on-surface text-sm"},"Sell at a price",-1)),e[12]||(e[12]=s("p",{class:"text-xs text-on-surface-variant mt-0.5"}," Your space collects the revenue (subject to platform + author splits). ",-1)),l(t)==="resell"?(m(),x("div",Z,[h(s("select",{"onUpdate:modelValue":e[2]||(e[2]=g=>k(d)?d.value=g:null),class:"text-sm rounded-lg border border-outline-variant/40 bg-surface-container-lowest px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-primary/40"},[...e[10]||(e[10]=[s("option",{value:"IDR"},"IDR",-1),s("option",{value:"USD"},"USD",-1)])],512),[[E,l(d)]]),h(s("input",{"onUpdate:modelValue":e[3]||(e[3]=g=>k(v)?v.value=g:null),type:"text",inputmode:"decimal",placeholder:"Price",class:"flex-1 text-sm rounded-lg border border-outline-variant/40 bg-surface-container-lowest px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-primary/40"},null,512),[[F,l(v)]])])):w("",!0),l(_)?w("",!0):(m(),x("p",$," Your license does not permit resale. "))])],2)]),l(n)?(m(),x("p",ee,S(l(n)),1)):w("",!0),s("div",se,[s("button",{type:"button",class:"px-4 py-2 text-sm font-semibold text-on-surface-variant hover:text-on-surface rounded-xl",onClick:P}," Skip "),s("button",{type:"button",class:"px-4 py-2 text-sm font-bold rounded-xl bg-primary text-on-primary shadow disabled:opacity-50 disabled:cursor-not-allowed hover:brightness-110 active:scale-[0.98] transition-[filter,transform]",disabled:!l(R),onClick:V},[l(o)?(m(),x("span",le,"Publishingâ¦")):(m(),x("span",oe,"Publish"))],8,te)])])])):w("",!0)]))}}),ne=Object.assign(re,{__name:"BuyerPublishModeModal"});export{ne as _,A as u};
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.