PageSourceSearch

https://xynergy.ai/_next/static/chunks/6983.237ebbcdac63fc22.js

js xynergy.ai collected 2026-10-05 16:02:28 UTC 41,781 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6983],{6983:(e,s,a)=>{a.r(s),a.d(s,{EstateBeneficiaries:()=>eu,EstateDocuments:()=>ex,EstateTaxCalculator:()=>em});var t=a(85047),i=a(31615),n=a(18710),l=a(19548),r=a(21410),d=a(82520),c=a(18534),o=a(866),u=a(96968),m=a(21582),x=a(79705),h=a(38187),p=a(31917);let j=(0,a(46775).A)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);var f=a(42119),g=a(38410),v=a(54296),b=a(73521),N=a(41178),y=a(85084),C=a(61325),w=a(98553),T=a(69454);function Y({children:e}){let[s,a]=(0,i.useState)(null);return((0,i.useEffect)(()=>{a(document.getElementById("dbui-tools"))},[]),s)?(0,T.createPortal)(e,s):null}var I=a(47026),_=a(53855),W=a(56878),k=a(46136);function E(e){let{assets:s}=(0,W.d)(e),{policies:a}=(0,k.I5)(e),t=(0,i.useMemo)(()=>(s||[]).reduce((e,s)=>e+(0,I.A7)(s.value,s.currency),0),[s]),n=(0,i.useMemo)(()=>(a??[]).filter(e=>"life"===e.category).reduce((e,s)=>e+(0,_.J)(s),0),[a]),[r,d]=(0,i.useState)([]),[c,o]=(0,i.useState)({hasAdvanceDirective:!1,advanceDirectiveAnswers:null,hasGuardianshipMandate:!1,hasWill:!1,willList:[]}),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(0),p=(0,i.useCallback)(()=>{h(e=>e+1)},[]),j=(0,i.useCallback)(()=>{h(e=>e+1)},[]),f=(0,i.useCallback)(()=>{h(e=>e+1)},[]);return(0,i.useEffect)(()=>{if(!e)return;let s=!1;return m(!0),(async()=>{try{let a=await y.mK.hasAdvanceDirective(e),t=null;if(a){let s=await y.mK.getAdvanceDirective(e);t=s?.answers??null}let i=await y.sE.hasMandate(e),n=await C.b.hasWill(e),l=[];n&&(l=await C.b.getUserWills(e));let r=await y.MR.getBeneficiaries(e);if(s)return;o({hasAdvanceDirective:a,advanceDirectiveAnswers:t,hasGuardianshipMandate:i,hasWill:n,willList:l}),d(r??[])}catch(a){let s=a instanceof Error?a:Error(String(a));l.Cp(s,{level:"error",extra:{message:"載入遺產頁資料失敗",scope:"estate/useEstateDashboardData/load",userId:e},tags:{source:"useEstateDashboardData.load"}})}finally{s||m(!1)}})(),()=>{s=!0}},[e,x]),{assetsTotalYuan:t,lifeTotalInYuan:n,beneficiaryList:r,documents:c,loading:u,reloadAll:f,reloadDocuments:p,reloadBeneficiaries:j}}var A=a(15418);let S=A.Ik({estateTotal:A.ai().finite().min(0),deductionsTotal:A.ai().finite().min(0),exemptionsTotal:A.ai().finite().min(0),creditsTotal:A.ai().finite().min(0)}).strict();function D(e){return Number.isFinite(e)?Math.max(0,Math.round(e)):0}function M(e){let s,a=S.parse(e),t=D(a.estateTotal),i=D(a.deductionsTotal),n=D(a.exemptionsTotal),l=D(a.creditsTotal),r=Math.max(0,t-i-n),{computedTax:d,bracket:c}=(s=Math.max(0,r))<=5621e4?{computedTax:.1*s,bracket:"10%"}:s<=11242e4?{computedTax:5621e3+(s-5621e4)*.15,bracket:"15%"}:{computedTax:0xd66c94+(s-11242e4)*.2,bracket:"20%"},o=D(d),u=Math.max(0,o-l);return{estateTotal:t,deductionsTotal:i,exemptionsTotal:n,creditsTotal:l,taxableEstateNet:r,computedTax:o,payableTax:u,bracket:c}}let J=A.Ik({hasSpouse:A.zM(),linealHeirCount:A.ai().finite().int().min(0).max(10),underageExtraYears:A.ai().finite().int().min(0).max(60),disabledCount:A.ai().finite().int().min(0).max(10)}).strict(),V=A.Ik({debtDeduction:A.ai().finite().min(0),medicalDeduction:A.ai().finite().min(0),propertyDeduction:A.ai().finite().min(0)}).strict(),F=A.Yj().refine(e=>""===e||!Number.isNaN(Number(e))&&Number.isFinite(Number(e))&&Number(e)>=0,{message:"萬元輸入需為非負數或空字串"}),P=A.Ik({giftEstateValueIncludedWan:F,foreignEstateValueIncludedWan:F,giftTaxPaidWithin2YearsWan:F,landValueIncrementTaxPaidWithin2YearsWan:F,giftTaxInterestWithin2YearsWan:F,foreignEstateTaxPaidWan:F}).strict(),R=A.Ik({assetsYuan:A.ai().finite().min(0),beneficiariesCount:A.ai().finite().int().min(0),lifeTotalInYuan:A.ai().finite().min(0),exemptionInputs:J,deductionInputs:V,creditInputs:P}).strict();function B(e){let s=Number(e);return!Number.isFinite(s)||s<=0?0:Math.round(1e4*s)}function O(e){return M({estateTotal:e.estateTotalYuan,deductionsTotal:e.deductionsTotalYuan,exemptionsTotal:e.exemptionsTotalYuan,creditsTotal:0}).computedTax}var $=a(72287),z=a(34071),G=a(92788),L=a(26345),U=a(19726),q=a(37323),H=a(41819),Z=a(62557),K=a(35617);function Q(e){let{assetsYuan:s,beneficiariesCount:a,lifeTotalInYuan:n,isExemptionOpen:l,setIsExemptionOpen:c,hasS
1pouse:m,setHasSpouse:h,linealHeirCount:p,setLinealHeirCount:j,underageExtraYears:f,setUnderageExtraYears:g,disabledCount:v,setDisabledCount:b,exemptionTotalYuan:N,isDeductionOpen:y,setIsDeductionOpen:C,debtDeduction:w,setDebtDeduction:T,medicalDeduction:Y,setMedicalDeduction:I,propertyDeduction:_,setPropertyDeduction:W,deductionTotalYuan:k,isCreditOpen:E,setIsCreditOpen:A,credits:S,giftEstateValueIncludedWan:D,setGiftEstateValueIncludedWan:M,giftTaxPaidWithin2YearsWan:J,setGiftTaxPaidWithin2YearsWan:V,landValueIncrementTaxPaidWithin2YearsWan:F,setLandValueIncrementTaxPaidWithin2YearsWan:P,giftTaxInterestWithin2YearsWan:R,setGiftTaxInterestWithin2YearsWan:B,foreignEstateValueIncludedWan:O,setForeignEstateValueIncludedWan:Q,foreignEstateTaxPaidWan:X,setForeignEstateTaxPaidWan:ee,sanitizeWanInput:es,estateTaxBreakdown:ea,taxableEstateNetProgressPercent:et,perBeneficiaryYuan:ei,insuranceCoveragePercent:en}=e,el=(0,i.useMemo)(()=>`${et}%`,[et]);return(0,t.jsxs)(d.Zp,{children:[(0,t.jsxs)(d.aR,{children:[(0,t.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,t.jsx)($.A,{className:"h-5 w-5"}),"遺產稅試算器"]}),(0,t.jsx)(d.BT,{children:"調整以下參數來計算預估的遺產稅和每位受益人可獲得的金額"})]}),(0,t.jsxs)(d.Wu,{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"assets",children:"遺產總額"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(s)})]}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"此金額根據您的資產總值自動計算"})]}),(0,t.jsxs)(q.bL,{open:l,onOpenChange:c,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(u.J,{htmlFor:"exemption",children:"免稅額"}),(0,t.jsx)(H.Bc,{children:(0,t.jsx)(H.m_,{content:"包含基本免稅額及各項特殊扣除額",children:(0,t.jsx)("button",{className:"inline-flex items-center justify-center",children:(0,t.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground"})})})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(N)}),(0,t.jsx)(q.l9,{asChild:!0,children:(0,t.jsx)(r.$,{variant:"ghost",size:"sm",className:"w-9 p-0",children:l?(0,t.jsx)(G.A,{className:"h-4 w-4"}):(0,t.jsx)(L.A,{className:"h-4 w-4"})})})]})]}),(0,t.jsxs)(q.UC,{className:"space-y-4 mt-4",children:[(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(Z.S,{id:"hasSpouse",checked:m,onCheckedChange:e=>h(e)}
1),(0,t.jsx)(u.J,{htmlFor:"hasSpouse",children:"是否有配偶"})]})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"linealHeirCount",children:"直系血親卑親屬(繼承人)人數"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:[p," 位"]})]}),(0,t.jsx)(x.A,{id:"linealHeirCount",min:0,max:10,step:1,value:[p],onValueChange:e=>j(e[0]),className:"py-4"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"underageExtraYears",children:"未成年距成年年數合計"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:[f," 年"]})]}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:"依規定:每人每年加扣 56 萬(成年以 18 歲計;不滿 1 年以 1 年計)。"}),(0,t.jsx)(x.A,{id:"underageExtraYears",min:0,max:60,step:1,value:[f],onValueChange:e=>g(e[0]),className:"py-4"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"disabledCount",children:"身心障礙人數(重度以上)"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:[v," 位"]})]}),(0,t.jsx)(x.A,{id:"disabledCount",min:0,max:10,step:1,value:[v],onValueChange:e=>b(e[0]),className:"py-4"})]})]})]}),(0,t.jsxs)(q.bL,{open:y,onOpenChange:C,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(u.J,{htmlFor:"deduction",children:"扣除額"}),(0,t.jsx)(H.Bc,{children:(0,t.jsx)(H.m_,{content:"包含喪葬費、債務、醫療費用等扣除額",children:(0,t.jsx)("button",{className:"inline-flex items-center justify-center",children:(0,t.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground"})})})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(k)}),(0,t.jsx)(q.l9,{asChild:!0,children:(0,t.jsx)(r.$,{variant:"ghost",size:"sm",className:"w-9 p-0",children:y?(0,t.jsx)(G.A,{className:"h-4 w-4"}):(0,t.jsx)(L.A,{className:"h-4 w-4"})})})]})]}),(0,t.jsxs)(q.UC,{className:"space-y-4 mt-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"debtDeduction",children:"債務扣除額"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(w)})]}),(0,t.jsx)(x.A,{id:"debtDeduction",min:0,max:2e6,step:1e4,value:[w],onValueChange:e=>T(e[0]),className:"py-4"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"medicalDeduction",children:"醫療費用扣除額"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(Y)})]}),(0,t.jsx)(x.A,{id:"medicalDeduction",min:0,max:2e6,step:1e4,value:[Y],onValueChange:e=>I(e[0]),className:"py-4"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"propertyDeduction",children:"不計入遺產之財產"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(_)})]}),(0,t.jsx)(x.A,{id:"propertyDeduction",min:0,max:2e6,step:1e4,value:[_],onValueChange:e=>W(e[0]),className:"py-4"})]})]})]}),(0,t.jsxs)(q.bL,{open:E,onOpenChange:A,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(u.J,{htmlFor:"credits",children:"扣抵額"}),(0,t.jsx)(H.Bc,{children:(0,t.jsx)(H.m_,{content:"依法『遺產及贈與稅法第11條』:扣抵額不得超過『因併計該項財產而增加之應納稅額』。本試算器會依你填的「併計價額」自動套用上限。",children:(0,t.jsx)("button",{className:"inline-flex items-center justify-center",children:(0,t.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground"})})})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(S.totalCreditsAppliedYuan)}),(0,t.jsx)(q.l9,{asChild:!0,children:(0,t.jsx)(r.$,{variant:"ghost",size:"sm",className:"w-9 p-0",children:E?(0,t.jsx)(G.A,{className:"h-4 w-4"}):(0,t.jsx)(L.A,{className:"h-4 w-4"})})})]})]}
1),(0,t.jsxs)(q.UC,{className:"space-y-4 mt-4",children:[(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:"系統會分別計算「2 年內贈與」與「國外遺產」兩類扣抵上限(以你填的併計價額為準),並自動取較低者作為實際可扣抵額。"})}),(0,t.jsxs)("div",{className:"rounded-lg border p-4 space-y-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:"A. 死亡前 2 年內贈與(贈與稅/土增稅/利息)"}),(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-4",children:[(0,t.jsxs)("div",{className:"space-y-2 md:col-span-2",children:[(0,t.jsx)(u.J,{htmlFor:"giftEstateValueIncludedWan",children:"併計遺產總額之贈與財產價額(萬元)"}),(0,t.jsx)(o.p,{id:"giftEstateValueIncludedWan",type:"number",min:0,value:D,placeholder:"0",onChange:e=>es(e.target.value,M)})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(u.J,{htmlFor:"giftTaxPaidWithin2YearsWan",children:"已繳贈與稅(萬元)"}),(0,t.jsx)(o.p,{id:"giftTaxPaidWithin2YearsWan",type:"number",min:0,value:J,placeholder:"0",onChange:e=>es(e.target.value,V)})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(u.J,{htmlFor:"landValueIncrementTaxPaidWithin2YearsWan",children:"已繳土增稅(萬元)"}),(0,t.jsx)(o.p,{id:"landValueIncrementTaxPaidWithin2YearsWan",type:"number",min:0,value:F,placeholder:"0",onChange:e=>es(e.target.value,P)})]}),(0,t.jsxs)("div",{className:"space-y-2 md:col-span-2",children:[(0,t.jsx)(u.J,{htmlFor:"giftTaxInterestWithin2YearsWan",children:"利息(萬元,選填)"}),(0,t.jsx)(o.p,{id:"giftTaxInterestWithin2YearsWan",type:"number",min:0,value:R,placeholder:"0",onChange:e=>es(e.target.value,B)})]}),(0,t.jsxs)("div",{className:"md:col-span-2 rounded-md bg-muted/40 p-3 text-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"扣抵上限(增加之應納稅額)"}),(0,t.jsx)("span",{className:"font-medium",children:(0,K.C)(S.giftCreditCapYuan)})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"你輸入的扣抵合計"}),(0,t.jsx)("span",{className:"font-medium",children:(0,K.C)(S.giftCreditsRawYuan)})]}),(0,t.jsxs)("div",{className:"flex justify-between border-t pt-2",children:[(0,t.jsx)("span",{className:"font-medium",children:"實際可扣抵(套用上限)"}),(0,t.jsx)("span",{className:"font-semibold",children:(0,K.C)(S.giftCreditsAppliedYuan)})]})]})]})]}),(0,t.jsxs)("div",{className:"rounded-lg border p-4 space-y-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:"B. 國外已繳遺產稅"}),(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-4",children:[(0,t.jsxs)("div",{className:"space-y-2 md:col-span-2",children:[(0,t.jsx)(u.J,{htmlFor:"foreignEstateValueIncludedWan",children:"併計遺產總額之國外遺產價額(萬元)"}),(0,t.jsx)(o.p,{id:"foreignEstateValueIncludedWan",type:"number",min:0,value:O,placeholder:"0",onChange:e=>es(e.target.value,Q)})]}),(0,t.jsxs)("div",{className:"space-y-2 md:col-span-2",children:[(0,t.jsx)(u.J,{htmlFor:"foreignEstateTaxPaidWan",children:"在國外繳納之遺產稅(萬元)"}),(0,t.jsx)(o.p,{id:"foreignEstateTaxPaidWan",type:"number",min:0,value:X,placeholder:"0",onChange:e=>es(e.target.value,ee)})]}),(0,t.jsxs)("div",{className:"md:col-span-4 rounded-md bg-muted/40 p-3 text-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"扣抵上限(增加之應納稅額)"}),(0,t.jsx)("span",{className:"font-medium",children:(0,K.C)(S.foreignCreditCapYuan)})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"你輸入的扣抵"}),(0,t.jsx)("span",{className:"font-medium",children:(0,K.C)(S.foreignCreditsRawYuan)})]}),(0,t.jsxs)("div",{className:"flex justify-between border-t pt-2",children:[(0,t.jsx)("span",{className:"font-medium",children:"實際可扣抵(套用上限)"}),(0,t.jsx)("span",{className:"font-semibold",children:(0,K.C)(S.foreignCreditsAppliedYuan)})]})]})]})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"taxable-estate",children:"課稅遺產淨額"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,K.C)(ea.taxableEstateNet)})]}),(0,t.jsx)("div",{className:"h-2 w-full rounded-full bg-secondary",children:(0,t.jsx)("div",{className:"h-2 rounded-full bg-primary",style:{width:el}})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"beneficiaries",children:"受益人數量"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:[a," 位"]})]}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"此數值根據已新增的受益人數量自動計算"})]})]}),(0,t.jsxs)(d.wL,{className:"flex-col items-start border-t p-6 space-y-4",children:[(0,t.jsxs)("div",{className:"grid w-full gap-2 md:grid-cols-3",children:[(0,t.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"預估遺產稅"}),(0,t.jsx)("div",{className:"text-2xl font-bold",children:(0,K.C)(ea.payableTax)}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:["計算稅額 ",(0,K.C)(ea.computedTax),"(",ea.bracket,")- 扣抵"," ",(0,K.C)(ea.creditsTotal)]})]}),(0,t.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"每位受益人可獲得"}),(0,t.jsx)("div",{className:"text-2xl font-bold",children:(0,K.C)(ei)})]}),(0,t.jsxs)("div",{className:`rounded-lg border p-3 ${en>=100?"bg-amber-400 shadow-[0_0_15px_rgba(234,179,8,0.5)]":""}`,children:[(0,t.jsxs)("div",{className:`text-sm font-medium flex items-center ${en>=100?"text-amber-900":"text-muted-foreground"}`,children:[(0,t.jsx)(U.A,{className:"h-4 w-4 mr-1 text-blue-500"}),"預留稅源 (壽險保額)"]}),(0,t.jsx)("div",{className:"text-2xl font-bold",children:(0,K.C)(n)}),(0,t.jsxs)("div",{className:"text-xs text-blue-500 mt-1",children:[en,"% 的遺產稅覆蓋率"]})]})]}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"此計算機根據台灣現行遺產稅法計算,包含免稅額、扣除額和累進稅率。實際稅額可能因特殊情況而有所不同,建議諮詢專業稅務顧問。壽險保額可作為預留稅源,幫助受益人支付遺產稅,避免變賣資產。"})})]})]})}function X(e){let{hasWill:s,willListLength:a,onOpenWillGenerator:i,hasAdvanceDirective:n,onOpenAdvanceDirective:l,hasGuardianshipMandate:c,onOpenGuardianship:o}=e;return(0,t.jsxs)(d.Zp,{children:[(0,t.jsxs)(d.aR,{children:[(0,t.jsx)(d.ZB,{children:"遺產文件"}),(0,t.jsx)(d.BT,{children:"管理您的遺囑、授權書和其他重要法律文件"})]}),(0,t.jsx)(d.Wu,{className:"p-0",children:(0,t.jsxs)("div",{className:"divide-y",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("div",{className:"font-medium",children:"遺囑產生器"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:s?`已儲存 ${a} 份遺囑`:"尚未建立遺囑"})]}),(0,t.jsx)(r.$,{variant:"outline",size:"sm",onClick:i,children:s?"管理":"使用"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("div",{className:"font-medium",children:"預立醫療決定書"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:n?"已完成":"尚未填寫"})]}),(0,t.jsx)(r.$,{variant:"outline",size:"sm",onClick:l,children:n?"查看":"填寫"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("div",{className:"font-medium",children:"意定監護契約"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:c?"已完成":"尚未填寫"})]}),(0,t.jsx)(r.$,{variant:"outline",size:"sm",onClick:o,children:c?"查看":"填寫"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("div",{className:"font-medium",children:"財產清單"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"最後更新: 2025/02/05"})]}),(0,t.jsx)(r.$,{variant:"outline",size:"sm",children:"查看"})]})]})})]})}var ee=a(35435);let es="decedent",ea=[{value:"spouse",label:"配偶"},{value:"child",label:"子女"},{value:"grandchild",label:"孫子女"},{value:"parent",label:"父母"},{value:"grandparent",label:"祖父母"},{value:"sibling",label:"兄弟姊妹"},{value:"legal",label:"法定受益人"},{value:"other",label:"其他"}];function et(e){return Array.from(new Set(e.filter(e=>!!(e&&e.trim()))))}function ei(e,s,a=[]){let t=e.pedigree?.gender??"unknown",i=e.pedigree?.chartOnly===!0,n=(e.pedigree?.parentIds??[]).filter(e=>e!==es),l=e.pedigree?.spouseId??null,r=[...n];switch(l===es&&(l=null),s){case"spouse":l=es,r=n;break;case"child":r=et([es,...n]);break;case"grandchild":{let e=a.find(e=>"child"===e.type&&e.id);r=e?.id?et([e.id,...n.filter(s=>s!==e.id)]):n;break}case"sibling":{let e=a.filter(e=>"parent"===e.type&&e.id).slice(0,2);r=e.length>0?e.map(e=>e.id):n;break}case"parent":case"grandparent":case"legal":case"other":r=n}return{...e,type:s,relationship:"other"===s?e.relationship:"",pedigree:{...e.pedigree,gender:t,chartOnly:i,spouseId:l,parentIds:r}}}let en=(0,n.default)(()=>Promise.all([a.e(5193),a.e(5116),a.e(8045),a.e(270)]).then(a.bind(a,30270)),{loadableGenerated:{webpack:()=>[30270]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"rounded-lg border p-10 text-center text-sm text-muted-foreground",children:"載入家族圖譜…"})}),el=(0,n.default)(()=>a.e(9192).then(a.bind(a,89192)),{loadableGenerated:{webpack:()=>[89192]},ssr:!1}),er=(0,n.default)(()=>a.e(8178).then(a.bind(a,68178)),{loadableGenerated:{webpack:()=>[68178]},ssr:!1}),ed=(0,n.default)(()=>a.e(8080).then(a.bind(a,18080)),{loadableGenerated:{webpack:()=>[18080]},ssr:!1}),ec=(0,n.default)(()=>a.e(7831).then(a.bind(a,212)),{loadableGenerated:{webpack:()=>[212]},ssr:!1}),eo=ei({id:void 0,name:"",type:"spouse",relationship:"",distributionRatio:0,notes:"",pedigree:{gender:"unknown",parentIds:[],spouseId:null,chartOnly:!1}},"spouse");function eu(){let{toast:e}=(0,N.dj)(),{user:s}=(0,b.A)(),a=s?.uid,{beneficiaryList:n}=E(a),[d,C]=(0,i.useState)([]),[T,I]=(0,i.useState)(null),[_,W]=(0,i.useState)(!1),[k,A]=(0,i.useState)(eo),[S,D]=(0,i.useState)("table");(0,i.useEffect)(()=>{let{list:e,changed:s}=(0,w.o8)(n);C(e),s&&a&&e.length>0&&y.MR.updateBeneficiaries(a,e)},[n,a]);let M=(0,i.useCallback)(async s=>{if(a)try{let{list:e}=(0,w.o8)(s);await y.MR.updateBeneficiaries(a,e),C(e)}catch(t){let s=t instanceof Error?t:Error(String(t));l.Cp(s,{level:"error",extra:{message:"儲存受益人列表失敗",scope:"dbui/estate/beneficiaries",userId:a},tags:{source:"EstateBeneficiaries.save"}}),e({title:"儲存失敗",description:"無法儲存受益人資料,請稍後再試",variant:"destructive"})}},[e,a]),J=(0,i.useCallback)(async()=>
1{if(!k.name.trim())return void e({title:"請填寫必要欄位",description:"姓名為必填項目",variant:"destructive"});if("spouse"===k.type&&d.some(e=>"spouse"===e.type))return void e({title:"無法新增",description:"配偶只能有一位",variant:"destructive"});if(d.reduce((e,s)=>e+s.distributionRatio,0)+k.distributionRatio>100)return void e({title:"分配比例過高",description:"總分配比例不能超過100%",variant:"destructive"});let s={...k,id:"u">typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`b-${Date.now()}`},a=[...d,s];C(a),await M(a),A(eo),W(!1),I(null),e({title:"新增成功",description:`已新增受益人:${s.name}`})},[d,k,M,e]),V=(0,i.useCallback)((e,s)=>{I(s),A({...e,pedigree:e.pedigree??{gender:"unknown",parentIds:[],spouseId:null,chartOnly:!1}}),W(!0)},[]),F=(0,i.useCallback)(async()=>{if(!k.name.trim())return void e({title:"請填寫必要欄位",description:"姓名為必填項目",variant:"destructive"});if(null===T)return;if("spouse"===k.type&&d.some((e,s)=>"spouse"===e.type&&s!==T))return void e({title:"無法更新",description:"配偶只能有一位",variant:"destructive"});if(d.reduce((e,s,a)=>a===T?e:e+s.distributionRatio,0)+k.distributionRatio>100)return void e({title:"分配比例過高",description:"總分配比例不能超過100%",variant:"destructive"});let s=[...d];s[T]={...k,id:k.id||d[T]?.id},C(s),await M(s),A(eo),I(null),W(!1),e({title:"更新成功",description:`已更新受益人:${k.name}`})},[d,T,k,M,e]),P=(0,i.useCallback)(async s=>{let a=d[s],t=d.filter((e,a)=>a!==s);C(t),await M(t),e({title:"已刪除受益人",description:`已移除受益人:${a?.name??""}`})},[d,M,e]),R=s?.displayName||s?.email?.split("@")[0]||"您",B=Math.max(1,100-d.reduce((e,s,a)=>a===T?e:e+s.distributionRatio,0)),O=e=>{let s,a={...k,pedigree:{...k.pedigree,...e}};A((s=function(e,s){let a=e.pedigree?.spouseId,t=e.pedigree?.parentIds??[];if(a===es)return"spouse";if(t.includes(es))return"child";let i=t.map(e=>s.find(s=>s.id===e)).filter(e=>!!e);if(i.length>0&&i.every(e=>"child"===e.type||(e.pedigree?.parentIds??[]).includes(es)))return"grandchild";let n=s.filter(e=>"parent"===e.type);return n.length>0&&t.length>0&&t.every(e=>n.some(s=>s.id===e))&&"sibling"===e.type?"sibling":e.type}(a,d.filter((e,s)=>s!==T)))===a.type?a:{...a,type:s,relationship:"other"===s?a.relationship:""})},$=()=>{W(!1),I(null),A(eo)},z=e=>`flex items-center gap-1.5 rounded px-2.5 py-1 transition-colors ${e?"bg-accent/15 font-semibold text-accent":"text-muted-foreground hover:text-foreground"}`;return(0,t.jsxs)("div",{children:[(0,t.jsx)(Y,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"inline-flex rounded-md border p-0.5 text-[12.5px]",children:[(0,t.jsxs)("button",{onClick:()=>D("table"),className:z("table"===S),children:[(0,t.jsx)(p.A,{className:"h-3.5 w-3.5"}),"表格"]}),(0,t.jsxs)("button",{onClick:()=>D("tree"),className:z("tree"===S),children:[(0,t.jsx)(j,{className:"h-3.5 w-3.5"}),"家族圖譜"]})]}),(0,t.jsxs)("button",{onClick:()=>{I(null),A(eo),W(!0)},className:"inline-flex items-center gap-1 rounded-md bg-primary px-3 py-1.5 text-[12.5px] font-semibold text-primary-foreground transition-opacity hover:opacity-90",children:[(0,t.jsx)(f.A,{className:"h-3.5 w-3.5"}),"新增"]})]})}),"tree"===S?(0,t.jsx)(en,{beneficiaries:d,userName:R,onEdit:V,onDelete:P}):0===d.length?(0,t.jsx)("div",{className:"rounded-lg border border-dashed p-10 text-center text-sm text-muted-foreground",children:"尚無受益人,點右上「新增」開始"}):(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,t.jsxs)("table",{className:"w-full text-[13px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b text-left text-muted-foreground",children:[(0,t.jsx)("th",{className:"px-4 py-2.5 font-medium",children:"受益人"}),(0,t.jsx)("th",{className:"px-4 py-2.5 font-medium",children:"關係"}),(0,t.jsx)("th",{className:"px-4 py-2.5 text-right font-medium",children:"分配比例"}),(0,t.jsx)("th",{className:"px-4 py-2.5 font-medium",children:"備註"}),(0,t.jsx)("th",{className:"px-4 py-2.5"})]})}),(0,t.jsx)("tbody",{children:d.map((e,s)=>{let a,i;return(0,t.jsxs)("tr",{className:"border-b last:border-0 hover:bg-muted/40",children:[(0,t.jsx)("td",{className:"px-4 py-2.5 font-medium",children:e.name}),(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsx)(h.E,{variant:"secondary",className:"font-normal",children:(a=e.type,i=e.relationship,(0,ee.qM)(a,i))})}),(0,t.jsxs)("td",{className:"px-4 py-2.5 text-right tabular-nums",children:[e.distributionRatio,"%"]}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-muted-foreground",children:e.notes||"—"}),(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,t.jsx)("button",{onClick:()=>V(e,s),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"編輯",children:(0,t.jsx)(g.A,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{onClick:()=>P(s),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-red-500","aria-label":"刪除",children:(0,t.jsx)(v.A,{className:"h-3.5 w-3.5"})})]})})]},e.id??s)})})]})}),(0,t.jsx)(c.lG,{open:_,onOpenChange:e=>e?W(!0):$(),children:(0,t.jsxs)(c.Cf,{children:[(0,t.jsxs)(c.c7,{children:[(0,t.jsx)(c.L3,{children:null!==T?"編輯受益人":"新增受益人"}),(0,t.jsx)(c.rr,{children:"請填寫受益人資料和分配比例"})]}),(0,t.jsxs)("div",{className:"grid gap-4 py-2",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{htmlFor:"b-name",children:"姓名"}),(0,t.jsx)(o.p,{id:"b-name",value:k.name,onChange:e=>A({...k,name:e.target.value}),placeholder:"請輸入受益人姓名"})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)(u.J,{htmlFor:"b-ratio",children:"分配比例"}),(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:[k.distributionRatio,"%(可分配上限 ",B,"%)"]})]}),(0,t.jsx)(x.A,{id:"b-ratio",min:0,max:B,step:1,value:[k.distributionRatio],onValueChange:e=>A({...k,distributionRatio:e[0]??0})})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{htmlFor:"b-notes",children:"備註"}),(0,t.jsx)(o.p,{id:"b-notes",value:k.notes,onChange:e=>A({...k,notes:e.target.value}),placeholder:"可選填"})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{children:"家族圖譜"}),(0,t.jsxs)("div",{className:"grid gap-3 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",htmlFor:"b-kinship",children:"與本人"}),(0,t.jsxs)(m.l6,{value:k.type,onValueChange:e=>{A(ei(k,e,d.filter((e,s)=>s!==T)))},children:[(0,t.jsx)(m.bq,{id:"b-kinship",children:(0,t.jsx)(m.yv,{placeholder:"選擇與本人的連結"})}),(0,t.jsx)(m.gC,{children:ea.map(e=>(0,t.jsx)(m.eb,{value:e.value,children:e.label},e.value))})]})]}),"other"===k.type&&(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",htmlFor:"b-rel",children:"具體稱呼"}),(0,t.jsx)(o.p,{id:"b-rel",value:k.relationship,onChange:e=>A({...k,relationship:e.target.value}
1),placeholder:"例如:表哥、乾爹"})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"性別"}),(0,t.jsxs)(m.l6,{value:k.pedigree?.gender??"unknown",onValueChange:e=>O({gender:e}),children:[(0,t.jsx)(m.bq,{children:(0,t.jsx)(m.yv,{})}),(0,t.jsxs)(m.gC,{children:[(0,t.jsx)(m.eb,{value:"unknown",children:"未指定"}),(0,t.jsx)(m.eb,{value:"male",children:"男"}),(0,t.jsx)(m.eb,{value:"female",children:"女"})]})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"配偶連結"}),(0,t.jsxs)(m.l6,{value:k.pedigree?.spouseId??"__none__",onValueChange:e=>O({spouseId:"__none__"===e?null:"__decedent__"===e?"decedent":e}),children:[(0,t.jsx)(m.bq,{children:(0,t.jsx)(m.yv,{placeholder:"無"})}),(0,t.jsxs)(m.gC,{children:[(0,t.jsx)(m.eb,{value:"__none__",children:"無"}),(0,t.jsx)(m.eb,{value:"__decedent__",children:"本人"}),d.filter((e,s)=>e.id&&s!==T).map(e=>(0,t.jsx)(m.eb,{value:e.id,children:e.name},e.id))]})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"父母 1"}),(0,t.jsxs)(m.l6,{value:k.pedigree?.parentIds?.[0]??"__none__",onValueChange:e=>{O({parentIds:["__none__"===e?void 0:"__decedent__"===e?"decedent":e,k.pedigree?.parentIds?.[1]].filter(Boolean)})},children:[(0,t.jsx)(m.bq,{children:(0,t.jsx)(m.yv,{placeholder:"無"})}),(0,t.jsxs)(m.gC,{children:[(0,t.jsx)(m.eb,{value:"__none__",children:"無"}),(0,t.jsx)(m.eb,{value:"__decedent__",children:"本人"}),d.filter((e,s)=>e.id&&s!==T).map(e=>(0,t.jsx)(m.eb,{value:e.id,children:e.name},e.id))]})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"父母 2"}),(0,t.jsxs)(m.l6,{value:k.pedigree?.parentIds?.[1]??"__none__",onValueChange:e=>{O({parentIds:[k.pedigree?.parentIds?.[0],"__none__"===e?void 0:"__decedent__"===e?"decedent":e].filter(Boolean)})},children:[(0,t.jsx)(m.bq,{children:(0,t.jsx)(m.yv,{placeholder:"無"})}),(0,t.jsxs)(m.gC,{children:[(0,t.jsx)(m.eb,{value:"__none__",children:"無"}),(0,t.jsx)(m.eb,{value:"__decedent__",children:"本人"}),d.filter((e,s)=>e.id&&s!==T).map(e=>(0,t.jsx)(m.eb,{value:e.id,children:e.name},e.id))]})]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:k.pedigree?.chartOnly===!0,onChange:e=>A({...k,pedigree:{...k.pedigree,chartOnly:e.target.checked},distributionRatio:e.target.checked?0:k.distributionRatio})}),"僅顯示於圖譜(不參與分配)"]})]})]})]}),(0,t.jsxs)(c.Es,{children:[(0,t.jsx)(r.$,{variant:"outline",onClick:$,children:"取消"}),(0,t.jsx)(r.$,{onClick:null!==T?F:J,children:null!==T?"確認更新":"確認新增"})]})]})})]})}function em(){let{user:e}=(0,b.A)(),{assetsTotalYuan:s,lifeTotalInYuan:a,beneficiaryList:n}=E(e?.uid),l=n.length,[r,d]=(0,i.useState)(!1),[c,o]=(0,i.useState)(!1),[u,m]=(0,i.useState)(0),[x,h]=(0,i.useState)(0),[p,j]=(0,i.useState)(0),[f,g]=(0,i.useState)(!1),[v,N]=(0,i.useState)(0),[y,C]=(0,i.useState)(0),[w,T]=(0,i.useState)(0),[Y,I]=(0,i.useState)(!1),[_,W]=(0,i.useState)(""),[k,A]=(0,i.useState)(""),[S,D]=(0,i.useState)(""),[F,$]=(0,i.useState)(""),[z,G]=(0,i.useState)(""),[L,U]=(0,i.useState)(""),q=(0,i.useCallback)((e,s)=>{if(""===e)return s("");let a=Number(e);Number.isNaN(a)||s(Math.max(0,a).toString())},[]),{exemptionTotalYuan:H,deductionTotalYuan:Z,credits:K,estateTaxBreakdown:X,perBeneficiaryYuan:ee,insuranceCoveragePercent:es,taxableEstateNetProgressPercent:ea}=(0,i.useMemo)(()=>{var e,t,i,n;let r,d,o,m,h,j,f,g,b,N,C,T,Y,I,W,E,A,D,$,G,U,q,H,Z;return e={assetsYuan:s,beneficiariesCount:l,lifeTotalInYuan:a,exemptionInputs:{hasSpouse:c,linealHeirCount:u,underageExtraYears:x,disabledCount:p},deductionInputs:{debtDeduction:v,medicalDeduction:y,propertyDeduction:w},creditInputs:{giftEstateValueIncludedWan:z,foreignEstateValueIncludedWan:L,giftTaxPaidWithin2YearsWan:_,landValueIncrementTaxPaidWithin2YearsWan:k,giftTaxInterestWithin2YearsWan:S,foreignEstateTaxPaidWan:F}},t=(r=R.parse(e)).exemptionInputs,o=1333e4+553e4*!!(d=J.parse(t)).hasSpouse+56e4*d.linealHeirCount+56e4*d.underageExtraYears+693e4*d.disabledCount,i=r.deductionInputs,h=Math.max(0,Math.round(138e4+(m=V.parse(i)).debtDeduction+m.medicalDeduction+m.propertyDeduction)),n={assetsYuan:r.assetsYuan,deductionsTotalYuan:h,exemptionsTotalYuan:o,creditInputs:r.creditInputs},f=B((j=P.parse(n.creditInputs)).giftEstateValueIncludedWan),g=B(j.foreignEstateValueIncludedWan),b=O({estateTotalYuan:n.assetsYuan+f+g,deductionsTotalYuan:n.deductionsTotalYuan,exemptionsTotalYuan:n.exemptionsTotalYuan}),N=O({estateTotalYuan:n.assetsYuan+g,deductionsTotalYuan:n.deductionsTotalYuan,exemptionsTotalYuan:n.exemptionsTotalYuan}),C=O({estateTotalYuan:n.assetsYuan+f,deductionsTotalYuan:n.deductionsTotalYuan,exemptionsTotalYuan:n.exemptionsTotalYuan}),T=Math.max(0,b-N),Y=Math.max(0,b-C),I=B(j.giftTaxPaidWithin2YearsWan)+B(j.landValueIncrementTaxPaidWithin2YearsWan)+B(j.giftTaxInterestWithin2YearsWan),W=B(j.foreignEstateTaxPaidWan),E=Math.min(I,T),A=Math.min(W,Y),D={giftCredit
1CapYuan:T,foreignCreditCapYuan:Y,giftCreditsRawYuan:I,foreignCreditsRawYuan:W,giftCreditsAppliedYuan:E,foreignCreditsAppliedYuan:A,totalCreditsAppliedYuan:E+A},$=M({estateTotal:r.assetsYuan,deductionsTotal:h,exemptionsTotal:o,creditsTotal:D.totalCreditsAppliedYuan}),U=(G=Math.max(0,r.assetsYuan-h-o))>0?Math.max(0,G-$.payableTax):0,q=r.beneficiariesCount>0?Math.round(U/r.beneficiariesCount):0,H=$.payableTax>0?Number((r.lifeTotalInYuan/$.payableTax*100).toFixed(1)):0,Z=Math.min(100,Math.max(0,$.taxableEstateNet/11242e4*100)),{exemptionTotalYuan:o,deductionTotalYuan:h,credits:D,estateTaxBreakdown:$,netEstateYuan:G,perBeneficiaryYuan:q,insuranceCoveragePercent:H,taxableEstateNetProgressPercent:Z}},[s,l,a,c,u,x,p,v,y,w,z,L,_,k,S,F]);return(0,t.jsx)(Q,{assetsYuan:s,beneficiariesCount:l,lifeTotalInYuan:a,isExemptionOpen:r,setIsExemptionOpen:d,hasSpouse:c,setHasSpouse:o,linealHeirCount:u,setLinealHeirCount:m,underageExtraYears:x,setUnderageExtraYears:h,disabledCount:p,setDisabledCount:j,exemptionTotalYuan:H,isDeductionOpen:f,setIsDeductionOpen:g,debtDeduction:v,setDebtDeduction:N,medicalDeduction:y,setMedicalDeduction:C,propertyDeduction:w,setPropertyDeduction:T,deductionTotalYuan:Z,isCreditOpen:Y,setIsCreditOpen:I,credits:K,giftEstateValueIncludedWan:z,setGiftEstateValueIncludedWan:G,giftTaxPaidWithin2YearsWan:_,setGiftTaxPaidWithin2YearsWan:W,landValueIncrementTaxPaidWithin2YearsWan:k,setLandValueIncrementTaxPaidWithin2YearsWan:A,giftTaxInterestWithin2YearsWan:S,setGiftTaxInterestWithin2YearsWan:D,foreignEstateValueIncludedWan:L,setForeignEstateValueIncludedWan:U,foreignEstateTaxPaidWan:F,setForeignEstateTaxPaidWan:$,sanitizeWanInput:q,estateTaxBreakdown:X,taxableEstateNetProgressPercent:ea,perBeneficiaryYuan:ee,insuranceCoveragePercent:es})}function ex(){let{toast:e}=(0,N.dj)(),{user:s}=(0,b.A)(),a=s?.uid,{beneficiaryList:n,documents:o,reloadDocuments:u}=E(a),[m,x]=(0,i.useState)(!1),[h,p]=(0,i.useState)(!1),[j,f]=(0,i.useState)(!1),[g,v]=(0,i.useState)(null),y=o.willList;return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(X,{hasWill:o.hasWill,willListLength:y.length,onOpenWillGenerator:()=>{v(null),f(!0)},hasAdvanceDirective:o.hasAdvanceDirective,onOpenAdvanceDirective:()=>x(!0),hasGuardianshipMandate:o.hasGuardianshipMandate,onOpenGuardianship:()=>p(!0)}),(0,t.jsx)(c.lG,{open:m,onOpenChange:x,children:(0,t.jsxs)(c.Cf,{className:"max-w-6xl max-h-[90vh] overflow-y-auto",children:[(0,t.jsxs)(c.c7,{children:[(0,t.jsx)(c.L3,{children:"預立醫療決定書"}),(0,t.jsx)(c.rr,{children:"請針對每種臨床條件,選擇您的醫療照護意願。完成後需經過預立醫療照護諮商並辦理見證或公證,才能正式生效。"})]}),(0,t.jsx)(el,{userId:a,onComplete:()=>{x(!1),e({title:"預立醫療決定書已完成",description:"您的醫療照護意願已成功儲存到資料庫"}),u()}})]})}),(0,t.jsx)(c.lG,{open:h,onOpenChange:p,children:(0,t.jsxs)(c.Cf,{className:"max-w-4xl max-h-[90vh] overflow-y-auto scrollbar-hide",children:[(0,t.jsxs)(c.c7,{children:[(0,t.jsx)(c.L3,{children:"意定監護契約"}),(0,t.jsx)(c.rr,{children:"填寫並儲存您指定監護人的相關資訊與授權範圍。此契約需經公證人公證,並向法院聲請選定監護人後才能生效。"})]}),(0,t.jsx)(er,{userId:a,onComplete:()=>{p(!1),e({title:"意定監護已儲存",description:"您的意定監護資料已成功儲存到資料庫"}),u()}})]})}),j&&!g&&(0,t.jsx)(ed,{existingBeneficiaries:n.map(e=>({name:e.name,type:e.type,relationship:"other"===e.type&&e.relationship||"",distributionRatio:e.distributionRatio})),onSave:()=>{f(!1),v(null),u()},onClose:()=>f(!1)}),g&&(0,t.jsx)(ec,{will:g,onSave:()=>{v(null),f(!0),u()},onClose:()=>{v(null),f(!0)}}),j&&!g&&y.length>0&&(0,t.jsxs)(d.Zp,{children:[(0,t.jsx)(d.aR,{children:(0,t.jsx)(d.ZB,{children:"已儲存的遺囑"})}),(0,t.jsx)(d.Wu,{children:(0,t.jsx)("div",{className:"space-y-2",children:y.map(s=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-lg border p-3 hover:bg-muted/50",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:s.title}),(0,t.jsxs)("div",{className:"text-sm text-muted-foreground",children:["最後更新: ",s.updatedAt.toDate().toLocaleDateString("zh-TW")]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(r.$,{variant:"outline",size:"sm",onClick:()=>{v(s),f(!1)},children:"編輯"}),(0,t.jsx)(r.$,{variant:"ghost",size:"sm",onClick:async()=>
1{if(s.id&&confirm("確定要刪除此遺囑嗎?"))try{await C.b.deleteWill(s.id),e({title:"刪除成功",description:"遺囑已刪除"}),u()}catch(t){let s=t instanceof Error?t:Error(String(t));l.Cp(s,{level:"error",extra:{message:"刪除遺囑失敗",scope:"dbui/estate/wills",userId:a},tags:{source:"EstateDocuments.deleteWill"}}),e({title:"刪除失敗",description:s.message||"無法刪除遺囑",variant:"destructive"})}},children:"刪除"})]})]},s.id))})})]})]})}},35435:(e,s,a)=>{a.d(s,{Me:()=>t,qM:()=>i});let t=[{value:"spouse",label:"配偶"},{value:"child",label:"子女"},{value:"grandchild",label:"孫子女"},{value:"parent",label:"父母"},{value:"grandparent",label:"祖父母"},{value:"sibling",label:"兄弟姊妹"},{value:"legal",label:"法定受益人"},{value:"other",label:"其他"}];function i(e,s){return"other"===e&&s?s:t.find(s=>s.value===e)?.label??e}},38410:(e,s,a)=>{a.d(s,{A:()=>t});let t=(0,a(46775).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},53855:(e,s,a)=>{a.d(s,{J:()=>i});var t=a(47026);function i(e){let s,a=e?.coverage;if(null==a||"number"!=typeof a||a<0)return 0;if(a>=1e3)return Math.round(a);let i=1e4*a,n=null==(s=e.premiumCurrency)||"string"!=typeof s||""===s.trim()?"twd":(0,t.WC)(s);return"twd"===n?Math.round(i):Math.round((0,t.A7)(i,n))}}}]);

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.