1import{c as tt,j as e,z as m,p as rt,I as H,w as ls,bT as it,bU as nt,bV as at,bW as ot,B as y,C as ce,e as le,v as ct,g as lt,f as dt,au as mt,a0 as ut,r as c,u as Ie,A as pt,n as C,L as oe,ac as ds,aE as ht,a as xt,d as ft,b as gt,a8 as yt,Y as G,h as ms,a1 as vt,Z as jt,G as bt,H as Nt,J as wt,K as Ct,M as kt,N as St,O as _t,P as Tt,s as B}from"./index-Dez-oSnR.js";import{i as us,C as ps}from"./CountryMultiSelect-BUZf1uUB.js";import{L as At}from"./LegalConsent-DfuCyExC.js";import{b as Pt,D as It}from"./DashboardLayout-3OIB0lqO.js";import{S as Wt}from"./ServiceVersionHistory-BjQVPJUp.js";import{N as V}from"./number-field-O1fP21ib.js";import{T as D}from"./textarea-C48VZxjf.js";import{S as de,a as me,b as ue,c as pe,d as U}from"./select-Bxso9sXF.js";import{C as Mt}from"./CurrencyCombobox-E8j4xLAv.js";import{B as Me}from"./badge-yW4cizPl.js";import{S as qt}from"./ServiceArtwork-DNgbgnRA.js";import{A as hs,b as xs,a as fs}from"./alert-C1rjzbpU.js";import{S as Lt}from"./StaticMapCard-C4ShpUCE.js";import{p as gs}from"./coordinates-B__8YkrD.js";import{f as _s}from"./fx-dX9whpvG.js";import{p as Ut}from"./money-CKRVbYsr.js";import{u as Dt}from"./useFx-DWz-Sdia.js";import{u as Et}from"./useMoney-CG1xZfPK.js";import{R as ys,a as We}from"./radio-group-BfMAhNqG.js";import{r as Ft,f as Ts,b as he,d as As,l as Ps,c as zt,S as vs,e as Bt}from"./servicePolicies-D7gReXaU.js";import{I as Vt}from"./info-7OKLN8g4.js";import{U as $t}from"./undo-2-DFhYXGl9.js";import{T as qe}from"./trash-2-CGtAMMae.js";import{P as Is}from"./plus-CRaR48Qu.js";import{u as Rt}from"./useServiceBuilder-CUgfJ68r.js";import{u as Ot}from"./useAccountCurrency-XIKkdZLu.js";import{I as js}from"./image-plus-BXWvOK_Z.js";import{E as bs}from"./external-link-BJULMmzV.js";import{R as Ns}from"./refresh-cw-Bmb7T1v0.js";import{M as ws}from"./map-pin-Ct68SQRW.js";import"./command-OW5jsm3u.js";import"./countries-DeJYvkYi.js";import"./chevrons-up-down-CH-xjYTl.js";import"./LegalMarkdown-5ptMpNpV.js";import"./index-CeL3OwpF.js";import"./avatar-C2NRJr1o.js";import"./users-zz_qt8by.js";import"./shield-alert-DeuvNM6t.js";import"./file-text-CwBnU9sJ.js";import"./log-out-wlGMeySR.js";import"./shield-DcML5May.js";import"./circle-BncPRdvQ.js";import"./sparkles-CBNheZ_O.js";import"./badge-check-C9XorX9A.js";import"./scroll-area-BqV4Cw9-.js";import"./index-BdQq_4o_.js";import"./clock-D-_YvUhs.js";import"./circle-x-DYvvPcC-.js";import"./circle-help-BNW3EL8a.js";import"./history-CfP5vPYj.js";import"./rotate-ccw-B4t8R_P8.js";import"./chevron-up-CzuEkt6r.js";import"./format-Cn9lVP48.js";import"./plane-B91yvS4g.js";import"./accountCurrencyCache-BLrPF5jy.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Yt=tt("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);function Ws(r){return r.filter(i=>i.hours.trim()!==""||i.percent.trim()!=="").map(i=>({hours:Number(i.hours)||0,percent:Number(i.percent)||0}))}function Kt(r){return!Array.isArray(r)||r.length===0?Ms.customWindows:r.map(i=>({hours:(i==null?void 0:i.hours)===null||(i==null?void 0:i.hours)===void 0?"":String(i.hours),percent:(i==null?void 0:i.percent)===null||(i==null?void 0:i.percent)===void 0?"":String(i.percent)}
6))}const Ms={category:"visa",refundKind:"",refundText:"",refundPercent:"50",refundTarget:"",claimWindowApplies:null,redemptionMonths:"6",cancellationTier:"moderate",cancellationText:"",customWindows:[{hours:"",percent:""}]};function Gt(r){const i=Ts(r.refundKind),b=i?he(i,{percent:r.refundPercent,target:r.refundTarget}):void 0,o=As(i,r.refundText,b);return o==="required"?!0:o==="none"?!1:r.claimWindowApplies??!Ps(r.refundText)}function Ht({value:r,onChange:i}){var J;const b=Ft(r.category),o=Ts(r.refundKind),T=o?he(o,{percent:r.refundPercent,target:r.refundTarget}):void 0,N=As(o,r.refundText,T),E=r.claimWindowApplies??(Ps(r.refundText)?!1:null),v=N==="required"||N==="ask"&&E===!0,Q=a=>{const g=b.find(I=>I.key===a);g&&i({refundKind:a,refundText:he(g,{percent:r.refundPercent,target:r.refundTarget})})},F=a=>{const g={...r,...a};i(o?{...a,refundText:he(o,{percent:g.refundPercent,target:g.refundTarget})}:a)},Z=zt(r.cancellationTier,{windows:Ws(r.customWindows)});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"What kind of service is this? *"}),e.jsxs(de,{value:r.category,onValueChange:a=>i({category:a,refundKind:""}),children:[e.jsx(me,{children:e.jsx(ue,{})}),e.jsx(pe,{children:vs.map(a=>e.jsx(U,{value:a.value,children:a.label},a.value))})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(J=vs.find(a=>a.value===r.category))==null?void 0:J.hint," We use this to suggest the right refund wording and to ask students the right questions if something goes wrong."]})]}),e.jsxs("div",{className:"panel-soft space-y-3 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"h-4 w-4 text-primary"}),e.jsx(m,{className:"text-base font-semibold",children:"Refund / outcome policy *"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick the closest option â it writes the wording for you, and you can edit every word before publishing. This is what the student sees, and what our support team follows if they claim."}),e.jsx(ys,{value:r.refundKind,onValueChange:Q,className:"space-y-2",children:b.map(a=>e.jsxs("label",{className:"panel-inset flex cursor-pointer items-start gap-3 rounded-md p-3 hover:border-primary/50",children:[e.jsx(We,{value:a.key,className:"mt-0.5"}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.key))}),((o==null?void 0:o.needsPercent)||(o==null?void 0:o.needsTarget))&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[(o==null?void 0:o.needsPercent)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Refund percentage"}),e.jsx(V,{min:1,max:100,placeholder:"50",value:r.refundPercent,onValueChange:a=>F({refundPercent:a})})]}),(o==null?void 0:o.needsTarget)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Agreed target"}),e.jsx(H,{placeholder:"e.g. IELTS 7.0 overall",value:r.refundTarget,onChange:a=>F({refundTarget:a.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Your policy in your own words *"}),e.jsx(D,{rows:5,value:r.refundText,onChange:a=>i({refundText:a.target.value,claimWindowApplies:null}),placeholder:"Pick an option above to start from our wording, or write your own from scratch."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Students read this exact text. Be specific about what is and isn't covered â official fees, deadlines, and what you need from them."})]}),N==="none"&&e.jsxs("div",{className:"panel-inset flex items-start gap-2 rounded-lg p-3",children:[e.jsx(ls,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:"No claim timeline needed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You're not promising a refund or a redo, so there's no promise to expire. If a student says the work was never delivered, that's handled under the platform's standard window instead."})]})]}),N==="ask"&&e.jsxs("div",{className:"panel-inset space-y-2 rounded-lg p-3",children:[e.jsxs(m,{className:"flex items-center gap-2",children:["Does your policy promise a refund or redo if something goes wrong?",e.jsx(it,{children:e.jsxs(nt,{children:[e.jsx(at,{asChild:!0,children:e.jsx(Vt,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),e.jsx(ot,{className:"max-w-xs text-xs",children:"If your wording includes any money back, a free redo, a retake or a reapplication, students get a limited time to claim it â that's the timeline below. If it promises none of those, no timeline is needed."})]})})]}),e.jsxs(ys,{value:E===null?"":E?"yes":"no",onValueChange:a=>i({claimWindowApplies:a==="yes"}),className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("label",{className:"panel-soft flex cursor-pointer items-center gap-2 rounded-md p-3 hover:border-primary/50",children:[e.jsx(We,{value:"yes"}),e.jsx("span",{className:"text-sm",children:"Yes â it promises a refund or redo"})]}),e.jsxs("label",{className:"panel-soft flex cursor-pointer items-center gap-2 rounded-md p-3 hover:border-primary/50",children:[e.jsx(We,{value:"no"}),e.jsx("span",{className:"text-sm",children:"No timeline needed"})]})]}),r.claimWindowApplies===null&&E===!1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:`Your wording reads as no refund, so we've set "No timeline needed" â change it if that's wrong.`})]}),v&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"How long after completion can a student claim this?"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{min:0,max:60,placeholder:"6",className:"w-24",value:r.redemptionMonths,onValueChange:a=>i({redemptionMonths:a})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"months after the final milestone"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After this window the promise expires and no claim can be opened. Six months is typical for visa work. Set 0 for no deadline."})]})]}),e.jsxs("div",{className:"panel-soft space-y-3 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($t,{className:"h-4 w-4 text-primary"}),e.jsx(m,{className:"text-base font-semibold",children:"Cancellation policy *"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This covers a student changing their mind before the work is finished â separate from the outcome policy above."}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Bt.map(a=>
6e.jsxs("label",{className:`cursor-pointer rounded-md border p-3 transition-colors ${r.cancellationTier===a.value?"border-primary bg-primary/5":"border-border bg-background hover:border-primary/40"}`,onClick:()=>i({cancellationTier:a.value}),children:[e.jsx("p",{className:"text-sm font-semibold",children:a.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.summary})]},a.value))}),r.cancellationTier==="custom"&&e.jsxs("div",{className:"space-y-2",children:[r.customWindows.map((a,g)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Within"}),e.jsx(V,{min:1,placeholder:"48",className:"w-24",value:a.hours,onValueChange:I=>{const A=[...r.customWindows];A[g]={...a,hours:I},i({customWindows:A})}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours refund"}),e.jsx(V,{min:0,max:100,placeholder:"100",className:"w-24",value:a.percent,onValueChange:I=>{const A=[...r.customWindows];A[g]={...a,percent:I},i({customWindows:A})}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"%"}),e.jsx(y,{type:"button",variant:"ghost",size:"icon",onClick:()=>i({customWindows:r.customWindows.filter((I,A)=>A!==g)}),children:e.jsx(qe,{className:"h-4 w-4 text-destructive/70"})})]},g)),e.jsxs(y,{type:"button",variant:"outline",size:"sm",onClick:()=>i({customWindows:[...r.customWindows,{hours:"",percent:""}]}),children:[e.jsx(Is,{className:"mr-1 h-4 w-4"})," Add window"]})]}),e.jsx(ce,{className:"border-primary/20 bg-primary/5",children:e.jsxs(le,{className:"space-y-2 p-4",children:[e.jsx("p",{className:"text-xs font-semibold",children:"What students will see"}),e.jsx("ul",{className:"space-y-1",children:Z.map((a,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Me,{variant:"secondary",className:"mt-0.5 h-4 shrink-0 px-1 text-[10px]",children:g+1}),a]},g))})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Anything to add? (optional)"}),e.jsx(D,{rows:3,value:r.cancellationText,onChange:a=>i({cancellationText:a.target.value}),placeholder:"e.g. Appointment slots already booked with the embassy can't be refunded."})]})]})]})}function Cs(r){return!r||typeof r!="object"||Array.isArray(r)?{}:r}const Zt=/^[A-Z]{3}$/;function Qt(r){return typeof r=="string"&&Zt.test(r.trim().toUpperCase())}function ks(r){const i=b=>{const o=(b??"").trim().toUpperCase();return Qt(o)?o:""};return i(r.chosen)||i(r.saved)||i(r.accountCurrency)||""}function Jt(r){const i=String((r==null?void 0:r.message)??r??"");return/row-level security|not authorized|Unauthorized|permission denied/i.test(i)?"Your account can't save services for this business. Ask an owner to give you service editing access.":/duplicate key|already exists/i.test(i)?"A service with those details already exists. Open it from your services list instead.":/network|fetch failed|Failed to fetch|timeout/i.test(i)?"We couldn't reach the server. Check your connection and try again â your answers are still here.":"We couldn't save this service just now. Nothing you typed was lost â please try again."}const Ss={required:{label:"Required",description:"Needed before you can begin the service."},recommended:{label:"Recommended",description:"Strongly helpful for a smoother or stronger case."},optional:{label:"Optional",description:"Useful if available, but not necessary."}};function ii(){const r=ct(),i=lt(),{user:b}=dt(),o=Rt(),T=mt(),{canPublish:N}=Pt(),[E]=ut(),v=E.get("edit"),Q=T.isOwner||(v?T.canAny("services.edit_draft","services.edit_approved"):T.can("services.create")),[F,Z]=c.useState(!1),[J,a]=c.useState(!1),g=T.isOwner||T.can("services.submit_review"),I=Ot(),[A,Le]=c.useState(null);c.useEffect(()=>{!T.loading&&!Q&&r("/agency",{replace:!0})},[Q,r,T.loading]);const{data:$,isLoading:qs}=Ie({queryKey:["vendor-profile",o],queryFn:async()=>{if(!o)return null;const{data:s}=await B.from("vendors").select("*").eq("id",o).maybeSingle();return s},enabled:!!o}),Ls=($==null?void 0:$.legal_name)&&($==null?void 0:$.bio),{data:xe=[],refetch:X}=Ie({queryKey:["vendor-locations",o],queryFn:async()=>
6{if(!o)return[];const{data:s}=await B.from("vendor_locations").select("*").eq("vendor_id",o).eq("is_active",!0).order("kind",{ascending:!1});return s||[]},enabled:!!o,refetchOnWindowFocus:!0});c.useEffect(()=>{const s=()=>X();return window.addEventListener("focus",s),()=>window.removeEventListener("focus",s)},[X]);const fe=s=>[s.address_line1,s.city,s.state,s.country_code].filter(Boolean).join(", "),{data:l,isLoading:Us}=Ie({queryKey:["service",v,o],queryFn:async()=>{if(!v||!o)return null;const{data:s}=await B.from("services").select("*").eq("id",v).eq("vendor_id",o).maybeSingle();return s},enabled:!!v&&!!o,staleTime:0,gcTime:0,refetchOnMount:"always"}),[ee,Ue]=c.useState(""),[ge,De]=c.useState(""),[ye,Ee]=c.useState(""),[se,Fe]=c.useState([]),[ve,ze]=c.useState([]),[te,Be]=c.useState(!1),[re,Ve]=c.useState(!1),[k,$e]=c.useState(Ms),Ds=s=>$e(t=>({...t,...s}));c.useState(!1);const[R,Re]=c.useState(""),[Es,Fs]=c.useState(!1),[j,ie]=c.useState({}),[je,Oe]=c.useState(!1),[be,Ye]=c.useState(!1),[W,Ne]=c.useState(""),we=c.useRef(!1),zs=s=>{we.current=!0,Ne((s||"").toUpperCase())},[Ke,Ge]=c.useState(""),[He,Ze]=c.useState("days"),[M,Qe]=c.useState("chat"),[Je,Xe]=c.useState(""),[er,Bs]=c.useState(""),[Ce,es]=c.useState(""),[sr,Vs]=c.useState(null),[tr,$s]=c.useState(null),[ss,ts]=c.useState([]),[Rs,ke]=c.useState(null),O=xe.filter(s=>ss.includes(s.id)),z=O.find(s=>s.id===Rs)||O[0]||null,[S,ne]=c.useState([]),[rs,is]=c.useState(!1),[Se,_e]=c.useState(0),[ns,as]=c.useState("cover"),[os,Y]=c.useState([]);c.useEffect(()=>{var s,t;if(l){Ue(l.title||""),De(l.short_description||""),Ee(l.description||""),Fe(l.destination_country||[]),ze(l.passport_countries||[]),Be(!!l.accepts_any_passport),Ve(!!l.serves_any_destination);const n=l.refund_policy_config||{},p=l.cancellation_config||{};$e({category:l.service_category||"visa",refundKind:l.refund_policy_kind||"",refundText:l.refund_policy||"",refundPercent:String(n.percent??"50"),refundTarget:n.target??"",claimWindowApplies:typeof n.claim_window_applies=="boolean"?n.claim_window_applies:n.redemption_months!=null?!0:null,redemptionMonths:String(n.redemption_months??"6"),cancellationTier:l.cancellation_tier||"moderate",cancellationText:l.cancellation_policy||"",customWindows:Kt(p.windows)}),Re(((s=l.base_price)==null?void 0:s.toString())||""),Fs(!!l.ai_generated),ie(Cs(l.service_extras)),Oe(!!l.policy_confirmed),Ye(!!l.scope_confirmed);const u=ks({saved:l.peg_currency||l.currency});u&&(we.current=!0,Ne(u)),Ge(((t=l.delivery_time_value)==null?void 0:t.toString())||""),Ze(l.delivery_time_unit||"days"),Qe(l.meeting_location_type||"chat");const h=l.meeting_details;if(h&&typeof h=="object"){Xe(h.zoom_link||""),Bs(h.physical_address||""),es(h.instructions||"");const d=gs(h.latitude,h.longitude);if(Vs((d==null?void 0:d.latitude)??null),$s((d==null?void 0:d.longitude)??null),Array.isArray(h.locations)){const f=h.locations.map(x=>x.id).filter(Boolean);ts(f),ke(f[0]??null)}}l.images&&Array.isArray(l.images)&&ne(l.images),_e(Number(l.cover_image_index??0)),as(l.image_display_mode==="cycle"?"cycle":"cover");const P=l.documents_required;if(Array.isArray(P)&&Y(P.map(d=>({name:(d==null?void 0:d.name)??"",importance:["required","recommended","optional"].includes(d==null?void 0:d.importance)?d.importance:"required",note:(d==null?void 0:d.note)??""}))),l.original_milestones&&Array.isArray(l.original_milestones)){const d=l.original_milestones.map(f=>({id:crypto.randomUUID(),label:f.label||"",description:f.description||"",percent:f.percent===null||f.percent===void 0||f.percent===""?"":String(f.percent),color:f.color||"#60a5fa"}));ae(d)}}},[l]),c.useEffect(()=>{if(we.current||W)return;const s=ks({accountCurrency:I.data});s&&Ne(s)},[I.data,W]);const _=(s,t)=>(Le({field:s,message:t}),Z(!1),C.error(t),requestAnimationFrame(()=>{const n=document.getElementById(s);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),typeof n.focus=="function"&&n.focus({preventScroll:!0}))}),!1),Os=[{label:"Initial consultation",description:"Kickoff call, case review and a personalised document checklist",percent:"20"},{label:"Documents prepared",description:"Forms completed and your documents checked, ready to submit",percent:"40"},{label:"Application submitted",description:"Everything filed with the confirmation shared with you",percent:"30"},{label:"Outcome and follow-up",description:"Decision reviewed together and next steps agreed",percent:"10"}],Te=s=>Os[s]??{label:`Milestone ${s+1}`,description:"What the student receives at this step",percent:"10"},[K,ae]=c.useState([{id:crypto.randomUUID(),label:"",description:"",percent:"",color:"#60a5fa"}]),q=K.reduce((s,t)=>s+(Number(t.percent)||0),0),Ys=()=>{ae(s=>[...s,{id:crypto.randomUUID(),label:"",description:"",percent:"",color:"#a78bfa"}])},Ae=(s,t)=>{ae(n=>n.map(p=>p.id===s?{...p,...t}:p))},Ks=s=>ae(t=>t.filter(n=>n.id!==s)),Gs=async s=>{const t=s.target.files;if(!t||!b)return;if(S.length+t.length>6){C.error("You can add up to 6 images");return}const n=10*1024*1024,p=Array.from(t),u=p.find(d=>d.size>n);if(u){C.error(`"${u.name}" is over the 10 MB limit. Try a smaller picture.`),s.target.value="";return}
6const h=p.find(d=>!d.type.startsWith("image/"));if(h){C.error(`"${h.name}" isn't a picture. Use a JPG, PNG or WebP file.`),s.target.value="";return}is(!0);const P=[];try{for(const d of p){const f=(d.name.split(".").pop()||"jpg").toLowerCase(),x=`${b.id}/${crypto.randomUUID()}.${f}`,{error:w}=await B.storage.from("service-images").upload(x,d,{contentType:d.type,upsert:!1});if(w)throw w;const{data:L}=B.storage.from("service-images").getPublicUrl(x);P.push(L.publicUrl)}ne(d=>[...d,...P]),C.success(P.length>1?"Pictures added":"Picture added")}catch(d){P.length&&ne(w=>[...w,...P]);const f=String((d==null?void 0:d.message)||""),x=/row-level security|not authorized|Unauthorized|permission/i.test(f)?"Your account can't add pictures for this company. Ask an owner to give you service editing access.":/exceeded the maximum allowed size|Payload too large|too large/i.test(f)?"That file is over the limit. Try a picture under 10 MB.":/mime|content type/i.test(f)?"That file type isn't supported. Use a JPG, PNG or WebP picture.":"We couldn't add that picture. Please try again.";C.error(x)}finally{is(!1),s.target.value=""}},Hs=s=>{ne(t=>t.filter((n,p)=>p!==s)),_e(t=>s===t?0:s<t?t-1:t)},[Zs,cs]=c.useState(!1),[Qs,Js]=c.useState(!1),Pe=async(s,t=!1)=>{if(s.preventDefault(),!b||!o){C.error("You must be signed in to a business account to create a service");return}Z(!0),Le(null);try{if(!t&&!g&&(C.info("Saved as a draft. Your role can't submit services for review â ask an owner to submit it."),t=!0),!t&&!N&&(C.info("Your service is saved as a draft. Your identity check must be complete before this can go live."),t=!0),!t&&!ee.trim())return void _("title","Give this service a title before submitting.");
6if(!t&&!ge.trim())return void _("short-description","Add the one-line description students see first.");if(!t&&!ye.trim())return void _("description","Add the full description before submitting.");if(!t&&q!==100)return void _("milestones-section","Milestone percentages must total 100%.");if(!t&&se.length===0&&!re)return void _("destinations-section","Choose the destinations you serve, or tick 'Works for any destination'.");if(!t&&ve.length===0&&!te)return void _("passports-section","Choose the student passport countries you can help, or tick 'Any passport'.");if(!t&&!k.refundText.trim())return void _("policy-section","Add your refund / outcome policy before submitting.");const n=R.trim()===""?null:parseFloat(R);if(!t&&!W)return void _("price","Choose the currency this service is priced in before submitting.");if(!t&&(n===null||!(n>0)))return void _("price","Set your price before submitting this service.");if(!t&&!je)return void _("confirmations-section","Confirm your refund and cancellation policy before submitting.");if(!t&&!be)return void _("confirmations-section","Confirm that what's included is accurate before submitting.");const p=M==="in_person"||M==="hybrid";if(!t&&p&&O.length===0)return void _("meeting-type","Choose at least one company address for this service. Students compare distance before booking.");const u={};if((M==="zoom"||M==="hybrid")&&(u.zoom_link=Je),p){const x=O.map(L=>({id:L.id,label:L.label||(L.kind==="head_office"?"Head office":"Branch"),address:fe(L),...gs(L.latitude,L.longitude)??{latitude:null,longitude:null}}));u.locations=x;const w=x[0];w&&(u.physical_address=w.address,w.latitude!==null&&w.longitude!==null&&(u.latitude=w.latitude,u.longitude=w.longitude))}Ce&&(u.instructions=Ce);const h=Gt(k),P={vendor_id:o,title:ee,short_description:ge,description:ye,destination_country:se,passport_countries:ve,accepts_any_passport:te,serves_any_destination:re,service_category:k.category,refund_policy_kind:k.refundKind||null,refund_policy:k.refundText,refund_policy_config:{percent:Number(k.refundPercent)||null,target:k.refundTarget||null,claim_window_applies:h,redemption_months:h?Number(k.redemptionMonths)||0:null},cancellation_tier:k.cancellationTier,cancellation_config:{windows:Ws(k.customWindows)},cancellation_policy:k.cancellationText||null,base_price:n,price_state:n&&n>0?"vendor_confirmed":"missing",policy_confirmed:je,scope_confirmed:be,service_extras:Cs(j),...W?{currency:W,peg_currency:W}:{},delivery_time_value:parseInt(Ke)||0,delivery_time_unit:He,meeting_location_type:M,meeting_details:u,original_milestones:K.map(({id:x,label:w,description:L,percent:Xs,...et},st)=>({...et,label:w.trim()||`Milestone ${st+1}`,description:(L??"").trim(),percent:Number(Xs)||0})),images:S.length>0?S:null,cover_image_index:S.length?Math.min(Se,S.length-1):0,image_display_mode:ns,documents_required:os.filter(x=>x.name.trim()).map(x=>({name:x.name.trim(),importance:x.importance,note:x.note.trim()||null})),status:t?"draft":"pending_approval"};let d,f;if(v){const x=await B.from("services").update(P).eq("id",v).eq("vendor_id",o).select().single();d=x.data,f=x.error}else{const x=await B.from("services").insert(P).select().single();d=x.data,f=x.error}if(f)throw f;C.success(v?t?"Draft updated successfully!":"Service updated and submitted!":t?"Service draft saved successfully!":"Service submitted for approval!"),i.removeQueries({queryKey:["service"]}),i.invalidateQueries({queryKey:["service-versions"]}),await i.invalidateQueries({queryKey:["vendor-my-services"]}),await i.invalidateQueries({queryKey:["service-review-rounds"]}),r("/services")}catch(n){console.error("Error saving service:",n),C.error(Jt(n))}finally{Z(!1)}};return e.jsx(It,{title:v?"Edit Service":"Create New Service",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(y,{variant:"ghost",onClick:()=>r("/services"),className:"mb-4",children:[e.jsx(pt,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]}),v&&l&&e.jsx("div",{className:"mb-4",children:e.jsx(Wt,{serviceId:v,onRestore:s=>{const{id:t,vendor_id:n,revision_of:p,...u}=s;i.setQueryData(["service",v,o],{...l,...u}),C.success("Older version loaded into the form. Save it to keep it."),window.scrollTo({top:0,behavior:"smooth"})}})}),qs||Us?e.jsx(ce,{className:"shadow-lg",children:e.jsxs(le,{className:"py-12 text-center",children:[e.jsx(oe,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"text-muted-foreground mt-4",children:"Loading..."})]})}):Ls?e.jsxs(ce,{className:"shadow-lg",children:[e.jsxs(xt,{className:"bg-gradient-to-r from-primary/5 to-secondary/5",children:[e.jsx(ft,{children:v?"Edit Service":"Service Details"}),e.jsx(gt,{children:v?"Update your visa service offering":"Create a new visa service offering for students"})]}),e.jsx(le,{className:"pt-6",children:e.jsxs("form",{onSubmit:Pe,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"title",children:"Service Title *"}),e.jsx(H,{id:"title",placeholder:"e.g., F1 Student Visa Processing for USA",value:ee,onChange:s=>Ue(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"short-description",children:"Short Description *"}),e.jsx(H,{id:"short-description",placeholder:"Brief one-line description",value:ge,onChange:s=>De(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"description",children:"Full Description *"}),e.jsx(D,{id:"description",placeholder:"Detailed description of your service...",value:ye,onChange:s=>Ee(s.target.value),rows:6,required:!0})]}),e.jsxs("div",{className:"panel-soft space-y-3 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsxs(m,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("span",{id:"service-images-section"}),"Service images (up to 6)"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[S.some(us)&&e.jsx("span",{className:"block mb-1 text-amber-600",children:"Tip: you're using template photos. Upload your own to look more original."}),"Pick one cover image â it's what students see first. You can also let all your images cycle on the listing."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[S.map((s,t)=>e.jsxs("div",{className:`relative h-28 w-28 overflow-hidden rounded-lg border group ${Se===t?"border-primary ring-2 ring-primary/40":"border-border"}`,children:[e.jsx("img",{src:s,alt:`Service ${t+1}`,className:"h-full w-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>Hs(t),className:"absolute right-1 top-1 rounded-full bg-destructive p-1 text-destructive-foreground opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(yt,{className:"h-3 w-3"})}),Se===t?e.jsx("span",{className:"absolute bottom-0 left-0 right-0 bg-primary py-0.5 text-center text-[10px] font-semibold text-primary-foreground",children:"Cover"}):e.jsx("button",{type:"button",onClick:()=>_e(t),className:"absolute bottom-0 left-0 right-0 bg-background/85 py-0.5 text-center text-[10px] font-medium opacity-0 transition-opacity group-hover:opacity-100",children:"Make cover"})]},t)),S.length<6&&e.jsxs("label",{className:"flex h-28 w-28 cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-border transition-colors hover:border-primary/50",children:[rs?e.jsx(oe,{className:"h-6 w-6 animate-spin text-muted-foreground"}):e.jsxs(e.Fragment,{children:[e.jsx(js,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("span",{className:"mt-1 text-xs text-muted-foreground",children:"Add"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Gs,disabled:rs})]})]}),S.length===0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"No pictures yet â students will see this until you add one:"}),e.jsx("div",{className:"h-32 w-full max-w-xs overflow-hidden rounded-lg border border-border",children:e.jsx(qt,{destinations:se,label:ee})})]}),S.length>1&&e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-sm",children:[e.jsx(G,{checked:ns==="cycle",onCheckedChange:s=>as(s?"cycle":"cover")}),e.jsxs("span",{children:["Cycle through my images automatically",e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Off means students always see the cover image only."})]})]})]}),e.jsxs("div",{className:"panel-soft space-y-4 rounded-lg p-4 sm:p-5",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-base font-semibold",children:"Documents you'll need from the student"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Tell students what to prepare, how important each item is, and any instructions they should follow."})]}),os.map((s,t)=>e.jsxs("div",{className:"panel-inset relative space-y-4 rounded-lg p-4 shadow-sm",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,1fr)_220px_auto] sm:items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:`document-name-${t}`,children:"Document name"}),e.jsx(H,{id:`document-name-${t}`,placeholder:"e.g. Passport bio page",value:s.name,onChange:n=>Y(p=>p.map((u,h)=>h===t?{...u,name:n.target.value}:u))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Importance"}),e.jsxs(de,{value:s.importance,onValueChange:n=>Y(p=>p.map((u,h)=>h===t?{...u,importance:n}:u)),children:[e.jsx(me,{"aria-label":`Importance for ${s.name||`document ${t+1}`}`,children:e.jsx(ue,{})}),e.jsx(pe,{children:Object.entries(Ss).map(([n,p])=>e.jsx(U,{value:n,children:p.label},n))})]})]}),e.jsx(y,{type:"button",variant:"ghost",size:"icon","aria-label":`Remove ${s.name||`document ${t+1}`}`,onClick:()=>Y(n=>n.filter((p,u)=>u!==t)),children:e.jsx(qe,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ss[s.importance].description}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:`document-note-${t}`,children:"Notes for the student"}),e.jsx(D,{id:`document-note-${t}`,rows:2,placeholder:"e.g. Upload a clear colour scan with all four corners visible.",value:s.note,onChange:n=>Y(p=>p.map((u,h)=>h===t?{...u,note:n.target.value}:u))})]})]},t)),e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>Y(s=>[...s,{name:"",importance:"required",note:""}]),children:"Add a document"})]}),e.jsxs("div",{className:"panel-soft space-y-5 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-lg font-semibold",children:"Who this service supports"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Students see these details on your listing. They help students understand fit and improve recommendations, but they never stop anyone from viewing, messaging, or buying your service."})]}),e.jsxs("div",{id:"passports-section",className:"space-y-3",children:[e.jsx(m,{children:"Which student passport countries can this service help? *"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This is about the student's own passport, not where they're going. Pick every country whose students you're willing to take on for this service â you can choose as many as you like, and it doesn't have to be ones you've done before."}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[e.jsx(G,{checked:te,onCheckedChange:s=>Be(!!s)}),e.jsx("span",{className:"text-sm",children:"I'll take students on any passport for this service"})]}),!te&&e.jsx(ps,{value:ve,onChange:ze,placeholder:"Search and add passport countriesâ¦",quickPicks:["Nigeria","Ghana","Kenya","South Africa","India"]})]}),e.jsxs("div",{id:"destinations-section",className:"space-y-3 border-t border-border pt-4",children:[e.jsx(m,{children:"Which countries does this
6service help students go to? *"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add as many destinations as this service covers. A US student-visa package serves the United States only, while a personal statement review can work for many countries."}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[e.jsx(G,{checked:re,onCheckedChange:s=>Ve(!!s)}),e.jsx("span",{className:"text-sm",children:"Works for any destination"})]}),!re&&e.jsx(ps,{value:se,onChange:Fe,placeholder:"Select destinations...",quickPicks:["United States","United Kingdom","Canada","Germany","Australia"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"price",children:"Service currency & price *"}),e.jsxs("div",{className:"flex flex-wrap gap-2 sm:flex-nowrap",children:[e.jsx(Mt,{value:W,onChange:zs,className:"w-full sm:w-[190px]"}),e.jsx(V,{id:"price",step:"0.01",min:0,placeholder:"0.00",value:R,onValueChange:Re,className:"flex-1"})]}),!W&&!I.isLoading&&e.jsx("p",{className:"text-xs text-destructive",children:"Choose the currency this service is priced in â we don't guess it for you."}),R.trim()===""?e.jsx("p",{className:"text-xs text-muted-foreground",children:"You can leave this blank while it's a draft â we never invent a price. You'll need it before submitting for review."}):e.jsx(Xt,{amount:parseFloat(R)||0,peg:W}),e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold",children:"How the service peg currency works"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["The ",e.jsx("b",{children:"peg currency"})," is the currency this service is ",e.jsx("i",{children:"valued"})," in â the amount you're guaranteed regardless of where the student pays from. Students always see the price converted into their own currency at the live rate plus a small FX margin, rounded up to a clean amount, and the exact figure is locked at checkout."]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["When a milestone is released, VZgate converts the pegged amount into your"," ",e.jsx("b",{children:"account currency"}),", and you withdraw from that balance to your payout method. You can peg each service differently â the conversion is handled for you."]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"delivery-time",children:"Estimated delivery time *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{id:"delivery-time",min:1,step:1,placeholder:"7",value:Ke,onValueChange:Ge,className:"flex-1",required:!0}),e.jsxs(de,{value:He,onValueChange:Ze,children:[e.jsx(me,{className:"w-24",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(U,{value:"days",children:"Days"}),e.jsx(U,{value:"weeks",children:"Weeks"}),e.jsx(U,{value:"months",children:"Months"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A typical turnaround â give or take. Students see this as an estimate, not a promise."})]})]}),e.jsxs("div",{className:"panel-soft space-y-4 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-lg font-semibold",children:"Meeting Location"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Where will consultations/meetings take place?"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"meeting-type",children:"Meeting Type *"}),e.jsxs(de,{value:M,onValueChange:Qe,required:!0,children:[e.jsx(me,{id:"meeting-type",children:e.jsx(ue,{placeholder:"Select meeting type"})}),e.jsxs(pe,{children:[e.jsx(U,{value:"chat",children:"In-App Chat Only"}),e.jsx(U,{value:"zoom",children:"Zoom/Video Call Only"}),e.jsx(U,{value:"in_person",children:"In-Person Only"}),e.jsx(U,{value:"hybrid",children:"Hybrid (Online + In-Person)"})]})]})]}),(M==="zoom"||M==="hybrid")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"zoom-link",children:"Zoom Link / Meeting URL"}),e.jsx(H,{id:"zoom-link",type:"url",placeholder:"https://zoom.us/j/...",value:Je,onChange:s=>Xe(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You can update this link later or provide it in the chat"})]}),(M==="in_person"||M==="hybrid")&&e.jsx(e.Fragment,{children:xe.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-4 space-y-3 bg-background",children:[e.jsx("p",{className:"text-sm font-medium",children:"You have no company addresses saved"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add them on your company page, then choose which ones deliver this service."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(y,{type:"button",variant:"outline",size:"sm",onClick:()=>r("/agency/profile?section=locations#section-locations"),children:[e.jsx(bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Open company page"]}),e.jsxs(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>X(),children:[e.jsx(Ns,{className:"h-3.5 w-3.5 mr-1.5"}),"I've added them â refresh"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Which of your addresses deliver this service? *"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Students compare distance before booking, so hybrid services need at least one address too."})]}),e.jsx("div",{className:"space-y-2",children:xe.map(s=>
6{const t=s.verification_state==="rejected",n=ss.includes(s.id);return e.jsxs("label",{className:ms("flex items-start gap-3 rounded-lg border p-3 cursor-pointer transition-colors",n?"border-primary bg-primary/5":"bg-background",t&&"opacity-50 cursor-not-allowed"),children:[e.jsx(G,{checked:n,disabled:t,onCheckedChange:p=>{ts(u=>p?[...u,s.id]:u.filter(h=>h!==s.id)),p&&ke(s.id)}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ws,{className:"h-3.5 w-3.5 text-primary"}),s.label||(s.kind==="head_office"?"Head office":"Branch"),t&&e.jsx(Me,{variant:"secondary",className:"text-xs",children:"Paused by VZgate"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:fe(s)})]})]},s.id)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>r("/agency/profile?section=locations#section-locations"),children:[e.jsx(bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Add another address"]}),e.jsxs(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>X(),children:[e.jsx(Ns,{className:"h-3.5 w-3.5 mr-1.5"}),"Refresh list"]})]}),O.length>1&&e.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(s=>e.jsx(y,{type:"button",size:"sm",variant:(z==null?void 0:z.id)===s.id?"default":"outline",onClick:()=>ke(s.id),children:s.label||(s.kind==="head_office"?"Head office":"Branch")},s.id))}),z&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4"}),"Location Preview"]}),e.jsx(Lt,{latitude:z.latitude,longitude:z.longitude,address:fe(z),zoom:15,precise:!0,heightClass:"h-64"})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"meeting-instructions",children:"Additional Meeting Instructions (Optional)"}),e.jsx(D,{id:"meeting-instructions",placeholder:"Any special instructions for students (e.g., 'Schedule via chat', 'Bring passport copy', etc.)",value:Ce,onChange:s=>es(s.target.value),rows:3})]})]}),e.jsxs("div",{id:"milestones-section",className:"space-y-5 rounded-lg border border-border bg-background p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-lg font-semibold",children:"Service milestones"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:"Break the service into clear deliverables. Students see every step before they buy, and each share must add up to 100%."})]}),e.jsxs(Me,{variant:q===100?"default":"destructive",className:"w-fit shrink-0 gap-1.5 px-3 py-1.5",children:[q===100?e.jsx(vt,{className:"h-3.5 w-3.5"}):e.jsx(Yt,{className:"h-3.5 w-3.5"}),q,"% allocated"]})]}),e.jsxs("div",{className:"space-y-2","aria-label":`${q}% of the service price allocated`,children:[e.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-muted",children:K.map((s,t)=>e.jsx("div",{className:ms("h-full border-r border-primary-foreground/40 bg-primary transition-all last:border-r-0",t%2===1&&"bg-primary/70"),style:{width:`${Math.max(0,Math.min(Number(s.percent)||0,100))}%`}},s.id))}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Payment allocation"}),e.jsx("span",{className:q===100?"font-medium text-primary":"font-medium text-destructive",children:q===100?"Ready â totals 100%":q<100?`${100-q}% left to allocate`:`${q-100}% over the limit`})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute bottom-8 left-5 top-8 w-px bg-border","aria-hidden":"true"}),e.jsx("div",{className:"relative space-y-4",children:K.map((s,t)=>{const n=Number(R),p=Number.isFinite(n)&&n>0?_s(n*(Number(s.percent)||0)/100,W):null;return e.jsxs("div",{className:"relative pl-12",children:[e.jsx("div",{className:"absolute left-0 top-5 flex h-10 w-10 items-center justify-center rounded-full border-2 border-primary bg-background text-sm font-bold text-primary shadow-sm",children:t+1}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 shadow-sm transition-colors focus-within:border-primary/60 focus-within:ring-2 focus-within:ring-primary/10",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:["Milestone ",t+1]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown to students in this order"})]}),p&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"of the service price"})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_9rem]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{htmlFor:`milestone-name-${s.id}`,children:"Milestone name"}),e.jsx(H,{id:`milestone-name-${s.id}`,value:s.label,onChange:u=>Ae(s.id,{label:u.target.value}),placeholder:Te(t).label})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{htmlFor:`milestone-description-${s.id}`,children:"What the student receives"}),e.jsx(D,{id:`milestone-description-${s.id}`,value:s.description||"",onChange:u=>Ae(s.id,{description:u.target.value}),placeholder:Te(t).description,rows:2})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{htmlFor:`milestone-percent-${s.id}`,children:"Payment share"}),e.jsxs("div",{className:"relative",children:[e.jsx(V,{id:`milestone-percent-${s.id}`,min:0,max:100,value:s.percent,onValueChange:u=>Ae(s.id,{percent:u}),className:"pr-9 text-right font-semibold",placeholder:Te(t).percent}),e.jsx("span",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"%"})]})]}),e.jsxs(y,{type:"button",variant:"ghost",size:"sm",className:"mt-auto justify-start gap-2 text-destructive hover:text-destructive",onClick:()=>Ks(s.id),disabled:K.length===1,title:K.length===1?"A service needs at least one milestone":"Remove milestone",children:[e.jsx(qe,{className:"h-4 w-4"}),"Remove"]})]})]})]})]},s.id)})})]}),e.jsxs(y,{type:"button",variant:"outline",onClick:Ys,className:"w-full gap-2 border-dashed",children:[e.jsx(Is,{className:"h-4 w-4"}),"Add another milestone"]})]}),e.jsxs("div",{id:"policy-section",className:"space-y-4 rounded-lg border border-border bg-background p-4",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-lg font-semibold",children:"Your promises to the student"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Clear policies win more orders â and they're what our support team follows if a student asks for a redo or a refund."})]}),e.jsx(Ht,{value:k,onChange:Ds})]}),Object.keys(j).length>0&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"What students will also see"}),Array.isArray(j.included)&&j.included.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"What's included (one per line)"}),e.jsx(D,{rows:4,value:j.included.join(` 7`),onChange:s=>ie({...j,included:s.target.value.split(` 8`).filter(t=>t.trim())})})]}),Array.isArray(j.excluded)&&j.excluded.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Not included (one per line)"}),e.jsx(D,{rows:3,value:j.excluded.join(` 9`),onChange:s=>ie({...j,excluded:s.target.value.split(` 10`).filter(t=>t.trim())})})]}),Array.isArray(j.prerequisites)&&j.prerequisites.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Students must already have (one per line)"}),e.jsx(D,{rows:3,value:j.prerequisites.join(` 11`),onChange:s=>ie({...j,prerequisites:s.target.value.split(` 12`).filter(t=>t.trim())})})]})]}),e.jsxs("div",{id:"confirmations-section",className:"space-y-3 rounded-lg border border-primary/20 bg-primary/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your confirmation"}),Es&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"This draft was prepared with AI assistance from your own answers. It isn't approved or verified â you're responsible for everything it says."}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-sm",children:[e.jsx(G,{checked:be,onCheckedChange:s=>Ye(s===!0)}),e.jsx("span",{children:"What's included, excluded and required is accurate for this service."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-sm",children:[e.jsx(G,{checked:je,onCheckedChange:s=>Oe(s===!0)}),e.jsx("span",{children:"My refund and cancellation policy above is my own, and I will honour it."})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Both are required before you submit for review. Drafts can be saved without them."})]}),e.jsxs("div",{className:"bg-muted/50 p-4 rounded-lg space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Next Steps:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Services must be approved by admin before going live"}),e.jsx("li",{children:"You can edit drafts anytime before submission"}),!N&&e.jsx("li",{className:"text-amber-600",children:"Submit for Approval is unlocked once your identity verification is complete. Save as Draft now and publish later."})]})]}),A&&e.jsxs(hs,{variant:"destructive",children:[e.jsx(ds,{className:"h-4 w-4"}),e.jsx(xs,{children:"One thing to fix before submitting"}),e.jsxs(fs,{className:"space-y-2",children:[e.jsx("p",{children:A.message}),e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=document.getElementById(A.field);s==null||s.scrollIntoView({behavior:"smooth",block:"center"}),s&&typeof s.focus=="function"&&s.focus({preventScroll:!0})},children:"Take me there"})]})]}),g&&e.jsx(At,{notice:"notice-listing-submit",context:"listing_submit",hideButton:!0,onTickChange:a}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>r("/services"),children:"Cancel"}),e.jsxs(y,{type:"button",variant:"secondary",onClick:s=>Pe(s,!0),disabled:F,className:"flex-1",children:[F&&e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as Draft"]}),g&&e.jsxs(y,{id:"vz-submit-approval",type:"submit",disabled:F||!J,className:"flex-1",onClick:async s=>{if(s.preventDefault(),S.length>0&&S.every(us)&&!Qs){cs(!0);return}try{await jt(["notice-listing-submit"],"listing_submit")}catch(t){C.error(t.message);return}Pe(s,!1)},children:[F&&e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit for Approval"]}),e.jsx(bt,{open:Zs,onOpenChange:cs,children:e.jsxs(Nt,{children:[e.jsxs(wt,{children:[e.jsx(Ct,{children:"You're using template photos"}),e.jsx(kt,{children:"You're using one of our template photos. We recommend uploading your own so your service looks more original."})]}),e.jsxs(St,{children:[e.jsx(_t,{onClick:()=>{var s;return(s=document.getElementById("service-images-section"))==null?void 0:s.scrollIntoView({behavior:"smooth"})},children:"Upload my own"}),e.jsx(Tt,{onClick:()=>{Js(!0),setTimeout(()=>{var s;return(s=document.getElementById("vz-submit-approval"))==null?void 0:s.click()},0)},children:"Submit anyway"})]})]})})]}),!g&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your role can save drafts. An owner submits services for VZgate review."})]})})]}):e.jsx(ce,{className:"shadow-lg border-destructive/50",children:e.jsxs(le,{className:"pt-6",children:[e.jsxs(hs,{variant:"destructive",children:[e.jsx(ds,{className:"h-4 w-4"}),e.jsx(xs,{children:"Public Page Required"}),e.jsx(fs,{children:'You cannot create services until you activate your public page. Go to your dashboard and click "Create Public Page" to get started.'})]}),e.jsxs("div",{className:"mt-6 flex gap-3",children:[e.jsxs(y,{onClick:()=>r("/vendor-edit?section=about#section-about"),className:"flex-1",children:[e.jsx(ht,{className:"h-4 w-4 mr-2"}),"Activate Public Page Now"]}),e.jsx(y,{variant:"outline",onClick:()=>r("/services"),className:"flex-1",children:"Back to Dashboard"})]})]})})]})})}function Xt({amount:r,peg:i}){const{data:b}=Dt(),{data:o}=Et();if(!r||!b)return null;const T=["NGN","USD","GBP"].filter(N=>N!==i.toUpperCase()).slice(0,2);return e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pegged in ",i.toUpperCase(),". Students see"," ",T.map(N=>{try{const{amount:E}=Ut(r,i,N,b,o);return`â ${_s(E,N)} ${N}`}catch{return null}}
12).filter(Boolean).join(" · ")]})}export{ii 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.