PageSourceSearch

https://contentlyai.ai/assets/StudioNewImage-CanKCHcD.js

js contentlyai.ai collected 2026-10-05 15:30:49 UTC 24,480 bytes, 10 lines download raw bytes

1import{d as Qe,u as Ye,z as Ze,r as d,G as es,s as g,v as p,j as e,D as ss,f as rs,g as ts,h as as,i as os,E as ns,I as Ee,B as x,l as is,J as ee,C as De,a as Ue,X as ls}from"./index-BkXX1jM4.js";import{T as cs}from"./textarea-FktuWBif.js";import{O as ds}from"./OrbAnimation-C1TgZQjU.js";import{I as ms}from"./ImageModificationChat-DlKwDklg.js";import{u as us,C as N}from"./useCredits-DkygUqBh.js";import{C as hs}from"./CreditCostBadge-BAY0FiL8.js";import{L as gs}from"./LowCreditWarning-CW2wtOrF.js";import{u as ps}from"./useAgencyCredits-Bw4hSGDW.js";import{A as xs}from"./AgencyProjectSelector-DXxZiKfZ.js";import{c as se,g as fs}from"./contentlyStudioApi-G0V88yD5.js";import{u as bs}from"./useLeaveConfirmation-BYQNug_1.js";import{A as ys}from"./arrow-right-C-wpBS12.js";import{C as ws}from"./coins-D5nU1AAH.js";import{D as Ae}from"./download-6tWh1GIC.js";import{S as Le}from"./sparkles-C_SyXNKS.js";import{R as re}from"./refresh-cw-D-rPzfAS.js";import{L as js}from"./lightbulb-DRbvYNpY.js";import"./loader-circle-CCPo_TM_.js";import"./triangle-alert-D7SqPwNc.js";import"./folder-open-DZ5nAnFb.js";import"./check-CSNF23FR.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 vs=Qe("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);function Hs(){var we,je,ve,Ne,_e;
6const Te=Ye(),te=Ze(),{credits:Pe,checkCredits:ae,deductCredits:oe}=us(),[S,ne]=d.useState(""),[_,$e]=d.useState(null),[L,ie]=d.useState(!1),[k,le]=d.useState([]),[ce,Me]=d.useState(0),[E,de]=d.useState(""),[me,ue]=d.useState(!0),[Re,F]=d.useState(!1),[D,J]=d.useState([]),[U,z]=d.useState(0),[K,T]=d.useState(""),[P,C]=d.useState(null),[Oe,he]=d.useState(!1),[Ns,I]=d.useState(null),[u,q]=d.useState([]),[f,$]=d.useState([]),[l,M]=d.useState(0),[Ge,X]=d.useState(!1),[R,ge]=d.useState([]),[O,pe]=d.useState(!1),[Q,B]=d.useState(null),{agency:b,selectedProject:y,isAgencyUser:w}=es(),{pointsBalance:Fe,checkCredits:xe,deductCredits:fe}=ps((b==null?void 0:b.id)||null),{LeaveConfirmationDialog:ze}=bs({isActive:L,title:"هل تريد إلغاء توليد الصورة؟",description:"عملية توليد الصورة قيد التنفيذ وقد تستغرق بعض الوقت. هل أنت متأكد أنك تريد إلغاء العملية والمغادرة؟"}),Y=["صورة احترافية لمنتج على خلفية بيضاء نظيفة...","تصميم بوست إعلاني جذاب لوسائل التواصل الاجتماعي...","صورة تعبيرية عن النجاح والإنجاز في العمل...","تصميم كوفر لقصة انستجرام بألوان جذابة...","صورة احترافية لفريق عمل في مكتب عصري...","تصميم إنفوجرافيك توضيحي بأسلوب عصري..."];d.useEffect(()=>{He(),Be();const s=te.state;s!=null&&s.imageUrl&&(C(s.imageUrl),I(s.htmlCode||null),q([[{url:s.imageUrl,html:s.htmlCode||"",prompt:s.prompt||"صورة محفوظة"}]]),$([0]),M(0))},[te]);const Be=async()=>{try{const{data:{user:s}}=await g.auth.getUser();if(!s)return;const{data:r,error:t}=await g.from("image_prompt_suggestions").select("id, suggestion").eq("user_id",s.id).order("created_at",{ascending:!1});if(t)throw t;r&&(B(null),ge(r),r.length===0&&Z({showToast:!1}))}catch(s){console.error("Error loading suggestions:",s),B("تعذّر تحميل اقتراحات الذكاء الاصطناعي.")}},Z=async({showToast:s=!0}={})=>{pe(!0);try{B(null);const{data:{user:r}}=await g.auth.getUser();if(!r)return;const t=await se("/api/v1/image/suggest-prompts",{method:"POST",body:JSON.stringify({user_id:r.id,count:5})});if(!t.ok)throw new Error("Failed to fetch suggestions");const a=await t.json(),i=Array.isArray(a==null?void 0:a.suggestions)?a.suggestions:Array.isArray(a==null?void 0:a.prompts)?a.prompts:[];if(i.length===0)return;const v=i.map(h=>({user_id:r.id,suggestion:h}
6)),{data:c,error:n}=await g.from("image_prompt_suggestions").insert(v).select("id, suggestion");if(n)throw n;c&&c.length>0&&(ge(h=>[...c,...h]),s&&p.success("تم تحميل اقتراحات جديدة!"))}catch(r){console.error("Error fetching suggestions:",r),B("فشل في تحميل الاقتراحات."),s&&p.error("فشل في تحميل الاقتراحات")}finally{pe(!1)}},Ve=s=>{ne(s)};d.useEffect(()=>{const s=Y[ce];let r;return me?E.length<s.length?r=setTimeout(()=>{de(s.slice(0,E.length+1))},50):r=setTimeout(()=>{ue(!1)},2e3):E.length>0?r=setTimeout(()=>{de(E.slice(0,-1))},30):(Me(t=>(t+1)%Y.length),ue(!0)),()=>clearTimeout(r)},[E,me,ce,Y]);const He=async()=>{try{const{data:{user:s}}=await g.auth.getUser();if(!s)return;const{data:r,error:t}=await g.from("branding").select("*").eq("user_id",s.id).maybeSingle();if(t)throw t;r&&$e({business_name:r.business_name||"",logo_url:r.logo_url||"",brand_colors:r.brand_colors||[],brand_fonts:r.brand_fonts||[],business_brief:r.business_brief||"",tagline:r.tagline||"",additional_info:r.additional_info||""})}catch(s){console.error("Error loading branding data:",s)}},We=s=>{const r=s.target.files;if(r){const t=Array.from(r);J(t),z(0),T(""),F(!0)}s.target.value=""},be=()=>{if(!K.trim()){p.error("الرجاء إدخال وصف للصورة");return}const r={file:D[U],description:K.trim()};le(t=>[...t,r]),U<D.length-1?(z(t=>t+1),T("")):(F(!1),J([]),z(0),T(""))},Je=s=>{le(r=>r.filter((t,a)=>a!==s))},ye=async()=>{var r;if(!S.trim()){p.error("الرجاء إدخال وصف للصورة");return}if(w&&!y){X(!0);return}if(w?xe(N.IMAGE):await ae(N.IMAGE)){ie(!0);try{const{data:{user:t}}=await g.auth.getUser();if(!t){p.error("يجب تسجيل الدخول أولاً");return}const a=[];if(k.length>0)for(const o of k){const m=o.file.name.split(".").pop(),j=`${t.id}/${Date.now()}_${Math.random().toString(36).substring(7)}.${m}`,{data:Ce,error:W}=await g.storage.from("user-uploads").upload(j,o.file);if(W){console.error("Error uploading image:",W);continue}const{data:{publicUrl:G}}=g.storage.from("user-uploads").getPublicUrl(j);a.push(G),o.url=G}let i=S;k.length>0&&(i+=`
7
8Reference images:
9`,k.forEach((o,m)=>{i+=`${m+1}. ${o.description}`,o.url&&(i+=` (URL: ${o.url})`),i+=`
10`})),_&&(_.business_name&&(i+=` For ${_.business_name}.`),_.brand_colors&&_.brand_colors.length>0&&(i+=` Use brand colors: ${_.brand_colors.join(", ")}.`),_.business_brief&&(i+=` Brand style: ${_.business_brief}`));const v=await se("/api/v1/image/generate-ai",{method:"POST",body:JSON.stringify({prompt:i,width:1080,height:1080,user_id:t.id})});if(!v.ok)throw new Error("فشل في الاتصال بالخادم");const c=await v.json();if(!c.success)throw new Error(c.error||"فشل في إنشاء الصورة");const n=[];if(c.results&&Array.isArray(c.results)&&c.results.length>0){for(const o of c.results)if(o.image_url){const m=fs(o.image_url);n.push({image_url:m,html_code:o.html_code||null})}}else if(c.image_urls&&c.image_urls.length>0)c.image_urls.forEach(o=>{const m=o.startsWith("http")?o:`https://contently-studio.onrender.com${o}`;n.push({image_url:m,html_code:c.html_code||null})});else if(c.image_url){const o=c.image_url.startsWith("http")?c.image_url:`https://contently-studio.onrender.com${c.image_url}`;n.push({image_url:o,html_code:c.html_code||null})}if(n.length===0)throw new Error("لم يتم إرجاع أي صور");const h=[];for(let o=0;o<n.length;o++){const m=n[o];try{const j=await fetch(m.image_url);if(!j.ok){console.error(`Failed to fetch image ${o+1}`);continue}const Ce=await j.blob(),W=Date.now(),G=`${t.id}/${W}_${o}.png`,{error:Ie}=await g.storage.from("generated-images").upload(G,Ce,{contentType:"image/png",upsert:!1});if(Ie){console.error(`Failed to upload image ${o+1}:`,Ie);continue}const{data:Xe}=g.storage.from("generated-images").getPublicUrl(G),Se=Xe.publicUrl;h.push({url:Se,html_code:m.html_code||null});const{error:ke}=await g.from("archived_images").insert({user_id:t.id,prompt:S,image_url:Se,html_code:m.html_code||null,agency_id:w&&y?b==null?void 0:b.id:null,agency_project_id:w&&y?y.id:null});ke&&console.error(`Error saving image ${o+1} to database:`,ke)}catch(j){console.error(`Error processing image ${o+1}:`,j)}}if(h.length===0)throw new Error("فشل في حفظ الصور");if(w&&b&&y){const{data:o}=await g.auth.getUser();await fe(N.IMAGE,"image",((r=o.user)==null?void 0:r.id)||"",y.id)}else await oe(N.IMAGE,"توليد صورة بالذكاء الاصطناعي");const A=h.map(o=>[{url:o.url,html:o.html_code||"",prompt:S}]);q(A),$(h.map(()=>0));const V=h[0];C(V.url),I(V.html_code),M(0);const H=h.length>1?`تم إنشاء ${h.length} صور بنجاح!`:"تم إنشاء الصورة بنجاح!";p.success(H)}catch(t){console.error("Error generating image:",t),p.error("فشل إنشاء الصورة")}finally{ie(!1)}}},Ke=async s=>{if(!P||u.length===0)return;const r=u[l],t=f[l]||0;if(!(!r||r.length===0||!(w?xe(N.IMAGE_EDIT):await ae(N.IMAGE_EDIT)))){he(!0);try{const{data:{user:i}}=await g.auth.getUser();if(!i)return;const v=r[t].html,c=await se("/api/v1/html/edit",{method:"POST",body:JSON.stringify({html_code:v,prompt:s,model:"gpt-5.1",width:1080,height:1080,render_image:!0})});let n=null;try{n=await c.json()}catch(o){console.error("Error parsing HTML edit response:",o)}if(!c.ok||(n==null?void 0:n.success)===!1)throw console.error("HTML edit API error:",c.status,n),new Error((n==null?void 0:n.message)||"فشل في الاتصال بالخادم");const h=(n==null?void 0:n.edited_html)||(n==null?void 0:n.html_code)||v,A=n!=null&&n.image_url?`https://contently-studio.onrender.com${n.image_url}`:P;if(!h||!A)throw console.error("Invalid HTML edit response payload:",n),new Error("استجابة غير صالحة من الخادم");C(A),I(h);const V={url:A,html:h,prompt:s};q(o=>{const m=[...o];return m[l]=[...m[l]||[],V],m}),$(o=>{var j;const m=[...o];return m[l]=((j=u[l])==null?void 0:j.length)||0,m});const{error:H}=await g.from("archived_images").insert({user_id:i.id,prompt:s,image_url:A,html_code:h,agency_id:w&&y?b==null?void 0:b.id:null,agency_project_id:w&&y?y.id:null});H&&console.error("Error saving modified image:",H),w&&b&&y?await fe(N.IMAGE_EDIT,"image_edit",i.id,y.id):await oe(N.IMAGE_EDIT,"تعديل صورة بالذكاء الاصطناعي"),p.success("تم تعديل الصورة بنجاح!")}catch(i){console.error("Error modifying image:",i),p.error("فشل تعديل الصورة")}finally{he(!1)}}},qe=async()=>{var a;const s=u[l],r=f[l]||0,t=((a=s==null?void 0:s[r])==null?void 0:a.url)||P;if(t)try{const v=await(await fetch(t)).blob(),c=window.URL.createObjectURL(v),n=document.createElement("a");n.href=c,n.download=`contently-image-${Date.now()}.png`,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(c),p.success("تم تنزيل الصورة بنجاح!")}catch(i){console.error("Error downloading image:",i),p.error("فشل تنزيل الصورة")}};return e.jsxs("div",{className:"min-h-screen bg-background",dir:"rtl",children:[e.jsx(ze,{}),e.jsx(ss,{open:Re,onOpenChange:F,children:e.jsxs(rs,{className:"sm:max-w-md border-0 shadow-2xl rounded-3xl backdrop-blur-xl",dir:"rtl",children:[e.jsxs(ts,{children:[e.jsx(as,{className:"text-right",children:"وصف الصورة"}),e.jsxs(os,{className:"text-right",children:["الصورة ",U+1," من ",D.length]})]}),e.jsxs("div",{className:"space-y-4",children:[D[U]&&e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:URL.createObjectURL(D[U]),alt:"Preview",className:"max-h-48 rounded-lg border-0 shadow-sm"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ns,{htmlFor:"image-description",className:"text-right block",children:"وصف الصورة (مثال: شعار، منتج، خلفية)"}),e.jsx(Ee,{id:"image-description",value:K,onChange:s=>T(s.target.value),placeholder:"اكتب وصف الصورة...",className:"text-right",onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),be())}})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(x,{variant:"outline",onClick:()=>{F(!1),J([]),z(0),T("")},children:"إلغاء"}
10),e.jsx(x,{onClick:be,children:U<D.length-1?"التالي":"إضافة"})]})]})]})}),L&&e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/95 backdrop-blur-sm",children:e.jsx(ds,{title:"جاري توليد الصورة...",subtitle:"كونتنتلي يعمل على إنشاء صورة احترافية لك"})}),e.jsx("header",{className:"sticky top-0 z-10 backdrop-blur-xl bg-background/90 border-b border-border/10",children:e.jsx("div",{className:"container mx-auto px-4 sm:px-6 py-3 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:()=>Te("/studio"),className:"hover:bg-primary/10 hover:text-primary transition-all rounded-xl h-9 w-9 sm:h-10 sm:w-10",children:e.jsx(ys,{className:"h-4 w-4 sm:h-5 sm:w-5"})}),e.jsx("div",{className:"h-6 sm:h-8 w-px bg-border/30 hidden sm:block"}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("img",{src:is,alt:"Contently Logo",className:"h-5 sm:h-7 w-auto brightness-0 dark:brightness-100"}),e.jsx("h1",{className:"text-base sm:text-xl font-semibold text-foreground hidden sm:block",children:"إنشاء صورة جديدة"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-4 py-1.5 sm:py-2 rounded-xl bg-gradient-to-l from-primary/10 to-primary/5 border border-primary/20",children:[e.jsx("span",{className:"text-xs sm:text-sm font-medium text-foreground",children:w?Fe??0:Pe??0}),e.jsx(ws,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4 text-primary"}),e.jsx("span",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"نقطة"})]})]})})}),e.jsxs("main",{className:"container mx-auto px-4 sm:px-6 py-4 sm:py-8",children:[e.jsx(gs,{}),P?e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6 min-h-[calc(100vh-10rem)] lg:h-[calc(100vh-12rem)]",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4",children:[e.jsx(ee,{className:"p-4 bg-card/50 backdrop-blur-sm border-0 shadow-sm rounded-2xl",children:e.jsx("img",{src:((je=(we=u[l])==null?void 0:we[f[l]||0])==null?void 0:je.url)||P,alt:"Generated",className:"max-w-full max-h-[calc(100vh-20rem)] rounded-xl shadow-lg"})}),u.length>1&&e.jsxs("div",{className:"flex items-center gap-2 bg-card/50 backdrop-blur-sm border-0 shadow-sm rounded-xl px-4 py-2",children:[e.jsx(x,{variant:"ghost",size:"sm",disabled:l===0,onClick:()=>{var a;const s=l-1;M(s);const r=f[s]||0,t=(a=u[s])==null?void 0:a[r];t&&(C(t.url),I(t.html))},className:"h-8 w-8 p-0 hover:bg-primary/10 disabled:opacity-30",children:e.jsx(De,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:u.map((s,r)=>e.jsx("button",{onClick:()=>{var i;M(r);const t=f[r]||0,a=(i=u[r])==null?void 0:i[t];a&&(C(a.url),I(a.html))},className:`w-2 h-2 rounded-full transition-all ${r===l?"bg-primary w-4":"bg-muted-foreground/30 hover:bg-muted-foreground/50"}`},r))}),e.jsx(x,{variant:"ghost",size:"sm",disabled:l===u.length-1,onClick:()=>{var a;const s=l+1;M(s);const r=f[s]||0,t=(a=u[s])==null?void 0:a[r];t&&(C(t.url),I(t.html))},className:"h-8 w-8 p-0 hover:bg-primary/10 disabled:opacity-30",children:e.jsx(Ue,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-muted-foreground mr-2",children:["صورة ",l+1," من ",u.length]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(x,{onClick:qe,className:"bg-gradient-to-l from-primary to-primary/80 hover:from-primary/90 hover:to-primary/70 text-primary-foreground shadow-lg hover:shadow-xl transition-all rounded-xl",children:[e.jsx(Ae,{className:"w-4 h-4 ml-2"}),"تحميل الصورة"]}),(((ve=u[l])==null?void 0:ve.length)||0)>1&&e.jsxs("div",{className:"flex items-center gap-2 bg-gradient-to-l from-secondary/80 to-secondary/40 backdrop-blur-sm border border-border/20 shadow-sm rounded-xl px-4 py-2",children:[e.jsx(x,{variant:"ghost",size:"sm",disabled:(f[l]||0)===(((Ne=u[l])==null?void 0:Ne.length)||1)-1,onClick:()=>{var t;const s=(f[l]||0)+1;$(a=>{const i=[...a];return i[l]=s,i});const r=(t=u[l])==null?void 0:t[s];r&&(C(r.url),I(r.html))},className:"h-8 w-8 p-0 hover:bg-primary/10 disabled:opacity-30",title:"النسخة التالية",children:e.jsx(De,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex flex-col items-center min-w-[80px]",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"سجل التعديلات"}),e.jsxs("span",{className:"text-sm font-medium text-foreground",children:["نسخة ",(f[l]||0)+1," من ",((_e=u[l])==null?void 0:_e.length)||1]})]}),e.jsx(x,{variant:"ghost",size:"sm",disabled:(f[l]||0)===0,onClick:()=>{var t;const s=(f[l]||0)-1;$(a=>{const i=[...a];return i[l]=s,i});const r=(t=u[l])==null?void 0:t[s];r&&(C(r.url),I(r.html))},className:"h-8 w-8 p-0 hover:bg-primary/10 disabled:opacity-30",title:"النسخة السابقة",children:e.jsx(Ue,{className:"h-4 w-4"})})]})]})]}),e.jsx("div",{className:"h-full",children:e.jsx(ms,{onModify:Ke,isModifying:Oe})})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:`max-w-3xl mx-auto 
10space-y-6 sm:space-y-8 transition-opacity duration-300 ${L?"opacity-0 pointer-events-none":"opacity-100"}`,children:[e.jsx(ee,{className:"p-4 sm:p-6 md:p-8 bg-gradient-to-br from-card/80 to-card/40 backdrop-blur-xl border border-border/10 shadow-2xl rounded-2xl sm:rounded-3xl",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-6 sm:h-8 w-1 bg-gradient-to-b from-primary to-primary/40 rounded-full"}),e.jsx("h2",{className:"text-base sm:text-lg font-medium text-foreground",children:"اكتب وصف الصورة"})]}),e.jsx(cs,{id:"prompt-input",value:S,onChange:s=>ne(s.target.value),placeholder:E,className:"min-h-[120px] sm:min-h-[140px] text-right resize-none text-sm sm:text-base rounded-xl sm:rounded-2xl border-0 bg-background/60 backdrop-blur-sm shadow-inner focus-visible:ring-2 focus-visible:ring-primary/20 focus-visible:ring-offset-0 transition-all placeholder:text-muted-foreground/50",onKeyDown:s=>{s.key==="Enter"&&s.ctrlKey&&(s.preventDefault(),ye())}})]}),e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row items-stretch sm:items-center justify-between gap-3 sm:gap-4 pt-2",children:[e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground text-center sm:text-right",children:"Ctrl+Enter للإنشاء السريع"}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer flex-1 sm:flex-none",children:[e.jsx(x,{type:"button",variant:"outline",className:"rounded-xl border border-border/30 hover:border-primary/30 hover:bg-primary/5 hover:text-primary transition-all h-10 sm:h-11 px-3 sm:px-5 w-full sm:w-auto text-sm",asChild:!0,children:e.jsxs("div",{children:[e.jsx(vs,{className:"w-4 h-4 ml-1.5 sm:ml-2"}),e.jsx("span",{className:"hidden sm:inline",children:"إرفاق صورة"}),e.jsx("span",{className:"sm:hidden",children:"إرفاق"})]})}),e.jsx(Ee,{id:"image-upload",type:"file",accept:"image/*",multiple:!0,onChange:We,className:"hidden"})]}),e.jsx(x,{onClick:ye,disabled:L||!S.trim(),className:"bg-gradient-to-l from-primary to-primary/80 hover:from-primary/90 hover:to-primary/70 text-primary-foreground shadow-lg hover:shadow-xl hover:scale-[1.02] transition-all rounded-xl h-10 sm:h-11 px-4 sm:px-6 gap-1.5 sm:gap-2 flex-1 sm:flex-none text-sm",children:L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-primary-foreground/30 border-t-primary-foreground ml-1.5 sm:ml-2"}),e.jsx("span",{className:"hidden sm:inline",children:"جاري الإنشاء..."}),e.jsx("span",{className:"sm:hidden",children:"جاري..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{className:"w-4 h-4 ml-1 sm:ml-2"}),e.jsx("span",{className:"hidden sm:inline",children:"إنشاء صورة"}),e.jsx("span",{className:"sm:hidden",children:"إنشاء"}),e.jsx(hs,{cost:N.IMAGE})]})})]})]})]})}),(R.length>0||O||Q)&&e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>Z({showToast:!0}),disabled:O,className:"text-[10px] sm:text-xs text-muted-foreground hover:text-primary hover:bg-primary/5 rounded-lg gap-1 sm:gap-1.5 h-7 sm:h-8 px-2 sm:px-3",children:[O?e.jsx(re,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5 animate-spin"}):e.jsx(re,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),"تحديث"]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-xs sm:text-sm font-medium text-foreground",children:"اقتراحات ذكية"}),e.jsx("div",{className:"p-1 sm:p-1.5 rounded-lg bg-primary/10",children:e.jsx(js,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-primary"})})]})]}),R.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2 justify-end",children:R.slice(0,8).map(s=>{let r=s.suggestion,t=s.suggestion;try{const a=JSON.parse(s.suggestion);r=a.title||s.suggestion,t=a.prompt||s.suggestion}catch{}return e.jsx("button",{onClick:()=>Ve(t),className:"px-2.5 sm:px-4 py-1.5 sm:py-2 text-xs sm:text-sm bg-background/60 hover:bg-primary/10 text-foreground rounded-lg sm:rounded-xl border border-border/20 hover:border-primary/30 hover:text-primary transition-all text-right shadow-sm hover:shadow-md active:scale-95",title:t,children:r.length>
10(window.innerWidth<640?25:40)?r.substring(0,window.innerWidth<640?25:40)+"...":r},s.id)})}),R.length===0&&O&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-8",children:[e.jsx(re,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"جاري تحميل الاقتراحات..."})]}),R.length===0&&!O&&Q&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Q}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>Z({showToast:!0}),className:"mt-3 rounded-xl",children:[e.jsx(Le,{className:"w-4 h-4 ml-2"}),"تحميل اقتراحات"]})]})]}),k.length>0&&e.jsx(ee,{className:"p-4 sm:p-6 bg-card/50 backdrop-blur-sm border border-border/10 rounded-xl sm:rounded-2xl",children:e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("h3",{className:"text-xs sm:text-sm font-medium text-foreground text-right",children:"الصور المرفقة"}),e.jsx("div",{className:"space-y-2 sm:space-y-3",children:k.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2 sm:p-3 bg-background/60 rounded-lg sm:rounded-xl",children:[e.jsx("img",{src:URL.createObjectURL(s.file),alt:s.description,className:"w-10 h-10 sm:w-14 sm:h-14 object-cover rounded-md sm:rounded-lg shadow-sm"}),e.jsxs("div",{className:"flex-1 text-right min-w-0",children:[e.jsx("p",{className:"text-xs sm:text-sm font-medium text-foreground truncate",children:s.description}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground truncate",children:s.file.name})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>{const t=URL.createObjectURL(s.file),a=document.createElement("a");a.href=t,a.download=s.file.name,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t),p.success("تم تنزيل الصورة")},className:"bg-primary/10 text-primary hover:bg-primary/20 rounded-full w-7 h-7 sm:w-8 sm:h-8 flex items-center justify-center transition-colors active:scale-95",children:e.jsx(Ae,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"})}),e.jsx("button",{onClick:()=>Je(r),className:"bg-destructive/10 text-destructive hover:bg-destructive/20 rounded-full w-7 h-7 sm:w-8 sm:h-8 flex items-center justify-center transition-colors active:scale-95",children:e.jsx(ls,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]},r))})]})})]})})]}),e.jsx(xs,{open:Ge,onOpenChange:X,onSelect:()=>{X(!1)},title:"اختر ملف العميل",description:"يرجى اختيار ملف العميل قبل توليد الصورة"})]})}export{Hs 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.