1import{j as e,m as cs}from"./vendor-motion-DGLXHZ0B.js";import{r as o,L as Ds}from"./vendor-react-DUB4Vjci.js";import{s as xs,ad as Ye,ae as Ke,af as Qe,ag as Xe,aw as Ze,v as C,I as B,B as T,c as Q,ap as es,S as Re,w as Me,x as $e,y as qe,z as ae,ay as Ls,a1 as ve,L as Oe,D as Ts,a6 as pe,g as we,ar as us,as as Fs,aB as Fe,C as W,h as me,i as xe,T as Ue,a as K,j as te,A as We,ab as Ps,b as Es,k as Pe,u as Rs,a8 as Ms,aC as $s,a3 as qs,W as _e,aq as He,aD as Os,q as Us,a2 as Vs,a4 as zs,aj as Bs}from"./index-gimFOjch.js";import{T as Ws,a as Hs,b as De,c as Le}from"./tabs-BTr_byu4.js";import{S as Gs}from"./search-CCwL8nBE.js";import{S as ss}from"./star-DLJ5LIf8.js";import{R as Je}from"./refresh-cw-BcB5Fx7V.js";import{d as Js,C as Ee,P as Ys}from"./PropertyManagementModal-2C9CSFZx.js";import{R as hs,A as Ks,C as Qs,X as Xs,Y as Zs,T as ps,b as et,D as st,P as tt,d as at,e as rt}from"./vendor-charts-DZ_hHnrz.js";import{h as gs}from"./he-HReJu3jL.js";import{A as nt,b as lt,a as it}from"./alert-Ca-cAhSs.js";import{S as ct}from"./save-Djv9LtEc.js";import{H as os}from"./heart-pulse-Dpa_twLu.js";import{W as ds}from"./wallet-2eDQCvb8.js";import{S as ot}from"./shield-alert-BccFSNUN.js";import{M as dt}from"./map-pin-BsuoWXTF.js";import{S as ys}from"./sparkles-BOG37L-k.js";import{C as mt}from"./circle-check-CL2VkGfS.js";import{C as xt}from"./circle-alert-BOKkWrVn.js";import{C as ut}from"./chart-line-BZCYrv4b.js";import{P as ht}from"./pencil-C1diM48g.js";import"./vendor-pdf-ckwbz45p.js";/** 2 * @license lucide-react v0.475.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 pt=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],gt=xs("ArrowDown",pt);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const yt=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ft=xs("ArrowUp",yt),jt=[".TA",".TASE"],Se=r=>{if(!r||typeof r!="string")return!1;const i=r.toUpperCase();return jt.some(m=>i.endsWith(m))},_t=r=>typeof r!="number"||isNaN(r)?0:r/100,ms=(r,i)=>Se(i)?typeof r!="number"||isNaN(r)||r<=0?0:r>50?_t(r):r:r,Ge=(r,i="ILS",m={})=>{const{minimumFractionDigits:s=2,maximumFractionDigits:a=2,...h}=m,p={style:"currency",currency:i,minimumFractionDigits:s,maximumFractionDigits:a,...h};try{new Intl.NumberFormat("he-IL",p).format(0)}catch{console.warn(`Invalid currency code '${i}'. Falling back to 'ILS'.`),p.currency="ILS"}return new Intl.NumberFormat("he-IL",p).format(r||0)},bt=r=>{const{quantity:i=0,purchase_price:m=0,current_price:s=0,ticker_symbol:a="",currency:h="ILS"}=r,p=Se(a)?ms(m,a):m,y=Se(a)?ms(s,a):s,_=i*p,x=i*y,v=x-_,X=_>0?v/_*100:0;return{normalizedPurchasePrice:p,normalizedCurrentPrice:y,totalInvestment:_,currentValue:x,returnAmount:v,returnPercentage:X,currency:Se(a)?"ILS":h}},vt=async({query:r})=>{var s;const i=` 12 Search for up-to-date and accurate financial asset information for: "${r}". 13 14 IMPORTANT GUIDELINES: 15 1. For Bitcoin/BTC or other major cryptocurrencies: Return price in USD. Set source to 'crypto'. Asset type should be 'crypto'. 16 2. For Israeli stocks (ending with .TA or traded on TASE): Return price in Agorot as displayed on the exchange. Set source to 'israeli'. Asset type should be 'stocks' or 'etf'. 17 3. For other international stocks/ETFs: Return price in their original currency. Set source to 'international'. Asset type should be 'stocks' or 'etf'. 18 4. Use real and current data from the internet. 19 5. Provide exchange name and sector where applicable. If no specific sector is found, return an empty string. 20 21 Return JSON with a list of precise matches, ordered by relevance: 22 { 23 "results": [ 24 { 25 "name": "Company/Asset Name (e.g., Apple Inc., Bitcoin)", 26 "ticker": "Symbol (e.g., AAPL, BTC-USD, TASE:ELAL.TA)", 27 "current_price": real_current_price_number, 28 "currency": "USD_or_ILS_or_EUR (based on asset)", 29 "asset_type": "stocks_or_crypto_or_etf_or_bonds_or_mutual_funds", 30 "source": "israeli_or_crypto_or_international", 31 "exchange": "Exchange Name (e.g., NASDAQ, TASE, Binance)", 32 "sector": "Sector (e.g., Technology, Financials, Consumer Goods) or empty string" 33 } 34 ] 35 } 36 `,m={type:"object",properties:{results:{type:"array",items:{type:"object",properties:{name:{type:"string"},ticker:{type:"string"},current_price:{type:"number"},currency:{type:"string"},asset_type:{type:"string"},source:{type:"string",enum:["israeli","crypto","international"]},exchange:{type:"string"},sector:{type:"string"}},required:["name","ticker","current_price","currency","asset_type","source"]}}}};try{return{data:{results:((s=(await pe.InvokeLLM({prompt:i,add_context_from_internet:!0,response_json_schema:m})).results)==null?void 0:s.map(p=>{var _,x,v;const y={...p};return(_=y.ticker)!=null&&_.toUpperCase().includes("BTC")||(x=y.name)!=null&&x.toLowerCase().includes("bitcoin")?(y.asset_type="crypto",y.currency="USD",y.source="crypto"):(v=y.ticker)!=null&&v.includes(".TA")&&(y.currency="ILS",y.source="israeli"),(typeof y.current_price!="number"||isNaN(y.current_price)||y.current_price<0)&&(y.current_price=0),y}))||[]}}}catch(a){return console.error("Error invoking LLM for searchAsset:",a),{data:{results:[]}}}};function Nt({isOpen:r,onClose:i,onSave:m,editStock:s=null}
36){const[a,h]=o.useState({asset_type:"stocks",asset_name:"",ticker_symbol:"",quantity:"",purchase_price:"",current_price:"",purchase_date:new Date().toISOString().split("T")[0],currency:"USD",a10f_score:{},sector:""}),[p,y]=o.useState(""),[_,x]=o.useState([]),[v,X]=o.useState(!1),[A,M]=o.useState(null),[u,D]=o.useState(!1),[H,Z]=o.useState(!1),[ee,S]=o.useState(!1),[U,d]=o.useState(null);o.useEffect(()=>{var l,N,P;s?(h({id:s.id,asset_type:s.asset_type||"stocks",asset_name:s.asset_name||"",ticker_symbol:s.ticker_symbol||"",quantity:((l=s.quantity)==null?void 0:l.toString())||"",purchase_price:((N=s.purchase_price)==null?void 0:N.toString())||"",current_price:((P=s.current_price)==null?void 0:P.toString())||"",purchase_date:s.purchase_date||new Date().toISOString().split("T")[0],currency:s.currency||"USD",a10f_score:s.a10f_score||{},sector:s.sector||""}),s.a10f_score&&Object.keys(s.a10f_score).length>0?(d(s.a10f_score),S(!0),D(!1)):(d(null),S(!1),D(!1))):(h({asset_type:"stocks",asset_name:"",ticker_symbol:"",quantity:"",purchase_price:"",current_price:"",purchase_date:new Date().toISOString().split("T")[0],currency:"USD",a10f_score:{},sector:""}),M(null),y(""),x([]),D(!1),Z(!1),S(!1),d(null))},[s,r]);const F=async()=>{if(p.trim()){X(!0),x([]);try{const{data:l}=await vt({query:p.trim()});l&&l.results?x(l.results):x([])}catch(l){console.error("Error searching assets:",l),x([])}finally{X(!1)}}},b=l=>{M(l);let N=l.currency||"USD",P=l.current_price||0,R=l.current_price||0,J=l.asset_type||"stocks";l.source==="israeli"?N="ILS":l.source==="crypto"&&(J="crypto",N="USD"),(typeof P!="number"||isNaN(P)||P<=0)&&(console.warn(`×××ר ×× ×ª×§×× ×¢××ר ${l.name}: ${P}. ××פס ×-0.`),P=0,R=0),h({...a,asset_name:l.name,ticker_symbol:l.ticker,current_price:P,purchase_price:R,asset_type:J,currency:N,sector:l.sector||""}),x([]),y(""),D(!1),Z(!1),S(!1),d(null)},V=(l,N)=>{h({...a,[l]:N})},G=()=>bt({quantity:parseFloat(a.quantity)||0,purchase_price:parseFloat(a.purchase_price)||0,current_price:parseFloat(a.current_price)||0,ticker_symbol:a.ticker_symbol,currency:a.currency}),L=async l=>{if(!l.ticker_symbol||!u)return null;Z(!0),S(!1),d(null);try{const N=` 37 You are an expert equity analyst performing a 10-factor (A10F-Score) analysis for the stock with ticker: ${l.ticker_symbol} (${l.asset_name}). 38 Your task is to provide a detailed, evidence-based assessment. 39 40 Return a single JSON object with the following structure. Do NOT include any text or explanations outside of the JSON object. 41 The analysis date is ${new Date().toISOString().split("T")[0]}. 42 `,P={type:"object",properties:{g5x_growth_potential:{type:"number",minimum:0,maximum:5},brand_clarity:{type:"number",minimum:0,maximum:5},revenue_model_clarity:{type:"number",minimum:0,maximum:5},product_quality:{type:"number",minimum:0,maximum:5},competitive_moat:{type:"number",minimum:0,maximum:5},long_term_thesis:{type:"number",minimum:0,maximum:5},founder_involvement:{type:"number",minimum:0,maximum:5},crisis_resilience:{type:"number",minimum:0,maximum:5},geographic_quality:{type:"number",minimum:0,maximum:5},public_selection:{type:"number",minimum:0,maximum:5},thesis_5y:{type:"string"},key_risks:{type:"array",items:{type:"string"}},evidence_sources:{type:"array",items:{type:"string"}},confidence_level:{type:"string",enum:["low","medium","high"]}},required:["g5x_growth_potential","brand_clarity","revenue_model_clarity","product_quality","competitive_moat","long_term_thesis","founder_involvement","crisis_resilience","geographic_quality","public_selection","thesis_5y","key_risks","evidence_sources","confidence_level"]},R=await pe.InvokeLLM({prompt:N,add_context_from_internet:!0,response_json_schema:P});if(R&&typeof R=="object"){let J=R.thesis_5y;if(R.thesis_5y)try{const k=await pe.InvokeLLM({prompt:`Translate the following investment thesis to Hebrew, keep it concise: "${R.thesis_5y}"`});k&&typeof k=="string"&&(J=k)}catch(k){console.warn("Translation failed, using original thesis:",k)}const Y={g5x_growth_potential:15,brand_clarity:10,revenue_model_clarity:10,product_quality:10,competitive_moat:15,long_term_thesis:15,founder_involvement:5,crisis_resilience:5,geographic_quality:10,public_selection:5};let ge=0,ie=0;
42for(const k in Y)typeof R[k]=="number"&&(ge+=R[k]*Y[k],ie+=5*Y[k]);const E=ie>0?ge/ie*100:0,ue=k=>k>=90?"A+":k>=85?"A":k>=80?"A-":k>=75?"B+":k>=70?"B":k>=65?"B-":k>=60?"C+":k>=55?"C":k>=50?"C-":k>=40?"D":"F",ne={...R,thesis_5y:J,weighted_score:parseFloat(E.toFixed(1)),letter_grade:ue(E),analysis_date:new Date().toISOString().split("T")[0]};return d(ne),S(!0),ne}}catch(N){console.error("AI analysis failed:",N)}finally{Z(!1)}return null},q=async l=>{l.preventDefault();const N=G();let P=a.a10f_score;if(u&&!ee&&!H){const J=await L(a);J&&(P=J)}else U&&(P=U);const R={...a,quantity:parseFloat(a.quantity),purchase_price:N.normalizedPurchasePrice,current_price:N.normalizedCurrentPrice,total_investment:N.totalInvestment,current_value:N.currentValue,return_amount:N.returnAmount,return_percentage:N.returnPercentage,currency:N.currency,sector:a.sector||"",risk_level:(s==null?void 0:s.risk_level)||"medium",a10f_score:P};m(R)},$=G(),z=Se(a.ticker_symbol);return e.jsx(Ye,{open:r,onOpenChange:i,children:e.jsxs(Ke,{className:"sm:max-w-4xl w-full max-h-[90vh] overflow-hidden p-0 rounded-xl z-[1100]",children:[e.jsxs(Qe,{className:"p-6 pb-4",children:[e.jsx(Xe,{className:"text-xl flex items-center gap-2",children:s?"ער××ת ×שקע×":"××ספת ××©×§×¢× ××ש×"}),e.jsx(Ze,{children:s?"×¢××× ×ת פר×× ×× ×ס ×××¢×¨× ×× ×××× ×©××.":"××סף × ×ס ××ש ×××¢×§× ×ת××§ ××שקע×ת ש××."})]}),e.jsxs("form",{onSubmit:q,className:"p-6 pt-0 max-h-[85vh] overflow-y-auto pb-32 space-y-6",children:[!s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{className:"font-medium",children:"×פש ×× ××, ETF ×× ×§×¨×פ××"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{value:p,onChange:l=>y(l.target.value),placeholder:"××§×× ×©× ××ר×, ×× ×× ×× ×§×¨×פ×× (××ש×: Apple, AAPL, Bitcoin)",onKeyPress:l=>l.key==="Enter"&&F(),className:"flex-1"}),e.jsx(T,{type:"button",onClick:F,disabled:v||!p.trim(),className:"bg-blue-600 hover:bg-blue-700",children:v?"××פש...":e.jsx(Gs,{className:"w-4 h-4"})})]}),v?e.jsx("div",{className:"text-center text-gray-500 py-4",children:"××פש × ×ס×× ××× ×ש×××§××..."}):_.length>0&&e.jsxs("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:[e.jsx("h4",{className:"font-medium text-gray-700",children:"ת×צ××ת ××פ×ש:"}),_.map((l,N)=>e.jsx("div",{onClick:()=>b(l),className:"p-3 border rounded-lg cursor-pointer hover:bg-blue-50 transition-colors",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"font-semibold",children:l.name}),e.jsxs("span",{className:"text-gray-600",children:["(",l.ticker,")"]}),l.source==="israeli"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700",children:"ð®ð± ×שר×××"}),l.source==="crypto"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-orange-50 text-orange-700",children:"⿠קר×פ××"}),l.source==="international"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-green-50 text-green-700",children:"ð ××× '×"})]}),e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:[l.exchange," ⢠",l.sector||l.asset_type]})]}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-bold text-lg",children:l.current_price?e.jsxs(e.Fragment,{children:[new Intl.NumberFormat("he-IL",{style:"decimal",minimumFractionDigits:l.source==="israeli"?0:2,maximumFractionDigits:l.source==="crypto"?6:2}).format(l.current_price),e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:l.currency==="ILS"?"âª":l.currency==="USD"?"$":"â¬"})]}):e.jsx("span",{className:"text-gray-400",children:"×× ××××"})}),l.source==="israeli"&&e.jsx("div",{className:"text-xs text-gray-500",children:"××××ר×ת"})]})]})},N))]})]}),z&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(es,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold text-amber-800",children:"×× ×× ×שר×××ת ×××ת×"}),e.jsx("p",{className:"text-amber-700 mt-1",children:"××ער×ת ת××¤× ×××××××ת ×××רת ×××ר×× ××××ר×ת ×שק×××. ××× ×××ר×× ××¤× ×©×× ××פ××¢×× ××תר ××××¨×¡× (××××ר×ת)."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"ס×× × ×ס"}),e.jsxs(Re,{value:a.asset_type,onValueChange:l=>V("asset_type",l),children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"stocks",children:"×× ××ת"}),e.jsx(ae,{value:"etf",children:"×§×¨× ×ת ×¡× (ETF)"}),e.jsx(ae,{value:"bonds",children:"×××ר×ת ×××"}),e.jsx(ae,{value:"mutual_funds",children:"×§×¨× ×ת × ××× ×ת"}),e.jsx(ae,{value:"crypto",children:"קר×פ××"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"××××¢"}),e.jsxs(Re,{value:a.currency,onValueChange:l=>V("currency",l),disabled:z,children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"USD",children:"×××ר ($)"}),e.jsx(ae,{value:"ILS",children:"×©×§× (âª)"}),e.jsx(ae,{value:"EUR",children:"×××¨× (â¬)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"asset_name",children:"×©× ×× ×ס/×× ××"}),e.jsx(B,{id:"asset_name",name:"asset_name",value:a.asset_name,onChange:l=>V("asset_name",l.target.value),placeholder:"×©× ×××ר×/קר×פ××",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"ס×××× (Ticker)"}),e.jsx(B,{value:a.ticker_symbol,onChange:l=>{V("ticker_symbol",l.target.value.toUpperCase()),D(!1),Z(!1),S(!1),d(null)},placeholder:"AAPL, BTC-USD, ELAL.TA"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"סק××ר"}),e.jsx(B,{value:a.sector,onChange:l=>V("sector",l.target.value),placeholder:"××× ××××××, פ×× × ×¡×× ×××'"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"×××ת ×××××ת"}
42),e.jsx(B,{type:"number",step:"any",value:a.quantity,onChange:l=>V("quantity",l.target.value),placeholder:"10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["×××ר ר×××©× ××××××",z&&e.jsx("span",{className:"text-amber-600 font-normal",children:" (××××ר×ת ××× ×××רס×)"})]}),e.jsx(B,{type:"number",step:"any",value:a.purchase_price,onChange:l=>V("purchase_price",l.target.value),placeholder:z?"15000 (××××ר×ת)":"150.00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["×××ר × ×××× ××××××",z&&e.jsx("span",{className:"text-amber-600 font-normal",children:" (××××ר×ת ××× ×××רס×)"})]}),e.jsx(B,{type:"number",step:"any",value:a.current_price,onChange:l=>V("current_price",l.target.value),placeholder:z?"15500 (××××ר×ת)":"155.00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"ת×ר×× ×¨××ש×"}),e.jsx(B,{type:"date",value:a.purchase_date,onChange:l=>V("purchase_date",l.target.value)})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-purple-50 to-indigo-50 p-4 rounded-lg border border-purple-200",children:[e.jsxs("div",{className:"flex items-center space-x-2 rtl:space-x-reverse mb-3",children:[e.jsx(Ls,{id:"performAnalysis",checked:u,onCheckedChange:D,disabled:!a.ticker_symbol||s!=null}),e.jsxs(C,{htmlFor:"performAnalysis",className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(ve,{className:"w-4 h-4 text-purple-600"}),"×צע × ×ת×× A10F-Score ××××××× (××× ××ת ××ש×ת ××××)"]})]}),e.jsx("p",{className:"text-sm text-purple-700",children:"××ער×ת ×ª× ×ª× ×ת ××× ×× ×¢× ×¤× 10 קר××ר××× ×× ×תק×××× ×תספק צ××× ××©×§×¢× ×קצ××¢×. × ×ת×× ×××× ×¨×§ ×¢××ר × ×ס×× ××ש×× ×××¢×× ×¡××××."}),H&&e.jsxs("div",{className:"mt-4 p-3 text-center text-gray-600 flex items-center justify-center gap-2",children:[e.jsx(Oe,{className:"w-5 h-5 animate-spin"}),"××צע × ×ת×× AI..."]}),!H&&ee&&U&&e.jsxs("div",{className:"mt-4 p-3 bg-white rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ss,{className:"w-4 h-4 text-yellow-500"}),e.jsxs("span",{className:"font-semibold",children:["צ××× A10F: ",U.weighted_score]}),e.jsx(Q,{className:`${U.weighted_score>=80?"bg-green-100 text-green-800":U.weighted_score>=60?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:U.letter_grade})]}),U.thesis_5y&&e.jsx("p",{className:"text-sm text-gray-700 line-clamp-2",children:U.thesis_5y}),e.jsx(T,{type:"button",variant:"link",className:"p-0 h-auto text-sm mt-2",onClick:()=>{D(!0),S(!1),d(null)},children:"×צע × ×ת×× ×××ש"})]}),!H&&u&&!ee&&a.ticker_symbol&&e.jsx("div",{className:"mt-4 p-3 text-center text-gray-600",children:'×××¥ "××סף ××שקע×ת" ××× ××צע × ×ת×× A10F-Score.'})]}),a.quantity&&a.purchase_price&&e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[e.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Ts,{className:"w-5 h-5 text-green-600"}),"ס×××× ××שקע×"]}),z&&e.jsx("div",{className:"bg-blue-100 border-r-4 border-blue-500 text-blue-800 p-2 text-xs rounded-md mb-3",children:e.jsx("p",{className:"font-medium",children:"×××ר×× ××צ××× ×שק××× ×××ר ×××¨× ×××××××ת ××××ר×ת"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"×¡× ×שקע×:"}),e.jsx("p",{className:"font-bold",children:Ge($.totalInvestment,"ILS")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"ש××× × ××××:"}),e.jsx("p",{className:"font-bold",children:Ge($.currentValue,"ILS")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"ר×××/×פס×:"}),e.jsxs("p",{className:`font-bold ${$.returnAmount>=0?"text-green-600":"text-red-600"}`,children:[$.returnAmount>=0?"+":"",Ge($.returnAmount,"ILS")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"תש×××:"}),e.jsxs("p",{className:`font-bold ${$.returnPercentage>=0?"text-green-600":"text-red-600"}`,children:[$.returnPercentage>=0?"+":"",$.returnPercentage.toFixed(2),"%"]})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(T,{type:"submit",disabled:!a.asset_name||!a.quantity||!a.purchase_price||H,className:"flex-1 bg-blue-600 hover:bg-blue-700",children:H?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"}),"××צע × ×ת×× ×ש××ר..."]}):s?"×¢××× ×שקע×":"××סף ××שקע×ת"}),e.jsx(T,{type:"button",variant:"outline",onClick:i,className:"flex-1",children:"×××××"})]})]})]})})}function wt({isOpen:r,onClose:i,onSave:m,property:s}
42){const[a,h]=o.useState({property_type:"",size_sqm:"",rooms:"",location:{city:"",neighborhood:"",address:""},financial_details:{purchase_price:"",down_payment:"",loan_amount:"",monthly_rent:"",monthly_expenses:""},purchase_date:"",status:"rented",current_estimated_value:""}),[p,y]=o.useState(!1);o.useEffect(()=>{var A,M,u,D,H,Z,ee,S;h(s?{property_type:s.property_type||"",size_sqm:s.size_sqm||"",rooms:s.rooms||"",location:{city:((A=s.location)==null?void 0:A.city)||"",neighborhood:((M=s.location)==null?void 0:M.neighborhood)||"",address:((u=s.location)==null?void 0:u.address)||""},financial_details:{purchase_price:((D=s.financial_details)==null?void 0:D.purchase_price)||"",down_payment:((H=s.financial_details)==null?void 0:H.down_payment)||"",loan_amount:((Z=s.financial_details)==null?void 0:Z.loan_amount)||"",monthly_rent:((ee=s.financial_details)==null?void 0:ee.monthly_rent)||"",monthly_expenses:((S=s.financial_details)==null?void 0:S.monthly_expenses)||""},purchase_date:s.purchase_date?new Date(s.purchase_date).toISOString().split("T")[0]:"",status:s.status||"rented",current_estimated_value:s.current_estimated_value||""}:{property_type:"",size_sqm:"",rooms:"",location:{city:"",neighborhood:"",address:""},financial_details:{purchase_price:"",down_payment:"",loan_amount:"",monthly_rent:"",monthly_expenses:""},purchase_date:"",status:"rented",current_estimated_value:""})},[s,r]);const _=A=>{const{name:M,value:u}=A.target;h(D=>({...D,[M]:u}))},x=A=>{const{name:M,value:u}=A.target;h(D=>({...D,financial_details:{...D.financial_details,[M]:u}}))},v=A=>{const{name:M,value:u}=A.target;h(D=>({...D,location:{...D.location,[M]:u}}))},X=async()=>{y(!0);try{const{location:A,property_type:M,financial_details:u,purchase_date:D,size_sqm:H,rooms:Z}=a;if(!A.city||!A.neighborhood||!u.purchase_price){alert("×× × ××× ×ת ×× ×¤×¨×× ××××§×× ××××ר ×ר×××©× ××¤× × ×©××ר×."),y(!1);return}const ee=D?new Date(D).getFullYear():"",S=H?`××××: ${H} ×"ר`:"",U=Z?`×ספר ××ר××: ${Z}`:"",d=` 43 ××× ×ער×ת ×ש××× ××¢××× ×ת (ש××× ×©××§) ×××× ×ער×ת ש×ר ××××¨× ×××××©× ×× ×ס ×¢× ×××פ××× ×× ×××××: 44 - ס×× ×× ×ס: '${M}' 45 - ×¢×ר: '${A.city}' 46 - ש××× ×: '${A.neighborhood}' 47 ${S?`- ${S}`:""} 48 ${U?`- ${U}`:""} 49 - × ×¨×ש ××©× ×ª: ${ee} 50 - × ×¨×ש ××××ר: ${u.purchase_price} ש"× 51 52 ×סס ×ת ×ער××ª× ×¢× ××××¨× ×¢×¡×§××ת ×ש××ר×ת ש×××¦×¢× ×××ר×× × ××××ר ×¢××ר × ×ס×× ×××××. 53 ×תש××× ××××ת ××××ת ×פ×ר×× JSON, ××××× ×× ×¨×§ ×ת ×ער××× ××ספר××× ×©× ×ש××× ××©× ×©×ר ××××¨× ×שק××× ××ש××. 54 55 פ×ר×× JSON ××××××: 56 { 57 "current_estimated_value": 3500000, 58 "estimated_monthly_rent": 7500 59 } 60 `,F=await pe.InvokeLLM({prompt:d,add_context_from_internet:!0,response_json_schema:{type:"object",properties:{current_estimated_value:{type:"number"},estimated_monthly_rent:{type:"number"}},required:["current_estimated_value","estimated_monthly_rent"]}}),{current_estimated_value:b,estimated_monthly_rent:V}=F,G={...a,financial_details:{purchase_price:parseFloat(a.financial_details.purchase_price)||0,down_payment:parseFloat(a.financial_details.down_payment)||0,loan_amount:parseFloat(a.financial_details.loan_amount)||0,monthly_rent:V||parseFloat(a.financial_details.monthly_rent)||0,monthly_expenses:parseFloat(a.financial_details.monthly_expenses)||0},current_estimated_value:b||parseFloat(a.financial_details.purchase_price)||0,purchase_date:a.purchase_date};m(G),i()}catch(A){console.error("Error fetching property estimates:",A),alert("ש×××× ××§××ת ×ער×ת ש××× ×××× ×©××ר×ת ×××ער×ת. ×× × ××××§ ×ת ×פר××× ×× ×¡× ×©××.")}finally{y(!1)}};return r?e.jsx(Ye,{open:r,onOpenChange:i,children:e.jsxs(Ke,{className:"max-w-4xl",dir:"rtl",children:[e.jsxs(Qe,{children:[e.jsxs(Xe,{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-6 h-6 text-green-600"}),s?'ער××ת × ×ס × ××"×':'××ספת × ×ס × ××"× ×פ×ר×פ××××']}),e.jsx(Ze,{children:"××× ×ת ×פר××× ××× ×××ס××£ ×ת ×× ×ס ×ת××§ ××שקע×ת ש××."})]}),e.jsxs("div",{className:"grid gap-6 py-4 max-h-[70vh] overflow-y-auto px-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:"פר×× ×× ×ס"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"property_type",children:"ס×× ×× ×ס"}),e.jsxs(Re,{name:"property_type",value:a.property_type,onValueChange:A=>h({...a,property_type:A}),children:[e.jsx(Me,{children:e.jsx($e,{placeholder:"××ר ס×× × ×ס"})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"apartment",children:"××ר×"}),e.jsx(ae,{value:"house",children:"××ת פר××"}),e.jsx(ae,{value:"commercial",children:"×ס×ר×"}),e.jsx(ae,{value:"land",children:"קרקע"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"status",children:"ס×××ס"}),e.jsxs(Re,{name:"status",value:a.status,onValueChange:A=>h({...a,status:A}),children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"rented",children:"××ש×ר"}),e.jsx(ae,{value:"for_sale",children:"××××ר×"}),e.jsx(ae,{value:"personal_use",children:"ש×××ש ××ש×"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"size_sqm",children:'×××× (×"ר)'}),e.jsx(B,{id:"size_sqm",name:"size_sqm",type:"number",placeholder:"××××××: 85",value:a.size_sqm,onChange:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rooms",children:"×ספר ××ר××"}),e.jsx(B,{id:"rooms",name:"rooms",type:"number",placeholder:"××××××: 4",value:a.rooms,onChange:_})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:"×××§××"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"city",children:"×¢×ר"}),e.jsx(B,{id:"city",name:"city",value:a.location.city,onChange:v,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"neighborhood",children:"ש××× ×"}),e.jsx(B,{id:"neighborhood",name:"neighborhood",value:a.location.neighborhood,onChange:v,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"address",children:"×ת××ת"}),e.jsx(B,{id:"address",name:"address",value:a.location.address,onChange:v,required:!0})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:'פר××× ×¤×× × ×¡××× (×ש"×)'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"purchase_price",children:"×××ר ר××ש×"}),e.jsx(B,{id:"purchase_price",name:"purchase_price",type:"number",value:a.financial_details.purchase_price,onChange:x,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"down_payment",children:"××× ×¢×¦××"}),e.jsx(B,{id:"down_payment",name:"down_payment",type:"number",value:a.financial_details.down_payment,onChange:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"loan_amount",children:"ס××× ×ש×× ×ª×"}),e.jsx(B,{id:"loan_amount",name:"loan_amount",type:"number",value:a.financial_details.loan_amount,onChange:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"monthly_expenses",children:"××צ××ת ×××ש××ת (××× ×ש×× ×ª×)"}),e.jsx(B,{id:"monthly_expenses",name:"monthly_expenses",type:"number",value:a.financial_details.monthly_expenses,onChange:x,placeholder:"××¢× ××ת, ××¨× ×× × ×××'"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"purchase_date",children:"ת×ר×× ×¨××ש×"}),e.jsx(B,{id:"purchase_date",name:"purchase_date",type:"date",value:a.purchase_date,onChange:_})]})]}),e.jsx("p",{className:"text-xs text-gray-500 pt-2",children:"ש××× ×× ×ס ×× ×××× ×××× ×ש××ר×ת ××××ש××× ××ער×× ×××××××ת ×¢× ××× ××ער×ת ××¤× × ×ª×× × ×ש××§."})]})]}),e.jsxs(us,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(T,{type:"button",variant:"outline",disabled:p,children:"×××××"})}),e.jsx(T,{type:"button",onClick:X,disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 ml-2 animate-spin"}),"×ער×× ×©××× ×ש××ר..."]}):"ש××ר × ×ס"})]})]})}):null}const St=({active:r,payload:i,label:m})=>
60{if(r&&i&&i.length){const s=i[0].payload,a=new Date(s.date),h=Fe(a,"d MMMM yyyy",{locale:gs});return e.jsxs("div",{className:"p-4 bg-white/80 dark:bg-gray-900/80 backdrop-blur-sm rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 text-right",dir:"rtl",children:[e.jsx("p",{className:"font-bold text-gray-800 dark:text-gray-200",children:h}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["ש××× ×ת××§: ",e.jsx("span",{className:"font-semibold",children:new Intl.NumberFormat("he-IL",{style:"currency",currency:"ILS"}).format(s.totalValue)})]}),s.transaction&&e.jsxs("div",{className:`mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 flex items-center gap-2 ${s.transaction.type==="buy"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[s.transaction.type==="buy"?e.jsx(ft,{className:"w-4 h-4"}):e.jsx(gt,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-semibold",children:[s.transaction.type==="buy"?"×§× ×××":"×××ר×",": ",s.transaction.name]}),e.jsxs("span",{children:["(",new Intl.NumberFormat("he-IL",{style:"currency",currency:"ILS"}).format(s.transaction.amount),")"]})]})]})}return null},kt=r=>{const{cx:i,cy:m,payload:s}=r;return s.transaction?e.jsx(st,{cx:i,cy:m,r:5,fill:s.transaction.type==="buy"?"#16a34a":"#dc2626",stroke:"#fff",strokeWidth:2}):null};function Ct({snapshots:r,transactions:i,isLoading:m}){const s=o.useMemo(()=>{if(!r||!i)return[];const h=r.map(x=>({date:Fe(new Date(x.snapshot_date),"yyyy-MM-dd"),totalValue:Number(x.total_value_ils),transaction:null})),p=i.map(x=>({date:Fe(new Date(x.transaction_date),"yyyy-MM-dd"),totalValue:Number(x.portfolio_value_after),transaction:{type:x.transaction_type,name:x.asset_name,amount:Number(x.transaction_amount)}})),y=[...h,...p].filter(x=>x.date&&typeof x.totalValue=="number"&&!isNaN(x.totalValue)).sort((x,v)=>new Date(x.date).getTime()-new Date(v.date).getTime()),_=new Map;for(const x of y)if(_.has(x.date)){const v=_.get(x.date);x.transaction?_.set(x.date,x):v.transaction||_.set(x.date,x)}else _.set(x.date,x);return Array.from(_.values()).sort((x,v)=>new Date(x.date).getTime()-new Date(v.date).getTime())},[r,i]);if(m)return e.jsx("div",{className:"flex items-center justify-center h-[400px] bg-gray-50 dark:bg-gray-800/20 rounded-xl",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"×××¢× ×ת ××ס××ר××ת ×ת××§..."})]})});if(!s||s.length<2)return e.jsxs(W,{className:"border-0 shadow-lg bg-gray-50 dark:bg-gray-800/20",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800 dark:text-gray-200",children:[e.jsx(Ue,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"}),"××ס××ר××ת ש××× ×ת××§"]})}),e.jsx(K,{className:"h-72 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:"××× ×ספ××§ × ×ª×× ×× ××צ×ת ×רף."}),e.jsx("p",{className:"text-sm",children:"××סף × ×ס×× ×××ס××ר×× ×ª×ª××× ××צ××ר."})]})})]});const a=[Math.min(...s.map(h=>h.totalValue))*.95,Math.max(...s.map(h=>h.totalValue))*1.05];return e.jsxs(W,{className:"border-0 shadow-lg bg-gray-50 dark:bg-gray-800/20",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800 dark:text-gray-200",children:[e.jsx(Ue,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),"××ס××ר××ת ש××× ×ת××§"]})}),e.jsx(K,{className:"h-[400px] p-2",children:e.jsx(hs,{width:"100%",height:"100%",children:e.jsxs(Ks,{data:s,margin:{top:10,right:30,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),e.jsx(Qs,{strokeDasharray:"3 3",stroke:"#e0e0e0",className:"dark:stroke-gray-700"}),e.jsx(Xs,{dataKey:"date",tickFormatter:h=>Fe(new Date(h),"MMM yy",{locale:gs}
60),angle:-45,textAnchor:"end",height:60,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},axisLine:{stroke:"hsl(var(--border))"},tickLine:{stroke:"hsl(var(--border))"}}),e.jsx(Zs,{tickFormatter:h=>new Intl.NumberFormat("he-IL",{notation:"compact",style:"currency",currency:"ILS"}).format(h),domain:a,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},axisLine:{stroke:"hsl(var(--border))"},tickLine:{stroke:"hsl(var(--border))"}}),e.jsx(ps,{content:e.jsx(St,{})}),e.jsx(et,{type:"monotone",dataKey:"totalValue",name:"ש××× ×ת××§",stroke:"hsl(var(--primary))",strokeWidth:2,fillOpacity:1,fill:"url(#colorUv)",dot:e.jsx(kt,{}),activeDot:{r:8,stroke:"hsl(var(--background))",strokeWidth:2,fill:"hsl(var(--primary))"}})]})})})]})}class At{static async getValuation(i,m,s,a=!1){if(!i||!m||!s)return console.error("Missing parameters for valuation"),null;try{const h=await te.PropertyValuation.filter({property_id:i},"-valuation_date",1);if(h.length>0){const y=h[0];if(Js(new Date,new Date(y.valuation_date))<30&&!a)return console.log(`Using recent valuation for property ${i}`),y}console.log(`Fetching new AI valuation for property ${i}`);const p=await this.getAIValuation(s);return p&&p.estimated_value?await te.PropertyValuation.create({property_id:i,user_email:m,valuation_date:new Date().toISOString().split("T")[0],estimated_value:p.estimated_value,valuation_source:"ai_estimate",confidence_score:p.confidence_score,address_details:{city:s.city,neighborhood:s.neighborhood,street:s.address},market_data:{neighborhood_trend:p.trend}}):null}catch(h){return console.error(`Error getting valuation for property ${i}:`,h),null}}static async getAIValuation(i){const m=` 61 Provide an estimated market value for a residential property in: 62 City: ${i.city} 63 Neighborhood: ${i.neighborhood} 64 Address: ${i.address||"N/A"} 65 66 Base your analysis on current market trends, recent sales in the area, and economic indicators. 67 `;try{return await pe.InvokeLLM({prompt:m,add_context_from_internet:!0,response_json_schema:{type:"object",properties:{estimated_value:{type:"number",description:"The estimated market value in ILS."},confidence_score:{type:"number",description:"Confidence score from 0 to 100."},trend:{type:"string",description:"Market trend (e.g., 'rising', 'stable', 'falling')."}},required:["estimated_value","confidence_score","trend"]}})}catch(s){return console.error("Error getting AI valuation:",s),null}}}const It=({score:r,size:i=80,strokeWidth:m=8,label:s})=>{const a=(i-m)/2,h=a*2*Math.PI,p=h-r/100*h,_=(v=>v>=80?"text-green-500":v>=60?"text-yellow-500":v>=40?"text-orange-500":"text-red-500")(r),x=_.replace("text-","stroke-");return e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs(cs.div,{className:"relative flex items-center justify-center",style:{width:i,height:i},initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:260,damping:20},children:[e.jsxs("svg",{className:"absolute top-0 left-0",width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[e.jsx("circle",{className:"stroke-gray-200",strokeWidth:m,fill:"transparent",r:a,cx:i/2,cy:i/2}),e.jsx(cs.circle,{className:x,strokeWidth:m,strokeLinecap:"round",fill:"transparent",r:a,cx:i/2,cy:i/2,style:{transform:"rotate(-90deg)",transformOrigin:"center"},strokeDasharray:h,initial:{strokeDashoffset:h},animate:{strokeDashoffset:p},transition:{duration:1,ease:"circOut"}})]}),e.jsxs("div",{className:`absolute flex items-baseline justify-center ${_}`,children:[e.jsx("span",{className:"text-2xl font-bold",children:Math.round(r)}),e.jsx("span",{className:"text-sm font-medium",children:"/100"})]})]}),s&&e.jsx("p",{className:"text-sm font-medium text-gray-700 text-center",children:s})]})},Dt=({stock:r,onScoreUpdate:i})=>{const[m,s]=o.useState({g5x_growth_potential:0,brand_clarity:0,revenue_model_clarity:0,product_quality:0,competitive_moat:0,long_term_thesis:0,founder_involvement:0,crisis_resilience:0,geographic_quality:0,public_selection:0}),[a,h]=o.useState({thesis_5y:"",key_risks:[],evidence_sources:[],confidence_level:"medium"}
67),[p,y]=o.useState(!1),[_,x]=o.useState(!1),[v,X]=o.useState(""),A={g5x_growth_potential:15,brand_clarity:10,revenue_model_clarity:10,product_quality:10,competitive_moat:15,long_term_thesis:15,founder_involvement:5,crisis_resilience:5,geographic_quality:10,public_selection:5},M=[{key:"g5x_growth_potential",name:"פ××× ×¦××× ×¦×××ת ר××× ×¤× 5",description:"××× ×¨×××× ××××¨× ×××××× ×צ××× ×¤× 5 ×××ש ×©× ××?"},{key:"brand_clarity",name:"×××ר×ת ×××ת×",description:"×¢× ××× ××××ª× ×ר×ר ×צר×× ×ס×פ×?"},{key:"revenue_model_clarity",name:"שק×פ×ת ×××× ××× ×¡×ת",description:"×¢× ××× ×××× ××× ×¡×ת ××××××× ×©×§××£ ×××××?"},{key:"product_quality",name:"××××ת ××צר/ש×ר×ת",description:"ר×ת ×פרפקצ××× ××× ×××צר ×× ×ש×ר×ת"},{key:"competitive_moat",name:"×תר×× ×ª×ר×ת×",description:"×¢× ××× ×§×©× ×××§×ת ×ת ×× ×©××××¨× ×¢×ש×?"},{key:"long_term_thesis",name:"ת×ת ××©×§×¢× ×-5 ×©× ××",description:"××××§ ×ת×× ×××××§× ×ר××ת ××××"},{key:"founder_involvement",name:"××¢×ר××ת ×××ס×",description:"ר×ת ×××¢×ר××ת ××××¢××ת ×©× ××××ס×"},{key:"crisis_resilience",name:"×××¡× ××ש×ר××",description:"××××ת ××¢××× ××ש×ר×× ×× ×× ××¡× ××××ר ××××× ×ת"},{key:"geographic_quality",name:"××××ת ×××××רפ×ת",description:"××××ת ××××× ×ת ××× ××××¨× ×¤××¢×ת"},{key:"public_selection",name:"×××¨× ×¦×××ר×ת × ××רת",description:"× ××××ת, ××××× ×××××ª× ××××©× ×ª×××××"}];o.useEffect(()=>{if(r!=null&&r.a10f_score&&Object.keys(r.a10f_score).length>0){const d={};Object.keys(m).forEach(F=>{d[F]=r.a10f_score[F]||0}),s(d),h({thesis_5y:r.a10f_score.thesis_5y||"",key_risks:r.a10f_score.key_risks||[],evidence_sources:r.a10f_score.evidence_sources||[],confidence_level:r.a10f_score.confidence_level||"medium"}),x(!0)}},[r]);const u=()=>{let d=0;for(const b in m)A[b]&&(d+=m[b]*A[b]);const F=d/5;return Math.round(F*10)/10},D=d=>d>=90?"A+":d>=85?"A":d>=80?"A-":d>=75?"B+":d>=70?"B":d>=65?"B-":d>=60?"C+":d>=55?"C":d>=50?"C-":d>=40?"D":"F",H=(d,F)=>{s(b=>({...b,[d]:Math.min(5,Math.max(0,parseInt(F)||0))})),x(!0)},Z=async()=>{if(!r.ticker_symbol){X("× ×רש ס×××× ×× ×× (ticker) ×××צ××¢ × ×ת×× ×××××××.");return}y(!0),X("");const d=` 68 You are an expert equity analyst performing a 10-factor (A10F-Score) analysis for the stock with ticker: ${r.ticker_symbol} (${r.asset_name}). 69 Your task is to provide a detailed, evidence-based assessment. 70 71 Return a single JSON object with the following structure. Do NOT include any text or explanations outside of the JSON object. 72 The analysis date is ${new Date().toISOString().split("T")[0]}. 73 `,F={type:"object",properties:{g5x_growth_potential:{type:"number",minimum:0,maximum:5},brand_clarity:{type:"number",minimum:0,maximum:5},revenue_model_clarity:{type:"number",minimum:0,maximum:5},product_quality:{type:"number",minimum:0,maximum:5},competitive_moat:{type:"number",minimum:0,maximum:5},long_term_thesis:{type:"number",minimum:0,maximum:5},founder_involvement:{type:"number",minimum:0,maximum:5},crisis_resilience:{type:"number",minimum:0,maximum:5},geographic_quality:{type:"number",minimum:0,maximum:5},public_selection:{type:"number",minimum:0,maximum:5},thesis_5y:{type:"string"},key_risks:{type:"array",items:{type:"string"}},evidence_sources:{type:"array",items:{type:"string"}},confidence_level:{type:"string",enum:["low","medium","high"]}},required:["g5x_growth_potential","brand_clarity","revenue_model_clarity","product_quality","competitive_moat","long_term_thesis","founder_involvement","crisis_resilience","geographic_quality","public_selection","thesis_5y","key_risks","evidence_sources","confidence_level"]};try{const b=await pe.InvokeLLM({prompt:d,add_context_from_internet:!0,response_json_schema:F});if(b&&typeof b=="object"){if(b.thesis_5y){const G=await pe.InvokeLLM({prompt:`Translate the following investment thesis to Hebrew: "${b.thesis_5y}"`});G&&(b.thesis_5y=G)}const V={};for(const G in m)V[G]=Math.min(5,Math.max(0,b[G]||0));s(V),h({thesis_5y:b.thesis_5y||"",key_risks:b.key_risks||[],evidence_sources:b.evidence_sources||[],confidence_level:b.confidence_level||"medium"}),x(!0)}else throw new Error("Invalid AI response format")}catch(b){console.error("AI analysis failed:",b),X("ש×××× ×× ×ת×× ××××××××. ×× × × ×¡× ×©×× ×× ××× ××× ×ת.")}finally{y(!1)}},ee=()=>{const d=u(),F=D(d),b={...m,...a,weighted_score:d,letter_grade:F,analysis_date:new Date().toISOString().split("T")[0]};i(b)},S=u(),U=D(S);return e.jsx("div",{className:"flex flex-col h-full",dir:"rtl",children:e.jsxs("div",{className:"flex-grow overflow-y-auto space-y-6 pr-3 -mr-3",children:[e.jsxs(W,{children:[e.jsxs(K,{className:"p-4 flex flex-col md:flex-row gap-4",children:[" ",e.jsx(T,{onClick:Z,disabled:p,className:"w-full md:flex-1 bg-gradient-to-r from-purple-500 to-indigo-600 hover:from-purple-600 hover:to-indigo-700 text-white",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"})," ××צע × ×ת×× AI..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4 ml-2"})," ×צע × ×ת×× A10F ×××××××"]})}),e.jsxs(T,{onClick:ee,disabled:!_,className:"w-full md:flex-1 bg-green-600 hover:bg-green-700 text-white",children:[e.jsx(ct,{className:"w-5 h-5 ml-2"}),"ש××ר × ×ת×× A10F"]})]}),v&&e.jsx("p",{className:"text-red-500 text-sm px-4 pb-2 text-center",children:v})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800",children:[e.jsx(ss,{className:"w-5 h-5 text-yellow-500"}),"צ××× A10F ס×פ×"]})}),e.jsxs(K,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"text-3xl font-bold text-blue-600",children:S.toFixed(1)}),e.jsx(Q,{className:`text-lg px-3 py-1 ${U.startsWith("A")?"bg-green-100 text-green-800":U.startsWith("B")?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:U})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-3",children:e.jsx("div",{className:"bg-gradient-to-r from-red-500 via-yellow-500 to-green-500 h-3 rounded-full transition-all duration-300",style:{width:`${Math.min(100,S)}%`}})})]})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsx(xe,{children:"קר××ר××× ×× ×× ××§××"})}),e.jsx(K,{className:"space-y-4",children:M.map(d=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(C,{className:"font-medium",children:d.name}),e.jsxs(Q,{variant:"outline",className:"text-xs",children:["×שק×: ",A[d.key],"%"]})]}),e.jsx("p",{className:"text-sm text-gray-600",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"0"}),e.jsx("input",{type:"range",min:"0",max:"5",value:m[d.key],onChange:F=>H(d.key,F.target.value),className:"flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer"}),e.jsx("span",{className:"text-sm font-bold text-blue-600 w-6 text-center",children:m[d.key]})]})]},d.key))})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsx(xe,{children:"× ×ת×× × ×סף"})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(C,{children:"ת×ת ××©×§×¢× ×-5 ×©× ××"}),e.jsx(We,{value:a.thesis_5y,onChange:d=>{h(F=>({...F,thesis_5y:d.target.value})),x(!0)},placeholder:"ת×ר ×ת ×ת×× ××××× ××ר××...",className:"mt-1",rows:3})]}),e.jsxs("div",{children:[e.jsx(C,{children:"ס×××× ×× ×¢×קר×××"}),e.jsx(We,{value:Array.isArray(a.key_risks)?a.key_risks.join(`
74`):"",onChange:d=>{h(F=>({...F,key_risks:d.target.value.split(` 75`).filter(Boolean)})),x(!0)},placeholder:"רש×× ×¡×××× ××× ××× ×©×ר×...",className:"mt-1",rows:3})]}),e.jsxs("div",{children:[e.jsx(C,{children:"××§×ר×ת ××××¢"}),e.jsx(We,{value:Array.isArray(a.evidence_sources)?a.evidence_sources.join(` 76`):"",onChange:d=>{h(F=>({...F,evidence_sources:d.target.value.split(` 77`).filter(Boolean)})),x(!0)},placeholder:"רש×× ××§×ר ××× ××× ×©×ר×...",className:"mt-1",rows:2})]})]})]})]})})},Te=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6"],se=r=>{const i=Number(r);return isNaN(i)||!isFinite(i)?0:i},Lt=(r,i,m)=>{if(r<=0||m<=0)return 0;const s=i/100/12,a=m*12;return r*s*Math.pow(1+s,a)/(Math.pow(1+s,a)-1)},Tt=5,Ft=30;function be({icon:r,label:i,value:m,sub:s,color:a="text-gray-800",warning:h}){return e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600",children:i})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[h&&e.jsxs(Q,{variant:"outline",className:"text-xs bg-orange-50 text-orange-700 border-orange-200",children:[e.jsx(es,{className:"w-3 h-3 ml-1"}),h]}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${a}`,children:m}),s&&e.jsx("p",{className:"text-xs text-gray-400",children:s})]})]})]})}function Pt({result:r}){if(!r)return null;const{summary:i,strengths:m=[],risks:s=[],actions:a=[]}=r,h={high:"bg-red-100 text-red-700 border-red-200",medium:"bg-orange-100 text-orange-700 border-orange-200",low:"bg-green-100 text-green-700 border-green-200"},p={high:"×××××",medium:"××× ×× ×ת",low:"× ××××"};return e.jsxs("div",{className:"mt-4 space-y-4 p-4 rounded-xl bg-gradient-to-br from-purple-50 to-indigo-50 border border-purple-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4 text-purple-600"}),e.jsx("h4",{className:"font-bold text-purple-800 text-sm",children:"ת××× ×ת AI ×ת××§"})]}),i&&e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed",children:i}),m.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-green-700 mb-1",children:"××××§×ת"}),e.jsx("ul",{className:"space-y-1",children:m.map((y,_)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-xs text-gray-700",children:[e.jsx(mt,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:y})]},_))})]}),s.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-orange-700 mb-1",children:"ס×××× ×× / × ×§×××ת ×ש×פ×ר"}),e.jsx("ul",{className:"space-y-1",children:s.map((y,_)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-xs text-gray-700",children:[e.jsx(es,{className:"w-3.5 h-3.5 text-orange-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:y})]},_))})]}),a.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-indigo-700 mb-1.5",children:"פע×××ת ××××צ×ת"}),e.jsx("div",{className:"space-y-2",children:a.map((y,_)=>e.jsxs("div",{className:"p-2.5 rounded-lg bg-white/70 border border-purple-100",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:y.title}),e.jsx(Q,{variant:"outline",className:`text-xs ${h[y.priority]||h.medium}`,children:p[y.priority]||"××× ×× ×ת"})]}),y.detail&&e.jsx("p",{className:"text-xs text-gray-600",children:y.detail})]},_))})]}),e.jsx("p",{className:"text-xs text-gray-400 italic",children:"* ×××××¢ ××××¦× ××× × ××××× ×××¢××¥ ×שקע×ת."})]})}function Et(){return e.jsxs("div",{className:"mt-4 space-y-3 p-4 rounded-xl bg-purple-50 border border-purple-200 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-purple-200 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-purple-100 rounded w-full"}),e.jsx("div",{className:"h-3 bg-purple-100 rounded w-5/6"}),e.jsx("div",{className:"h-20 bg-purple-100 rounded"}),e.jsx("div",{className:"h-20 bg-purple-100 rounded"})]})}function Rt({realEstateAssets:r=[],stockAssets:i=[],cashAccounts:m=[],convertCurrency:s,formatCurrency:a,displayCurrency:h="ILS",user:p,rates:y}){var V,G;
77const[_,x]=o.useState(null),[v,X]=o.useState(!1),[A,M]=o.useState(null),u=o.useMemo(()=>{const L=Array.isArray(r)?r:[],q=Array.isArray(i)?i:[],$=Array.isArray(m)?m:[],z=L.map(g=>{var j;return se(g.current_estimated_value)||se((j=g.financial_details)==null?void 0:j.purchase_price)}),l=q.map(g=>{const j=se(g.current_value)||se(g.total_investment);return s?s(j,g.currency||"ILS","ILS"):j}),N=$.map(g=>{const j=se(g.current_balance);return s?s(j,g.currency||"ILS","ILS"):j}),P=z.reduce((g,j)=>g+j,0),R=l.reduce((g,j)=>g+j,0),J=N.reduce((g,j)=>g+j,0),Y=P+R+J;if(Y===0&&L.length===0&&q.length===0&&$.length===0)return{empty:!0};const ge=Y>0?[{name:'× ××"×',value:P,pct:P/Y*100},{name:"×× ××ת",value:R,pct:R/Y*100},{name:"×××××",value:J,pct:J/Y*100}].filter(g=>g.value>0):[],ie={};L.forEach((g,j)=>{var re;const O=((re=g.location)==null?void 0:re.city)||"×× ××××¢";ie[O]=(ie[O]||0)+z[j]});const E=Object.entries(ie).map(([g,j])=>({city:g,value:j,pct:P>0?j/P*100:0})).sort((g,j)=>j.value-g.value),ue=P>0?E.reduce((g,j)=>g+Math.pow(j.pct,2),0):0,ne=E[0]||null;let k=0;Y>0&&(L.forEach((g,j)=>{k+=se(g.calculated_roi)*z[j]}),q.forEach((g,j)=>{k+=se(g.return_percentage)*l[j]}),k=k/Y);const ts=L.reduce((g,j)=>{var O;return g+se((O=j.financial_details)==null?void 0:O.loan_amount)},0),ke=P>0?ts/P*100:0,de={ILS:0,USD:0,EUR:0};q.forEach((g,j)=>{const O=(g.currency||"ILS").toUpperCase();de[O]||(de[O]=0),de[O]+=l[j]});const Ce=R>0?Object.entries(de).map(([g,j])=>({currency:g,pct:j/R*100})).filter(g=>g.pct>0):[],Ae=Y>0?J/Y*100:0;let ye=0,fe=!1;return L.forEach(g=>{const j=g.financial_details||{},O=se(j.monthly_rent),re=se(j.monthly_expenses),Ne=se(j.loan_amount);let oe=se(j.monthly_mortgage_payment);Ne>0&&oe<=0&&(oe=Lt(Ne,Tt,Ft),fe=!0),ye+=O-re-oe}),q.forEach(g=>{const j=se(g.annual_dividend);if(j>0)ye+=j/12;else{const O=se(g.dividend_yield),re=se(g.current_value)||se(g.total_investment);O>0&&re>0&&(ye+=re*O/100/12)}}),{empty:!1,totalNetWorth:Y,totalRE:P,totalStocks:R,totalCash:J,allocation:ge,cityBreakdown:E,hhi:ue,topCity:ne,weightedReturn:k,ltv:ke,currencyExposure:Ce,liquidityRatio:Ae,monthlyCashFlow:ye,mortgageEstimated:fe,counts:{re:L.length,stocks:q.length,cash:$.length}}},[r,i,m,s]),D=u.empty?"text-gray-800":u.weightedReturn>=5?"text-green-600":u.weightedReturn>=0?"text-orange-600":"text-red-600",H=u.empty?"text-gray-800":u.ltv<=50?"text-green-600":u.ltv<=70?"text-orange-600":"text-red-600",Z=!u.empty&&u.ltv>70?"××× ××£ ××××":null,ee=!u.empty&&u.topCity&&u.topCity.pct>50?"ר××××××ת":null,S=!u.empty&&u.liquidityRatio<5&&u.totalNetWorth>0?"× ×××":null,U=async()=>{var L,q;X(!0),M(null);try{const $=await Pe.optimizePortfolio({}),z=$.data||$;z.error?M(z.error):z.ok?(x(z.ai_recommendations),z.metrics):M("ש×××× ×× ×ת×× ×ת××§")}catch($){const z=((q=(L=$==null?void 0:$.response)==null?void 0:L.data)==null?void 0:q.error)||($==null?void 0:$.message)||"ש×××× ×× ×ת×× ×ת××§";M(z)}finally{X(!1)}};p&&p.role!=="admin"&&(!p.subscription||((V=p.subscription)==null||V.status));const d=(G=p==null?void 0:p.subscription)==null?void 0:G.plan,F=(p==null?void 0:p.role)==="admin"||["premium","business"].includes(d);if(u.empty)return e.jsxs(W,{className:"border-0 shadow-lg",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-lg",children:[e.jsx(os,{className:"w-5 h-5 text-blue-600"}),"×ר×××ת ×ת××§"]})}),e.jsx(K,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ds,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"×ת××§ ש×× ×¨××§ ×ר××¢. ××ס××¤× × ×ס×× ××× ×ר××ת × ×ת×× ×ר×××ת."})]})})]});const b=L=>a?a(L,h):Math.round(L).toLocaleString();return e.jsxs(W,{className:"border-0 shadow-lg",children:[e.jsx(me,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2 text-lg",children:[e.jsx(os,{className:"w-5 h-5 text-blue-600"}),"×ר×××ת ×ת××§"]}),e.jsxs(Q,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[u.counts.re+u.counts.stocks+u.counts.cash," × ×ס××"]})]})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[u.allocation.length>0&&e.jsx("div",{className:"w-32 h-32 flex-shrink-0",children:e.jsx(hs,{width:"100%",height:"100%",children:e.jsxs(tt,{children:[e.jsx(at,{data:u.allocation,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:32,outerRadius:56,paddingAngle:2,children:u.allocation.map((L,q)=>e.jsx(rt,{fill:Te[q%Te.length]},q))}),e.jsx(ps,{formatter:L=>b(L),contentStyle:{direction:"rtl",textAlign:"right",borderRadius:"8px",fontSize:"12px"}})]})})}),e.jsxs("div",{className:"flex-1 w-full space-y-1",children:[u.allocation.map((L,q)=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Te[q%Te.length]}}),e.jsx("span",{className:"text-gray-600",children:L.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-semibold text-gray-800",children:[L.pct.toFixed(1),"%"]}),e.jsx("span",{className:"text-xs text-gray-400",children:b(L.value)})]})]},L.name)),u.allocation.length===0&&e.jsx("p",{className:"text-sm text-gray-400 text-center py-4",children:"××× × ×ª×× × ×©×××"})]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx(be,{icon:Ue,label:"תש××× ×ש××§××ת",value:`${u.weightedReturn.toFixed(2)}%`,color:D}),e.jsx(be,{icon:ot,label:"××× ××£ ×××× (LTV)",value:`${u.ltv.toFixed(1)}%`,color:H,warning:Z}),u.topCity&&e.jsx(be,{icon:dt,label:"×¢×ר ××××××",value:u.topCity.city,sub:`${u.topCity.pct.toFixed(1)}% ×× ××"×`,warning:ee}),u.currencyExposure.length>0&&e.jsx(be,{icon:Ee,label:"×ש××¤× ××××¢×ת",value:u.currencyExposure.map(L=>`${L.currency} ${L.pct.toFixed(0)}%`).join(" / ")}),e.jsx(be,{icon:ds,label:"××ס × ××××ת",value:`${u.liquidityR
77atio.toFixed(1)}%`,color:u.liquidityRatio<5?"text-orange-600":"text-green-600",warning:S}),e.jsx(be,{icon:Ps,label:"ת×ר×× ××××©× × ××",value:b(u.monthlyCashFlow),sub:u.mortgageEstimated?"×ש×× ×ª× ×ש×ערת":void 0,color:u.monthlyCashFlow>=0?"text-green-600":"text-red-600"})]}),e.jsx("div",{className:"pt-2 border-t border-gray-100",children:F?e.jsxs(e.Fragment,{children:[e.jsx(T,{onClick:U,disabled:v,className:"w-full bg-gradient-to-r from-purple-500 to-indigo-600 hover:from-purple-600 hover:to-indigo-700 text-white",children:v?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"}),"×× ×ª× ×ת ×ת××§..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 ml-2"}),"× ×ת×× AI ×©× ×ת××§"]})}),v&&e.jsx(Et,{}),A&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-red-50 border border-red-200",children:e.jsx("p",{className:"text-sm text-red-700",children:A})}),_&&e.jsx(Pt,{result:_})]}):e.jsxs("div",{className:"p-3 rounded-lg bg-gray-50 border border-gray-200 text-center",children:[e.jsx(Es,{className:"w-5 h-5 text-gray-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 mb-1",children:"× ×ת×× AI ×©× ×ת××§"}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"×××× ××× ××× Premium ×××¢××. ש×ר×× ××× ××§×× ×ª××× ×ת ××ת×××ת ××ש×ת."}),e.jsx(T,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"/Pricing",children:"ש×ר×× ×¢×ש××"})})]})})]})]})}function na(){var ls;const[r,i]=o.useState(null),[m,s]=o.useState([]),[a,h]=o.useState([]),[p,y]=o.useState([]),[_,x]=o.useState([]),[v,X]=o.useState([]),[A,M]=o.useState([]),[u,D]=o.useState(0),[H,Z]=o.useState(null),[ee,S]=o.useState("initializing"),[U,d]=o.use
77State(0),[F,b]=o.useState("××ת×× ×ת ××ער×ת..."),[V,G]=o.useState(!1),[L,q]=o.useState(""),[$,z]=o.useState(!1),[l,N]=o.useState(!1),[P,R]=o.useState(!1),[J,Y]=o.useState(null),[ge,ie]=o.useState(!1),[E,ue]=o.useState("ILS"),[ne,k]=o.useState({USD_to_ILS:3.75,EUR_to_ILS:4.05}),[ts,ke]=o.useState({}),[de,Ce]=o.useState(!1),[Ae,ye]=o.useState(null),[fe,g]=o.useState(null),{toast:j}=Rs(),[O,re]=o.useState({isOpen:!1,stockToDelete:null,isDeleting:!1}),[Ne,oe]=o.useState(null),he=o.useCallback(async t=>{var f,c;G(!1),q("");try{S("initializing"),d(10),b("××ת×× ×ת ××ער×ת..."),await new Promise(n=>setTimeout(n,500)),S("rates"),d(20),b("×××¢× ×©×¢×¨× ×××פ××..."),await fs(),await new Promise(n=>setTimeout(n,300)),S("stocks"),d(35),b("×××¢× ×שקע×ת ×ש××§ ××××...");try{const n=await te.InvestmentPortfolio.filter({created_by:t.email});s(n||[])}catch(n){console.warn("Failed to load stocks:",n),s([])}await new Promise(n=>setTimeout(n,400)),S("realestate"),d(50),b('×××¢× × ××¡× × ××"×...');try{const n=await te.PortfolioProperty.filter({created_by:t.email});y(n||[])}catch(n){console.warn("Failed to load real estate:",n),y([])}await new Promise(n=>setTimeout(n,400)),S("savings"),d(65),b("×××¢× ××ר×ת ×ס×××...");try{const n=await te.SavingsGoal.filter({created_by:t.email});h(n||[])}catch(n){console.warn("Failed to load savings goals:",n),h([])}await new Promise(n=>setTimeout(n,400)),S("cash"),d(80),b("×××¢× ×ש××× ×ת ××××× ××...");try{const n=await te.CashAccount.filter({created_by:t.email});x(n||[])}catch(n){console.warn("Failed to load cash accounts:",n),x([])}await new Promise(n=>setTimeout(n,400)),S("history"),d(90),b("×××¢× ××ס××ר××ת ת××§...");try{const n=await te.PortfolioSnapshot.filter({user_email:t.email});X(n||[]);const I=await te.PortfolioTransaction.filter({user_email:t.email});M(I||[])}catch(n){console.warn("Failed to load portfolio history:",n),X([]),M([])}d(100),b("ס××£ ××¢×× ×..."),await new Promise(n=>setTimeout(n,300)),S("complete")}catch(n){console.error("Portfolio loading failed:",n),G(!0),(f=n.message)!=null&&f.includes("429")||(c=n.message)!=null&&c.includes("Rate limit")?q("×שרת ×¢××ס ×ר××¢. ×× × ×¨×¢× × ×ת ×××£ ××¢×× ×ספר ××§×ת."):q("×××¨×¢× ×©×××× ×××¢×× ×ª × ×ª×× × ×ת××§. ×× × × ×¡× ×©××."),S("error")}},[]),fs=o.useCallback(async()=>{const t="exchangeRatesCache";try{const n=localStorage.getItem(t);if(n){const{rates:I,timestamp:w}=JSON.parse(n);if(Date.now()-w<36e5)return k(I),I}}catch(n){console.error("Could not read from localStorage cache",n)}const c={USD_to_ILS:3.75,EUR_to_ILS:4.05};try{const n=await te.ExchangeRate.list();if(n&&n.length>0){const I={};if(n.forEach(w=>{w.currency_pair&&typeof w.rate=="number"&&(I[w.currency_pair]=w.rate)}),I.USD_to_ILS||I.EUR_to_ILS){const w={...c,...I};k(w);try{localStorage.setItem(t,JSON.stringify({rates:w,timestamp:Date.now()}))}catch{}return w}}}catch(n){console.warn("Could not fetch ExchangeRate entity, using fallback",n)}return k(c),c},[]),Ve=o.useCallback(async()=>{var t,f;try{const c=await te.User.me();i(c),await he(c)}catch(c){console.error("Initialization failed:",c),G(!0),(t=c.message)!=null&&t.includes("401")||(f=c.message)!=null&&f.includes("Unauthorized")?q("×ש ××ת××ר ××× ×צפ×ת ×ת××§ ××שקע×ת."):q("×××¨×¢× ×©×××× ×××¢×× ×ª ×××£. ×× × × ×¡× ×©××."),S("error")}},[he]);o.useEffect(()=>{Ve()},[Ve]);const as=o.useCallback(()=>!r||Ms(r)||(r==null?void 0:r.role)==="admin"?!1:p.length+m.length>=2,[r,p,m]),ze=()=>{if(as()){oe("properties");return}R(!0)},js=()=>{if(as()){oe("properties");return}N(!0),g(null)},_s=o.useCallback(async()=>{if(r){Ce(!0);try{const t=m.filter(c=>c.ticker_symbol);if(t.length>0){const{data:c}=await Pe.refreshAssetPrices({assetIds:t.map(n=>n.id)});if(c!=null&&c.success){const n=c.refreshed_at?new Date(c.refreshed_at):new Date;ye(n);const I=n.toLocaleTimeString("he-IL",{hour:"2-digit",minute:"2-digit"});try{const w=await te.InvestmentPortfolio.filter({created_by:r.email},"-updated_date");s(w)}catch(w){console.warn("Failed to reload stock assets after price refresh:",w)}j({title:"××××ר×× ×¢×××× ×",description:`${c.updated||0} × ×ס×× ×¢×××× × ××צ××× â¢ ×©×¢×ª ×¢××××: ${I}${c.skipped?` ⢠${c.skipped} ××××× (××××× ×¢××× ×)`:""}${c.failed?` ⢠${c.failed} × ×ש××`:""}`})}else throw new Error((c==null?void 0:c.error)||"ש×××× ×× ×¦×¤×××")}const f=await Promise.all(p.map(async c=>{ke(n=>({...n,[c.id]:!0}));try{const n=await At.getValuation(c.id,r.email,c.location,!0);if(n&&n.estimated_value){const I={...c,current_estimated_value:n.estimated_value,last_value_update:new Date().toISOString()};return await te.PortfolioProperty.update(c.id,{current_estimated_value:n.estimated_value,last_value_update:new Date().toISOString()}),I}}catch(n){console.error(`Failed to update valuation for ${c.location.city}`,n)}finally{ke(n=>({...n,[c.id]:!1}))}return c}));y(f)}catch(t){console.error("Error refreshing asset values:",t),j({title:"ש×××× ××¨×¢× ×× ×©××× ×× ×ס××",description:t.message||"× ×¡× ×©× ×ת ××××ר ××תר",variant:"destructive"})}Ce(!1)}},[r,m,p]),le=o.useCallback((t,f,c)=>{if(!ne||f===c||t===void 0||t===null)return t;const n={USD:ne.USD_to_ILS,EUR:ne.EUR_to_ILS,ILS:1},I=n[f],w=n[c];return I===void 0||w===void 0?t:t*I/w},[ne]),rs=o.useMemo(()=>
77{if(!ne)return 0;const t=m.reduce((I,w)=>I+le(w.current_value||w.total_investment||0,w.currency||"ILS",E),0),f=p.reduce((I,w)=>{var je;return I+le(w.current_estimated_value||((je=w.financial_details)==null?void 0:je.purchase_price)||0,"ILS",E)},0),c=a.reduce((I,w)=>I+le(w.current_amount||0,"ILS",E),0),n=_.reduce((I,w)=>I+le(w.current_balance||0,w.currency||"ILS",E),0);return t+f+c+n},[m,a,p,_,E,ne,le]);o.useEffect(()=>{D(rs)},[rs]);const ce=(t,f="ILS")=>{const c={style:"currency",currency:f,maximumFractionDigits:2,minimumFractionDigits:2};try{new Intl.NumberFormat("he-IL",c).format(0)}catch{c.currency="ILS"}return new Intl.NumberFormat("he-IL",c).format(t||0)},bs=({stock:t,setIsAddStockModalOpen:f,setEditingAsset:c,loadPortfolioData:n,user:I,formatCurrency:w,setDeleteConfirmDialog:je})=>{const[Ns,Ie]=o.useState(!1),ws=(t.return_percentage||0)>=0,Be=t.a10f_score&&(t.a10f_score.weighted_score>0||t.a10f_score.analysis_date),Ss=()=>{c(t),f(!0)},ks=()=>{je({isOpen:!0,stockToDelete:t,isDeleting:!1})},Cs=async is=>{try{await te.InvestmentPortfolio.update(t.id,{a10f_score:is}),Ie(!1),await n(I)}catch(Is){console.error("Error updating A10F score:",Is)}},As=async is=>{Ie(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(W,{className:"border-0 shadow-lg hover:shadow-xl transition-shadow duration-300",children:[e.jsx(me,{className:"flex flex-col space-y-0 p-5 pb-0",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center relative",children:[e.jsx(Ee,{className:"w-6 h-6 text-blue-600"}),Be&&e.jsx("div",{className:"absolute -top-1 -right-1 w-4 h-4 bg-gradient-to-r from-purple-500 to-indigo-600 rounded-full flex items-center justify-center",children:e.jsx(ve,{className:"w-2.5 h-2.5 text-white"})})]}),e.jsxs("div",{className:"text-right flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(xe,{className:"text-lg",children:t.asset_name}),t.ticker_symbol&&e.jsx(Q,{variant:"outline",children:t.ticker_symbol}),Be&&e.jsxs(Q,{className:"bg-gradient-to-r from-purple-500 to-indigo-600 text-white text-xs",children:[e.jsx(ve,{className:"w-3 h-3 mr-1"}),"× ×ת×× AI"]})]}),t.a10f_score&&t.a10f_score.weighted_score!==void 0&&e.jsx("div",{className:"mb-3",children:e.jsx(It,{score:t.a10f_score.weighted_score,total:100,grade:t.a10f_score.letter_grade})}),e.jsxs("div",{className:"flex flex-row gap-2 items-center justify-start mt-2",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:Ss,className:"text-gray-500 hover:text-blue-600 flex-shrink-0 h-8 px-2",children:e.jsx(ht,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>As(),className:"text-purple-500 hover:text-purple-700 flex-shrink-0 h-8 px-2",title:"× ×ת×× AI ×××××××",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>Ie(!0),className:"text-blue-500 hover:text-blue-700 flex-shrink-0 h-8 px-2",title:"× ×ת×× A10F-Score",children:e.jsx(ss,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:ks,className:"text-red-500 hover:text-red-700 flex-shrink-0 h-8 px-2",title:"×××§ ×× ××",children:e.jsx(Bs,{className:"w-4 h-4"})})]})]})]})}),e.jsxs(K,{className:"p-5 pt-0",children:[Be&&t.a10f_score.thesis_5y&&e.jsxs("div",{className:"mb-4 p-3 bg-gradient-to-r from-purple-50 to-indigo-50 rounded-lg border border-purple-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ve,{className:"w-4 h-4 text-purple-600"}),e.jsx("span",{className:"text-sm font-semibold text-purple-800",children:"ת×ת ××©×§×¢× AI"})]}),e.jsx("p",{className:"text-sm text-purple-700 line-clamp-2",children:t.a10f_score.thesis_5y})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-x-4 gap-y-2 pt-4 border-t border-gray-100",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"ש××× × ××××"}),e.jsx("p",{className:"font-bold text-base text-gray-800",children:w(t.current_value||t.total_investment,t.currency||"ILS")})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"תש×××"}),e.jsx("p",{className:`font-bold text-base ${ws?"text-green-600":"text-red-600"}`,children:t.return_percentage?`${t.return_percentage.toFixed(2)}%`:"-"})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"×××ת"}),e.jsxs("p",{className:"font-semibold text-base text-gray-700",children:[t.quantity," ××׳"]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"×××ר ×××׳"}),e.jsx("p",{className:"text-base text-gray-700",children:w(t.current_price||t.purchase_price,t.currency||"ILS")})]})]})]})]}),Ns&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:e.jsx("div",{className:"bg-white rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h2",{className:"text-xl font-bold",children:["× ×ת×× A10F-Score - ",t.asset_name]}),e.jsx(T,{variant:"ghost",onClick:()=>Ie(!1),children:"Ã"})]}),e.jsx(Dt,{stock:t,onScoreUpdate:Cs})]})})})]})},vs=async()=>
77{if(O.stockToDelete){re(t=>({...t,isDeleting:!0}));try{await te.InvestmentPortfolio.delete(O.stockToDelete.id),await he(r),re({isOpen:!1,stockToDelete:null,isDeleting:!1})}catch(t){console.error("Error deleting stock:",t),alert("ש×××× ××××קת ××× ××. ×× × × ×¡× ×©××."),re(f=>({...f,isDeleting:!1}))}}},ns=()=>{re({isOpen:!1,stockToDelete:null,isDeleting:!1})};return ee!=="complete"&&!V?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-4 md:p-8 flex items-center justify-center",children:e.jsx("div",{className:"max-w-md w-full",children:e.jsx(W,{className:"border-0 shadow-2xl bg-white/90 backdrop-blur-sm",children:e.jsxs(K,{className:"p-8 text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center shadow-xl",children:e.jsx(Ue,{className:"w-10 h-10 text-white animate-pulse"})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-800 mb-2",children:"×××¢× ×ת ×ת××§ ש××"}),e.jsx("p",{className:"text-gray-600 mb-6 text-sm",children:F}),e.jsx("div",{className:"w-full mb-4",children:e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-purple-600 rounded-full transition-all duration-500 ease-out",style:{width:`${U}%`}})})}),e.jsxs("p",{className:"text-blue-600 font-medium text-sm",children:[U,"% ××ש××"]}),e.jsx("div",{className:"mt-6 flex justify-center space-x-2 rtl:space-x-reverse",children:["stocks","realestate","savings","cash","history"].map((t,f)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors duration-300 ${ee===t?"bg-blue-500 animate-pulse":["stocks","realestate","savings","cash","history"].indexOf(ee)>f?"bg-green-500":"bg-gray-300"}`},t))})]})})})}):V?e.jsx("div",{className:"min-h-screen bg-gray-50 p-4 md:p-8 flex items-center justify-center",children:e.jsx(nt,{variant:"destructive",className:"max-w-lg text-right bg-red-50 border-red-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xt,{className:"h-5 w-5 mt-1 text-red-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(lt,{className:"font-bold text-red-800",children:"ש×××ת תקש×רת"}),e.jsxs(it,{className:"text-red-700",children:[L,e.jsx(T,{onClick:Ve,variant:"link",className:"p-0 h-auto text-red-700 font-bold ml-2",children:"× ×¡× ×©××"})]})]})]})})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-4 md:p-8 pb-32",dir:"rtl",children:[e.jsx(Nt,{isOpen:l,onClose:()=>{N(!1),g(null)},onSave:async t=>{var f,c;try{if(fe)await te.InvestmentPortfolio.update(fe.id,t);else if(!((f=(await Pe.addPortfolioAsset({asset_type:"stock",data:t})).data)!=null&&f.success))throw new Error("Failed to add asset");await he(r),N(!1),g(null)}catch(n){((c=n.response)==null?void 0:c.status)===403?(oe("properties"),N(!1),g(null)):console.error("Error saving stock:",n)}},editingStock:fe}),e.jsx(wt,{isOpen:P,onClose:()=>R(!1),onSave:async t=>{var f,c;try{(f=(await Pe.addPortfolioAsset({asset_type:"real_estate",data:t})).data)!=null&&f.success&&(await he(r),R(!1))}catch(n){((c=n.response)==null?void 0:c.status)===403?oe("properties"):console.error("Error saving real estate property:",n)}}}),J&&e.jsx(Ys,{property:J,isOpen:ge,onClose:()=>{ie(!1),Y(null)},onSuccess:async t=>{await he(r),ie(!1),Y(null),alert(t)}}),e.jsx(Ye,{open:O.isOpen,onOpenChange:t=>!t&&ns(),children:e.jsxs(Ke,{className:"sm:max-w-md",dir:"rtl",children:[e.jsxs(Qe,{children:[e.jsx(Xe,{className:"text-right",children:"×××קת ×× ××"}),e.jsxs(Ze,{className:"text-right",children:["××× ××ª× ×××× ×©×רצ×× × ×××××§ ×ת ××× ××"," ",e.jsx("span",{className:"font-semibold",children:(ls=O.stockToDelete)==null?void 0:ls.asset_name}),"?",e.jsx("br",{}),"פע××× ×× ×× × ××ª× ×ª ××××××."]})]}),e.jsxs(us,{className:"flex-row-reverse gap-2",children:[e.jsx(T,{variant:"destructive",onClick:vs,disabled:O.isDeleting,children:O.isDeleting?"××××§...":"××, ×××§"}),e.jsx(T,{variant:"outline",onClick:ns,disabled:O.isDeleting,children:"×××××"})]})]})}
77),e.jsxs("div",{className:"max-w-7xl mx-auto space-y-8 mb-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 text-right mb-8",children:[e.jsxs("div",{className:"text-right pt-4 pr-4 sm:pt-0 sm:pr-0",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-extrabold text-gray-800 mb-3",children:"ת××§ ×שקע×ת"}),e.jsx("p",{className:"text-gray-500 text-lg md:text-xl",children:"× ××× ×ת ת××§ ××שקע×ת ש××× ×צ××¨× ×××× ×××¢×××"})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2 sm:gap-4 mt-4 md:mt-0",children:[" ",e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsxs(T,{onClick:_s,disabled:de,className:"flex-shrink-0",children:[de?e.jsx(Je,{className:"w-4 h-4 ml-2 animate-spin"}):e.jsx(Je,{className:"w-4 h-4 ml-2"}),"×¨×¢× × ×©××× × ×ס××"]}),Ae&&!de&&e.jsxs("span",{className:"text-xs text-gray-400",children:["×¢××××: ",Ae.toLocaleTimeString("he-IL",{hour:"2-digit",minute:"2-digit"})]})]}),e.jsxs(T,{onClick:ze,children:[e.jsx(we,{className:"w-4 h-4 ml-2"}),'××ספת × ×ס × ××"×']})]})]}),e.jsxs("main",{className:"space-y-8",children:[e.jsx(W,{className:"glass-effect border-0 shadow-xl",children:e.jsx(K,{className:"p-4 sm:p-6 md:p-8",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 md:w-16 md:h-16 bg-gradient-to-r from-green-500 to-blue-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx($s,{className:"w-6 h-6 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl font-bold text-gray-800 mb-2",children:"ש××× ×ת××§ ×××××"}),e.jsx("p",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold text-gray-900 break-all",children:ce(u,E)})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4 sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 font-medium",children:"××××¢ תצ×××:"}),e.jsxs("div",{className:"flex items-center bg-white/80 backdrop-blur-sm rounded-lg p-1 border border-gray-200 shadow-sm",children:[e.jsxs("button",{onClick:()=>ue("ILS"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="ILS"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"âª"}),e.jsx("span",{className:"text-xs",children:"ILS"})]}),e.jsxs("button",{onClick:()=>ue("USD"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="USD"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"$"}),e.jsx("span",{className:"text-xs",children:"USD"})]}),e.jsxs("button",{onClick:()=>ue("EUR"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="EUR"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"â¬"}),e.jsx("span",{className:"text-xs",children:"EUR"})]})]})]}),e.jsx("div",{className:"w-full sm:w-auto",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(T,{onClick:()=>N(!0),variant:"outline",className:"flex-1 sm:flex-none px-6 py-3 border-2 border-blue-200 hover:border-blue-300 hover:bg-blue-50",children:[e.jsx(ut,{className:"w-4 h-4 ml-2"}),"××סף ×× ××"]}),e.jsx(Ds,{to:qs("Calculator"),className:"block flex-1 sm:flex-none",children:e.jsxs(T,{variant:"outline",className:"w-full px-6 py-3 border-2 border-blue-200 hover:border-blue-300 hover:bg-blue-50",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"××סף × ×ס"]})})]})})]})]})})}),e.jsx(Ct,{snapshots:v,transactions:A,isLoading:!1}),e.jsxs(Ws,{defaultValue:"overview",className:"w-full",children:[e.jsxs(Hs,{className:"grid w-full grid-cols-4",children:[e.jsx(De,{value:"stocks",children:"ש××§ ××××"}),e.jsx(De,{value:"real_estate",children:"× ×××´×"}),e.jsx(De,{value:"savings",children:"×ס××× ×ת"}),e.jsx(De,{value:"overview",children:"סק×ר×"})]}),e.jsxs(Le,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-blue-100",children:e.jsx(Ee,{className:"w-5 h-5 text-blue-600"})}),e.jsx(Q,{variant:"outline",className:"bg-blue-50 text-blue-700 text-xs",children:"ש××§ ××××"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(m.reduce((t,f)=>t+le(f.current_value||f.total_investment||0,f.currency||"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[m.length," × ×ס××"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-green-100",children:e.jsx(we,{className:"w-5 h-5 text-green-600"})}),e.jsx(Q,{variant:"outline",className:"bg-green-50 text-green-700 text-xs",children:"× ×××´×"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(p.reduce((t,f)=>{var c;return t+le(f.current_estimated_value||((c=f.financial_details)==null?void 0:c.purchase_price)||0,"ILS",E)},0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[p.length," × ×ס××"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-purple-100",children:e.jsx(He,{className:"w-5 h-5 text-purple-600"})}),e.jsx(Q,{variant:"outline",className:"bg-purple-50 text-purple-700 text-xs",children:"×ס××× ×ת"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(a.reduce((t,f)=>t+le(f.current_amount||0,"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[a.length," ××ר×ת"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-yellow-100",children:e.jsx(Os,{className:"w-5 h-5 text-yellow-600"})}),e.jsx(Q,{variant:"outline",className:"bg-yellow-50 text-yellow-700 text-xs",children:"××××× ××"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(_.reduce((t,f)=>t+le(f.current_balance||0,f.currency||"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[_.length," ×ש××× ×ת"]})]})})]}
77),e.jsx(Rt,{realEstateAssets:p,stockAssets:m,cashAccounts:_,convertCurrency:le,formatCurrency:ce,displayCurrency:E,user:r,rates:ne})]}),e.jsxs(Le,{value:"stocks",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"×שקע×ת ×ש××§ ××××"}),e.jsxs(T,{onClick:js,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"××סף ×שקע×"]})]}),m.length>0?e.jsx("div",{className:"space-y-4",children:m.map(t=>e.jsx(bs,{stock:t,setIsAddStockModalOpen:N,setEditingAsset:g,loadPortfolioData:he,user:r,formatCurrency:ce,setDeleteConfirmDialog:re},t.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"××× ×שקע×ת ×ש××§ ××××"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"×ת×× ×× ×× ×ת ת××§ ××× ××ת ××××× ×©××"}),e.jsxs(T,{onClick:()=>{N(!0),g(null)},className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"××סף ××©×§×¢× ×¨×ש×× ×"]})]})]}),e.jsxs(Le,{value:"real_estate",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"× ××¡× × ×××´×"}),e.jsxs(T,{onClick:ze,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"××סף × ×ס"]})]}),p.length>0?e.jsx("div",{className:"space-y-4",children:p.map(t=>{var f,c,n,I;return e.jsx(W,{className:"border-0 shadow-lg hover:shadow-xl transition-shadow duration-300",children:e.jsx(K,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-green-100 to-green-200 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(we,{className:"w-8 h-8 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h4",{className:"font-bold text-xl text-gray-900",children:(f=t.location)==null?void 0:f.city}),e.jsx(Q,{className:"text-xs px-2 py-1 bg-blue-100 text-blue-800",children:t.status==="for_sale"?"××××ר×":t.status==="personal_use"?"ש×××ש ××ש×":"××ש×ר"})]}),e.jsxs("p",{className:"text-gray-600 mb-3 font-medium",children:[(c=t.location)==null?void 0:c.neighborhood,((n=t.location)==null?void 0:n.address)&&` ⢠${t.location.address}`]})]})]}),e.jsxs("div",{className:"w-full sm:w-auto text-center sm:text-right mt-4 pt-4 border-t border-gray-100 sm:mt-0 sm:pt-0 sm:border-0",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:"ש××× × ××××"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:ce(le(t.current_estimated_value||((I=t.financial_details)==null?void 0:I.purchase_price)||0,"ILS",E),E)})]})]})})},t.id)})}):e.jsxs(W,{className:"border-dashed border-2 text-center py-12",children:[e.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"××× × ××¡× × ×××´×"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"×ת×× ×× ××× ×ת × ××¡× ×× ×××´× ×©××"}),e.jsxs(T,{onClick:ze,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Us,{className:"w-4 h-4 ml-2"}),"××סף × ×ס ר×ש××"]})]})]}),e.jsxs(Le,{value:"savings",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"××ר×ת ×ס×××"}),e.jsxs(T,{className:"bg-purple-600 hover:bg-purple-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"××סף ××ר×"]})]}),a.length>0?e.jsx("div",{className:"space-y-4",children:a.map(t=>{const f=t.target_amount>0?t.current_amount/t.target_amount*100:0;return e.jsx(W,{className:"border-0 shadow-lg",children:e.jsx(K,{className:"p-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsx(He,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-lg",children:t.goal_name}),e.jsx(Q,{className:"text-xs bg-purple-100 text-purple-800",children:t.goal_type})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-lg font-bold",children:[ce(t.current_amount||0,"ILS")," / ",ce(t.target_amount,"ILS")]}),e.jsxs("p",{className:"text-sm text-gray-500",children:[f.toFixed(1),"% ××ש××"]})]})]}),e.jsx("div",{children:e.jsx(Vs,{value:f,className:"h-3"})})]})})},t.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(He,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"××× ××ר×ת ×ס×××"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"×××ר ××ר×ת ×ס××× ××¢×§×× ×××¨× ××תק×××ת ש××"}),e.jsxs(T,{className:"bg-purple-600 hover:bg-purple-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}
77),"×××ר ×××¨× ×¨×ש×× ×"]})]})]})]})]}),e.jsx(zs,{isOpen:!!Ne,onClose:()=>oe(null),limitType:Ne||"properties"})]})]})}export{na 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.