@creaditor/business-ai 1.0.59 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/business-ai.es.js
CHANGED
|
@@ -26988,7 +26988,7 @@ const Gl = Tl, TO = [
|
|
|
26988
26988
|
};
|
|
26989
26989
|
function KO(e, t, n) {
|
|
26990
26990
|
let a = "";
|
|
26991
|
-
const r = n.trim().toLowerCase();
|
|
26991
|
+
const r = (n || "").trim().toLowerCase();
|
|
26992
26992
|
if (r)
|
|
26993
26993
|
try {
|
|
26994
26994
|
const o = /^https?:\/\//i.test(r) ? r : `https://${r}`;
|
package/dist/business-ai.umd.js
CHANGED
|
@@ -521,7 +521,7 @@ data: `)[1];throw console.error("[v3-sse] error event:",W),new Error(JSON.parse(
|
|
|
521
521
|
${c(u,.8)} 0%,
|
|
522
522
|
${c(u,.6)} 50%,
|
|
523
523
|
${c(u,.4)} 100%
|
|
524
|
-
)`,animationDelay:`${f*.15}s`}},f))})]}),A.jsxs(fe,{className:l?gh:"",sx:{fontSize:{xs:"0.875rem",sm:"1rem"},fontWeight:500,color:"text.secondary"},children:[e,A.jsx("span",{className:fh,children:a})]}),t&&A.jsxs(K,{className:l?hh:"",sx:{width:"100%",maxWidth:"600px",display:"flex",flexDirection:"column",gap:2,mt:1},children:[A.jsx(hg,{variant:"rectangular",height:60,sx:{borderRadius:2}}),A.jsx(hg,{variant:"rectangular",height:40,width:"80%",sx:{borderRadius:2}}),A.jsx(hg,{variant:"rectangular",height:40,width:"60%",sx:{borderRadius:2}})]})]}):null}const $o=Ul,nO=["קהילה ועמותות","טכנולוגיה","בריאות","חינוך","אוכל ומסעדות","אופנה","נדל״ן","כספים וביטוח","תחבורה ולוגיסטיקה","תקשורת ושיווק","אמנות ותרבות","ספורט ופנאי","ייעוץ וניהול","מסחר קמעונאי","ייצור","אנרגיה וסביבה","משפטים","בנייה","חקלאות","תיירות","בידור","ביטחון"],aO=["מקצועי","ידידותי","פורמלי","לא פורמלי","חברתי","מעודכן","קלאסי","צעיר","משפחתי","איכותי","מהיר","אמין","יצירתי","חכם","חם","קר","מעורר השראה","מעשי","יוקרתי","נגיש"],js=e=>{if(!e||typeof e!="string")return e;const t=e.trim();return!t||/^https?:\/\//i.test(t)?t:`https://${t}`};function rO(e,t,n){let a="";const r=n.trim().toLowerCase();if(r)try{const o=/^https?:\/\//i.test(r)?r:`https://${r}`;a=new URL(o).hostname.replace(/^www\./,"")}catch{}const l=`${a} ${r} ${e.toLowerCase()} ${t.toLowerCase()}`;return/linkedin|לינקדאין|לינקדין/.test(l)?Sx:/facebook|fb\.com|fb\.me|פייסבוק/.test(l)?mx:/instagram|instagr\.am|אינסטגרם/.test(l)?vx:/youtube|youtu\.be|יוטיוב/.test(l)?xx:/(^|\.)x\.com|twitter\.com|טוויטר|טוויט/.test(l)?bx:/tiktok|טיקטוק|tik tok/.test(l)?jx:/whatsapp|wa\.me|וואטסאפ|ווטסאפ/.test(l)?wx:/telegram|t\.me|טלגרם/.test(l)?Bx:/reddit|רדיט/.test(l)?Mx:/pinterest|פינטרסט/.test(l)?Vx:/github|גיטהאב|גיטהב/.test(l)?Fx:qx}function lO({platform:e,url:t,onPlatformCommit:n,onUrlChange:a,onRemove:r}){const[l,o]=v.useState(e);v.useEffect(()=>{o(e)},[e]);const i=v.useCallback(()=>{l!==e&&n(e,l)},[e,l,n]),s=rO(e,l,t);return A.jsxs(K,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:1,flexDirection:{xs:"column",sm:"row"}},children:[A.jsx(at,{fullWidth:!0,label:"פלטפורמה",value:l,onChange:p=>o(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),p.target.blur())},variant:"outlined",margin:"normal",size:"small",sx:{flex:{xs:"1 1 100%",sm:"0 0 min(200px, 34%)"}},placeholder:"לדוגמה: LinkedIn",InputProps:{startAdornment:A.jsx(ug,{position:"start",sx:{mr:0},children:A.jsx(s,{sx:{fontSize:22,color:"primary.main"},"aria-hidden":!0})})}}),A.jsx(at,{fullWidth:!0,label:"קישור",value:t,onChange:p=>a(e,p.target.value),variant:"outlined",margin:"normal",size:"small",sx:{flex:1},placeholder:"https://..."}),A.jsx(Hn,{color:"error",onClick:()=>r(e),sx:{mt:1},"aria-label":"הסר רשת חברתית",children:A.jsx(Qs,{})})]})}const oO=e=>({business_name:"",industry:"",business_type:"",business_type_options:[],keywords:[],profit_intent:"",is_haredi_sector:null,business_tone:"",description:"",overall_confidence:0,owner:"",owner_gender:"",business_address:"",website:e||"",contacts:{email:"",phone:""},socials:{linkedin:"",instagram:"",facebook:""},theme:void 0,website_confidence:0,confidence_scores:{website:0,contacts:{phone:0},socials:{},overall:0},token_usage:{total:{prompt_tokens:0,completion_tokens:0,total_tokens:0},breakdown:{analyze_business:{prompt_tokens:0,completion_tokens:0,total_tokens:0}}},estimated_cost_usd:0,source_urls:[],analyzed_at:new Date().toISOString()}),Ts=e=>{var t,n;return e?{...e,business_address:e.business_address??(e==null?void 0:e.address)??"",business_type_options:Array.isArray(e.business_type_options)?e.business_type_options:[],keywords:Array.isArray(e.keywords)?e.keywords:[],description:Array.isArray(e.description)?e.description:e.description?[e.description]:[""],contacts:{email:((t=e.contacts)==null?void 0:t.email)??"",phone:((n=e.contacts)==null?void 0:n.phone)??""},socials:e.socials&&typeof e.socials=="object"?e.socials:{linkedin:"",instagram:"",facebook:""},theme:(()=>{var o;const a=(o=e.theme)==null?void 0:o.logoHeaderBackground,r=(e==null?void 0:e.logoHeaderBackground)??(e==null?void 0:e.logoBackgroundHex),l=typeof a=="string"?a:typeof r=="string"?r:void 0;if(e.theme)return{primary:e.theme.primary||"",secondary:e.theme.secondary||"",colors:Array.isArray(e.theme.colors)?e.theme.colors:[],...l?{logoHeaderBackground:l}:{}};if(l)return{primary:"",secondary:"",colors:[],logoHeaderBackground:l}})()}:null};function iO({data:e,websiteUrl:t,setActiveStep:n,onSave:a,urls:r,language:l}){var Pe,je,it,D,ne;const o=Go(),[i,s]=v.useState(null),[p,u]=v.useState(!0),[c,d]=v.useState(null),[f,W]=v.useState(!1),[m,x]=v.useState(null),[h,g]=v.useState([]),[C,y]=v.useState([]),[E,S]=v.useState((e==null?void 0:e.logo)||(e&&typeof e=="object"&&"logo"in e?e.logo:"")),k=v.useRef(null),R=v.useRef(""),V=v.useRef(!1),b=v.useRef(!1),[B,M]=v.useState(0),F=v.useRef(new Map),z=v.useRef(0),T=()=>{F.current=new Map,z.current=0},j=U=>{const O=F.current;let Y=O.get(U);return Y||(Y=`social-row-${z.current++}`,O.set(U,Y)),Y},{shadowRoot:P,stepBeforeStep1:L,step2Data:q}=Ua(),[w,G]=v.useState(!1),te=v.useCallback(U=>{if(!U){S(""),s(Y=>{var Ie,Se,pe,xe;return!Y||!((Ie=Y.theme)!=null&&Ie.logoHeaderBackground)?Y:{...Y,theme:{...Y.theme,primary:((Se=Y.theme)==null?void 0:Se.primary)??"",secondary:((pe=Y.theme)==null?void 0:pe.secondary)??"",colors:((xe=Y.theme)==null?void 0:xe.colors)??[],logoHeaderBackground:void 0}}});return}U.startsWith("http://")||U.startsWith("https://")?zj(U).then(Y=>{S(Y.pngDataUrl),s(Ie=>{var Se,pe,xe,Qe;return Ie&&{...Ie,theme:{...Ie.theme,primary:((Se=Ie.theme)==null?void 0:Se.primary)??"",secondary:((pe=Ie.theme)==null?void 0:pe.secondary)??"",colors:((xe=Ie.theme)==null?void 0:xe.colors)??[],logoHeaderBackground:((Qe=Ie.theme)==null?void 0:Qe.logoHeaderBackground)??Y.backgroundHex}}})}).catch(()=>{S(U)}):S(U)},[]),Q=U=>{var Ie;const O=(Ie=U.target.files)==null?void 0:Ie[0];if(!O)return;if(!O.type.startsWith("image/")){alert("אנא בחר קובץ תמונה בלבד");return}if(O.size>5*1024*1024){alert("קובץ התמונה גדול מדי. אנא בחר קובץ קטן מ-5MB");return}const Y=new FileReader;Y.onloadend=()=>{const Se=Y.result;S(Se)},Y.onerror=()=>{alert("שגיאה בקריאת הקובץ. אנא נסה שוב.")},Y.readAsDataURL(O)},N=()=>{S(""),s(U=>{var O,Y,Ie,Se;return(O=U==null?void 0:U.theme)!=null&&O.logoHeaderBackground?{...U,theme:{...U.theme,primary:((Y=U.theme)==null?void 0:Y.primary)??"",secondary:((Ie=U.theme)==null?void 0:Ie.secondary)??"",colors:((Se=U.theme)==null?void 0:Se.colors)??[],logoHeaderBackground:void 0}}:U}),k.current&&(k.current.value="")},re=v.useCallback(()=>[...nO].sort(),[]),ue=v.useCallback(()=>[...aO].sort(),[]);v.useEffect(()=>{g(re()),y(ue())},[re,ue]),v.useEffect(()=>{if(i!=null&&i.industry){const U=re();U.includes(i.industry)||U.push(i.industry),g(U.sort())}},[i==null?void 0:i.industry,re]),v.useEffect(()=>{if(i!=null&&i.business_tone){const U=ue();U.includes(i.business_tone)||U.push(i.business_tone),y(U.sort())}},[i==null?void 0:i.business_tone,ue]);const _=U=>!U||typeof U!="object"?!1:"business_name"in U||"industry"in U||"business_type"in U||"keywords"in U||"description"in U;v.useEffect(()=>{if(e&&_(e)&&e.logo){const U=e.logo;U.startsWith("http://")||U.startsWith("https://")?te(U):S(U)}else if(e&&"logo"in e&&e.logo){const U=e.logo;U.startsWith("http://")||U.startsWith("https://")?te(U):S(U)}},[e,te]),v.useEffect(()=>{!p&&i&&G(!0)},[p,i]),v.useEffect(()=>{(async()=>{var xe,Qe,Je,ft,bt,kt,Dt,rt;const O=t?js(t).replace(/\/$/,"").toLowerCase():"",Y=t&&t.trim()!=="";if(R.current===O&&i!==null&&Y){u(!1);return}if(V.current)return;const Se=!!(e&&_(e));if(!Se&&(q!=null&&q.businessData)&&(q!=null&&q.websiteUrl)){const Xe=Ts(q.businessData);if(Xe){T(),s(Xe),u(!1),R.current="",q.logo&&(q.logo.startsWith("http://")||q.logo.startsWith("https://")?te(q.logo):S(q.logo));return}}if(Y){const Xe=e==null?void 0:e.business_name;if(!b.current&&Se&&Xe&&Xe.trim()!==""){const _e=Ts(e);if(_e){T(),s(_e),u(!1),R.current=O;const Ve=e==null?void 0:e.logo;Ve&&(Ve.startsWith("http://")||Ve.startsWith("https://")?te(Ve):S(Ve));return}}const Ce=Array.isArray(r)?r.map(js):[];Ce.push(js(t));try{V.current=!0,b.current=!1,u(!0),d(null);const _e=await ox(t,Ce,"",l);let Ve=Ts(_e);const It=(xe=e==null?void 0:e.theme)==null?void 0:xe.logoHeaderBackground;if(Ve&&typeof It=="string"&&(Ve={...Ve,theme:{...Ve.theme,primary:((Qe=Ve.theme)==null?void 0:Qe.primary)??"",secondary:((Je=Ve.theme)==null?void 0:Je.secondary)??"",colors:Array.isArray((ft=Ve.theme)==null?void 0:ft.colors)?Ve.theme.colors:[],logoHeaderBackground:It}}),Ve){T(),s(Ve),R.current=O;const Tt=_e==null?void 0:_e.logo;Tt&&te(Tt)}else d("שגיאה בעיבוד הנתונים שהתקבלו מהשרת")}catch(_e){d(_e instanceof Error?_e.message:"שגיאה בטעינת הנתונים")}finally{u(!1),V.current=!1}return}if(e&&_(e)){const Xe=Ts(e);if(Xe){T(),s(Xe),u(!1),R.current="";const Ce=e==null?void 0:e.logo;Ce&&(Ce.startsWith("http://")||Ce.startsWith("https://")?te(Ce):S(Ce));return}}const pe=Array.isArray(r)?r.map(js):[];if(pe.length===0){T(),s(oO(t)),u(!1),R.current="";return}try{V.current=!0,u(!0),d(null);const Xe=await ox(t,pe,"",l);let Ce=Ts(Xe);const _e=(bt=e==null?void 0:e.theme)==null?void 0:bt.logoHeaderBackground;if(Ce&&typeof _e=="string"&&(Ce={...Ce,theme:{...Ce.theme,primary:((kt=Ce.theme)==null?void 0:kt.primary)??"",secondary:((Dt=Ce.theme)==null?void 0:Dt.secondary)??"",colors:Array.isArray((rt=Ce.theme)==null?void 0:rt.colors)?Ce.theme.colors:[],logoHeaderBackground:_e}}),Ce){T(),s(Ce),R.current="";const Ve=Xe==null?void 0:Xe.logo;Ve&&te(Ve)}else d("שגיאה בעיבוד הנתונים שהתקבלו מהשרת")}catch(Xe){d(Xe instanceof Error?Xe.message:"שגיאה בטעינת הנתונים")}finally{u(!1),V.current=!1}})()},[t,q,B]);const H=(U,O)=>{i&&s({...i,[U]:O})},de=(U,O,Y)=>{i&&s({...i,[U]:{...i[U],[O]:Y}})},ae=(U,O)=>{if(i){const Y=i.theme||{primary:"",secondary:"",colors:[]};s({...i,theme:{...Y,[U]:O}})}},X=U=>{if(!i)return;const O={primary:"",secondary:"",colors:[],...i.theme},Y=xe=>xe.toLowerCase(),Ie=new Set(U.map(Y)),Se=O.primary&&Ie.has(Y(O.primary))?O.primary:"",pe=O.secondary&&Ie.has(Y(O.secondary))?O.secondary:"";s({...i,theme:{...O,primary:Se,secondary:pe,colors:U}})},he=(U,O,Y)=>{if(i)if(U==="description"){const Se=[...Array.isArray(i.description)?i.description:i.description?[i.description]:[""]];Se[O]=Y,s({...i,description:Se})}else{const Ie=[...i[U]];Ie[O]=Y,s({...i,[U]:Ie})}},We=()=>{if(i){const U=[...i.business_type_options,""];s({...i,business_type_options:U})}},me=U=>{if(i){const O=i.business_type_options.filter((Y,Ie)=>Ie!==U);s({...i,business_type_options:O})}},ve=()=>{if(i){const O=[...Array.isArray(i.description)?i.description:i.description?[i.description]:[""],""];s({...i,description:O})}},ce=U=>{if(i){const Y=(Array.isArray(i.description)?i.description:i.description?[i.description]:[""]).filter((Ie,Se)=>Se!==U);s({...i,description:Y.length>0?Y:[""]})}},Ze=()=>{if(i){const U={...i.socials};let O=1,Y="social_media";for(;U[Y];)Y=`social_media_${O}`,O++;U[Y]="",F.current.has(Y)||F.current.set(Y,`social-row-${z.current++}`),s({...i,socials:U})}},le=U=>{if(i){F.current.delete(U);const O={...i.socials};delete O[U],s({...i,socials:O})}},Ke=(U,O)=>{if(i&&U!==O){const Y={...i.socials},Ie=Y[U]||"";delete Y[U];const Se=O.trim(),pe=F.current.get(U);pe&&(F.current.delete(U),Se&&F.current.set(Se,pe)),Se&&(Y[Se]&&Se!==U?Y[Se]=Ie||Y[Se]:Y[Se]=Ie),s({...i,socials:Y})}},qe=(U,O)=>{if(i){const Y={...i.socials};Y[U]=O,s({...i,socials:Y})}},Be=async()=>{var ft,bt,kt,Dt;if(!i)return;const U=(t==null?void 0:t.trim())||((ft=i.website)==null?void 0:ft.trim())||"";let O=!1;(bt=i.website)!=null&&bt.trim()||(O=!1);const Y=E||"",Ie=Y.startsWith("data:image/"),Se=(kt=i==null?void 0:i.theme)==null?void 0:kt.logoHeaderBackground,pe=Se&&/^#(000|000000)$/i.test(String(Se).trim()),xe=Se&&!pe?Se:Se&&pe?"white":void 0,Qe=(Dt=i==null?void 0:i.theme)!=null&&Dt.logoHeaderBackground&&/^#(000|000000)$/i.test(String(i.theme.logoHeaderBackground).trim())?{...i,theme:{...i.theme,logoHeaderBackground:"white"}}:i;if(!Qe.business_name){x("שם העסק הוא שדה חובה"),W(!1);return}const Je={businessData:Qe,logo:Y,websiteUrl:U,...xe?{logoBackgroundHex:xe}:{}};Ie&&(Je.logoToUpload=Y),W(!0),x(null);try{const rt={...Qe};delete rt._id,delete rt.__v,rt.business_address!==void 0&&(rt.address=rt.business_address),Array.isArray(rt.description)&&(rt.description=rt.description.filter(Boolean).join(`
|
|
524
|
+
)`,animationDelay:`${f*.15}s`}},f))})]}),A.jsxs(fe,{className:l?gh:"",sx:{fontSize:{xs:"0.875rem",sm:"1rem"},fontWeight:500,color:"text.secondary"},children:[e,A.jsx("span",{className:fh,children:a})]}),t&&A.jsxs(K,{className:l?hh:"",sx:{width:"100%",maxWidth:"600px",display:"flex",flexDirection:"column",gap:2,mt:1},children:[A.jsx(hg,{variant:"rectangular",height:60,sx:{borderRadius:2}}),A.jsx(hg,{variant:"rectangular",height:40,width:"80%",sx:{borderRadius:2}}),A.jsx(hg,{variant:"rectangular",height:40,width:"60%",sx:{borderRadius:2}})]})]}):null}const $o=Ul,nO=["קהילה ועמותות","טכנולוגיה","בריאות","חינוך","אוכל ומסעדות","אופנה","נדל״ן","כספים וביטוח","תחבורה ולוגיסטיקה","תקשורת ושיווק","אמנות ותרבות","ספורט ופנאי","ייעוץ וניהול","מסחר קמעונאי","ייצור","אנרגיה וסביבה","משפטים","בנייה","חקלאות","תיירות","בידור","ביטחון"],aO=["מקצועי","ידידותי","פורמלי","לא פורמלי","חברתי","מעודכן","קלאסי","צעיר","משפחתי","איכותי","מהיר","אמין","יצירתי","חכם","חם","קר","מעורר השראה","מעשי","יוקרתי","נגיש"],js=e=>{if(!e||typeof e!="string")return e;const t=e.trim();return!t||/^https?:\/\//i.test(t)?t:`https://${t}`};function rO(e,t,n){let a="";const r=(n||"").trim().toLowerCase();if(r)try{const o=/^https?:\/\//i.test(r)?r:`https://${r}`;a=new URL(o).hostname.replace(/^www\./,"")}catch{}const l=`${a} ${r} ${e.toLowerCase()} ${t.toLowerCase()}`;return/linkedin|לינקדאין|לינקדין/.test(l)?Sx:/facebook|fb\.com|fb\.me|פייסבוק/.test(l)?mx:/instagram|instagr\.am|אינסטגרם/.test(l)?vx:/youtube|youtu\.be|יוטיוב/.test(l)?xx:/(^|\.)x\.com|twitter\.com|טוויטר|טוויט/.test(l)?bx:/tiktok|טיקטוק|tik tok/.test(l)?jx:/whatsapp|wa\.me|וואטסאפ|ווטסאפ/.test(l)?wx:/telegram|t\.me|טלגרם/.test(l)?Bx:/reddit|רדיט/.test(l)?Mx:/pinterest|פינטרסט/.test(l)?Vx:/github|גיטהאב|גיטהב/.test(l)?Fx:qx}function lO({platform:e,url:t,onPlatformCommit:n,onUrlChange:a,onRemove:r}){const[l,o]=v.useState(e);v.useEffect(()=>{o(e)},[e]);const i=v.useCallback(()=>{l!==e&&n(e,l)},[e,l,n]),s=rO(e,l,t);return A.jsxs(K,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:1,flexDirection:{xs:"column",sm:"row"}},children:[A.jsx(at,{fullWidth:!0,label:"פלטפורמה",value:l,onChange:p=>o(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),p.target.blur())},variant:"outlined",margin:"normal",size:"small",sx:{flex:{xs:"1 1 100%",sm:"0 0 min(200px, 34%)"}},placeholder:"לדוגמה: LinkedIn",InputProps:{startAdornment:A.jsx(ug,{position:"start",sx:{mr:0},children:A.jsx(s,{sx:{fontSize:22,color:"primary.main"},"aria-hidden":!0})})}}),A.jsx(at,{fullWidth:!0,label:"קישור",value:t,onChange:p=>a(e,p.target.value),variant:"outlined",margin:"normal",size:"small",sx:{flex:1},placeholder:"https://..."}),A.jsx(Hn,{color:"error",onClick:()=>r(e),sx:{mt:1},"aria-label":"הסר רשת חברתית",children:A.jsx(Qs,{})})]})}const oO=e=>({business_name:"",industry:"",business_type:"",business_type_options:[],keywords:[],profit_intent:"",is_haredi_sector:null,business_tone:"",description:"",overall_confidence:0,owner:"",owner_gender:"",business_address:"",website:e||"",contacts:{email:"",phone:""},socials:{linkedin:"",instagram:"",facebook:""},theme:void 0,website_confidence:0,confidence_scores:{website:0,contacts:{phone:0},socials:{},overall:0},token_usage:{total:{prompt_tokens:0,completion_tokens:0,total_tokens:0},breakdown:{analyze_business:{prompt_tokens:0,completion_tokens:0,total_tokens:0}}},estimated_cost_usd:0,source_urls:[],analyzed_at:new Date().toISOString()}),Ts=e=>{var t,n;return e?{...e,business_address:e.business_address??(e==null?void 0:e.address)??"",business_type_options:Array.isArray(e.business_type_options)?e.business_type_options:[],keywords:Array.isArray(e.keywords)?e.keywords:[],description:Array.isArray(e.description)?e.description:e.description?[e.description]:[""],contacts:{email:((t=e.contacts)==null?void 0:t.email)??"",phone:((n=e.contacts)==null?void 0:n.phone)??""},socials:e.socials&&typeof e.socials=="object"?e.socials:{linkedin:"",instagram:"",facebook:""},theme:(()=>{var o;const a=(o=e.theme)==null?void 0:o.logoHeaderBackground,r=(e==null?void 0:e.logoHeaderBackground)??(e==null?void 0:e.logoBackgroundHex),l=typeof a=="string"?a:typeof r=="string"?r:void 0;if(e.theme)return{primary:e.theme.primary||"",secondary:e.theme.secondary||"",colors:Array.isArray(e.theme.colors)?e.theme.colors:[],...l?{logoHeaderBackground:l}:{}};if(l)return{primary:"",secondary:"",colors:[],logoHeaderBackground:l}})()}:null};function iO({data:e,websiteUrl:t,setActiveStep:n,onSave:a,urls:r,language:l}){var Pe,je,it,D,ne;const o=Go(),[i,s]=v.useState(null),[p,u]=v.useState(!0),[c,d]=v.useState(null),[f,W]=v.useState(!1),[m,x]=v.useState(null),[h,g]=v.useState([]),[C,y]=v.useState([]),[E,S]=v.useState((e==null?void 0:e.logo)||(e&&typeof e=="object"&&"logo"in e?e.logo:"")),k=v.useRef(null),R=v.useRef(""),V=v.useRef(!1),b=v.useRef(!1),[B,M]=v.useState(0),F=v.useRef(new Map),z=v.useRef(0),T=()=>{F.current=new Map,z.current=0},j=U=>{const O=F.current;let Y=O.get(U);return Y||(Y=`social-row-${z.current++}`,O.set(U,Y)),Y},{shadowRoot:P,stepBeforeStep1:L,step2Data:q}=Ua(),[w,G]=v.useState(!1),te=v.useCallback(U=>{if(!U){S(""),s(Y=>{var Ie,Se,pe,xe;return!Y||!((Ie=Y.theme)!=null&&Ie.logoHeaderBackground)?Y:{...Y,theme:{...Y.theme,primary:((Se=Y.theme)==null?void 0:Se.primary)??"",secondary:((pe=Y.theme)==null?void 0:pe.secondary)??"",colors:((xe=Y.theme)==null?void 0:xe.colors)??[],logoHeaderBackground:void 0}}});return}U.startsWith("http://")||U.startsWith("https://")?zj(U).then(Y=>{S(Y.pngDataUrl),s(Ie=>{var Se,pe,xe,Qe;return Ie&&{...Ie,theme:{...Ie.theme,primary:((Se=Ie.theme)==null?void 0:Se.primary)??"",secondary:((pe=Ie.theme)==null?void 0:pe.secondary)??"",colors:((xe=Ie.theme)==null?void 0:xe.colors)??[],logoHeaderBackground:((Qe=Ie.theme)==null?void 0:Qe.logoHeaderBackground)??Y.backgroundHex}}})}).catch(()=>{S(U)}):S(U)},[]),Q=U=>{var Ie;const O=(Ie=U.target.files)==null?void 0:Ie[0];if(!O)return;if(!O.type.startsWith("image/")){alert("אנא בחר קובץ תמונה בלבד");return}if(O.size>5*1024*1024){alert("קובץ התמונה גדול מדי. אנא בחר קובץ קטן מ-5MB");return}const Y=new FileReader;Y.onloadend=()=>{const Se=Y.result;S(Se)},Y.onerror=()=>{alert("שגיאה בקריאת הקובץ. אנא נסה שוב.")},Y.readAsDataURL(O)},N=()=>{S(""),s(U=>{var O,Y,Ie,Se;return(O=U==null?void 0:U.theme)!=null&&O.logoHeaderBackground?{...U,theme:{...U.theme,primary:((Y=U.theme)==null?void 0:Y.primary)??"",secondary:((Ie=U.theme)==null?void 0:Ie.secondary)??"",colors:((Se=U.theme)==null?void 0:Se.colors)??[],logoHeaderBackground:void 0}}:U}),k.current&&(k.current.value="")},re=v.useCallback(()=>[...nO].sort(),[]),ue=v.useCallback(()=>[...aO].sort(),[]);v.useEffect(()=>{g(re()),y(ue())},[re,ue]),v.useEffect(()=>{if(i!=null&&i.industry){const U=re();U.includes(i.industry)||U.push(i.industry),g(U.sort())}},[i==null?void 0:i.industry,re]),v.useEffect(()=>{if(i!=null&&i.business_tone){const U=ue();U.includes(i.business_tone)||U.push(i.business_tone),y(U.sort())}},[i==null?void 0:i.business_tone,ue]);const _=U=>!U||typeof U!="object"?!1:"business_name"in U||"industry"in U||"business_type"in U||"keywords"in U||"description"in U;v.useEffect(()=>{if(e&&_(e)&&e.logo){const U=e.logo;U.startsWith("http://")||U.startsWith("https://")?te(U):S(U)}else if(e&&"logo"in e&&e.logo){const U=e.logo;U.startsWith("http://")||U.startsWith("https://")?te(U):S(U)}},[e,te]),v.useEffect(()=>{!p&&i&&G(!0)},[p,i]),v.useEffect(()=>{(async()=>{var xe,Qe,Je,ft,bt,kt,Dt,rt;const O=t?js(t).replace(/\/$/,"").toLowerCase():"",Y=t&&t.trim()!=="";if(R.current===O&&i!==null&&Y){u(!1);return}if(V.current)return;const Se=!!(e&&_(e));if(!Se&&(q!=null&&q.businessData)&&(q!=null&&q.websiteUrl)){const Xe=Ts(q.businessData);if(Xe){T(),s(Xe),u(!1),R.current="",q.logo&&(q.logo.startsWith("http://")||q.logo.startsWith("https://")?te(q.logo):S(q.logo));return}}if(Y){const Xe=e==null?void 0:e.business_name;if(!b.current&&Se&&Xe&&Xe.trim()!==""){const _e=Ts(e);if(_e){T(),s(_e),u(!1),R.current=O;const Ve=e==null?void 0:e.logo;Ve&&(Ve.startsWith("http://")||Ve.startsWith("https://")?te(Ve):S(Ve));return}}const Ce=Array.isArray(r)?r.map(js):[];Ce.push(js(t));try{V.current=!0,b.current=!1,u(!0),d(null);const _e=await ox(t,Ce,"",l);let Ve=Ts(_e);const It=(xe=e==null?void 0:e.theme)==null?void 0:xe.logoHeaderBackground;if(Ve&&typeof It=="string"&&(Ve={...Ve,theme:{...Ve.theme,primary:((Qe=Ve.theme)==null?void 0:Qe.primary)??"",secondary:((Je=Ve.theme)==null?void 0:Je.secondary)??"",colors:Array.isArray((ft=Ve.theme)==null?void 0:ft.colors)?Ve.theme.colors:[],logoHeaderBackground:It}}),Ve){T(),s(Ve),R.current=O;const Tt=_e==null?void 0:_e.logo;Tt&&te(Tt)}else d("שגיאה בעיבוד הנתונים שהתקבלו מהשרת")}catch(_e){d(_e instanceof Error?_e.message:"שגיאה בטעינת הנתונים")}finally{u(!1),V.current=!1}return}if(e&&_(e)){const Xe=Ts(e);if(Xe){T(),s(Xe),u(!1),R.current="";const Ce=e==null?void 0:e.logo;Ce&&(Ce.startsWith("http://")||Ce.startsWith("https://")?te(Ce):S(Ce));return}}const pe=Array.isArray(r)?r.map(js):[];if(pe.length===0){T(),s(oO(t)),u(!1),R.current="";return}try{V.current=!0,u(!0),d(null);const Xe=await ox(t,pe,"",l);let Ce=Ts(Xe);const _e=(bt=e==null?void 0:e.theme)==null?void 0:bt.logoHeaderBackground;if(Ce&&typeof _e=="string"&&(Ce={...Ce,theme:{...Ce.theme,primary:((kt=Ce.theme)==null?void 0:kt.primary)??"",secondary:((Dt=Ce.theme)==null?void 0:Dt.secondary)??"",colors:Array.isArray((rt=Ce.theme)==null?void 0:rt.colors)?Ce.theme.colors:[],logoHeaderBackground:_e}}),Ce){T(),s(Ce),R.current="";const Ve=Xe==null?void 0:Xe.logo;Ve&&te(Ve)}else d("שגיאה בעיבוד הנתונים שהתקבלו מהשרת")}catch(Xe){d(Xe instanceof Error?Xe.message:"שגיאה בטעינת הנתונים")}finally{u(!1),V.current=!1}})()},[t,q,B]);const H=(U,O)=>{i&&s({...i,[U]:O})},de=(U,O,Y)=>{i&&s({...i,[U]:{...i[U],[O]:Y}})},ae=(U,O)=>{if(i){const Y=i.theme||{primary:"",secondary:"",colors:[]};s({...i,theme:{...Y,[U]:O}})}},X=U=>{if(!i)return;const O={primary:"",secondary:"",colors:[],...i.theme},Y=xe=>xe.toLowerCase(),Ie=new Set(U.map(Y)),Se=O.primary&&Ie.has(Y(O.primary))?O.primary:"",pe=O.secondary&&Ie.has(Y(O.secondary))?O.secondary:"";s({...i,theme:{...O,primary:Se,secondary:pe,colors:U}})},he=(U,O,Y)=>{if(i)if(U==="description"){const Se=[...Array.isArray(i.description)?i.description:i.description?[i.description]:[""]];Se[O]=Y,s({...i,description:Se})}else{const Ie=[...i[U]];Ie[O]=Y,s({...i,[U]:Ie})}},We=()=>{if(i){const U=[...i.business_type_options,""];s({...i,business_type_options:U})}},me=U=>{if(i){const O=i.business_type_options.filter((Y,Ie)=>Ie!==U);s({...i,business_type_options:O})}},ve=()=>{if(i){const O=[...Array.isArray(i.description)?i.description:i.description?[i.description]:[""],""];s({...i,description:O})}},ce=U=>{if(i){const Y=(Array.isArray(i.description)?i.description:i.description?[i.description]:[""]).filter((Ie,Se)=>Se!==U);s({...i,description:Y.length>0?Y:[""]})}},Ze=()=>{if(i){const U={...i.socials};let O=1,Y="social_media";for(;U[Y];)Y=`social_media_${O}`,O++;U[Y]="",F.current.has(Y)||F.current.set(Y,`social-row-${z.current++}`),s({...i,socials:U})}},le=U=>{if(i){F.current.delete(U);const O={...i.socials};delete O[U],s({...i,socials:O})}},Ke=(U,O)=>{if(i&&U!==O){const Y={...i.socials},Ie=Y[U]||"";delete Y[U];const Se=O.trim(),pe=F.current.get(U);pe&&(F.current.delete(U),Se&&F.current.set(Se,pe)),Se&&(Y[Se]&&Se!==U?Y[Se]=Ie||Y[Se]:Y[Se]=Ie),s({...i,socials:Y})}},qe=(U,O)=>{if(i){const Y={...i.socials};Y[U]=O,s({...i,socials:Y})}},Be=async()=>{var ft,bt,kt,Dt;if(!i)return;const U=(t==null?void 0:t.trim())||((ft=i.website)==null?void 0:ft.trim())||"";let O=!1;(bt=i.website)!=null&&bt.trim()||(O=!1);const Y=E||"",Ie=Y.startsWith("data:image/"),Se=(kt=i==null?void 0:i.theme)==null?void 0:kt.logoHeaderBackground,pe=Se&&/^#(000|000000)$/i.test(String(Se).trim()),xe=Se&&!pe?Se:Se&&pe?"white":void 0,Qe=(Dt=i==null?void 0:i.theme)!=null&&Dt.logoHeaderBackground&&/^#(000|000000)$/i.test(String(i.theme.logoHeaderBackground).trim())?{...i,theme:{...i.theme,logoHeaderBackground:"white"}}:i;if(!Qe.business_name){x("שם העסק הוא שדה חובה"),W(!1);return}const Je={businessData:Qe,logo:Y,websiteUrl:U,...xe?{logoBackgroundHex:xe}:{}};Ie&&(Je.logoToUpload=Y),W(!0),x(null);try{const rt={...Qe};delete rt._id,delete rt.__v,rt.business_address!==void 0&&(rt.address=rt.business_address),Array.isArray(rt.description)&&(rt.description=rt.description.filter(Boolean).join(`
|
|
525
525
|
`)||""),O&&await Fj(U,rt)}catch(rt){const Xe=rt instanceof Error?rt.message:String(rt);if(Xe.includes("404")||Xe.includes("not found"))console.warn("Business analysis not in DB, saving to context only:",Xe);else{console.error("Failed to save business analysis:",Xe),x(`שמירה נכשלה: ${Xe}`),W(!1);return}}W(!1),a(Je),o&&o.triggerEvent("onDataComplete",Je),window.dispatchEvent(new CustomEvent("business-analysis-saved",{detail:i,bubbles:!0,composed:!0})),n(2)};if(p)return A.jsx(K,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:{xs:2,sm:3,md:5},minHeight:{xs:"300px",sm:"350px",md:"400px"}},children:A.jsx(tO,{text:"Analyzing",showSkeletons:!0})});if(c)return A.jsxs(K,{sx:{padding:{xs:2,sm:3,md:5},width:{xs:"100%",sm:"500px"},maxWidth:"100%",boxSizing:"border-box"},children:[A.jsx(Ml,{severity:"error",sx:{fontSize:{xs:"0.875rem",sm:"1rem"}},children:c}),A.jsx(ze,{variant:"text",color:"primary",onClick:()=>n(L),sx:{mt:2,fontSize:{xs:"0.875rem",sm:"1rem"}},children:"חזרה"})]});if(!i)return null;const Te=(t==null?void 0:t.trim())||(e&&typeof e=="object"&&"websiteUrl"in e?(Pe=e.websiteUrl)==null?void 0:Pe.trim():"")||((je=i==null?void 0:i.website)==null?void 0:je.trim())||"";return A.jsxs(K,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%",width:"100%",maxWidth:"100%",boxSizing:"border-box",overflow:"hidden"},children:[A.jsxs(K,{sx:{flex:1,minHeight:0,height:"100%",maxHeight:"calc(90vh - 140px)",overflowY:"auto",overflowX:"hidden",padding:{xs:2,sm:3,md:5},paddingBottom:{xs:1,sm:1.5,md:2},WebkitOverflowScrolling:"touch"},children:[Te&&A.jsx(K,{className:w?$o.fadeUp:"",sx:{mb:{xs:2,sm:2.5},mt:{xs:.5,sm:1}},children:A.jsxs(K,{sx:{display:"flex",alignItems:"center",gap:1.25,px:{xs:1.5,sm:2},py:{xs:1,sm:1.125},borderRadius:2,border:"1px solid",borderColor:"divider",maxWidth:"100%",overflow:"hidden",bgcolor:U=>un(U.palette.primary.main,.06)},children:[A.jsx(dx,{sx:{fontSize:{xs:"1.125rem",sm:"1.25rem"},color:"text.secondary",flexShrink:0,opacity:.85}}),A.jsx(fe,{variant:"body2",sx:{fontSize:{xs:"0.8125rem",sm:"0.875rem"},color:"text.primary",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",flex:1,direction:"ltr",textAlign:"left",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontWeight:500},children:js(Te)}),A.jsx(Hn,{size:"small",onClick:()=>{R.current="",b.current=!0,M(U=>U+1)},disabled:p,title:"נתח מחדש",sx:{flexShrink:0,opacity:.7,"&:hover":{opacity:1}},children:A.jsx(fx,{sx:{fontSize:"1.125rem"}})})]})}),A.jsxs(K,{className:w?$o.fadeUp:"",sx:{mb:{xs:2.5,sm:3}},children:[A.jsx(fe,{component:"h1",variant:"h4",sx:{mt:Te?{xs:1.5,sm:2}:{xs:4,sm:4},fontSize:{xs:"1.5rem",sm:"1.875rem",md:"2rem"},fontWeight:700,letterSpacing:"-0.025em",lineHeight:1.2,color:"text.primary"},children:"עריכת פרטי העסק"}),A.jsx(fe,{variant:"body2",className:w?$o.fadeUpDelay1:"",color:"text.secondary",sx:{mt:{xs:.75,sm:1},fontSize:{xs:"0.875rem",sm:"0.9375rem"},maxWidth:"min(48ch, 100%)",lineHeight:1.55},children:"עברו על השדות, עדכנו מה שצריך, והמשיכו לשלב הבא."})]}),A.jsx(K,{className:w?$o.fadeUpDelay2:"",children:A.jsxs(Sa,{title:"לוגו",description:"מומלץ קובץ שקוף או רקע בהיר. אפשר לדלג אם אין לוגו מעודכן.",children:[A.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:Q,style:{display:"none"},id:"logo-upload-input"}),E?A.jsxs(K,{sx:{p:{xs:1.5,sm:2,md:2.5},border:"1px dashed",borderColor:"divider",borderRadius:2,bgcolor:U=>un(U.palette.common.black,.02),transition:"border-color 0.2s ease, background-color 0.2s ease",mb:{xs:1.5,sm:2},"&:hover":{borderColor:"text.secondary",bgcolor:U=>un(U.palette.common.black,.035)}},children:[A.jsxs(K,{sx:{display:"flex",alignItems:"center",gap:{xs:1,sm:1.5,md:2},mb:{xs:1.5,sm:2},flexDirection:{xs:"column",sm:"row"}},children:[A.jsx(Hn,{size:"small",color:"error",onClick:N,sx:{border:"1px solid rgba(211, 47, 47, 0.3)",alignSelf:{xs:"flex-start",sm:"auto"},"&:hover":{backgroundColor:"rgba(211, 47, 47, 0.08)",borderColor:"rgba(211, 47, 47, 0.5)"}},"aria-label":"הסר לוגו",children:A.jsx(Qs,{fontSize:"small"})}),A.jsx(K,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",minHeight:{xs:"80px",sm:"90px",md:"100px"},backgroundColor:(()=>{var Y;const U=((Y=i==null?void 0:i.theme)==null?void 0:Y.logoHeaderBackground)??"white";return/^#(000|000000)$/i.test(U.trim())||/^rgb\s*\(\s*0\s*,\s*0\s*,\s*0\s*\)$/i.test(U.trim())?"white":U})(),borderRadius:1,border:"1px solid rgba(0, 0, 0, 0.08)",p:{xs:.5,sm:1},width:{xs:"100%",sm:"auto"}},children:A.jsx("img",{src:E,alt:"Logo preview",style:{maxWidth:"100%",maxHeight:"100px",objectFit:"contain"}})})]}),A.jsx("label",{htmlFor:"logo-upload-input",children:A.jsx(ze,{variant:"outlined",component:"span",startIcon:A.jsx(Ax,{}),fullWidth:!0,sx:{textTransform:"none",borderRadius:{xs:1.5,sm:2},fontSize:{xs:"0.875rem",sm:"1rem"}},children:"החלף לוגו"})})]}):A.jsxs(K,{sx:{border:"1px dashed",borderColor:"divider",borderRadius:2,p:{xs:2,sm:2.5,md:3},textAlign:"center",bgcolor:U=>un(U.palette.common.black,.02),transition:"border-color 0.2s ease, background-color 0.2s ease","&:hover":{borderColor:"text.secondary",bgcolor:U=>un(U.palette.common.black,.035)}},children:[A.jsx("label",{htmlFor:"logo-upload-input",children:A.jsx(ze,{variant:"outlined",component:"span",startIcon:A.jsx(cx,{}),sx:{textTransform:"none",borderRadius:{xs:1.5,sm:2},px:{xs:2,sm:2.5,md:3},py:{xs:.75,sm:1},fontSize:{xs:"0.875rem",sm:"1rem"}},children:"העלה לוגו"})}),A.jsx(fe,{variant:"caption",color:"text.secondary",sx:{mt:{xs:1,sm:1.5},display:"block",fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:"תמונות PNG, JPG או SVG עד 5MB"})]})]})}),A.jsxs(ut,{spacing:0,className:w?$o.fadeUpDelay3:"",children:[A.jsx(Sa,{title:"פרטי העסק",description:"שם, תעשייה, כתובת והגדרות סוג עסק — משמשים לנתח ולייצר תוצרים מדויקים יותר.",children:A.jsxs(ct,{container:!0,spacing:{xs:2,sm:2.5,md:3},children:[A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"שם העסק",value:i.business_name,onChange:U=>H("business_name",U.target.value),variant:"outlined",margin:"normal"})}),A.jsxs(ct,{item:!0,xs:12,md:6,children:[A.jsx(at,{fullWidth:!0,label:"שם בעל.ת העסק (מלא)",value:i.owner,onChange:U=>H("owner",U.target.value),variant:"outlined",margin:"normal"}),A.jsxs(aq,{row:!0,value:i.owner_gender??"",onChange:U=>H("owner_gender",U.target.value),sx:{mt:.5,gap:{xs:.5,sm:1},"& .MuiFormControlLabel-root":{mr:0}},children:[A.jsx(Kc,{value:"male",control:A.jsx(Wg,{size:"small"}),label:A.jsxs(K,{component:"span",sx:{display:"flex",alignItems:"center",gap:.5},children:[A.jsx(Wx,{fontSize:"small"}),A.jsx("span",{children:"זכר"})]}),labelPlacement:"end"}),A.jsx(Kc,{value:"female",control:A.jsx(Wg,{size:"small"}),label:A.jsxs(K,{component:"span",sx:{display:"flex",alignItems:"center",gap:.5},children:[A.jsx(gx,{fontSize:"small"}),A.jsx("span",{children:"נקבה"})]}),labelPlacement:"end"}),A.jsx(Kc,{value:"other",control:A.jsx(Wg,{size:"small"}),label:A.jsxs(K,{component:"span",sx:{display:"flex",alignItems:"center",gap:.5},children:[A.jsx(hx,{fontSize:"small"}),A.jsx("span",{children:"אחר"})]}),labelPlacement:"end"})]})]}),A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx($W,{freeSolo:!0,options:h,value:i.industry||"",onChange:(U,O)=>{H("industry",O||"")},onInputChange:(U,O)=>{H("industry",O)},inputValue:i.industry||"",openOnFocus:!0,disablePortal:!0,componentsProps:{popper:{container:(P==null?void 0:P.getElementById("cdtr-business-ai-root"))||void 0,style:{zIndex:9999},modifiers:[{name:"offset",options:{offset:[0,4]}}]}},ListboxProps:{sx:{maxHeight:"300px","& .MuiAutocomplete-option":{padding:"8px 16px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"},"&[aria-selected='true']":{backgroundColor:"rgba(0, 0, 0, 0.08)"}}}},PaperComponent:({children:U,...O})=>A.jsx(K,{...O,sx:{borderRadius:"4px",border:"1px solid rgba(0, 0, 0, 0.1)",marginTop:"4px",backgroundColor:"white"},children:U}),renderInput:U=>A.jsx(at,{...U,label:"תעשייה",variant:"outlined",margin:"normal"}),noOptionsText:h.length===0?"הקלד תעשייה":"אין אפשרויות"})}),A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"סוג עסק",value:i.business_type,onChange:U=>H("business_type",U.target.value),variant:"outlined",margin:"normal"})}),A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"כתובת העסק",value:i.business_address??"",onChange:U=>H("business_address",U.target.value),variant:"outlined",margin:"normal"})}),A.jsxs(ct,{item:!0,xs:12,children:[A.jsx(fe,{variant:"subtitle2",sx:{mb:{xs:.75,sm:1},fontSize:{xs:"0.875rem",sm:"1rem"}},children:"אפשרויות סוג עסק"}),(Array.isArray(i.business_type_options)?i.business_type_options:[]).map((U,O)=>A.jsxs(K,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[A.jsx(at,{fullWidth:!0,value:U,onChange:Y=>he("business_type_options",O,Y.target.value),variant:"outlined",margin:"normal",size:"small"}),A.jsx(Hn,{color:"error",onClick:()=>me(O),sx:{mt:1},"aria-label":"הסר אפשרות",children:A.jsx(Qs,{})})]},O)),A.jsx(ze,{variant:"outlined",startIcon:A.jsx(Fl,{}),onClick:We,sx:{mt:1},children:"הוספת אפשרות"})]}),A.jsx(ct,{item:!0,xs:12,children:A.jsx(f6,{value:i.keywords,onChange:U=>H("keywords",U)})})]})}),A.jsx(er,{sx:{my:{xs:1.5,sm:2},borderColor:"divider"}}),A.jsx(Sa,{title:"צבעי מותג",description:"גררו צבעים או עדכנו ראשי ומשני — משפיעים על תצוגת המותג בחוויה.",children:A.jsx(H6,{colors:((it=i.theme)==null?void 0:it.colors)??[],primary:((D=i.theme)==null?void 0:D.primary)||"",secondary:((ne=i.theme)==null?void 0:ne.secondary)||"",onPrimaryChange:U=>ae("primary",U),onSecondaryChange:U=>ae("secondary",U),onColorsChange:X})}),A.jsx(er,{sx:{my:{xs:1.5,sm:2},borderColor:"divider"}}),A.jsx(Sa,{title:"טון ותוכן",description:"איך העסק נשמע, תיאור קצר וכתובת האתר לעדכון.",children:A.jsxs(ct,{container:!0,spacing:{xs:2,sm:2.5,md:3},children:[A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx($W,{freeSolo:!0,options:C,value:i.business_tone||"",onChange:(U,O)=>{H("business_tone",O||"")},onInputChange:(U,O)=>{H("business_tone",O)},inputValue:i.business_tone||"",openOnFocus:!0,disablePortal:!0,componentsProps:{popper:{container:(P==null?void 0:P.getElementById("cdtr-business-ai-root"))||void 0,style:{zIndex:9999},modifiers:[{name:"offset",options:{offset:[0,4]}}]}},ListboxProps:{sx:{maxHeight:"300px","& .MuiAutocomplete-option":{padding:"8px 16px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"},"&[aria-selected='true']":{backgroundColor:"rgba(0, 0, 0, 0.08)"}}}},PaperComponent:({children:U,...O})=>A.jsx(K,{...O,sx:{borderRadius:"4px",border:"1px solid rgba(0, 0, 0, 0.1)",marginTop:"4px",backgroundColor:"white"},children:U}),renderInput:U=>A.jsx(at,{...U,label:"טון עסקי",variant:"outlined",margin:"normal"}),noOptionsText:C.length===0?"הקלד טון עסקי":"אין אפשרויות"})}),A.jsxs(ct,{item:!0,xs:12,children:[A.jsx(fe,{variant:"subtitle2",sx:{mb:{xs:.75,sm:1},fontSize:{xs:"0.875rem",sm:"1rem"}},children:"תיאור"}),(Array.isArray(i.description)?i.description:i.description?[i.description]:[""]).map((U,O)=>A.jsxs(K,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:1},children:[A.jsx(at,{fullWidth:!0,value:U,onChange:Y=>he("description",O,Y.target.value),variant:"outlined",margin:"normal",multiline:!0,rows:3,size:"small"}),A.jsx(Hn,{color:"error",onClick:()=>ce(O),sx:{mt:1},"aria-label":"הסר תיאור",children:A.jsx(Qs,{})})]},O)),A.jsx(ze,{variant:"outlined",startIcon:A.jsx(Fl,{}),onClick:ve,sx:{mt:1},children:"הוספת תיאור"})]}),A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"אתר אינטרנט",value:i.website,onChange:U=>H("website",U.target.value),variant:"outlined",margin:"normal"})})]})}),A.jsx(er,{sx:{my:{xs:1.5,sm:2},borderColor:"divider"}}),A.jsxs(Sa,{title:"קשר ורשתות",description:"אימייל וטלפון ליצירת קשר, וקישורים לפרופילים ציבוריים.",children:[A.jsxs(ct,{container:!0,spacing:{xs:1.5,sm:2},children:[A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"אימייל",value:i.contacts.email,onChange:U=>de("contacts","email",U.target.value),variant:"outlined",margin:"normal"})}),A.jsx(ct,{item:!0,xs:12,md:6,children:A.jsx(at,{fullWidth:!0,label:"טלפון",value:i.contacts.phone,onChange:U=>de("contacts","phone",U.target.value),variant:"outlined",margin:"normal"})})]}),A.jsxs(K,{sx:{mt:{xs:2,sm:2.5},p:{xs:1.5,sm:2},borderRadius:2,border:"1px solid",borderColor:"divider",bgcolor:U=>un(U.palette.common.black,.02)},children:[Object.entries(i.socials).map(([U,O])=>A.jsx(lO,{platform:U,url:O,onPlatformCommit:Ke,onUrlChange:qe,onRemove:le},j(U))),A.jsx(ze,{variant:"outlined",startIcon:A.jsx(Fl,{}),onClick:Ze,sx:{mt:1,textTransform:"none"},children:"הוספת רשת חברתית"})]})]})]})]}),A.jsxs(K,{className:w?$o.fadeUpDelay4:"",sx:{position:"fixed",bottom:0,left:0,right:0,zIndex:10,padding:{xs:1,sm:1,md:1},paddingTop:{xs:1,sm:1,md:1},backgroundColor:"background.default",borderTop:"1px solid",borderColor:"divider"},children:[m&&A.jsx(Ml,{severity:"error",sx:{mb:1},onClose:()=>x(null),children:m}),A.jsxs(ct,{container:!0,spacing:{xs:1,sm:2},sx:{justifyContent:{xs:"center",sm:"space-between"}},children:[A.jsx(ct,{item:!0,xs:12,sm:"auto",children:A.jsx(ze,{variant:"text",color:"primary",onClick:()=>n(L),fullWidth:!0,sx:{fontSize:{xs:"0.875rem",sm:"1rem"},maxWidth:{xs:"100%",sm:"auto"}},children:"חזרה"})}),A.jsx(ct,{item:!0,xs:12,sm:"auto",children:A.jsx(ze,{variant:"contained",color:"primary",onClick:Be,disabled:f,fullWidth:!0,startIcon:f?A.jsx(va,{size:18,color:"inherit"}):null,sx:{fontSize:{xs:"0.875rem",sm:"1rem"},maxWidth:{xs:"100%",sm:"auto"},minWidth:120},children:f?"שומר...":"שלב הבא"})})]})]})]})}const sO=$t(A.jsx("path",{d:"M7 16c.55 0 1 .45 1 1 0 1.1-.9 2-2 2-.17 0-.33-.02-.5-.05.31-.55.5-1.21.5-1.95 0-.55.45-1 1-1M18.67 3c-.26 0-.51.1-.71.29L9 12.25 11.75 15l8.96-8.96c.39-.39.39-1.02 0-1.41l-1.34-1.34c-.2-.2-.45-.29-.7-.29M7 14c-1.66 0-3 1.34-3 3 0 1.31-1.16 2-2 2 .92 1.22 2.49 2 4 2 2.21 0 4-1.79 4-4 0-1.66-1.34-3-3-3"}),"BrushOutlined"),pO=$t(A.jsx("path",{d:"M20.97 7.27c.39-.39.39-1.02 0-1.41l-2.83-2.83a.9959.9959 0 0 0-1.41 0l-4.49 4.49-3.89-3.89c-.78-.78-2.05-.78-2.83 0l-1.9 1.9c-.78.78-.78 2.05 0 2.83l3.89 3.89L3 16.76V21h4.24l4.52-4.52 3.89 3.89c.95.95 2.23.6 2.83 0l1.9-1.9c.78-.78.78-2.05 0-2.83l-3.89-3.89zM5.04 6.94l1.89-1.9L8.2 6.31 7.02 7.5l1.41 1.41 1.19-1.19 1.2 1.2-1.9 1.9zm11.23 7.44-1.19 1.19 1.41 1.41 1.19-1.19 1.27 1.27-1.9 1.9-3.89-3.89 1.9-1.9zM6.41 19H5v-1.41l9.61-9.61 1.3 1.3.11.11zm9.61-12.44 1.41-1.41 1.41 1.41-1.41 1.41z"}),"DesignServicesOutlined");var Ch={},uO=Fe;Object.defineProperty(Ch,"__esModule",{value:!0});var aE=Ch.default=void 0,cO=uO(Oe()),AO=A;aE=Ch.default=(0,cO.default)((0,AO.jsx)("path",{d:"m19 9 1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25zm0 6-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25zm-7.5-5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12zm-1.51 3.49L9 15.17l-.99-2.18L5.83 12l2.18-.99L9 8.83l.99 2.18 2.18.99z"}),"AutoAwesomeOutlined");var vh={},dO=Fe;Object.defineProperty(vh,"__esModule",{value:!0});var rE=vh.default=void 0,fO=dO(Oe()),yh=A;rE=vh.default=(0,fO.default)([(0,yh.jsx)("path",{d:"M18 10.48V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4.48l4 3.98v-11zm-2-.79V18H4V6h12z"},"0"),(0,yh.jsx)("circle",{cx:"10",cy:"10",r:"2"},"1"),(0,yh.jsx)("path",{d:"M14 15.43c0-.81-.48-1.53-1.22-1.85-.85-.37-1.79-.58-2.78-.58-.99 0-1.93.21-2.78.58C6.48 13.9 6 14.62 6 15.43V16h8z"},"2")],"VideoCameraFrontOutlined");var Sh={},WO=Fe;Object.defineProperty(Sh,"__esModule",{value:!0});var Ih=Sh.default=void 0,gO=WO(Oe()),hO=A;Ih=Sh.default=(0,gO.default)((0,hO.jsx)("path",{d:"M21 11.01 3 11v2h18zM3 16h12v2H3zM21 6H3v2.01L21 8z"}),"NotesOutlined");var xh={},mO=Fe;Object.defineProperty(xh,"__esModule",{value:!0});var lE=xh.default=void 0,CO=mO(Oe()),vO=A;lE=xh.default=(0,CO.default)((0,vO.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-1 9H9V9h10zm-4 4H9v-2h6zm4-8H9V5h10z"}),"LibraryBooks");var Eh={},yO=Fe;Object.defineProperty(Eh,"__esModule",{value:!0});var oE=Eh.default=void 0,SO=yO(Oe()),IO=A;oE=Eh.default=(0,SO.default)((0,IO.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit");var bh={},xO=Fe;Object.defineProperty(bh,"__esModule",{value:!0});var iE=bh.default=void 0,EO=xO(Oe()),bO=A;iE=bh.default=(0,EO.default)((0,bO.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const sE=[{id:"authentic_text",label:"טקסט אישי",questions:[{id:"topic",label:"נושא / תיאור קצר",inputType:"multiline"}]},{id:"designed_mail",label:"מעוצב (מצב מהיר)",questions:[{id:"topic",label:"נושא / תיאור קצר",inputType:"multiline"}]},{id:"studio_design",label:"מעוצב (סטודיו)",questions:[{id:"topic",label:"נושא / תיאור קצר",inputType:"multiline"}]},{id:"designed_mail_advanced",comingSoon:!0,label:"מעצב פרו (סטודיו)",questions:[{id:"topic",label:"נושא / תיאור קצר",inputType:"multiline"}]}];function pE(e){return sE.find(t=>t.id===e)}function kh(e){return e==="other"}function uE(e,t,n){if(e==="other"&&n!=null){const l=n.trim();return l?l+(l.endsWith(".")?"":"."):"אני רוצה לבנות מייל."}const a=pE(e);if(!a)return"";const r=[];if(e==="webinar"){const l=t.date||"",o=t.time||"",i=t.topic||"";return r.push("אני רוצה לבנות מייל לוובינר"),(l||o)&&r.push(`בתאריך ${l}${o?` בשעה ${o}`:""}`),i&&r.push(`, ${i}`),r.join(" ")+"."}if(e==="designed_mail"){const l=t.topic||"";return l?`אני רוצה לבנות מייל מעוצב: ${l}.`:"אני רוצה לבנות מייל מעוצב."}if(e==="studio_design"){const l=t.topic||"";return l?`אני רוצה לבנות מייל מעוצב בסטודיו: ${l}.`:"אני רוצה לבנות מייל מעוצב בסטודיו."}if(e==="authentic_text"){const l=t.topic||"";return l?`אני רוצה לבנות מייל בטקסט אישי: ${l}.`:"אני רוצה לבנות מייל בטקסט אישי."}return a.label?`אני רוצה לבנות מייל מסוג ${a.label}.`:""}var wh={},kO=Fe;Object.defineProperty(wh,"__esModule",{value:!0});var nA=wh.default=void 0,wO=kO(Oe()),RO=A;nA=wh.default=(0,wO.default)((0,RO.jsx)("path",{d:"M2.5 4v3h5v12h3V7h5V4zm19 5h-9v3h3v7h3v-7h3z"}),"TextFields");var Rh={},BO=Fe;Object.defineProperty(Rh,"__esModule",{value:!0});var Os=Rh.default=void 0,LO=BO(Oe()),MO=A;Os=Rh.default=(0,LO.default)((0,MO.jsx)("path",{d:"M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11"}),"Extension");const cE=["newsletter.loadingSteps.building","newsletter.loadingSteps.searchingImages","newsletter.loadingSteps.choosingIcons","newsletter.loadingSteps.analyzing"],Bh=["https://images.pexels.com/photos/3184292/pexels-photo-3184292.jpeg?auto=compress&cs=tinysrgb&w=200","https://images.pexels.com/photos/2762247/pexels-photo-2762247.jpeg?auto=compress&cs=tinysrgb&w=200","https://images.pexels.com/photos/267350/pexels-photo-267350.jpeg?auto=compress&cs=tinysrgb&w=200"],QO={"@keyframes sceneIn":{"0%":{opacity:0,transform:"scale(0.94)"},"100%":{opacity:1,transform:"scale(1)"}},"@keyframes blockDrop":{"0%":{transform:"translate(-10px, -16px)",opacity:.5},"100%":{transform:"translate(0, 0)",opacity:1}},"@keyframes blockFloat":{"0%, 100%":{transform:"translate(0, 0)"},"50%":{transform:"translate(3px, -2px)"}}},Qn={animation:"blockDrop 0.5s ease-out both, blockFloat 2.2s ease-in-out 0.6s infinite",borderRadius:2,border:"1px solid rgba(0, 0, 0, 0.08)",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},AE={background:`linear-gradient(135deg, ${tA}61 0%, ${mh}61 100%)`};function VO(){return A.jsxs(K,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1.5},children:[A.jsx(K,{className:"block",sx:{...Qn,width:110,height:26,background:ta,color:"primary.contrastText"},children:A.jsx(nA,{sx:{fontSize:16}})}),A.jsx(K,{className:"block",sx:{...Qn,width:130,height:72},children:A.jsx("img",{src:Bh[0],alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),A.jsxs(K,{sx:{display:"flex",gap:1},children:[A.jsx(K,{className:"block",sx:{...Qn,width:36,height:36,bgcolor:"secondary.main",color:"secondary.contrastText"},children:A.jsx(Os,{sx:{fontSize:20}})}),A.jsx(K,{className:"block",sx:{...Qn,width:44,height:36,...AE}})]})]})}function UO(){return A.jsxs(K,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1.5},children:[A.jsx(K,{className:"block",sx:{...Qn,width:130,height:68},children:A.jsx("img",{src:Bh[1],alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),A.jsxs(K,{sx:{display:"flex",gap:1},children:[A.jsx(K,{className:"block",sx:{...Qn,width:100,height:24,background:ta,color:"primary.contrastText"},children:A.jsx(nA,{sx:{fontSize:14}})}),A.jsx(K,{className:"block",sx:{...Qn,width:36,height:36,bgcolor:"secondary.main",color:"secondary.contrastText"},children:A.jsx(Os,{sx:{fontSize:20}})})]}),A.jsx(K,{className:"block",sx:{...Qn,width:90,height:32,bgcolor:"grey.300"}})]})}function FO(){return A.jsxs(K,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1.5},children:[A.jsxs(K,{sx:{display:"flex",gap:1},children:[A.jsx(K,{className:"block",sx:{...Qn,width:38,height:38,background:ta,color:"primary.contrastText"},children:A.jsx(Os,{sx:{fontSize:22}})}),A.jsx(K,{className:"block",sx:{...Qn,width:50,height:38,...AE}}),A.jsx(K,{className:"block",sx:{...Qn,width:38,height:38,bgcolor:"secondary.main",color:"secondary.contrastText"},children:A.jsx(Os,{sx:{fontSize:20}})})]}),A.jsx(K,{className:"block",sx:{...Qn,width:120,height:70},children:A.jsx("img",{src:Bh[2],alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),A.jsx(K,{className:"block",sx:{...Qn,width:100,height:22,background:ta,color:"primary.contrastText"},children:A.jsx(nA,{sx:{fontSize:14}})})]})}const dE=[VO,UO,FO];function zO(e){const{t}=Nn(),[n,a]=v.useState(0),[r,l]=v.useState(0),[o,i]=v.useState(0);v.useEffect(()=>{const p=setInterval(()=>{a(u=>(u+1)%cE.length)},2500);return()=>clearInterval(p)},[]),v.useEffect(()=>{const p=setInterval(()=>{l(u=>(u+1)%dE.length)},3200);return()=>clearInterval(p)},[]),v.useEffect(()=>{const p=setInterval(()=>{i(u=>u+1)},1e3);return()=>clearInterval(p)},[]);const s=dE[r];return A.jsxs(K,{sx:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:2,paddingTop:4,...QO},children:[A.jsx(K,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1.5,mb:3,minHeight:180,"& .block":Qn,"& .block:nth-of-type(1)":{animationDelay:"0s, 0.6s"},"& .block:nth-of-type(2)":{animationDelay:"0.12s, 0.72s"},"& .block:nth-of-type(3)":{animationDelay:"0.24s, 0.84s"},"& .block:nth-of-type(4)":{animationDelay:"0.36s, 0.96s"},"& .block:nth-of-type(5)":{animationDelay:"0.48s, 1.08s"},"& .block:nth-of-type(6)":{animationDelay:"0.6s, 1.2s"}},children:A.jsx(K,{sx:{animation:"sceneIn 0.4s ease-out"},children:A.jsx(s,{})},r)}),A.jsx(K,{sx:{display:"flex",gap:.75,mb:1.5},children:[0,1,2,3].map(p=>A.jsx(K,{sx:{width:10,height:10,borderRadius:"50%",...p<=n?{background:ta}:{bgcolor:"action.hover"},opacity:p===n?1:p<n?.8:.4,transition:"opacity 0.3s ease, background-color 0.3s ease"}},p))}),A.jsx(fe,{variant:"body1",sx:{fontWeight:500,color:"text.secondary"},children:t(cE[n])}),A.jsxs(fe,{variant:"caption",sx:{mt:1,color:"text.disabled",fontVariantNumeric:"tabular-nums"},children:[Math.floor(o/60).toString().padStart(2,"0"),":",(o%60).toString().padStart(2,"0")]})]})}const fE={IL:"Israel",US:"United States",CA:"Canada",GB:"United Kingdom",UK:"United Kingdom",AU:"Australia",DE:"Germany",FR:"France",ES:"Spain",IT:"Italy",NL:"Netherlands",BR:"Brazil",MX:"Mexico",AR:"Argentina",RU:"Russia",JP:"Japan",CN:"China",IN:"India",ZA:"South Africa",AE:"United Arab Emirates",SA:"Saudi Arabia",PL:"Poland",SE:"Sweden",NO:"Norway",DK:"Denmark",FI:"Finland",CH:"Switzerland",AT:"Austria",BE:"Belgium",PT:"Portugal",GR:"Greece",TR:"Turkey",KR:"South Korea",SG:"Singapore",HK:"Hong Kong",TW:"Taiwan",NZ:"New Zealand",IE:"Ireland"},qO={"Asia/Jerusalem":"Israel","America/New_York":"United States","America/Los_Angeles":"United States","America/Chicago":"United States","America/Toronto":"Canada","America/Vancouver":"Canada","Europe/London":"United Kingdom","Europe/Paris":"France","Europe/Berlin":"Germany","Europe/Madrid":"Spain","Europe/Rome":"Italy","Europe/Amsterdam":"Netherlands","Australia/Sydney":"Australia","Australia/Melbourne":"Australia","Asia/Tokyo":"Japan","Asia/Shanghai":"China","Asia/Dubai":"United Arab Emirates","America/Sao_Paulo":"Brazil","America/Mexico_City":"Mexico"};function jO(){if(typeof navigator>"u")return null;try{const e=navigator,t=[navigator.language,...e.languages??[]].filter(Boolean);for(const n of t){if(!n)continue;const a=new Intl.Locale(n).region;if(a&&fE[a])return fE[a];if(n.startsWith("he")&&!a)return"Israel"}}catch{}try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(e){const t=qO[e];if(t)return t;if(e.split("/")[0]==="Asia"&&e.includes("Jerusalem"))return"Israel"}}catch{}return null}const TO={authentic_text:Ih,webinar:rE,designed_mail:aE,studio_design:sO,designed_mail_advanced:pO};function Lh({header:e,children:t,footer:n,compactBody:a}){return A.jsxs(K,{sx:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",bgcolor:"background.paper"},children:[A.jsx(K,{sx:{flexShrink:0,pt:{xs:6,sm:7},px:2.5,pb:2,borderBottom:"1px solid",borderColor:"divider"},children:e}),a?A.jsx(K,{sx:{flex:1,minHeight:0}}):A.jsx(K,{sx:{flex:1,minHeight:0,overflow:"auto",px:2.5,py:2,WebkitOverflowScrolling:"touch"},children:t}),n?A.jsx(K,{sx:{flexShrink:0,px:2.5,py:2,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:n}):null]})}function OO({domain:e,mergeTags:t=[],visibilityRules:n,location:a,onResult:r,result:l,language:o,context:i,onSeriesClick:s,onBack:p}){const{t:u}=Nn(),c=Go(),{step3Draft:d,setStep3Draft:f}=rx(),[W,m]=v.useState(0),[x,h]=v.useState(null),[g,C]=v.useState({}),[y,E]=v.useState(""),[S,k]=v.useState(!1),[R,V]=v.useState(null),[b,B]=v.useState(null),[M,F]=v.useState(!1),z=x?pE(x):null,T=(z==null?void 0:z.questions)??[],j=a&&a.trim()||jO()||void 0,P=_=>{h(_),C({}),m(1)},L=(_,H)=>{C(de=>({...de,[_]:H}))},q=async()=>{if(!y.trim())return;k(!0),V(null);const _=Date.now();try{const H=uE("other",{},y),de=await kg({prompt:H,domain:e,mergeTags:t,structureUrl:"",textStyleUrl:"",...n&&Object.keys(n).length>0?{visibilityRules:n}:{},...o?{language:o}:{},...j?{location:j}:{},...i?{context:i}:{}});B(Math.round((Date.now()-_)/1e3)),r(de)}catch(H){console.error("Newsletter generation failed:",H),V(u("common.errorGeneric"))}finally{k(!1)}},w=async(_,H)=>{k(!0),V(null);const de=Date.now();try{const ae=x==="studio_design"||x==="webinar",X=x==="designed_mail";if(X||ae){const he=o||"he",We=Kj(i,he),me={prompt:_,accountId:We.accountId,language:he,...t.length>0?{mergeTags:t}:{},businessContext:We},ve=X?await Tj(me):await Oj(me),ce={...ve,components:ve.nodes??[]};B(Math.round((Date.now()-de)/1e3)),r(ce)}else{const he=await kg({prompt:_,domain:e,mergeTags:t,structureUrl:"",textStyleUrl:H,...n&&Object.keys(n).length>0?{visibilityRules:n}:{},...o?{language:o}:{},...j?{location:j}:{},...i?{context:i}:{}});B(Math.round((Date.now()-de)/1e3)),r(he)}}catch(ae){console.error("Newsletter generation failed:",ae),V(u("common.errorGeneric"))}finally{k(!1)}},G=()=>{const _=uE(x,g);_&&w(_,"")},te=()=>{if(M||!c||!l)return;F(!0);const _=(d==null?void 0:d.components)??l.components??l.nodes??l.template,H=l.meta,de=l.name||(H==null?void 0:H.name)||(x?u(`newsletter.types.${x}`):"")||"Newsletter",ae=l.subject||(H==null?void 0:H.subject)||de,X=l.direction||(H==null?void 0:H.direction)||(o==="he"?"rtl":"ltr"),he={...l,components:_,template:_,name:de,subject:ae,direction:X,description:l.description||(H==null?void 0:H.preheader)||"",preheader:l.preheader||(H==null?void 0:H.preheader)||""};console.log("[handleEdit] result:",l),console.log("[handleEdit] meta:",H),console.log("[handleEdit] name:",de,"subject:",ae),console.log("[handleEdit] components count:",_==null?void 0:_.length),console.log("[handleEdit] full payload:",he);try{c.triggerEvent("onEditPage",he),f(null)}catch(We){console.error("[handleEdit] triggerEvent error:",We)}setTimeout(()=>F(!1),15e3)},Q=()=>{r(null),m(0),h(null),C({}),E(""),V(null),B(null)},N=()=>{m(0),h(null),C({}),E("")};if(l&&l.components)return A.jsx(Lh,{compactBody:!0,header:A.jsxs(ut,{spacing:1,children:[A.jsx(fe,{variant:"h6",component:"h1",sx:{fontWeight:700,letterSpacing:"-0.02em",lineHeight:1.35},children:u("newsletter.successHeading")}),A.jsx(fe,{variant:"body2",color:"text.secondary",sx:{lineHeight:1.55},children:u("newsletter.successMessage")}),b!=null&&A.jsxs(fe,{variant:"caption",color:"text.disabled",sx:{fontVariantNumeric:"tabular-nums"},children:[Math.floor(b/60).toString().padStart(2,"0"),":",(b%60).toString().padStart(2,"0")]})]}),footer:A.jsxs(ut,{direction:"row",flexWrap:"wrap",gap:1.5,justifyContent:"flex-start",children:[A.jsx(ze,{variant:"contained",color:"primary",disabled:M,startIcon:M?A.jsx(va,{size:18,color:"inherit"}):A.jsx(oE,{}),onClick:te,sx:{textTransform:"none"},children:u("newsletter.editDesign")}),A.jsx(ze,{variant:"outlined",color:"primary",startIcon:A.jsx(iE,{}),onClick:Q,sx:{textTransform:"none"},children:u("newsletter.startOver")})]})});if(S)return A.jsx(K,{sx:{height:"100%",minHeight:0,overflow:"auto"},children:A.jsx(zO,{language:o})});const re=W!==1||!x?"":kh(x)?u("newsletter.tellUs"):z?u(`newsletter.types.${z.id}`):"";if(W===0)return A.jsxs(Lh,{header:A.jsxs(ut,{spacing:1,children:[p?A.jsx(ze,{variant:"text",color:"primary",onClick:p,sx:{alignSelf:"flex-start",textTransform:"none",minWidth:"auto",px:.5,ml:-.5,mt:1},children:u("newsletter.back")}):A.jsxs(A.Fragment,{children:[A.jsx("br",{}),A.jsx("br",{})]}),A.jsx(fe,{component:"h1",variant:"h6",sx:{fontWeight:700,letterSpacing:"-0.02em",lineHeight:1.35,color:"text.primary"},children:u("newsletter.whatType")}),A.jsx(fe,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.8125rem",lineHeight:1.55,maxWidth:"52ch"},children:u("newsletter.typeSectionHint")})]}),children:[A.jsxs(ut,{spacing:1.25,children:[sE.map(_=>{const H=TO[_.id]??Ih;return A.jsx(eg,{elevation:0,variant:"outlined",sx:{borderRadius:2,borderColor:"divider",bgcolor:"background.paper",transition:"border-color 0.2s ease, box-shadow 0.2s ease","&:hover":{borderColor:"primary.main",boxShadow:de=>`0 2px 12px ${un(de.palette.primary.main,.12)}`},..._.comingSoon?{opacity:.5,cursor:"not-allowed"}:{}},children:A.jsx(eI,{onClick:()=>_.comingSoon?null:P(_.id),sx:{borderRadius:0,"&:focus-visible":{outlineOffset:-2}},children:A.jsx(ng,{sx:{py:1.75,px:2,"&:last-child":{pb:1.75}},children:A.jsxs(ut,{direction:"row",spacing:1.75,alignItems:"center",children:[A.jsx(K,{sx:{width:44,height:44,borderRadius:1.5,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:de=>un(de.palette.primary.main,.08),border:de=>`1px solid ${un(de.palette.primary.main,.16)}`},children:A.jsx(H,{sx:{fontSize:24,..._o}})}),A.jsx(fe,{variant:"subtitle1",sx:{fontWeight:600,fontSize:"0.9375rem",lineHeight:1.4,letterSpacing:"-0.01em",color:"text.primary"},children:u(`newsletter.types.${_.id}`)}),_.comingSoon?A.jsx(vn,{label:u("newsletter.comingSoon"),size:"small",color:"primary",variant:"outlined"}):null]})})})},_.id)}),s?A.jsx(eg,{elevation:0,variant:"outlined",sx:{borderRadius:2,borderColor:"divider",bgcolor:"background.paper",opacity:.5,cursor:"not-allowed"},children:A.jsx(eI,{onClick:void 0,disabled:!0,sx:{borderRadius:0,"&:focus-visible":{outlineOffset:-2}},children:A.jsx(ng,{sx:{py:1.75,px:2,"&:last-child":{pb:1.75}},children:A.jsxs(ut,{direction:"row",spacing:1.75,alignItems:"center",children:[A.jsx(K,{sx:{width:44,height:44,borderRadius:1.5,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:_=>un(_.palette.primary.main,.08),border:_=>`1px solid ${un(_.palette.primary.main,.16)}`},children:A.jsx(lE,{sx:{fontSize:24,..._o}})}),A.jsx(fe,{variant:"subtitle1",sx:{fontWeight:600,fontSize:"0.9375rem",lineHeight:1.4,letterSpacing:"-0.01em",color:"text.primary"},children:u("seriesPrompt.hub.title")}),A.jsx(vn,{label:u("newsletter.comingSoon"),size:"small",color:"primary",variant:"outlined"})]})})})}):null]}),R?A.jsx(fe,{color:"error",variant:"body2",sx:{mt:2},children:R}):null]});const ue=kh(x)?A.jsx(ut,{direction:"row",spacing:1.5,justifyContent:"flex-end",flexWrap:"wrap",children:A.jsx(ze,{variant:"contained",color:"primary",onClick:q,disabled:!y.trim()||S,sx:{textTransform:"none"},children:S?A.jsx(va,{size:22,color:"inherit"}):u("common.send")})}):A.jsx(ut,{direction:"row",spacing:1.5,justifyContent:"flex-end",flexWrap:"wrap",children:A.jsx(ze,{variant:"contained",color:"primary",onClick:G,disabled:S,sx:{textTransform:"none"},children:S?A.jsx(va,{size:22,color:"inherit"}):u("common.continue")})});return A.jsxs(Lh,{header:A.jsxs(ut,{spacing:1.25,children:[A.jsx(ze,{variant:"text",color:"primary",onClick:N,sx:{alignSelf:"flex-start",textTransform:"none",minWidth:"auto",px:.5,ml:-.5,mt:-.5},children:u("newsletter.back")}),A.jsx(fe,{variant:"h6",component:"h1",sx:{fontWeight:700,letterSpacing:"-0.02em",lineHeight:1.35},children:re}),A.jsx(fe,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.8125rem",lineHeight:1.55},children:u("newsletter.questionsSectionHint")})]}),footer:ue,children:[kh(x)?A.jsx(at,{multiline:!0,minRows:4,placeholder:u("newsletter.writeHere"),value:y,onChange:_=>E(_.target.value),fullWidth:!0,variant:"outlined",size:"small"}):A.jsx(ut,{spacing:2,children:T.map(_=>A.jsx(K,{children:_.inputType==="multiline"?A.jsxs(A.Fragment,{children:[A.jsx(fe,{variant:"caption",sx:{mb:.75,display:"block",fontWeight:600,color:"text.secondary",letterSpacing:"0.02em"},children:u("newsletter.topicLabel")}),A.jsx(at,{multiline:!0,minRows:3,placeholder:u("newsletter.writeHere"),value:g[_.id]??"",onChange:H=>L(_.id,H.target.value),fullWidth:!0,variant:"outlined",size:"small"})]}):A.jsx(at,{label:u(x==="webinar"&&_.id==="topic"?"newsletter.questions.topicShort":`newsletter.questions.${_.id}`),type:_.inputType==="date"?"date":_.inputType==="time"?"time":"text",value:g[_.id]??"",onChange:H=>L(_.id,H.target.value),fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:_.inputType==="date"||_.inputType==="time"?{shrink:!0}:void 0})},_.id))}),R?A.jsx(fe,{color:"error",variant:"body2",sx:{mt:2},children:R}):null]})}function KO({setActiveStep:e,placeholderSuggestions:t=[],language:n,data:a={},logo:r="",mergeTags:l=[],visibilityRules:o,location:i,onDesignChange:s}){const{t:p}=Nn(),u=v.useRef(s);u.current=s;const{step2Data:c}=bg(),{step3Draft:d,setStep3Draft:f}=rx(),W=c||a,m=(W==null?void 0:W.businessData)||W,x=(W==null?void 0:W.websiteUrl)||(m==null?void 0:m.website)||"",h=Xc({...m,websiteUrl:x})??void 0,g=(c==null?void 0:c.logo)||(W&&typeof W=="object"&&"logo"in W?W.logo:r),C=(c==null?void 0:c.logoBackgroundHex)??(W==null?void 0:W.logoBackgroundHex),y=v.useRef(null),E=v.useRef(!1),S=v.useRef(null),k=v.useRef(!1),[R,V]=v.useState(0),[b,B]=v.useState(0),[M,F]=v.useState([]),[z,T]=v.useState(null);v.useEffect(()=>{var q;if(k.current)return;const L=d;(q=L==null?void 0:L.components)!=null&&q.length&&(k.current=!0,F(Array.isArray(L.components)?L.components:[]),T(L.surveyResult??null))},[d]);const j=L=>{const q=(L==null?void 0:L.components)??(L==null?void 0:L.nodes);if(q){const w=Array.isArray(q)?q:[];F(w);const G={...L,components:w};T(G),f({components:w,surveyResult:G})}else F([]),T(null),f(null),B(w=>w+1)};v.useEffect(()=>{},[]),v.useEffect(()=>{var G;if(M.length===0||!y.current)return;const L=y.current.querySelector("iframe");L&&L.remove(),(G=S.current)!=null&&G.parentNode&&S.current.parentNode.removeChild(S.current),S.current=null,E.current=!1,E.current=!0;const q=document.createElement("iframe");q.width="100%",q.height="100%",q.style.border="none",S.current=q,y.current.appendChild(q);let w=!1;return q.onload=()=>{if(w)return;w=!0;const te=q.contentDocument,Q=q.contentWindow;if(!te||!Q||te.querySelector('script[src*="creaditor.bundle.js"]'))return;te.open(),te.write(`
|
|
526
526
|
<!DOCTYPE html>
|
|
527
527
|
<html>
|