1import{ej as Me,ek as Ut,el as Le,em as Ue,c$ as $t,en as $e,r as i,j as e,eo as zt,b5 as Ft,b6 as W,ep as qt,eq as Bt,er as Gt,es as Ht,et as Kt,eu as Vt,ev as Wt,ew as Yt,ex as Zt,ey as Xt,ez as Qt,eA as Jt,dd as ea,eB as ta,eC as aa,ak as N,l as sa,by as ze,dB as na,b as Fe,u as qe,bo as ra,G as oa,d as ia,V as la,bB as _e,bC as Pe,bD as ca,bE as Ie,bF as $,a2 as Be,ba as da,bb as ua,bc as ma,aU as xa,aV as pa,aW as ha,B as z,aF as fa,aG as ga,aH as Na,aI as va,aJ as ja,aK as Ca,aL as wa,aM as ba,e as I,aQ as de,aR as ue,aa as ya,aS as me,b3 as xe,b1 as Ma,L as _a,N as ke,a as Pa,a7 as Ia,az as ka,ar as Da,A as Ra,am as Aa,an as Ta,bm as Sa,X as De,Y as Re,a0 as Oa}from"./index-bFXlcYyz.js";import{u as Ea}from"./useWatchlists-CZaZVVm3.js";import{T as La}from"./TuningAssistant-B1yoyIAH.js";import{u as Ua}from"./usePropertyVerdicts-D3pHQTR2.js";import{a as $a,u as za}from"./useAIPropertyAnalysis-DvSIDaap.js";import{u as Fa,f as qa}from"./useAutoVerdict-D-gVxtvv.js";import{p as Ba,f as Ga,c as Ha,w as Ae,x as Te,y as Ka,a as Va,b as Wa,d as Ya,e as Za,r as Xa}from"./DealView-DoIFmlVH.js";import{b as Ge,e as w,T as Qa,a as Ja,c as b,d as es}from"./table-BVVIeujy.js";import{D as ts}from"./DealListLayout-DCnHj52W.js";import{u as as}from"./useDealListPanel-BQINxc3R.js";import{a as ss,C as ns}from"./CreateCollectionDialog-DDw26vtA.js";import{l as rs,i as Se,C as os}from"./visibility-kowbMwbs.js";import{a as is}from"./propertyCalculations-DGCOP__X.js";import{u as ls}from"./useCurrencyFormat-DcMSuJRA.js";import{o as cs}from"./openListingUrl-DQ4GYCV_.js";import{I as ds}from"./image-plus-_W2nLltm.js";import{u as us}from"./useTierVisibility-BEIgmmkT.js";import{L as ms}from"./locked-feature-B85fpJny.js";import{R as Oe}from"./radar-o_1ACXg2.js";import{L as xs}from"./list-8PGMaI4_.js";import"./filter-BMaGf2V1.js";import"./useDealCriteria-BA3Jfdcs.js";import"./useExternalAreaStats-DoXPnTaQ.js";import"./usePropertyContacts-DvuibqJb.js";import"./collapsible-DkaqcvzQ.js";import"./index-BRbaHrTg.js";import"./building-2-CtfoZBQH.js";import"./landmark-Cddh2Ek_.js";import"./camera-BQw4PKcD.js";import"./MarketContextCard-DMkujdcd.js";import"./soldPricing-eQwjLHLG.js";import"./info-B6Ac-tGF.js";import"./chart-column-BEDhxu54.js";import"./trending-down-CW5K0GDh.js";import"./useTriageRouteDisplay-B4Tfibwb.js";import"./CoreMetricsCard-CL4kc6b4.js";import"./phone-Bun5F62j.js";import"./arrow-right-left-CjKJxsca.js";import"./circle-check-big-DF5sDft0.js";import"./coins-4we5aqeU.js";import"./dollar-sign-Cg15hIu3.js";import"./useLocationOptions-zlULBHK3.js";import"./separator-arXeigQF.js";
1import"./pro-badge-BsxQ0i7b.js";import"./progress-9TyhDLJ9.js";import"./brain-D_tbFGmA.js";import"./percent-ClUTw5Vx.js";import"./waves-CO6uzCCS.js";import"./slider-DRghXidJ.js";import"./BookViewingDialog-BpzduYi1.js";import"./ContactProfileDialog-UraljS6X.js";import"./message-square-BHwubXiA.js";import"./useUserProfile-rUNwTd36.js";import"./circle-alert-B2iYFuRY.js";import"./usePropertyEditable-DP3U11y0.js";import"./MessageAIControls-Bhgd8Vm5.js";import"./arrow-up-right-CrrnRf7-.js";import"./useSoldReferenceBackfill-CbqzrQzO.js";import"./ruler-2LUhEgVp.js";import"./file-search-YB7AsCcZ.js";function ps(t,a){const s=Me(t),n=Me(a),o=Ee(s,n),p=Math.abs(Ut(s,n));s.setDate(s.getDate()-o*p);const u=+(Ee(s,n)===-o),m=o*(p-u);return m===0?0:m}function Ee(t,a){const s=t.getFullYear()-a.getFullYear()||t.getMonth()-a.getMonth()||t.getDate()-a.getDate()||t.getHours()-a.getHours()||t.getMinutes()-a.getMinutes()||t.getSeconds()-a.getSeconds()||t.getMilliseconds()-a.getMilliseconds();return s<0?-1:s>0?1:s}function hs(t,a){const n=vs(t);let o;if(n.date){const g=js(n.date,2);o=Cs(g.restDateString,g.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const p=o.getTime();let u=0,m;if(n.time&&(u=ws(n.time),isNaN(u)))return new Date(NaN);if(n.timezone){if(m=bs(n.timezone),isNaN(m))return new Date(NaN)}else{const g=new Date(p+u),h=new Date(0);return h.setFullYear(g.getUTCFullYear(),g.getUTCMonth(),g.getUTCDate()),h.setHours(g.getUTCHours(),g.getUTCMinutes(),g.getUTCSeconds(),g.getUTCMilliseconds()),h}return new Date(p+u+m)}const ee={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},fs=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,gs=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}
1(?:[.,]\d*)?))?$/,Ns=/^([+-])(\d{2})(?::?(\d{2}))?$/;function vs(t){const a={},s=t.split(ee.dateTimeDelimiter);let n;if(s.length>2)return a;if(/:/.test(s[0])?n=s[0]:(a.date=s[0],n=s[1],ee.timeZoneDelimiter.test(a.date)&&(a.date=t.split(ee.timeZoneDelimiter)[0],n=t.substr(a.date.length,t.length))),n){const o=ee.timezone.exec(n);o?(a.time=n.replace(o[1],""),a.timezone=o[1]):a.time=n}return a}function js(t,a){const s=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+a)+"})|(\\d{2}|[+-]\\d{"+(2+a)+"})$)"),n=t.match(s);if(!n)return{year:NaN,restDateString:""};const o=n[1]?parseInt(n[1]):null,p=n[2]?parseInt(n[2]):null;return{year:p===null?o:p*100,restDateString:t.slice((n[1]||n[2]).length)}}function Cs(t,a){if(a===null)return new Date(NaN);const s=t.match(fs);if(!s)return new Date(NaN);const n=!!s[4],o=Y(s[1]),p=Y(s[2])-1,u=Y(s[3]),m=Y(s[4]),g=Y(s[5])-1;if(n)return Is(a,m,g)?ys(a,m,g):new Date(NaN);{const h=new Date(0);return!_s(a,p,u)||!Ps(a,o)?new Date(NaN):(h.setUTCFullYear(a,p,Math.max(o,u)),h)}}function Y(t){return t?parseInt(t):1}function ws(t){const a=t.match(gs);if(!a)return NaN;const s=pe(a[1]),n=pe(a[2]),o=pe(a[3]);return ks(s,n,o)?s*Le+n*Ue+o*1e3:NaN}function pe(t){return t&&parseFloat(t.replace(",","."))||0}function bs(t){if(t==="Z")return 0;const a=t.match(Ns);if(!a)return 0;const s=a[1]==="+"?-1:1,n=parseInt(a[2]),o=a[3]&&parseInt(a[3])||0;return Ds(n,o)?s*(n*Le+o*Ue):NaN}function ys(t,a,s){const n=new Date(0);n.setUTCFullYear(t,0,4);const o=n.getUTCDay()||7,p=(a-1)*7+s+1-o;return n.setUTCDate(n.getUTCDate()+p),n}const Ms=[31,null,31,30,31,30,31,31,30,31,30,31];function He(t){return t%400===0||t%4===0&&t%100!==0}function _s(t,a,s){return a>=0&&a<=11&&s>=1&&s<=(Ms[a]||(He(t)?29:28))}function Ps(t,a){return a>=1&&a<=(He(t)?366:365)}function Is(t,a,s){return a>=1&&a<=53&&s>=0&&s<=6}function ks(t,a,s){return t===24?a===0&&s===0:s>=0&&s<60&&a>=0&&a<60&&t>=0&&t<25}function Ds(t,a){return a>=0&&a<=59}var he="ContextMenu",[Rs,hr]=$t(he,[$e]),C=$e(),[As,Ke]=Rs(he),Ve=t=>{const{__scopeContextMenu:a,children:s,onOpenChange:n,dir:o,modal:p=!0}=t,[u,m]=i.useState(!1),g=C(a),h=ea(n),f=i.useCallback(y=>{m(y),h(y)},[h]);return e.jsx(As,{scope:a,open:u,onOpenChange:f,modal:p,children:e.jsx(ta,{...g,dir:o,open:u,onOpenChange:f,modal:p,children:s})})};Ve.displayName=he;var We="ContextMenuTrigger",Ye=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,disabled:n=!1,...o}=t,p=Ke(We,s),u=C(s),m=i.useRef({x:0,y:0}),g=i.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...m.current})}),h=i.useRef(0),f=i.useCallback(()=>window.clearTimeout(h.current),[]),y=v=>{m.current={x:v.clientX,y:v.clientY},p.onOpenChange(!0)};return i.useEffect(()=>f,[f]),i.useEffect(()=>void(n&&f()),[n,f]),e.jsxs(e.Fragment,{children:[e.jsx(zt,{...u,virtualRef:g}),e.jsx(Ft.span,{"data-state":p.open?"open":"closed","data-disabled":n?"":void 0,...o,ref:a,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:n?t.onContextMenu:W(t.onContextMenu,v=>{f(),y(v),v.preventDefault()}),onPointerDown:n?t.onPointerDown:W(t.onPointerDown,te(v=>{f(),h.current=window.setTimeout(()=>y(v),700)})),onPointerMove:n?t.onPointerMove:W(t.onPointerMove,te(f)),onPointerCancel:n?t.onPointerCancel:W(t.onPointerCancel,te(f)),onPointerUp:n?t.onPointerUp:W(t.onPointerUp,te(f))})]})});Ye.displayName=We;var Ts="ContextMenuPortal",Ze=t=>{const{__scopeContextMenu:a,...s}=t,n=C(a);return e.jsx(aa,{...n,...s})};Ze.displayName=Ts;var Xe="ContextMenuContent",Qe=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=Ke(Xe,s),p=C(s),u=i.useRef(!1);return e.jsx(qt,{...p,...n,ref:a,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:m=>{var g;(g=t.onCloseAutoFocus)==null||g.call(t,m),!m.defaultPrevented&&u.current&&m.preventDefault(),u.current=!1},onInteractOutside:m=>{var g;(g=t.onInteractOutside)==null||g.call(t,m),!m.defaultPrevented&&!o.modal&&(u.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Qe.displayName=Xe;var Ss="ContextMenuGroup",Os=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Bt,{...o,...n,ref:a})});Os.displayName=Ss;var Es="ContextMenuLabel",Je=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Gt,{...o,...n,ref:a})});Je.displayName=Es;var Ls="ContextMenuItem",et=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Ht,{...o,...n,ref:a})});et.displayName=Ls;var Us="ContextMenuCheckboxItem",tt=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Kt,{...o,...n,ref:a})});tt.displayName=Us;var $s="ContextMenuRadioGroup",zs=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Vt,{...o,...n,ref:a})});zs.displayName=$s;var Fs="ContextMenuRadioItem",at=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Wt,{...o,...n,ref:a})});at.displayName=Fs;var qs="ContextMenuItemIndicator",st=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Yt,{...o,...n,ref:a})});st.displayName=qs;var Bs="ContextMenuSeparator",nt=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Zt,{...o,...n,ref:a})});nt.displayName=Bs;var Gs="ContextMenuArrow",Hs=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Xt,{...o,...n,ref:a})});Hs.displayName=Gs;var Ks="ContextMenuSubTrigger",rt=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Qt,{...o,...n,ref:a})});rt.displayName=Ks;var Vs="ContextMenuSubContent",ot=i.forwardRef((t,a)=>{const{__scopeContextMenu:s,...n}=t,o=C(s);return e.jsx(Jt,{...o,...n,ref:a,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ot.displayName=Vs;function te(t){return a=>a.pointerType!=="mouse"?t(a):void 0}var Ws=Ve,Ys=Ye,Zs=Ze,it=Qe,lt=Je,ct=et,dt=tt,ut=at,mt=st,xt=nt,pt=rt,ht=ot;const Xs=Ws,Qs=Ys,Js=i.forwardRef(({className:t,inset:a,children:s,...n},o)=>e.jsxs(pt,{ref:o,className:N("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",a&&"pl-8",t),...n,children:[s,e.jsx(sa,{className:"ml-auto h-4 w-4"})]}));Js.displayName=pt.displayName;const en=i.forwardRef(({className:t,...a},s)=>e.jsx(ht,{ref:s,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
1de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));en.displayName=ht.displayName;const ft=i.forwardRef(({className:t,...a},s)=>e.jsx(Zs,{children:e.jsx(it,{ref:s,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}));ft.displayName=it.displayName;const se=i.forwardRef(({className:t,inset:a,...s},n)=>e.jsx(ct,{ref:n,className:N("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",a&&"pl-8",t),...s}));se.displayName=ct.displayName;const tn=i.forwardRef(({className:t,children:a,checked:s,...n},o)=>e.jsxs(dt,{ref:o,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:s,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(mt,{children:e.jsx(ze,{className:"h-4 w-4"})})}),a]}));tn.displayName=dt.displayName;const an=i.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(ut,{ref:n,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(mt,{children:e.jsx(na,{className:"h-2 w-2 fill-current"})})}),a]}));an.displayName=ut.displayName;const sn=i.forwardRef(({className:t,inset:a,...s},n)=>e.jsx(lt,{ref:n,className:N("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));sn.displayName=lt.displayName;const nn=i.forwardRef(({className:t,...a},s)=>e.jsx(xt,{ref:s,className:N("-mx-1 my-1 h-px bg-border",t),...a}));nn.displayName=xt.displayName;const ae=(t,a="â¬")=>t?t>=1e6?`${(t/1e6).toFixed(1)}M ${a}`:`${Math.round(t/1e3)}k ${a}`:"-";function rn({propertyId:t,currentImage:a,onImageUpdated:s}){const[n,o]=i.useState(!1),[p,u]=i.useState(!1),m=i.useRef(null),g=async h=>{var y;h.stopPropagation();const f=(y=h.target.files)==null?void 0:y[0];if(f){if(!f.type.startsWith("image/")){I.error("Endast bildfiler");return}
1if(f.size>5*1024*1024){I.error("Max 5MB");return}o(!0);try{const v=new FileReader;v.onload=async F=>{var D;const k=(D=F.target)==null?void 0:D.result,{data:_}=await ke.from("properties").select("images").eq("id",t).single(),P=Array.isArray(_==null?void 0:_.images)?_.images:[],j=[k,...P];await ke.from("properties").update({images:j}).eq("id",t),s(),o(!1)},v.readAsDataURL(f)}catch{I.error("Kunde inte ladda upp bild"),o(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 w-8 rounded overflow-hidden bg-muted flex-shrink-0 flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:h=>{var f;h.stopPropagation(),h.preventDefault(),(f=m.current)==null||f.click()},children:n?e.jsx(_a,{className:"h-3 w-3 animate-spin text-muted-foreground"}):a&&!p?e.jsx("img",{src:a,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",loading:"lazy",onError:()=>u(!0)}):e.jsx(ds,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("input",{ref:m,type:"file",accept:"image/*",className:"hidden",onChange:g,disabled:n,onClick:h=>h.stopPropagation()})]})}function on({property:t,rank:a,areaAvgPricePerSqm:s,areaMinPricePerSqm:n,areaMaxPricePerSqm:o,onShowAd:p,onPropertyClick:u,showLocationColumn:m=!0,showSubLocation:g=!1,isSelected:h=!1,onToggleSelect:f,isActive:y=!1,aiScore:v=null,columnMode:F="quick",collections:k=[],propertyCollectionIds:_=[],aiCollectionIds:P=[],statusAgeDays:j,statusMedianDays:D,compact:x=!1,aiVerdict:R=null,onTriageDecision:A,onRequestCreateFolder:c,isReadOnly:E=!1,metrics:d=null}){const T=Fe(),{t:l}=qe(),q=ra(),gt=$a(),Nt=Ba(),vt=Ga(),jt=oa(),[Ct,fe]=i.useState(!1),[wt,Z]=i.useState(!1),[B,ge]=i.useState(null),[ne,re]=i.useState(null),[Ne,bt]=i.useState(!1),{user:oe}=ia(),{visible:ve,hidden:X}=rs(k,(oe==null?void 0:oe.id)??null),{settings:yt}=Ha(),ie=t.country_code||null,{symbol:Q}=ls(ie),L=(d==null?void 0:d.roi)??null,U=(d==null?void 0:d.roe)??null,Mt=(d==null?void 0:d.projectedReturn)??null,_t=(d==null?void 0:d.equity)??null,je=(d==null?void 0:d.renovationCost)??null,S=(d==null?void 0:d.profitAfterTax)??null,Pt=t.asking_price&&t.purchase_price?(t.purchase_price-t.asking_price)/t.asking_price*100:null,It={projectedReturn:Mt,diffAskingPurchasePercent:Pt,askingPrice:t.asking_price,areaAvgListingPrice:s?s*(t.living_area||100):null,worstScenarioProfit:(d==null?void 0:d.profitWithDepreciation)??null};is(It,yt.priorityCriteria);const Ce=[t.municipality,t.district].filter(Boolean).join(", ")||"-",kt=(Array.isArray(t.images)?t.images:[])[0]||null,G=t.fx_rate,{selectedCountryCode:le}=la(),we=le===ie||le!=="ALL"&&le===ie,ce=we||!G||G===1?t.asking_price:t.asking_price?t.asking_price*G:t.asking_price;ce&&t.living_area&&ce/t.living_area;const Dt=!we&&G!=null&&G!==1,be=t.listed_at,J=be?ps(new Date,hs(be)):null,H=_,Rt=k.filter(r=>H.includes(r.id)),At=async r=>{fe(!0);try{const M=Ka(t,r);await q.mutateAsync({id:t.id,...M}),t.is_example||gt.mutate({propertyId:t.id,signalType:"status_change",signalData:{new_status:r,old_status:t.status}}),I.success("Status uppdaterad")}catch{I.error("Kunde inte uppdatera")}finally{fe(!1)}},ye=async r=>{const M=H.includes(r);try{await Nt.mutateAsync({propertyId:t.id,collectionId:r,isCurrentlyIn:M}),I.success(M?"Borttagen från samling":"Tillagd i samling")}catch{I.error("Kunde inte uppdatera samling")}},Tt=()=>{window.open(`/app/deals/${t.id}`,"_blank")},O=Rt.filter(r=>!P.includes(r.id)),St=O.length>0?O.map(r=>r.name).join(", "):"-",Ot=O.length>1?`${O[0].name.substring(0,6)}⦠+${O.length-1}`:O.length===1?O[0].name:"-",K=t.triage_decision,Et=K||"undecided",Lt=K==="keep"?"Keep":K==="review"?"Review":K==="archive"?"Archive":"No verdict";return i.useRef(null),i.useEffect(()=>{},[t.id,t.status,K,Lt,R==null?void 0:R.verdict,H]),e.jsxs(Xs,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(Ge,{className:N("group h-10 hover:bg-muted/30 cursor-pointer text-sm",h&&"bg-destructive/10",y&&"bg-primary/10 border-l-2 border-l-primary",u&&"hover:bg-primary/10",E&&"opacity-70"),onClick:r=>{r.button!==0||r.metaKey||r.ctrlKey||r.shiftKey||(u?u(t.id):T(`/app/deals/${t.id}`))},"data-href":`/app/deals/${t.id}
1`,onAuxClick:r=>{r.button===1&&(r.preventDefault(),window.open(`/app/deals/${t.id}`,"_blank"))},onContextMenu:()=>{},children:[e.jsx(w,{className:"py-1 px-1 w-8",onClick:r=>r.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:h,onChange:()=>f==null?void 0:f(t.id),className:"h-3.5 w-3.5 rounded border-input accent-primary"})}),e.jsx(w,{className:"py-1 px-1 w-10",onClick:r=>r.stopPropagation(),children:e.jsx(rn,{propertyId:t.id,currentImage:kt,onImageUpdated:()=>jt.invalidateQueries({queryKey:["properties"]})})}),m&&e.jsx(w,{className:"py-1 px-2 w-32",children:e.jsxs("a",{href:`/app/deals/${t.id}`,onClick:r=>{r.button===0&&!r.metaKey&&!r.ctrlKey&&!r.shiftKey&&r.preventDefault()},className:"block",children:[e.jsx("div",{className:"truncate text-xs font-medium hover:underline",children:Ce}),J!==null&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[J,"d"]})]})}),g&&e.jsxs(w,{className:"py-1 px-2 w-32",children:[e.jsx("div",{className:"truncate text-xs font-medium",children:Ce}),J!==null&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[J,"d"]})]}),e.jsx(w,{className:"py-1 px-1 w-12 overflow-hidden text-right",onClick:r=>r.stopPropagation(),children:e.jsx("span",{className:"text-xs tabular-nums",children:v?Math.round(v.overall_score):"â"})}),e.jsx(w,{className:"py-1 px-1 w-20 text-right overflow-hidden",children:e.jsxs("div",{className:"text-xs font-medium whitespace-nowrap truncate",children:[ae(ce,Q),Dt&&e.jsx("span",{className:"text-[9px] text-muted-foreground ml-0.5",children:"fx"})]})}),!x&&e.jsxs(w,{className:"py-1 px-1 w-20 text-right overflow-hidden",children:[e.jsx("div",{className:"text-xs whitespace-nowrap tabular-nums",children:t.living_area?`${Math.round(t.living_area)} m²`:"-"}),e.jsx("div",{className:"text-[10px] text-muted-foreground whitespace-nowrap tabular-nums",children:(()=>{const r=t.plot_size??t.plot_area_m2??t.plot_area??null;return r?`${Math.round(r).toLocaleString()} m²`:"-"})()})]}),!x&&e.jsxs(w,{className:"py-1 px-1 w-18 text-right overflow-hidden",children:[e.jsx("div",{className:"text-xs whitespace-nowrap",children:e.jsx("span",{className:N(L!=null&&L>15?"text-emerald-600 font-semibold":L!=null&&L>0?"text-foreground":"text-muted-foreground"),children:L!=null?`${L.toFixed(0)}%`:"-"})}),e.jsx("div",{className:"text-[10px] whitespace-nowrap",children:e.jsx("span",{className:N(U!=null&&U>15?"text-emerald-600":U!=null&&U>0?"text-foreground":"text-muted-foreground"),children:U!=null?`${Number(U).toFixed(0)}%`:"-"})})]}),!x&&e.jsx(w,{className:"py-1 px-1 w-20 text-right overflow-hidden",children:e.jsx("div",{className:N("text-xs font-medium whitespace-nowrap truncate tabular-nums",S!=null&&S>5e4?"text-emerald-600":S!=null&&S>0?"text-foreground":S!=null&&S<0?"text-destructive":"text-muted-foreground"),children:ae(S,Q)})}),!x&&e.jsxs(w,{className:"py-1 px-1 w-22 text-right overflow-hidden",children:[e.jsx("div",{className:"text-xs font-medium whitespace-nowrap truncate",children:ae(_t,Q)}),e.jsx("div",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:je?ae(je,Q):"-"})]}),e.jsx(w,{className:"py-1 px-1 w-24 overflow-hidden",onClick:r=>r.stopPropagation(),"data-verdict-visible":"true",children:e.jsxs(_e,{value:Et,onValueChange:r=>{r!=="undecided"&&(A==null||A(t.id,r))},disabled:!A,children:[e.jsx(Pe,{className:"h-6 w-[96px] text-[10px] px-2",children:e.jsx(ca,{})}),e.jsxs(Ie,{children:[e.jsxs($,{value:"undecided",children:["â ",l("verdict.none")]}),e.jsxs($,{value:"keep",children:["â
",l("triage.action.keep")]}),e.jsxs($,{value:"review",children:["â ï¸ ",l("triage.action.review")]}),e.jsxs($,{value:"archive",children:["â ",l("triage.action.archive")]})]})]})}),!x&&e.jsx(w,{className:"py-1 px-1 w-20 overflow-hidden",onClick:r=>r.stopPropagation(),children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(_e,{value:Ae(t),onValueChange:At,disabled:Ct,children:[e.jsx(Pe,{className:"h-6 w-[70px] text-xs border-0 bg-transparent p-0",children:e.jsx(Be,{variant:"secondary",className:"text-xs px-1.5 py-0.5",children:l(`status.${Ae(t)}`)})}),e.jsxs(Ie,{children:[ss.map(r=>e.jsx($,{value:r,children:l(`status.${r}`)},r)),e.jsx($,{value:Te,children:l("status.sold")},Te)]})]}),j!=null&&t.status!=="exited"&&e.jsxs("span",{className:N("text-[9px] leading-tight",D!=null?j<D?"text-emerald-600":j<D*2?"text-amber-600":"text-destructive":"text-muted-foreground"),children:[j,"d"]})]})}),!x&&e.jsxs(w,{className:"py-1 px-1 w-20 overflow-hidden",onClick:r=>r.stopPropagation(),children:[e.jsxs(da,{open:wt,onOpenChange:Z,children:[e.jsx(ua,{asChild:!0,children:e.jsx("button",{className:"text-xs text-muted-foreground truncate max-w-full block hover:text-foreground transition-colors text-left whitespace-nowrap",title:St,children:Ot})}),e.jsxs(ma,{className:"w-52 p-2",align:"start",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:[ve.map(r=>{const M=H.includes(r.id);return e.jsxs("div",{className:"flex items-center gap-1 hover:bg-muted/50 p-1 rounded text-sm group/col",children:[e.jsxs("button",{className:N("flex items-center gap-2 flex-1 min-w-0 text-left",M&&"font-medium"),onClick:()=>
1ye(r.id),children:[e.jsx("input",{type:"checkbox",checked:M,readOnly:!0,className:"h-3 w-3 rounded border-input accent-primary flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]}),e.jsx("button",{className:"opacity-0 group-hover/col:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",onClick:V=>{V.preventDefault(),V.stopPropagation(),Z(!1),setTimeout(()=>ge({id:r.id,name:r.name,constraints:r.constraints}),0)},title:l("collection.edit")||"Redigera",children:e.jsx(xa,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("button",{className:"opacity-0 group-hover/col:opacity-100 transition-opacity p-0.5 rounded hover:bg-destructive/10",onClick:V=>{V.preventDefault(),V.stopPropagation(),Z(!1),setTimeout(()=>re(r.id),0)},title:l("collection.delete")||"Ta bort",children:e.jsx(pa,{className:"h-3 w-3 text-destructive"})})]},r.id)}),ve.length===0&&X.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground p-1",children:l("collection.none")||"Inga samlingar"}),X.length>0&&e.jsxs("div",{className:"border-t mt-1 pt-1",children:[e.jsxs("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),bt(M=>!M)},className:"flex items-center gap-1 w-full px-1 py-1 text-[10px] text-muted-foreground hover:text-foreground",children:[e.jsx(ha,{className:N("h-3 w-3 transition-transform",!Ne&&"-rotate-90")}),e.jsxs("span",{children:[l("filters.hidden")||"Dolda"," (",X.length,")"]})]}),Ne&&X.map(r=>{const M=H.includes(r.id);return e.jsx("div",{className:"flex items-center gap-1 hover:bg-muted/50 p-1 rounded text-sm opacity-70",children:e.jsxs("button",{className:N("flex items-center gap-2 flex-1 min-w-0 text-left",M&&"font-medium"),onClick:()=>
1ye(r.id),children:[e.jsx("input",{type:"checkbox",checked:M,readOnly:!0,className:"h-3 w-3 rounded border-input accent-primary flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]})},r.id)})]})]}),c&&e.jsx("div",{className:"border-t mt-2 pt-2",children:e.jsx(z,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs justify-start",onClick:r=>{r.preventDefault(),r.stopPropagation(),Z(!1),c(t.id)},children:"New folder"})})]})]}),B&&e.jsx(ns,{open:!!B,onOpenChange:r=>{r||ge(null)},editId:B.id,editName:B.name,editConstraints:B.constraints}),e.jsx(fa,{open:!!ne,onOpenChange:r=>{r||re(null)},children:e.jsxs(ga,{onClick:r=>r.stopPropagation(),children:[e.jsxs(Na,{children:[e.jsx(va,{children:l("collection.deleteConfirm")||"Ta bort samling?"}),e.jsx(ja,{children:l("collection.deleteDesc")||"Samlingen tas bort. Objekten pÃ¥verkas inte."})]}),e.jsxs(Ca,{children:[e.jsx(wa,{children:l("common.cancel")}),e.jsx(ba,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:async()=>{if(ne)try{await vt.mutateAsync(ne),I.success(l("collection.deleted")||"Samling borttagen")}catch{I.error(l("collection.deleteError")||"Kunde inte ta bort")}re(null)},children:l("common.delete")})]})]})})]}),!x&&e.jsx(w,{className:"py-1 px-1 text-right w-20",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsxs(de,{delayDuration:300,children:[e.jsx(ue,{asChild:!0,children:e.jsx(z,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:r=>{r.stopPropagation(),u?u(t.id):T(`/app/deals/${t.id}`)},children:e.jsx(ya,{className:"h-3 w-3"})})}),e.jsx(me,{side:"top",className:"text-xs",children:l("common.open")})]}),t.source_url&&Se(t.source_url)&&e.jsxs(de,{delayDuration:300,children:[e.jsx(ue,{asChild:!0,children:e.jsx(z,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:r=>{r.stopPropagation(),p==null||p(t.source_url)},children:e.jsx(xe,{className:"h-3 w-3"})})}),e.jsx(me,{side:"top",className:"text-xs",children:l("tooltip.actionViewAd")})]}),e.jsxs(de,{delayDuration:300,children:[e.jsx(ue,{asChild:!0,children:e.jsx("span",{children:e.jsx(os,{property:t,size:"sm",iconOnly:!0})})}),e.jsx(me,{side:"top",className:"text-xs",children:l("tooltip.actionContact")})]})]})})]})}),e.jsxs(ft,{children:[e.jsxs(se,{onClick:Tt,children:[e.jsx(xe,{className:"h-4 w-4 mr-2"})," ",l("property.openNewTab")||"Ãppna i ny flik"]}),t.source_url&&Se(t.source_url)&&e.jsxs(se,{onClick:()=>cs(t.source_url),children:[e.jsx(xe,{className:"h-4 w-4 mr-2"})," ",l("property.viewAd")||"Visa annons"]}),e.jsxs(se,{onClick:()=>f==null?void 0:f(t.id),children:[h?e.jsx(Ma,{className:"h-4 w-4 mr-2"}):e.jsx(ze,{className:"h-4 w-4 mr-2"}),h?l("common.deselect")||"Avmarkera":l("common.select")||"Markera"]})]})]})}function fr(){var A;const{id:t}=Pa(),a=Fe(),{t:s}=qe(),n=us(),{watchlists:o,update:p}=Ea(),{data:u=[]}=Ia(),{verdictMap:m,getVerdict:g}=Ua(u),{data:h}=za(),{data:f}=Fa(),{data:y=[]}=Va(),{data:v=[]}=Wa(),F=((A=u==null?void 0:u[0])==null?void 0:A.organization_id)||null,{data:k}=Ya(F),{data:_}=Za(null,F),P=o.find(c=>c.id===t),j=i.useMemo(()=>u.filter(c=>c.watchlist_id===t),[u,t]),D=i.useMemo(()=>j.map(c=>c.id),[j]),x=as({propertyIds:D}),R=i.useMemo(()=>{let c=0,E=0,d=0;return j.forEach(T=>{const l=m.get(T.id),q=(l==null?void 0:l.finalRoute)||(l==null?void 0:l.route);q==="pipeline"?c++:q==="review"?E++:q==="archive"&&d++}),{pass:c,review:E,reject:d,total:j.length}},[j,m]);return n.showWatchlists?P?e.jsxs(ka,{delayDuration:0,skipDelayDuration:300,children:[e.jsx(Da,{title:P.name,description:s("watchlists.results")}),e.jsxs("div",{className:"space-y-4 p-4 md:p-6 max-w-full mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a("/app/watchlists"),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h1",{className:"text-lg font-bold flex items-center gap-2 truncate",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary shrink-0"}),P.name]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:P.portals.map(c=>e.jsx(Be,{variant:"secondary",className:"text-xs",children:c},c))})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{label:s("watchlists.stats.total"),value:R.total,icon:Oe,color:"text-muted-foreground"},{label:s("watchlists.stats.pass"),value:R.pass,icon:Aa,color:"text-emerald-600"},{label:s("watchlists.stats.review"),value:R.review,icon:Ta,color:"text-amber-500"},{label:s("watchlists.stats.reject"),value:R.reject,icon:Sa,color:"text-destructive"}].map(c=>e.jsx(De,{className:"text-center",children:e.jsxs(Re,{className:"py-3 px-2",children:[e.jsx(c.icon,{className:N("h-4 w-4 mx-auto mb-1",c.color)}),e.jsx("div",{className:"text-lg font-bold",children:c.value}),e.jsx("div",{className:"text-xs text-muted-foreground",children:c.label})]})},c.label))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(z,{size:"sm",className:"gap-1.5",onClick:()=>a("/app/triage?queue=watchlist"),children:[e.jsx(Oa,{className:"h-3.5 w-3.5"})," ",s("watchlists.openTriage")]}),e.jsxs(z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>a("/app/properties"),children:[e.jsx(xs,{className:"h-3.5 w-3.5"})," ",s("watchlists.openList")]})]}
1),e.jsx(La,{watchlist:P,deals:j,verdictMap:m,onApply:c=>p.mutate({id:P.id,...c})}),e.jsx(ts,{activePanelId:x.activePanelId,onClosePanel:x.closePanel,onNavigate:x.navigate,hasPrev:x.hasPrev,hasNext:x.hasNext,children:j.length===0?e.jsx(De,{className:"border-dashed",children:e.jsx(Re,{className:"py-8 text-center text-sm text-muted-foreground",children:s("watchlists.noResults")})}):e.jsx("div",{className:"border rounded-lg bg-card overflow-x-auto",children:e.jsxs(Qa,{className:"table-fixed w-full",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-8"}),e.jsx("col",{className:"w-6"}),e.jsx("col",{className:"w-10"}),e.jsx("col",{className:x.isOpen?"w-20":"w-32"}),e.jsx("col",{className:"w-10"}),e.jsx("col",{className:"w-20"}),!x.isOpen&&e.jsx("col",{className:"w-16"}),!x.isOpen&&e.jsx("col",{className:"w-18"}),!x.isOpen&&e.jsx("col",{className:"w-22"}),!x.isOpen&&e.jsx("col",{className:"w-14"}),!x.isOpen&&e.jsx("col",{className:"w-20"}),!x.isOpen&&e.jsx("col",{className:"w-20"}),!x.isOpen&&e.jsx("col",{className:"w-20"})]}),e.jsx(Ja,{className:"sticky top-0 z-20 bg-card shadow-sm",children:e.jsxs(Ge,{className:"text-xs",children:[e.jsx(b,{className:"py-0.5 px-1 bg-card w-8"}),e.jsx(b,{className:"py-0.5 px-1 bg-card w-6",children:"#"}),e.jsx(b,{className:"py-0.5 px-0 bg-card w-10"}),e.jsx(b,{className:"py-0.5 px-1 bg-card",children:s("col.location")}),e.jsx(b,{className:"py-0.5 px-1 bg-card",children:s("col.score")||"Score"}),e.jsx(b,{className:"text-right py-0.5 px-1 bg-card",children:s("col.price")||"Price"}),!x.isOpen&&e.jsx(b,{className:"text-right py-0.5 px-1 bg-card",children:"â¬/m²"}),!x.isOpen&&e.jsx(b,{className:"text-right py-0.5 px-1 bg-card",children:s("col.roiIrr")||"ROI / IRR"}),!x.isOpen&&e.jsx(b,{className:"text-right py-0.5 px-1 bg-card",children:s("col.equityCarry")||"Equity"}),!x.isOpen&&e.jsx(b,{className:"py-0.5 px-1 bg-card",children:s("col.verdict")}),!x.isOpen&&e.jsx(b,{className:"py-0.5 px-1 bg-card",children:s("col.status")}),!x.isOpen&&e.jsx(b,{className:"py-0.5 px-1 bg-card",children:s("col.collection")}),!x.isOpen&&e.jsx(b,{className:"py-0.5 px-0 bg-card"})]})}),e.jsx(es,{children:j.map((c,E)=>{var T;const d=qa(f,c.municipality,c.district,c.urbanization);return e.jsx(on,{property:c,rank:E+1,areaAvgPricePerSqm:d==null?void 0:d.avg_price_per_sqm,areaMinPricePerSqm:d==null?void 0:d.min_price_per_sqm,areaMaxPricePerSqm:d==null?void 0:d.max_price_per_sqm,showLocationColumn:!0,onPropertyClick:l=>x.openPanel(l),isActive:x.activePanelId===c.id,aiScore:(h==null?void 0:h.find(l=>l.property_id===c.id))||null,collections:y,propertyCollectionIds:Xa(v,c.id),aiCollectionIds:v.filter(l=>l.property_id===c.id&&l.source==="ai").map(l=>l.collection_id),statusAgeDays:((T=k==null?void 0:k.get(c.id))==null?void 0:T.daysInStatus)??null,statusMedianDays:(_==null?void 0:_[c.status||"sourced"])??null,compact:x.isOpen,aiVerdict:m.get(c.id)||null},c.id)})})]})})})]})]}):e.jsx("div",{className:"p-6 text-center text-sm text-muted-foreground",children:s("watchlists.notFound")}):e.jsx("div",{className:"animate-fade-in p-6 lg:p-8 max-w-2xl mx-auto",children:e.jsx(ms,{featureName:s("premium.watchlists")||"Automated Deal Watchlists",variant:"overlay",children:e.jsx("div",{className:"h-64"})})})}export{fr 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.