1import{f as ee,d as te,r as i,j as e,L as ae}from"./vendor-react-NDqzZ9RJ.js";import{u as re,s as z,G as T,P as se,K as U,at as le,au as ne,L as ie,e as oe,a as x}from"./index-CoM1tmaP.js";import{B as M}from"./BackButton-nzMyGzSx.js";import{T as de}from"./tarot-CsO9odGI.js";import"./vendor-pdf-DcnCMWs_.js";import"./vendor-charts-BLT5JiYK.js";import"./vendor-tiptap-BiZ4HMKr.js";import"./arrow-left-CRn4fcxS.js";const B={kahve:{label:"Kahve Falı",kind:"coffee",noteLabel:"Falcıya iletmek istediÄin not (isteÄe baÄlı)",placeholder:"Merak ettiÄin konu, sormak istediÄin soruâ¦"},fal:{label:"Kahve Falı",kind:"coffee",noteLabel:"Falcıya iletmek istediÄin not (isteÄe baÄlı)",placeholder:"Merak ettiÄin konu, sormak istediÄin soruâ¦"},ruya:{label:"Rüya Yorumu",kind:"dream",noteLabel:"Rüyanı anlat",placeholder:"GördüÄün rüyayı olabildiÄince detaylı yazâ¦"},ask:{label:"AÅk Falı",kind:"love",noteLabel:"Durumunu / sorunu yaz",placeholder:"İliÅkinle ilgili merak ettiÄin, sormak istediÄin Åeyâ¦"},tarot:{label:"Tarot",kind:"tarot",noteLabel:"Tarot'a sormak istediÄin soru",placeholder:"Tarot'a sormak istediÄin soruâ¦"}};function ce(y=22){return i.useMemo(()=>{const f=[...de];for(let o=f.length-1;o>0;o--){const r=Math.floor(Math.random()*(o+1));[f[o],f[r]]=[f[r],f[o]]}return f.slice(0,y)},[y])}const k=10,_=10,Y=["GeçmiÅ","Åimdi","Yakın Gelecek","Duyguların","Zihnin","DıŠEtkiler","Engel / Ders","Tavsiye","Umutlar & Korkular","Sonuç"];function ke(){var P;const{orderId:y}=ee(),f=te(),{user:o}=re(),[r,I]=i.useState(null),[q,H]=i.useState(!0),[l,X]=i.useState(""),[w,A]=i.useState([]),[v,K]=i.useState([]),[L,D]=i.useState(!1),F=ce(22),[g,R]=i.useState([]),[p,$]=i.useState(null),Q=t=>{R(a=>a.includes(t)?a.filter(s=>s!==t):a.length>=_?a:[...a,t])},[b,E]=i.useState({name:"",birth:""}),[h,O]=i.useState({name:"",birth:""});i.useEffect(()=>{!y||!o||z.from("fortune_orders").select("*, teller:fortune_teller_profiles!fortune_orders_teller_id_fkey(display_name)").eq("id",y).maybeSingle().then(({data:t})=>{I(t),H(!1)})},[y,o]);const W=t=>{if(!t)return;const a=Array.from(t).filter(d=>d.type.startsWith("image/")),s=k-w.length;if(s<=0){x.error(`En fazla ${k} fotoÄraf yükleyebilirsin.`);return}const n=a.slice(0,s);A(d=>[...d,...n]),K(d=>[...d,...n.map(m=>URL.createObjectURL(m))]),a.length>n.length&&x.warning(`${k} fotoÄraf sınırına ulaÅıldı.`)},Z=t=>{A(a=>a.filter((s,n)=>n!==t)),K(a=>{const s=a[t];return s&&URL.revokeObjectURL(s),a.filter((n,d)=>d!==t)})},j=B[String((r==null?void 0:r.content_type)??"kahve")]??B.kahve,J=!!(r!=null&&r.customer_note||r!=null&&r.customer_image_url||Array.isArray(r==null?void 0:r.customer_image_urls)&&r.customer_image_urls.length>0)||(r==null?void 0:r.reading_status)==="done",S=j.kind==="coffee",c=j.kind==="tarot",C=j.kind==="love",V=async()=>{if(!(!o||!r||L)){if(S&&w.length===0&&!l.trim()){x.error("Lütfen en az bir fincan fotoÄrafı yükle ya da bir not yaz.");return}if(c&&p===null){x.error("Kartları kendin mi seçmek istersin, yoksa falcın mı çeksin?");return}if(c&&p==="self"&&g.length!==_){x.error(`Lütfen ${_} tarot kartı seç. (Åu an ${g.length})`);return}if(C&&(!b.name.trim()||!h.name.trim())){x.error("Lütfen iki kiÅinin adını gir.");return}if(!S&&!c&&!C&&l.trim().length<5){x.error("Lütfen falcıya iletmek istediÄini yaz.");return}D(!0);try{const t=[];for(let m=0;m<w.length;m++){const u=w[m],N=`${o.id}/order-${r.id}-${Date.now()}-${m}.jpg`,{error:G}=await z.storage.from("fortune-images").upload(N,u,{upsert:!0,contentType:u.type||"image/jpeg"});if(G)throw G;t.push(z.storage.from("fortune-images").getPublicUrl(N).data.publicUrl)}const a=t[0]??null;let s=l.trim(),n=null;if(c)if(p==="self"){const m=g.map((u,N)=>({position:Y[N]??`Kart ${N+1}`,name:F[u].name,symbol:F[u].symbol,order:N+1}));n=m,s=["ð´ 10 kartlık açılım (danıÅan seçti):",...m.map(u=>` ${u.order}. ${u.position} â ${u.name}`),"",l.trim()?`Soru: ${l.trim()}`:"Soru belirtilmedi."].join(` 2`)}else n=null,s=["ð´ DanıÅan kart seçimini FALCIYA bıraktı.","Lütfen 10 kartlık pozisyonlu açılımı sen çek ve pozisyonlarına göre yorumla.","",l.trim()?`Soru: ${l.trim()}`:"Soru belirtilmedi."].join(` 3`);else C?s=[`ð KiÅi 1: ${b.name.trim()}${b.birth?` (${b.birth})`:""}`,`ð KiÅi 2: ${h.name.trim()}${h.birth?` (${h.birth})`:""}`,l.trim()?`Soru: ${l.trim()}
3`:""].filter(Boolean).join(` 4`):S&&t.length>1&&(s=[`â ${t.length} fincan/tabak fotoÄrafı gönderildi.`,l.trim()?`Not: ${l.trim()}`:""].filter(Boolean).join(` 5`));const{error:d}=await z.from("fortune_orders").update({customer_note:s||null,customer_image_url:a,customer_image_urls:t,customer_cards:n}).eq("id",r.id);if(d)throw d;x.success(c&&p==="teller"?"Falcına iletildi â kartları o çekecek. Yorum hazır olunca bildirim alacaksın. ð®":"Falcına gönderildi! Falın hazır olunca bildirim alacaksın. ð®"),f("/siparislerim")}catch(t){x.error((t==null?void 0:t.message)||"Gönderilemedi, tekrar dene.")}finally{D(!1)}}};return q?e.jsx("p",{className:"text-center text-muted-foreground p-8",children:"Yükleniyorâ¦"}):r?e.jsxs("div",{className:"page-fade flex flex-col gap-4 max-w-md mx-auto",children:[e.jsx(M,{}),e.jsxs(T,{className:"flex flex-col gap-1 text-center",children:[e.jsxs("h2",{className:"font-display text-xl gold-text",children:[((P=r.teller)==null?void 0:P.display_name)??"Falcın"," için ",j.label]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ãdemen alındı. Åimdi falcına fal bilgini gönder; hazırlayıp sana iletecek."})]}),J?e.jsxs(T,{className:"flex flex-col items-center gap-3 text-center py-8",children:[e.jsx(se,{className:"w-12 h-12 text-mystic-green"}),e.jsx("p",{className:"font-semibold",children:"Fal bilgin falcına gönderildi."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Falcın hazırlıyor. Hazır olunca bildirim göndereceÄiz."}),e.jsx(ae,{to:"/siparislerim",children:e.jsx(U,{className:"bg-gradient-primary",children:"SipariÅlerime Git"})})]}):e.jsxs(T,{className:"flex flex-col gap-4",children:[S&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-semibold",children:"Fincan FotoÄrafları"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[v.length," / ",k]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground -mt-1",children:["En fazla ",k," fotoÄraf ekleyebilirsin. Fincanın içi, tabaÄı ve farklı açılardan çekimler yorumu zenginleÅtirir."]}),v.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:v.map((t,a)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border border-border/40 bg-bg-elevated",children:[e.jsx("img",{src:t,alt:`fincan ${a+1}`,className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>Z(a),"aria-label":`FotoÄraf ${a+1} kaldır`,className:"absolute top-1 right-1 w-6 h-6 rounded-full bg-black/70 text-white flex items-center justify-center hover:bg-black",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"absolute bottom-1 left-1 px-1.5 rounded bg-black/70 text-white text-[10px] font-semibold",children:a+1})]},a))}),v.length<k&&e.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 border-2 border-dashed border-border/60 rounded-xl p-6 cursor-pointer hover:border-primary/50",children:[e.jsx(ne,{className:"w-8 h-8 text-primary-glow"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["FotoÄraf ekle (",k-v.length," hakkın kaldı)"]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:t=>{W(t.target.files),t.currentTarget.value=""}})]})]}),c&&p===null&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("label",{className:"text-sm font-semibold",children:"Kartları kim çeksin?"}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"İstersen sezgine güvenip 10 kartı sen çek, ya da tamamen falcının enerjisine bırak â falcın senin için çeksin."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>$("self"),className:"p-4 rounded-xl border border-primary/40 bg-primary/10 hover:bg-primary/20 text-left transition",children:[e.jsx("div",{className:"font-semibold text-primary mb-1",children:"ð´ Kartları ben seçmek istiyorum"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"10 kartı sezgime göre kendim çekeyim."})]}),e.jsxs("button",{type:"button",onClick:()=>$("teller"),className:"p-4 rounded-xl border border-gold/40 bg-gold/10 hover:bg-gold/20 text-left transition",children:[e.jsx("div",{className:"font-semibold text-gold-soft mb-1",children:"ð® Falcım çeksin"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Kartları tamamen falcının enerjisine bırakıyorum."})]})]})]}),c&&p==="self"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-semibold",children:["Sezgine güvenerek ",_," kart seç"]}
5),e.jsx("button",{type:"button",onClick:()=>{$(null),R([])},className:"text-[11px] text-primary underline self-start -mt-1",children:"â Kart çekme yöntemini deÄiÅtir"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Kartların arkası dönük â hangileri seni çaÄırıyorsa sırayla dokun. SeçtiÄin sıraya göre ",e.jsx("span",{className:"text-gold-soft",children:"GeçmiÅ, Åimdi, Gelecek, Duygularâ¦"})," gibi 10 farklı pozisyona yerleÅir."]}),e.jsx("div",{className:"grid grid-cols-5 sm:grid-cols-6 gap-1.5 mt-1",children:F.map((t,a)=>{const s=g.includes(a),n=g.indexOf(a);return e.jsxs("button",{type:"button",onClick:()=>Q(a),className:"aspect-[2/3] rounded-lg border text-2xl flex items-center justify-center relative transition-all "+(s?"bg-gradient-gold text-[#1a0a00] border-gold shadow-gold":"bg-bg-elevated border-border/40 hover:border-primary/40"),children:[s?e.jsxs("span",{className:"flex flex-col items-center leading-tight px-1 text-center",children:[e.jsx("span",{children:t.symbol}),e.jsx("span",{className:"text-[9px] mt-0.5 font-semibold line-clamp-2",children:t.name})]}):e.jsx("span",{className:"text-primary-glow/70",children:"â¦"}),s&&e.jsx("span",{className:"absolute -top-1.5 -left-1.5 w-5 h-5 rounded-full bg-primary text-white text-[10px] font-bold flex items-center justify-center shadow",children:n+1})]},t.id)})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Seçilen: ",e.jsx("span",{className:"text-gold-soft font-semibold",children:g.length})," / ",_]}),g.length>0&&e.jsx("ol",{className:"text-[11px] text-muted-foreground grid grid-cols-1 sm:grid-cols-2 gap-x-3 gap-y-0.5 mt-1 pl-4 list-decimal",children:g.map((t,a)=>e.jsxs("li",{children:[e.jsx("span",{className:"text-gold-soft",children:Y[a]}),": ",F[t].name]},t))})]}),c&&p==="teller"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"p-3 rounded-lg border border-gold/40 bg-gold/10 text-sm",children:["ð® ",e.jsx("span",{className:"font-semibold text-gold-soft",children:"Kartları falcın çekecek."})," AÅaÄıya sadece merak ettiÄin soruyu yaz."]}),e.jsx("button",{type:"button",onClick:()=>$(null),className:"text-[11px] text-primary underline self-start",children:"â Kart çekme yöntemini deÄiÅtir"})]}),C&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-sm font-semibold",children:"Senin adın"}),e.jsx("input",{value:b.name,onChange:t=>E({...b,name:t.target.value}),placeholder:"Ad Soyad",className:"rounded-xl bg-bg-elevated border border-border/50 p-2.5 text-sm focus:border-primary outline-none"}),e.jsx("label",{className:"text-xs text-muted-foreground mt-1",children:"DoÄum tarihin"}),e.jsx("input",{type:"date",value:b.birth,onChange:t=>E({...b,birth:t.target.value}),className:"rounded-xl bg-bg-elevated border border-border/50 p-2 text-sm focus:border-primary outline-none"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-sm font-semibold",children:"DiÄer kiÅinin adı"}),e.jsx("input",{value:h.name,onChange:t=>O({...h,name:t.target.value}),placeholder:"Ad Soyad",className:"rounded-xl bg-bg-elevated border border-border/50 p-2.5 text-sm focus:border-primary outline-none"}),e.jsx("label",{className:"text-xs text-muted-foreground mt-1",children:"DoÄum tarihi (biliyorsan)"}),e.jsx("input",{type:"date",value:h.birth,onChange:t=>O({...h,birth:t.target.value}),className:"rounded-xl bg-bg-elevated border border-border/50 p-2 text-sm focus:border-primary outline-none"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold",children:j.noteLabel}),e.jsx("textarea",{value:l,onChange:t=>X(t.target.value),placeholder:j.placeholder,rows:S||c?3:6,className:"w-full rounded-xl bg-bg-elevated border border-border/50 p-3 text-sm resize-none focus:border-primary outline-none"})]}),e.jsx(U,{onClick:V,disabled:L,className:"bg-gradient-gold text-[#1a0a00] h-12 font-semibold shadow-gold",children:L?e.jsx(ie,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-4 h-4 mr-2"})," Falcıya Gönder"]})})]})]}):e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(M,{}),e.jsx("p",{className:"text-muted-foreground mt-4",children:"SipariÅ bulunamadı."})]})}
5export{ke 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.