PageSourceSearch

https://xynergy.ai/_next/static/chunks/6299-41324a0ca98119f7.js

js xynergy.ai collected 2026-10-05 16:01:44 UTC 24,731 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6299],{27280:(e,t,r)=>{r.d(t,{C:()=>a});class a{charts=new Map;status=new Map;cache=new Map;CACHE_DURATION=3e5;constructor(){this.initializeDefaultCharts()}initializeDefaultCharts(){[{key:"assetsChart",title:"資產分佈",priority:1,enabled:!1,category:"financial"},{key:"assetDistributionChart",title:"資產分布",priority:2,enabled:!1,category:"financial"},{key:"assetLiabilityTrendChart",title:"資產負債趨勢",priority:3,enabled:!1,category:"financial"},{key:"liabilitiesChart",title:"負債分佈",priority:4,enabled:!1,category:"financial"},{key:"netWorthChart",title:"淨值趨勢",priority:5,enabled:!1,category:"financial"},{key:"netWorthGrowthChart",title:"淨值成長",priority:6,enabled:!1,category:"financial"},{key:"incomeExpenseTrendChart",title:"收入支出趨勢",priority:7,enabled:!1,category:"financial"},{key:"incomeTrendChart",title:"每月收入趨勢",priority:8,enabled:!1,category:"financial"},{key:"expenseTrendChart",title:"每月支出趨勢",priority:9,enabled:!1,category:"financial"},{key:"insuranceLifeChart",title:"壽險保額分佈",priority:10,enabled:!1,category:"insurance"},{key:"insurancePremiumProjectionChart",title:"未來保費走勢",priority:11,enabled:!1,category:"insurance"},{key:"insuranceMedicalChart",title:"醫療險保額分佈",priority:12,enabled:!1,category:"insurance"},{key:"retirementSuccessChart",title:"退休成功率",priority:13,enabled:!1,category:"retirement"},{key:"retirementCashFlowChart",title:"退休現金流",priority:14,enabled:!1,category:"retirement"},{key:"retirementNetWorthChart",title:"退休淨值",priority:15,enabled:!1,category:"retirement"}].forEach(e=>{this.charts.set(e.key,e),this.status.set(e.key,{isLoaded:!1,hasData:!1,hasExport:!1,lastChecked:0})})}getCharts(){return Array.from(this.charts.values()).sort((e,t)=>e.priority-t.priority)}getChartsByCategory(e){return this.getCharts().filter(t=>t.category===e)}updateChartConfig(e,t){let r=this.charts.get(e);r&&(this.charts.set(e,{...r,...t}),this.cache.delete(e))}updateAllCharts(e){this.charts.forEach((t,r)=>{this.charts.set(r,{...t,enabled:e})}),this.cache.clear()}async checkChartStatus(e){let t=Date.now(),r=this.status.get(e);if(r&&t-r.lastChecked<this.CACHE_DURATION)return r;try{let r,a=null,i=0;for(;i<4&&!((a=window[e])&&a.container&&a.container.querySelector("svg"));)await new Promise(e=>setTimeout(e,500)),i++;let s=!0===window[`${e}HasData`],n=!1,l=!1;if(a){n=!0;let e=a.container&&a.container.querySelector("svg"),t="function"==typeof a.getSVG;l=e&&t,e?t||(r="圖表缺少 getSVG 方法"):r="圖表容器或 SVG 元素不存在"}else r="圖表實例不存在";let o={isLoaded:n,hasData:s,hasExport:l,lastChecked:t,error:r};return this.status.set(e,o),o}catch(a){let r={isLoaded:!1,hasData:!1,hasExport:!1,lastChecked:t,error:a instanceof Error?a.message:String(a)};return this.status.set(e,r),r}}async checkAllChartsStatus(){let e=Array.from(this.charts.keys()).map(e=>this.checkChartStatus(e).then(t=>({key:e,status:t})));
1return(await Promise.all(e)).forEach(({key:e,status:t})=>{this.status.set(e,t)}),new Map(this.status)}async loadAllCharts(){await new Promise(e=>setTimeout(e,3e3));let e=Array.from(this.charts.keys()).map(async e=>{try{let t,r=null,a=0;for(;a<10&&(r=window[e],t=window[`${e}HasData`],!(r&&r.container&&r.container.querySelector("svg")));)await new Promise(e=>setTimeout(e,500)),a++;if(r){let a=r.container&&r.container.querySelector("svg"),i="function"==typeof r.getSVG,s={isLoaded:!0,hasData:!0===t,hasExport:a&&i,lastChecked:Date.now(),error:a?i?void 0:"圖表缺少 getSVG 方法":"圖表容器或 SVG 元素不存在"};return this.status.set(e,s),{key:e,status:s}}{let r={isLoaded:!1,hasData:!0===t,hasExport:!1,lastChecked:Date.now(),error:"圖表尚未載入"};return this.status.set(e,r),{key:e,status:r}}}catch(r){let t={isLoaded:!1,hasData:!1,hasExport:!1,lastChecked:Date.now(),error:r instanceof Error?r.message:String(r)};return this.status.set(e,t),{key:e,status:t}}});return(await Promise.all(e)).forEach(({key:e,status:t})=>{this.status.set(e,t)}),new Map(this.status)}getAvailableCharts(){return this.getCharts().filter(e=>{let t=this.status.get(e.key);return e.enabled&&t?.isLoaded&&t?.hasData&&t?.hasExport})}async getChartSVG(e){let t=this.cache.get(e);if(t)return t;try{let t=window[e];if(!t)throw Error("圖表實例不存在");if(!t.container)throw Error("圖表容器不存在");let r=t.container.querySelector("svg");if(!r)throw Error("SVG 元素不存在");let a=null;if("function"==typeof t.getSVG)try{a=t.getSVG()}catch(e){a=r.outerHTML}else a=r.outerHTML;if(!a||a.length<100){let e=r.outerHTML;if(e&&e.length>=100)a=e;else{let e=a?.length??0;throw Error(`SVG 資料無效 (長度: ${e})`)}}if(!a)throw Error("SVG 資料為空");let i=a,s=this.compressSVG(i);return this.cache.set(e,s),s}catch(e){return null}}compressSVG(e){return e.replace(/\s+/g," ").replace(/>\s+</g,"><").trim()}clearCache(){this.cache.clear()}clearCacheForChart(e){this.cache.delete(e)}getChartStats(){let e=this.getCharts(),t=Array.from(this.status.values());return{total:e.length,enabled:e.filter(e=>e.enabled).length,available:this.getAvailableCharts().length,loaded:t.filter(e=>e.isLoaded).length,withData:t.filter(e=>e.hasData).length,withExport:t.filter(e=>e.hasExport).length}}getChartErrors(){let e=[];return this.status.forEach((t,r)=>{if(t.error){let a=this.charts.get(r);e.push({key:r,title:a?.title||r,error:t.error})}}),e}async waitForChartsToLoad(e=1e4){let t=Date.now();for(;Date.now()-t<e;){await this.checkAllChartsStatus();let e=this.getChartStats();if(e.loaded===e.total)return;await new Promise(e=>setTimeout(e,500))}throw Error("圖表載入超時")}}},34788:(e,t,r)=>{r.d(t,{Q:()=>G});var a=r(85047),i=r(31615),s=r(18534),n=r(21410),l=r(15203),o=r(11787),c=r(56620),h=r(34961);function d({imageDataUrl:e,isLoading:t=!1,className:r,containerRef:s,imageRef:n,overlay:l,onImageLoad:u}){let[g,m]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{m(!1)},[e]),t)?(0,a.jsx)("div",{className:(0,h.cn)("flex items-center justify-center bg-muted rounded-lg",r),children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-4 p-8",children:[(0,a.jsx)(o.A,{className:"h-8 w-8 animate-spin text-muted-foreground"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"正在生成圖片..."})]})}):!e||g?(0,a.jsx)("div",{className:(0,h.cn)("flex items-center justify-center bg-muted rounded-lg",r),children:(0,a.jsx)("div",{className:"flex flex-col items-center gap-2 p-8",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"無法載入圖片預覽"})})}):(0,a.jsxs)("div",{ref:s,className:(0,h.cn)("relative rounded-lg overflow-hidden bg-muted",r),children:[(0,a.jsx)(c.default,{ref:n,src:e,alt:"圖表預覽",fill:!0,sizes:"100vw",className:"object-contain",unoptimized:!0,onError:()=>m(!0),onLoad:u}),l]})}var u=r(18654),g=r(27280);class m{chartManager;constructor(){this.chartManager=new g.C}async generateImage(e,t={},r){try{r?.(10);let a=null;for(let t=0;t<6;t++){await new Promise(e=>setTimeout(e,500));let r=window[e];if(!r){if((0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}/6: 圖表實例不存在`),5===t)throw Error("圖表實例不存在,請確保圖表已完全載入");continue}let i=null;if(r.container)i=r.container;else if(r.renderTo){let e="string"==typeof r.renderTo?document.querySelector(r.renderTo):r.renderTo;e instanceof HTMLElement&&(i=e)}else r.chartContainer&&(i=r.chartContainer);if(!i){if((0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}/6: 圖表容器不存在 (container: ${!!r.container}, renderTo: ${!!r.renderTo})`),5!==t)continue;{let t=document.querySelectorAll(`[data-chart="${e}"], [id*="${e}"]`);if(t.length>0)i=t[0],(0,u.fH)("[ShareImageGenerator] 從 DOM 找到可能的容器");else throw Error("圖表容器不存在,圖表可能尚未完全載入")}}let s=i.querySelector("svg");if(!s){if((0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}/6: SVG 元素不存在`),5===t)throw Error("SVG 元素不存在,圖表可能尚未完全渲染");continue}try{if((a=s.outerHTML)&&a.length>=100){(0,u.fH)(`[ShareImageGenerator] 直接從 DOM 取得 SVG 成功 (長度: ${a.length})`);break}(0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}
1/6: 直接取得的 SVG 太短 (長度: ${a?.length||0})`)}catch(e){(0,u.vV)("[ShareImageGenerator] 直接取得 SVG 失敗:",e)}if("function"==typeof r.getSVG)try{let e=r.getSVG();if(e&&e.length>=100){a=e,(0,u.fH)(`[ShareImageGenerator] 使用 getSVG 方法取得 SVG 成功 (長度: ${e.length})`);break}(0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}/6: getSVG 返回的資料太短 (長度: ${e?.length||0})`)}catch(e){(0,u.vV)("[ShareImageGenerator] getSVG 方法執行失敗:",e)}else(0,u.fH)(`[ShareImageGenerator] 嘗試 ${t+1}/6: getSVG 方法不存在`);if(5===t)throw Error("無法取得有效的 SVG 資料,圖表可能尚未完全載入或渲染失敗")}if(!a||a.length<100)throw Error("無法取得有效的圖表 SVG");r?.(30);let i=await this.convertSVGToImage(a,{backgroundColor:t.backgroundColor||"#ffffff",pixelRatio:t.pixelRatio||3});if(!i)throw Error("SVG 轉圖片失敗");r?.(60);let s=i,{width:n,height:l}=await this.getImageDimensions(i),o=this.calculateTargetDimensions(n,l,t.aspectRatio||"original");(o.width!==n||o.height!==l)&&(s=await this.resizeImage(i,o.width,o.height)),r?.(90);let c=await this.getImageDimensions(s),h=this.calculateImageSize(s),d=this.getAspectRatioString(c.width,c.height);return r?.(100),(0,u.fH)("[ShareImageGenerator] 圖片生成成功",{width:c.width,height:c.height,size:h,aspectRatio:d}),{dataUrl:s,width:c.width,height:c.height,size:h,aspectRatio:d,format:"PNG"}}catch(e){return(0,u.vV)("[ShareImageGenerator] 圖片生成失敗:",e),null}}async convertSVGToImage(e,t){try{let a=document.createElement("div");a.style.position="fixed",a.style.left="-9999px",a.style.top="-9999px",a.innerHTML=e,document.body.appendChild(a);let i=a.firstChild;if(!i)return document.body.removeChild(a),null;if(!i.getAttribute("width")||!i.getAttribute("height")){let e=i.getAttribute("viewBox");if(e){let[,,t,r]=e.split(" ").map(Number);i.setAttribute("width",t.toString()),i.setAttribute("height",r.toString())}}if(!i.querySelector("rect[fill]")&&"transparent"!==t.backgroundColor){let e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("fill",t.backgroundColor),i.insertBefore(e,i.firstChild)}let s=parseFloat(i.getAttribute("width")||"800"),n=parseFloat(i.getAttribute("height")||"400"),l=await r.e(7705).then(r.bind(r,47705)),o=await l.toPng(i,{backgroundColor:t.backgroundColor,width:s*t.pixelRatio,height:n*t.pixelRatio,style:{width:`${s*t.pixelRatio}px`,height:`${n*t.pixelRatio}px`},pixelRatio:t.pixelRatio});return document.body.removeChild(a),o}catch(e){return(0,u.vV)("[ShareImageGenerator] SVG 轉圖片失敗:",e),null}}calculateTargetDimensions(e,t,r){if("original"===r)return{width:e,height:t};let a=e/t,i=e,s=t;switch(r){case"square":{let r=Math.max(e,t);i=r,s=r;break}case"landscape":{let r=16/9;a>16/9?(s=t,i=t*r):(i=e,s=e/r);break}case"portrait":{let r=9/16;a>9/16?(s=t,i=t*r):(i=e,s=e/r)}}return{width:Math.round(i),height:Math.round(s)}}async resizeImage(e,t,r){return new Promise((a,i)=>{let s=new Image;s.onload=()=>{let e=document.createElement("canvas");e.width=t,e.height=r;let n=e.getContext("2d");n?(n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",n.drawImage(s,0,0,t,r),a(e.toDataURL("image/png",.95))):i(Error("無法取得 Canvas 2D 上下文"))},s.onerror=i,s.src=e})}async getImageDimensions(e){return new Promise((t,r)=>{let a=new Image;a.onload=()=>{t({width:a.width,height:a.height})},a.onerror=r,a.src=e})}calculateImageSize(e){return Math.round(3*(e.length-22)/4)}getAspectRatioString(e,t){let r=(e,t)=>0===t?e:r(t,e%t),a=r(e,t),i=e/a,s=t/a;return 16===i&&9===s?"16:9":9===i&&16===s?"9:16":1===i&&1===s?"1:1":4===i&&3===s?"4:3":3===i&&4===s?"3:4":`${i}:${s}`}}var f=r(4153);class p{generateShareText(e){let t=[];if(e.title&&t.push(e.title),e.description&&t.push(e.description),e.hashtags&&e.hashtags.length>0){let r=e.hashtags.map(e=>e.startsWith("#")?e:`#${e}`).join(" ");t.push(r)}return t.join("\n\n")}getShareUrl(e){let t=f._K.app.url||window.location.origin;switch(e){case"facebook":return`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(t)}`;case"line":return`https://social-plugins.line.me/lineit/share?url=${encodeURIComponent(t)}`;case"twitter":return"https://twitter.com/intent/tweet";default:return null}}async share(e,t){try{switch((0,u.fH)(`[ChartShareService] 開始分享到 ${e}`),e){case"facebook":{if(t.image)try{let e=await this.dataUrlToBlob(t.image.dataUrl);"u">typeof ClipboardItem&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),(0,u.fH)("[ChartShareService] 圖片已複製到剪貼簿"))}catch(e){(0,u.vV)("[ChartShareService] 複製圖片失敗,將下載圖片:",e),await this.downloadImage(t.image)}let r=this.getShareUrl(e);if(r)return window.open(r,"_blank","width=600,height=400"),!0;return!1}case"twitter":{if(t.image)try{let e=await this.dataUrlToBlob(t.image.dataUrl);"u">typeof ClipboardItem&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),(0,u.fH)("[ChartShareService] X: 圖片已複製到剪貼簿"))}catch(e){(0,u.vV)("[ChartShareService] X: 複製圖片失敗:",e)}let r=this.getShareUrl(e);if(r)return window.open(r,"_blank","width=600,height=400"),!0;return!1}case"line":{let t=this.getShareUrl(e);if(t)return window.open(t,"_blank","width=600,height=400"),!0;return!1}case"instagram":return await this.shareToInstagram(t);case"download":return await this.downloadImage(t.image);default:return!1}}catch(t){return(0,u.vV)(`[ChartShareService] 分享到 ${e}
1 失敗:`,t),!1}}async shareToInstagram(e){if(!e.image)return(0,u.vV)("[ChartShareService] Instagram 分享失敗: 沒有圖片"),!1;if("u">typeof navigator&&"share"in navigator)try{let t=await this.dataUrlToBlob(e.image.dataUrl),r=new File([t],"chart.png",{type:"image/png"});if("canShare"in navigator&&"function"==typeof navigator.canShare)try{if(!navigator.canShare({files:[r]}))throw(0,u.fH)("[ChartShareService] Web Share API 不支援 files 參數,降級到複製功能"),Error("Web Share API 不支援 files")}catch(e){(0,u.fH)("[ChartShareService] canShare 檢查失敗,嘗試直接分享")}return await navigator.share({files:[r]}),(0,u.fH)("[ChartShareService] 使用 Web Share API 分享成功"),!0}catch(t){let e=t.name;if("AbortError"===e)return(0,u.fH)("[ChartShareService] 用戶取消分享"),!0;"NotAllowedError"===e?(0,u.vV)("[ChartShareService] Web Share API 被拒絕(可能需要用戶手勢觸發):",t):(0,u.vV)("[ChartShareService] Web Share API 失敗:",t)}try{let t=await this.dataUrlToBlob(e.image.dataUrl);if("u"<typeof ClipboardItem)return(0,u.vV)("[ChartShareService] 瀏覽器不支援 ClipboardItem API"),await this.downloadImage(e.image);let r=await navigator.permissions.query({name:"clipboard-write"});if("denied"===r.state)return(0,u.vV)("[ChartShareService] 剪貼簿權限被拒絕"),await this.downloadImage(e.image);return await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),(0,u.fH)("[ChartShareService] 圖片已複製到剪貼簿"),!0}catch(t){return(0,u.vV)("[ChartShareService] 複製圖片失敗:",t),(0,u.fH)("[ChartShareService] 降級到下載功能"),await this.downloadImage(e.image)}}async downloadImage(e){if(!e)return!1;try{let t=document.createElement("a");return t.href=e.dataUrl,t.download=`chart-${Date.now()}.png`,document.body.appendChild(t),t.click(),document.body.removeChild(t),(0,u.fH)("[ChartShareService] 圖片下載成功"),!0}catch(e){return(0,u.vV)("[ChartShareService] 圖片下載失敗:",e),!1}}async dataUrlToBlob(e){let t=await fetch(e);return await t.blob()}suggestHashtags(e){return({assetsChart:["理財","資產配置","財務規劃"],liabilitiesChart:["負債管理","理財","財務規劃"],netWorthChart:["淨值","理財","財務自由"],investmentsChart:["投資","理財","資產配置"],insuranceChart:["保險","風險管理","財務規劃"],retirementSuccessChart:["退休規劃","理財","財務自由"],retirementCashFlowChart:["退休規劃","現金流","理財"],retirementNetWorthChart:["退休規劃","淨值","理財"],incomeExpenseTrend:["收支管理","理財","財務規劃"]})[e]||["理財","財務規劃"]}}var w=r(41178),x=r(91595),b=r(96778),y=r(71899),v=r(84569),S=r(12129),C=r(8643),j=r(17749),k=r(96968),N=r(21582),E=r(82520);let I=[{value:"original",label:"原始尺寸"},{value:"square",label:"正方形 (1:1)"},{value:"landscape",label:"橫向 (16:9)"},{value:"portrait",label:"直向 (9:16)"}],A=[{id:"twitter",name:"X",icon:(0,a.jsx)(b.A,{className:"h-5 w-5"}),className:"bg-black hover:bg-gray-900 text-white border-black hover:border-gray-900"},{id:"facebook",name:"Facebook",icon:(0,a.jsx)(y.A,{className:"h-5 w-5"}),className:"bg-[#1877F2] hover:bg-[#166FE5] text-white border-[#1877F2] hover:border-[#166FE5]"},{id:"line",name:"LINE",icon:(0,a.jsx)(v.A,{className:"h-5 w-5"}),className:"bg-[#06C755] hover:bg-[#05B84A] text-white border-[#06C755] hover:border-[#05B84A]"},{id:"instagram",name:"Instagram",icon:(0,a.jsx)(S.A,{className:"h-5 w-5"}),className:"bg-gradient-to-r from-[#833AB4] via-[#FD1D1D] to-[#FCB045] hover:from-[#7229A3] hover:via-[#E01A1A] hover:to-[#E9A03A] text-white border-transparent"},{id:"download",name:"下載",icon:(0,a.jsx)(C.A,{className:"h-5 w-5"}),className:"bg-gray-700 hover:bg-gray-600 text-white border-gray-700 hover:border-gray-600"}];function G({open:e,onOpenChange:t,chartKey:r,chartTitle:o,extraSidebarContent:c,extraSidebarTitle:u,extraContentAboveChart:g,regenerateTrigger:f}){var b;let{isGenerating:y,generationProgress:v,generatedImage:S,imageOptions:C,generateImage:V,share:T,updateImageOptions:D}=function({chartKey:e,chartTitle:t}){let[r,a]=(0,i.useState)(!1),[s,n]=(0,i.useState)(0),[l,o]=(0,i.useState)(null),c=(0,i.useMemo)(()=>new p,[]),h=(0,i.useCallback)(()=>c.suggestHashtags(e),[e,c]),[d,u]=(0,i.useState)({title:t,description:"",hashtags:h()}),g=(0,i.useCallback)(()=>(0,x.py)().background,[]),[f,b]=(0,i.useState)({aspectRatio:"original",backgroundColor:g()}),{toast:y}=(0,w.dj)(),v=(0,i.useMemo)(()=>new m,[]);(0,i.useEffect)(()=>{u(e=>({...e,title:t||e.title,hashtags:h()}))},[e,t,h]);let S=(0,i.useCallback)(async()=>
1{if(r)return null;if(a(!0),n(0),!window[e]&&(await new Promise(e=>setTimeout(e,500)),!window[e]))return a(!1),n(0),y({title:"圖片生成失敗",description:"圖表尚未載入,請稍候再試",variant:"destructive"}),null;try{let t=g(),r=await v.generateImage(e,{...f,backgroundColor:t},e=>{n(e)});if(r)return o(r),r;return y({title:"圖片生成失敗",description:"無法生成分享圖片,請稍後再試",variant:"destructive"}),null}catch(e){return y({title:"圖片生成失敗",description:e instanceof Error?e.message:"發生未知錯誤",variant:"destructive"}),null}finally{a(!1),n(0)}},[e,g,v,f,r,y]),C=(0,i.useCallback)(async e=>{let t=l||await S();if(!t)return!1;let r=await c.share(e,{image:t});return r||y({title:"分享失敗",description:"無法完成分享,請稍後再試",variant:"destructive"}),r},[l,S,y,c]),j=(0,i.useCallback)(e=>{u(t=>({...t,...e}))},[]),k=(0,i.useCallback)(e=>{b(t=>{let r={...t,...e};return(t.aspectRatio!==r.aspectRatio||t.width!==r.width||t.height!==r.height||t.pixelRatio!==r.pixelRatio||t.backgroundColor!==r.backgroundColor)&&o(null),r})},[]),N=(0,i.useCallback)(()=>{j({hashtags:c.suggestHashtags(e)})},[e,j,c]);return{isGenerating:r,generationProgress:s,generatedImage:l,shareOptions:d,imageOptions:f,generateImage:S,share:C,updateShareOptions:j,updateImageOptions:k,suggestHashtags:N,reset:(0,i.useCallback)(()=>{o(null),n(0),a(!1),u({title:t,description:"",hashtags:h()}),b({aspectRatio:"original",backgroundColor:g()})},[t,h,g])}}({chartKey:r,chartTitle:o}),[H,$]=(0,i.useState)(!1),R=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{!e||H||y||S||M()},[e]),(0,i.useEffect)(()=>{e&&(R.current!==f&&H?(R.current=f,M()):R.current=f)},[e,f,H]);let M=async()=>{await new Promise(e=>setTimeout(e,300)),await V()&&$(!0)},P=async e=>{await T(e)};return(0,a.jsx)(s.lG,{open:e,onOpenChange:t,children:(0,a.jsxs)(s.Cf,{className:"max-w-6xl w-full h-[90vh] flex flex-col p-0",children:[(0,a.jsxs)(s.c7,{className:"px-6 pt-6 pb-4",children:[(0,a.jsx)(s.L3,{children:"分享圖表"}),(0,a.jsx)(s.rr,{children:"將圖表分享到社群平台或下載為圖片"})]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 px-6 pb-6 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[null!=g?(0,a.jsx)("div",{className:"flex-shrink-0 mb-4 flex flex-wrap items-center gap-4",children:g}):null,(0,a.jsx)(d,{imageDataUrl:S?.dataUrl||null,isLoading:y,className:"flex-1 min-h-[400px]"}),y&&(0,a.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,a.jsx)(l.k,{value:v}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground text-center",children:["正在生成圖片... ",v,"%"]})]})]}),(0,a.jsxs)("div",{className:"w-full lg:w-[400px] flex flex-col gap-4 overflow-y-auto",children:[null!=c?(0,a.jsxs)(E.Zp,{children:[(0,a.jsx)(E.aR,{className:"pb-2",children:(0,a.jsx)(E.ZB,{className:"text-sm font-medium",children:u??"圖表選項"})}),(0,a.jsx)(E.Wu,{className:"pt-0",children:c})]}):null,S&&!y&&(0,a.jsxs)(E.Zp,{children:[(0,a.jsx)(E.aR,{className:"pb-3",children:(0,a.jsx)(E.ZB,{className:"text-sm font-medium",children:"圖片資訊"})}),(0,a.jsx)(E.Wu,{children:(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"格式"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:S.format})]}),(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"比例"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:S.aspectRatio})]}),(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"大小"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:(b=S.size)<1024?`${b} B`:b<1048576?`${(b/1024).toFixed(2)} KB`:`${(b/1048576).toFixed(2)} MB`})]})]})})]}),(0,a.jsxs)(E.Zp,{children:[(0,a.jsx)(E.aR,{className:"pb-3",children:(0,a.jsx)(E.ZB,{className:"text-sm font-medium",children:"設定"})}),(0,a.jsxs)(E.Wu,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k.J,{htmlFor:"aspect-ratio",children:"圖片尺寸"}),(0,a.jsxs)(N.l6,{value:C.aspectRatio||"original",onValueChange:e=>D({aspectRatio:e}),children:[(0,a.jsx)(N.bq,{id:"aspect-ratio",className:"bg-background border-input",children:(0,a.jsx)(N.yv,{})}),(0,a.jsx)(N.gC,{children:I.map(e=>(0,a.jsx)(N.eb,{value:e.value,children:e.label},e.value))})]})]}),(!S||y)&&(0,a.jsx)(n.$,{onClick:M,disabled:y,className:"w-full",children:y?"生成中...":"生成圖片"})]})]}),S&&!y?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(j.A,{className:"h-5 w-5 text-muted-foreground"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"分享圖表"})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-3",children:A.map(e=>(0,a.jsxs)(n.$,{onClick:()=>P(e.id),className:(0,h.cn)("w-full h-12 justify-start gap-3 text-base font-medium transition-all duration-200 shadow-sm hover:shadow-md",e.className),children:[e.icon,(0,a.jsx)("span",{children:e.name})]},e.id))})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center space-y-4",children:[(0,a.jsx)("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center",children:(0,a.jsx)(j.A,{className:"h-8 w-8 text-muted-foreground"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-1",children:"準備分享"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"圖片生成中,請稍候..."})]})]})]})]})]})})}},79632:(e,t,r)=>{r.d(t,{S:()=>l});var a=r(85047),i=r(17749),s=r(21410),n=r(34961);function l({onClick:e,className:t,variant:r="ghost",size:o="icon"}){return(0,a.jsxs)(s.$,{onClick:t=>{t.stopPropagation(),t.preventDefault(),e()},onMouseDown:e=>e.stopPropagation(),variant:r,size:o,className:(0,n.cn)("shrink-0 z-10 text-muted-foreground hover:text-foreground",t),title:"分享圖表",type:"button",children:[(0,a.jsx)(i.A,{className:"h-4 w-4"}),"icon"!==o&&(0,a.jsx)("span",{className:"ml-2",children:"分享"})]})}}}]);

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.