1import{u as L,r as l,j as e,y as C,B as r,q as _,C as D,f as k,aw as P,d as $,e as T,aX as z,a1 as B,ay as S,aY as F,a5 as O,aO as R,a6 as q,a7 as A,a8 as G,a9 as H,p as U,aa as J,ab as V,b as p,t as N}from"./index-OESH-BF1.js";import{M as X}from"./mouse-pointer-6f9HoyvW.js";import{C as Y}from"./chart-no-axes-column-increasing-CH2bYFNv.js";var b=(x,h,c)=>new Promise((y,o)=>{var u=a=>{try{i(c.next(a))}catch(m){o(m)}},j=a=>{try{i(c.throw(a))}catch(m){o(m)}},i=a=>a.done?y(a.value):Promise.resolve(a.value).then(u,j);i((c=c.apply(x,h)).next())});function Z(){const x=L(),[h,c]=l.useState([]),[y,o]=l.useState(!0),[u,j]=l.useState(null),[i,a]=l.useState(null),[m,g]=l.useState(!1),[n,v]=l.useState(null);l.useEffect(()=>{document.title="Instagram DMãã£ã³ãã¼ã³"},[]),l.useEffect(()=>{f()},[]);const f=()=>b(null,null,function*(){try{o(!0),j(null);const s=yield p("GET","/api/tenants/me/instagram/dm-campaigns"),t=yield s.json();if(s.ok)c(t);else throw new Error(t.error||"ãã£ã³ãã¼ã³ã®åå¾ã«å¤±æãã¾ãã")}catch(s){const t=s instanceof Error?s.message:"äºæãã¬ã¨ã©ã¼ãçºçãã¾ãã";j(t),N.error(t)}finally{o(!1)}}),w=()=>{x("/tenant/instagram/dm-campaigns/create")},E=s=>b(null,null,function*(){try{const t=yield p("GET",`/api/tenants/me/instagram/dm-campaigns/${s}/stats`);yield t.json(),t.ok&&(N.success("çµ±è¨æ
å ±ãæ´æ°ãã¾ãã"),f())}catch(t){console.error("Error fetching stats:",t)}}),M=s=>b(null,null,function*(){v(s),g(!0)}),I=()=>b(null,null,function*(){if(n){a(n.id),g(!1);try{const s=yield p("POST",`/api/tenants/me/instagram/dm-campaigns/${n.id}/send`,{});if(s.ok){const t=yield s.json();N.success(`${t.sentCount||0}ä»¶ã®DMãéä¿¡ãã¾ãã`),f()}else{const t=yield s.json();throw new Error(t.error||"éä¿¡ã«å¤±æãã¾ãã")}}catch(s){const t=s instanceof Error?s.message:"äºæãã¬ã¨ã©ã¼ãçºçãã¾ãã";N.error(t)}finally{a(null),v(null)}}}),d=(s,t)=>!s||!t||t===0?"0%":`${Math.round(s/t*100)}%`;return y?e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-gray-400"})})}):u?e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-red-600 mb-4",children:u}),e.jsx(r,{onClick:f,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:"åèªã¿è¾¼ã¿"})]})}):e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsxs("div",{className:"max-w-4xl mx-auto p-3 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg sm:text-2xl font-bold text-gray-900 truncate",children:"Instagram DMãã£ã³ãã¼ã³"}),e.jsx("p",{className:"text-sm text-gray-500 hidden sm:block",children:"Instagramã®DMããLINE飿ºãä¿é²ãããã£ã³ãã¼ã³ã管çãã¾ã"})]}),e.jsxs(r,{onClick:w,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"æ°è¦ãã£ã³ãã¼ã³ä½æ"]})]}),h.length===0?e.jsx(D,{className:"shadow-sm border-0 rounded-none bg-white",children:e.jsxs(k,{className:"text-center py-12",children:[e.jsx(P,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"ã¾ã ãã£ã³ãã¼ã³ãããã¾ãã"}),e.jsxs(r,{onClick:w,variant:"outline",className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"æåã®ãã£ã³ãã¼ã³ã使"]})]})}):e.jsx("div",{className:"grid gap-4",children:h.map(s=>e.jsxs(D,{className:"shadow-sm border-0 rounded-none bg-white",children:[e.jsx($,{className:"pb-4 p-4 sm:p-6",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(T,{className:"text-lg",children:s.campaign_name}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:s.dm_message||s.message_template})]}),e.jsx(z,{variant:"secondary",className:"ml-4",children:s.liff_page_type==="coupon"?"ã¯ã¼ãã³":s.liff_page_type==="reservation"?"äºç´":"ã«ã¹ã¿ã "})]})}),e.jsxs(k,{className:"p-4 sm:p-6 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(B,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"対象è
"})]}),e.jsx("p",{className:"text-xl font-semibold",children:s.total_recipients||0})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(S,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"éä¿¡æ°"})]}),e.jsx("p",{className:"text-xl font-semibold",children:s.sent_count||0})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(X,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"ã¯ãªãã¯"})]}),e.jsxs("p",{className:"text-xl font-semibold",children:[s.clicked_count||0,e.jsxs("span",{className:"text-sm text-gray-500 ml-1",children:["(",d(s.clicked_count,s.sent_count),")"]})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(F,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"飿º"})]}),e.jsxs("p",{className:"text-xl font-semibold",children:[s.connected_count||0,e.jsxs("span",{className:"text-sm text-gray-500 ml-1",children:["(",d(s.connected_count,s.sent_count),")"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-gray-500",children:["使æ¥: ",new Date(s.created_at).toLocaleDateString("ja-JP")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>E(s.id),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),"çµ±è¨æ´æ°"]}),s.sent_count===0&&e.jsx(r,{size:"sm",onClick:()=>M(s),disabled:i===s.id,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:i===s.id?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"h-4 w-4 mr-1 animate-spin"}),"éä¿¡ä¸..."]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 mr-1"}),"éä¿¡å®è¡"]})}),s.sent_count&&s.sent_count>0&&e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>x(`/campaigns/page/${s.id}`),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(O,{className:"h-4 w-4 mr-1"}),"詳細"]})]})]}),s.sent_count&&s.sent_count>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"ææç"}),e.jsx(R,{className:"h-4 w-4 text-green-600"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{children:"ã¯ãªãã¯ç"}),e.jsx("span",{children:d(s.clicked_count,s.sent_count)}
1)]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${Math.min(100,parseInt(d(s.clicked_count,s.sent_count)))}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{children:"飿ºç"}),e.jsx("span",{children:d(s.connected_count,s.sent_count)})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-green-600 h-2 rounded-full",style:{width:`${Math.min(100,parseInt(d(s.connected_count,s.sent_count)))}%`}})})]})]})]})]})]},s.id))}),e.jsx(q,{open:m,onOpenChange:g,children:e.jsxs(A,{className:"bg-white border-0 rounded-none",children:[e.jsxs(G,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-yellow-600"}),"DMãã£ã³ãã¼ã³ãéä¿¡ãã¾ããï¼"]}),e.jsx(J,{children:n&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"bg-gray-50 p-4",children:[e.jsx("p",{className:"font-medium text-gray-900 mb-2",children:n.campaign_name}),e.jsx("p",{className:"text-sm text-gray-600",children:n.dm_message||n.message_template})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:"é信対象è
æ°"}),e.jsxs("span",{className:"font-medium",children:[n.total_recipients||0,"å"]})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"ãã®æä½ã¯åãæ¶ãã¾ããã対象è
å
¨å¡ã«DMãéä¿¡ããã¾ãã"})]})})]}),e.jsxs(V,{children:[e.jsx(r,{variant:"outline",onClick:()=>g(!1),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:"ãã£ã³ã»ã«"}),e.jsx(r,{onClick:I,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:"éä¿¡ãã"})]})]})})]})})}export{Z 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.