@universe-platform/ui 0.1.0-beta.26 → 0.1.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8795,7 +8795,8 @@ var PlacementBlock = (props) => {
8795
8795
  };
8796
8796
 
8797
8797
  // src/components/WhatsAppComponent/WhatsAppComponent.tsx
8798
- var import_lucide_react14 = require("lucide-react");
8798
+ var import_react23 = __toESM(require("react"));
8799
+ var import_lucide_react16 = require("lucide-react");
8799
8800
 
8800
8801
  // src/components/WhatsAppComponent/CreateTemplateModal.tsx
8801
8802
  var import_react18 = require("react");
@@ -13666,367 +13667,678 @@ function SettingsAndActionsBlock({
13666
13667
  ] });
13667
13668
  }
13668
13669
 
13669
- // src/components/WhatsAppComponent/WhatsAppComponent.tsx
13670
+ // src/components/WhatsAppComponent/inbox/useInboxState.ts
13671
+ var import_react21 = require("react");
13672
+ function useInboxState(orgId, actions) {
13673
+ const [conversations, setConversations] = (0, import_react21.useState)([]);
13674
+ const [activeConversationId, setActiveConversationId] = (0, import_react21.useState)(null);
13675
+ const [messages, setMessages] = (0, import_react21.useState)([]);
13676
+ const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
13677
+ const [isSending, setIsSending] = (0, import_react21.useState)(false);
13678
+ const [error, setError] = (0, import_react21.useState)(null);
13679
+ const actionsRef = (0, import_react21.useRef)(actions);
13680
+ (0, import_react21.useEffect)(() => {
13681
+ actionsRef.current = actions;
13682
+ });
13683
+ const fetchConversations = (0, import_react21.useCallback)(async () => {
13684
+ if (!orgId) return;
13685
+ const res = await actionsRef.current.getConversations(orgId);
13686
+ if (res.success && res.data) {
13687
+ setConversations(res.data);
13688
+ } else if (res.error) {
13689
+ setError(res.error);
13690
+ }
13691
+ }, [orgId]);
13692
+ const fetchMessages = (0, import_react21.useCallback)(async (conversationId) => {
13693
+ setIsLoading(true);
13694
+ const res = await actionsRef.current.getMessages(conversationId);
13695
+ if (res.success && res.data) {
13696
+ setMessages(res.data);
13697
+ setConversations(
13698
+ (prev) => prev.map((c) => c.id === conversationId ? __spreadProps(__spreadValues({}, c), { unreadCount: 0 }) : c)
13699
+ );
13700
+ } else if (res.error) {
13701
+ setError(res.error);
13702
+ }
13703
+ setIsLoading(false);
13704
+ }, []);
13705
+ (0, import_react21.useEffect)(() => {
13706
+ fetchConversations();
13707
+ const interval = setInterval(() => {
13708
+ fetchConversations();
13709
+ if (activeConversationId) {
13710
+ fetchMessages(activeConversationId);
13711
+ }
13712
+ }, 5e3);
13713
+ return () => clearInterval(interval);
13714
+ }, [fetchConversations, activeConversationId, fetchMessages]);
13715
+ const handleSelectConversation = (id) => {
13716
+ setActiveConversationId(id);
13717
+ fetchMessages(id);
13718
+ };
13719
+ const handleSendMessage = async (text) => {
13720
+ if (!activeConversationId || !text.trim()) return;
13721
+ setIsSending(true);
13722
+ const tempMsg = {
13723
+ id: Date.now().toString(),
13724
+ direction: "OUTBOUND",
13725
+ content: text,
13726
+ status: "SENDING",
13727
+ createdAt: /* @__PURE__ */ new Date()
13728
+ };
13729
+ setMessages((prev) => [...prev, tempMsg]);
13730
+ const res = await actions.sendMessage(activeConversationId, text, orgId);
13731
+ if (res.success && res.data) {
13732
+ setMessages((prev) => prev.map((m) => m.id === tempMsg.id ? res.data : m));
13733
+ fetchConversations();
13734
+ } else {
13735
+ setError("\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05E9\u05DC\u05D9\u05D7\u05EA \u05D4\u05D5\u05D3\u05E2\u05D4");
13736
+ setMessages((prev) => prev.filter((m) => m.id !== tempMsg.id));
13737
+ }
13738
+ setIsSending(false);
13739
+ };
13740
+ return {
13741
+ conversations,
13742
+ activeConversationId,
13743
+ messages,
13744
+ isLoading,
13745
+ isSending,
13746
+ error,
13747
+ handleSelectConversation,
13748
+ handleSendMessage
13749
+ };
13750
+ }
13751
+
13752
+ // src/components/WhatsAppComponent/inbox/ConversationList.tsx
13753
+ var import_lucide_react14 = require("lucide-react");
13670
13754
  var import_jsx_runtime20 = require("react/jsx-runtime");
13755
+ function ConversationList({ conversations, activeId, onSelect }) {
13756
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "w-80 border-l border-slate-200 bg-white flex flex-col h-full shrink-0", children: [
13757
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-4 border-b border-slate-100 bg-slate-50", children: [
13758
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { className: "text-lg font-bold text-slate-800 mb-3", children: "\u05E9\u05D9\u05D7\u05D5\u05EA \u05E0\u05DB\u05E0\u05E1\u05D5\u05EA" }),
13759
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative", children: [
13760
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Search, { className: "w-4 h-4 absolute right-3 top-1/2 -translate-y-1/2 text-slate-400" }),
13761
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13762
+ "input",
13763
+ {
13764
+ type: "text",
13765
+ placeholder: "\u05D7\u05D9\u05E4\u05D5\u05E9 \u05DC\u05E4\u05D9 \u05E9\u05DD \u05D0\u05D5 \u05DE\u05E1\u05E4\u05E8...",
13766
+ className: "w-full pl-3 pr-9 py-2 bg-white border border-slate-200 rounded-xl text-xs focus:outline-none focus:border-emerald-500"
13767
+ }
13768
+ )
13769
+ ] })
13770
+ ] }),
13771
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex-1 overflow-y-auto", children: (() => {
13772
+ const sortedConversations = [...conversations].sort(
13773
+ (a, b) => new Date(b.lastMessageAt).getTime() - new Date(a.lastMessageAt).getTime()
13774
+ );
13775
+ return sortedConversations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "p-6 text-center text-sm text-slate-400", children: "\u05D0\u05D9\u05DF \u05E9\u05D9\u05D7\u05D5\u05EA \u05E4\u05E2\u05D9\u05DC\u05D5\u05EA" }) : sortedConversations.map((conv) => {
13776
+ var _a, _b;
13777
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
13778
+ "button",
13779
+ {
13780
+ onClick: () => onSelect(conv.id),
13781
+ className: `w-full text-right p-4 border-b border-slate-100 transition-colors hover:bg-slate-50 flex items-start gap-3 ${activeId === conv.id ? "bg-emerald-50/50 border-r-4 border-r-emerald-500" : "border-r-4 border-r-transparent"}`,
13782
+ children: [
13783
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-10 h-10 rounded-full bg-slate-200 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.User, { className: "w-5 h-5 text-slate-500" }) }),
13784
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex-1 overflow-hidden", children: [
13785
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex justify-between items-center mb-1", children: [
13786
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-semibold text-slate-800 text-sm truncate", children: conv.contactName || conv.contactPhone }),
13787
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-slate-400", children: new Date(conv.lastMessageAt).toLocaleTimeString("he-IL", { hour: "2-digit", minute: "2-digit" }) })
13788
+ ] }),
13789
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex justify-between items-center", children: [
13790
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-xs text-slate-500 truncate w-4/5", children: ((_b = (_a = conv.messages) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) || "\u05D0\u05D9\u05DF \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA" }),
13791
+ conv.unreadCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "bg-emerald-500 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full min-w-[20px] text-center", children: conv.unreadCount })
13792
+ ] })
13793
+ ] })
13794
+ ]
13795
+ },
13796
+ conv.id
13797
+ );
13798
+ });
13799
+ })() })
13800
+ ] });
13801
+ }
13802
+
13803
+ // src/components/WhatsAppComponent/inbox/ChatWindow.tsx
13804
+ var import_react22 = require("react");
13805
+ var import_lucide_react15 = require("lucide-react");
13806
+ var import_jsx_runtime21 = require("react/jsx-runtime");
13807
+ function ChatWindow({ activeConversation, messages, isLoading, isSending, onSendMessage }) {
13808
+ const [inputText, setInputText] = (0, import_react22.useState)("");
13809
+ const messagesEndRef = (0, import_react22.useRef)(null);
13810
+ const scrollToBottom = () => {
13811
+ var _a;
13812
+ (_a = messagesEndRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
13813
+ };
13814
+ (0, import_react22.useEffect)(() => {
13815
+ scrollToBottom();
13816
+ }, [messages]);
13817
+ const handleSend = (e) => {
13818
+ e.preventDefault();
13819
+ if (!inputText.trim() || isSending) return;
13820
+ onSendMessage(inputText);
13821
+ setInputText("");
13822
+ };
13823
+ if (!activeConversation) {
13824
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex-1 bg-slate-50 flex items-center justify-center flex-col gap-4 text-slate-400", children: [
13825
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "w-16 h-16 rounded-full bg-slate-200 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { className: "w-8 h-8 text-slate-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5", d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }) }),
13826
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: "\u05D1\u05D7\u05E8 \u05E9\u05D9\u05D7\u05D4 \u05DE\u05D4\u05E8\u05E9\u05D9\u05DE\u05D4 \u05DB\u05D3\u05D9 \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC" })
13827
+ ] });
13828
+ }
13829
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex-1 flex flex-col bg-[#efeae2] h-full relative", children: [
13830
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "h-16 bg-white border-b border-slate-200 px-6 flex items-center gap-3 shrink-0 z-10 shadow-sm", children: [
13831
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "w-10 h-10 rounded-full bg-slate-200 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.User, { className: "w-5 h-5 text-slate-500" }) }),
13832
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
13833
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "font-bold text-slate-800", children: activeConversation.contactName || activeConversation.contactPhone }),
13834
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-xs text-slate-500", dir: "ltr", children: activeConversation.contactPhone })
13835
+ ] })
13836
+ ] }),
13837
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex-1 overflow-y-auto p-6 space-y-4", children: [
13838
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.Loader2, { className: "w-6 h-6 animate-spin text-emerald-600" }) }) : messages.map((msg, idx) => {
13839
+ const isOutbound = msg.direction === "OUTBOUND";
13840
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: `flex ${isOutbound ? "justify-start" : "justify-end"}`, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `max-w-[70%] rounded-2xl px-4 py-2 shadow-sm relative ${isOutbound ? "bg-[#d9fdd3] text-slate-900 rounded-tr-none" : "bg-white text-slate-900 rounded-tl-none"}`, children: [
13841
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm whitespace-pre-wrap", children: msg.content }),
13842
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "text-[10px] text-slate-400 mt-1 text-left flex items-center justify-end gap-1", children: [
13843
+ new Date(msg.createdAt).toLocaleTimeString("he-IL", { hour: "2-digit", minute: "2-digit" }),
13844
+ isOutbound && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: msg.status === "READ" || msg.status === "DELIVERED" ? "text-blue-500" : "text-slate-400", children: msg.status === "READ" ? "\u2713\u2713" : msg.status === "DELIVERED" ? "\u2713\u2713" : "\u2713" })
13845
+ ] })
13846
+ ] }) }, msg.id || idx);
13847
+ }),
13848
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref: messagesEndRef })
13849
+ ] }),
13850
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "bg-slate-50 p-4 border-t border-slate-200 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: handleSend, className: "flex items-end gap-2 max-w-4xl mx-auto", children: [
13851
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex-1 bg-white border border-slate-300 rounded-2xl overflow-hidden focus-within:border-emerald-500 focus-within:ring-1 focus-within:ring-emerald-500", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
13852
+ "textarea",
13853
+ {
13854
+ rows: 1,
13855
+ value: inputText,
13856
+ onChange: (e) => setInputText(e.target.value),
13857
+ onKeyDown: (e) => {
13858
+ if (e.key === "Enter" && !e.shiftKey) {
13859
+ e.preventDefault();
13860
+ handleSend(e);
13861
+ }
13862
+ },
13863
+ placeholder: "\u05D4\u05E7\u05DC\u05D3 \u05D4\u05D5\u05D3\u05E2\u05D4...",
13864
+ className: "w-full max-h-32 min-h-[44px] p-3 text-sm bg-transparent outline-none resize-none"
13865
+ }
13866
+ ) }),
13867
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
13868
+ "button",
13869
+ {
13870
+ type: "submit",
13871
+ disabled: !inputText.trim() || isSending,
13872
+ className: `w-11 h-11 rounded-full flex items-center justify-center shrink-0 transition-colors ${!inputText.trim() || isSending ? "bg-slate-200 text-slate-400" : "bg-emerald-600 hover:bg-emerald-700 text-white shadow-md"}`,
13873
+ children: isSending ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.Loader2, { className: "w-5 h-5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.Send, { className: "w-5 h-5 -ml-1" })
13874
+ }
13875
+ )
13876
+ ] }) })
13877
+ ] });
13878
+ }
13879
+
13880
+ // src/components/WhatsAppComponent/inbox/WhatsAppInbox.tsx
13881
+ var import_jsx_runtime22 = require("react/jsx-runtime");
13882
+ function WhatsAppInbox({
13883
+ orgId,
13884
+ getConversationsAction,
13885
+ getMessagesAction,
13886
+ sendInboxMessageAction
13887
+ }) {
13888
+ const {
13889
+ conversations,
13890
+ activeConversationId,
13891
+ messages,
13892
+ isLoading,
13893
+ isSending,
13894
+ handleSelectConversation,
13895
+ handleSendMessage
13896
+ } = useInboxState(orgId, {
13897
+ getConversations: getConversationsAction,
13898
+ getMessages: getMessagesAction,
13899
+ sendMessage: sendInboxMessageAction
13900
+ });
13901
+ const activeConversation = conversations.find((c) => c.id === activeConversationId);
13902
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex h-[calc(100vh-140px)] min-h-[600px] w-full border border-slate-200 rounded-2xl overflow-hidden bg-white shadow-xs", dir: "rtl", children: [
13903
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
13904
+ ConversationList,
13905
+ {
13906
+ conversations,
13907
+ activeId: activeConversationId,
13908
+ onSelect: handleSelectConversation
13909
+ }
13910
+ ),
13911
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
13912
+ ChatWindow,
13913
+ {
13914
+ activeConversation,
13915
+ messages,
13916
+ isLoading,
13917
+ isSending,
13918
+ onSendMessage: handleSendMessage
13919
+ }
13920
+ )
13921
+ ] });
13922
+ }
13923
+
13924
+ // src/components/WhatsAppComponent/WhatsAppComponent.tsx
13925
+ var import_jsx_runtime23 = require("react/jsx-runtime");
13671
13926
  function WhatsAppComponent(props) {
13672
13927
  var _a;
13673
13928
  const { className = "", settings, orgId, componentId, executeAction } = props;
13674
13929
  const state = useWhatsAppState(props);
13675
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
13930
+ const [activeTab, setActiveTab] = import_react23.default.useState("broadcast");
13931
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
13676
13932
  "div",
13677
13933
  {
13678
13934
  className: `w-full flex flex-col bg-white border border-slate-200 rounded-2xl shadow-xs overflow-hidden ${className}`,
13679
13935
  "data-testid": "whatsapp-component",
13680
13936
  dir: "rtl",
13681
13937
  children: [
13682
- state.feedback && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
13683
- "div",
13684
- {
13685
- className: `px-6 py-3 border-b text-xs flex items-center justify-between gap-3 ${state.feedback.type === "success" ? "bg-emerald-50 border-emerald-200 text-emerald-800" : "bg-rose-50 border-rose-200 text-rose-800"}`,
13686
- children: [
13687
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
13688
- state.feedback.type === "success" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.CheckCircle2, { className: "w-4 h-4 text-emerald-600 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.AlertCircle, { className: "w-4 h-4 text-rose-600 shrink-0" }),
13689
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: state.feedback.message })
13690
- ] }),
13691
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13692
- "button",
13693
- {
13694
- type: "button",
13695
- onClick: () => state.setFeedback(null),
13696
- className: "text-slate-400 hover:text-slate-700 cursor-pointer",
13697
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.X, { className: "w-4 h-4" })
13698
- }
13699
- )
13700
- ]
13701
- }
13702
- ),
13703
- state.fetchError && !state.isLoadingTemplates && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "px-6 py-3 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between", children: [
13704
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
13705
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.AlertCircle, { className: "w-4 h-4 text-amber-600 shrink-0" }),
13706
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
13707
- "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05D8\u05E2\u05D9\u05E0\u05EA \u05EA\u05D1\u05E0\u05D9\u05D5\u05EA \u05DE-Meta: ",
13708
- state.fetchError
13709
- ] })
13710
- ] }),
13711
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13938
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex border-b border-slate-200 bg-slate-50 px-6 pt-3 gap-4 shrink-0", children: [
13939
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
13712
13940
  "button",
13713
13941
  {
13714
13942
  type: "button",
13715
- onClick: state.loadTemplates,
13716
- className: "font-bold underline cursor-pointer",
13717
- children: "\u05E0\u05E1\u05D4 \u05E9\u05D5\u05D1"
13943
+ onClick: () => setActiveTab("broadcast"),
13944
+ className: `pb-3 text-sm font-bold border-b-2 transition-colors cursor-pointer ${activeTab === "broadcast" ? "border-emerald-600 text-emerald-700" : "border-transparent text-slate-500 hover:text-slate-800"}`,
13945
+ children: "\u{1F4E4} \u05E9\u05DC\u05D9\u05D7\u05EA \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA \u05D5\u05EA\u05E4\u05D5\u05E6\u05D4"
13946
+ }
13947
+ ),
13948
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
13949
+ "button",
13950
+ {
13951
+ type: "button",
13952
+ onClick: () => setActiveTab("inbox"),
13953
+ className: `pb-3 text-sm font-bold border-b-2 transition-colors cursor-pointer ${activeTab === "inbox" ? "border-emerald-600 text-emerald-700" : "border-transparent text-slate-500 hover:text-slate-800"}`,
13954
+ children: "\u{1F4AC} \u05EA\u05D9\u05D1\u05EA \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA (Inbox)"
13718
13955
  }
13719
13956
  )
13720
13957
  ] }),
13721
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-4 flex flex-col gap-4", children: [
13722
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "grid grid-cols-1 lg:grid-cols-12 gap-4 shrink-0 items-stretch", children: [
13723
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13724
- TemplateSelectionBlock,
13725
- {
13726
- selectedTemplate: state.selectedTemplate,
13727
- selectedTemplateId: state.selectedTemplateId,
13728
- setSelectedTemplateId: state.setSelectedTemplateId,
13729
- templates: state.templates,
13730
- isLoadingTemplates: state.isLoadingTemplates,
13731
- isDropdownOpen: state.isDropdownOpen,
13732
- setIsDropdownOpen: state.setIsDropdownOpen,
13733
- templateBodyText: state.templateBodyText,
13734
- templateHeaderComp: state.templateHeaderComp,
13735
- headerMediaUrl: state.headerMediaUrl,
13736
- handleHeaderMediaUrlChange: state.handleHeaderMediaUrlChange,
13737
- handleResetHeaderMediaUrl: state.handleResetHeaderMediaUrl,
13738
- templateVariables: state.templateVariables,
13739
- variableMapping: state.variableMapping,
13740
- handleVariableTypeChange: state.handleVariableTypeChange,
13741
- handleVariableValueChange: state.handleVariableValueChange,
13742
- textableColumnOptions: state.textableColumnOptions,
13743
- handleDeleteTemplate: state.handleDeleteTemplate,
13744
- isDeleting: state.isDeleting,
13745
- setIsModalOpen: state.setIsModalOpen,
13746
- setFeedback: state.setFeedback,
13747
- isUploadingMedia: state.isUploadingMedia,
13748
- handleFileUpload: state.handleFileUpload
13958
+ activeTab === "inbox" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "p-4 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
13959
+ WhatsAppInbox,
13960
+ {
13961
+ orgId: orgId || props.organizationId || "",
13962
+ getConversationsAction: async (id) => {
13963
+ if (!executeAction) return { success: false, error: "executeAction missing" };
13964
+ try {
13965
+ const data = await executeAction("GET_WHATSAPP_CONVERSATIONS", { orgId: id });
13966
+ return { success: true, data };
13967
+ } catch (e) {
13968
+ return { success: false, error: (e == null ? void 0 : e.message) || "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05D8\u05E2\u05D9\u05E0\u05EA \u05E9\u05D9\u05D7\u05D5\u05EA" };
13749
13969
  }
13750
- ),
13751
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13752
- DynamicFiltersBlock,
13753
- {
13754
- filterableColumns: state.filterableColumns,
13755
- filters: state.filters,
13756
- handleFilterChange: state.handleFilterChange,
13757
- handleClearFilters: state.handleClearFilters,
13758
- activeFiltersCount: state.activeFiltersCount,
13759
- relationOptions: state.relationOptions,
13760
- getRelationOptionsForCol: state.getRelationOptionsForCol,
13761
- selectedRowIds: state.selectedRowIds,
13762
- filteredRecordsCount: state.filteredRecords.length,
13763
- rawRecordsCount: state.rawRecords.length,
13764
- loadTableData: state.loadTableData,
13765
- isLoadingTableData: state.isLoadingTableData
13970
+ },
13971
+ getMessagesAction: async (convId) => {
13972
+ if (!executeAction) return { success: false, error: "executeAction missing" };
13973
+ try {
13974
+ const data = await executeAction("GET_WHATSAPP_MESSAGES", {
13975
+ conversationId: convId,
13976
+ orgId: orgId || props.organizationId || ""
13977
+ });
13978
+ return { success: true, data };
13979
+ } catch (e) {
13980
+ return { success: false, error: (e == null ? void 0 : e.message) || "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05D8\u05E2\u05D9\u05E0\u05EA \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA" };
13766
13981
  }
13767
- ),
13768
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13769
- SettingsAndActionsBlock,
13982
+ },
13983
+ sendInboxMessageAction: async (convId, text, currentOrgId) => {
13984
+ const res = await fetch(`/api/whatsapp/inbox/send`, {
13985
+ method: "POST",
13986
+ headers: { "Content-Type": "application/json" },
13987
+ body: JSON.stringify({ conversationId: convId, text, orgId: currentOrgId })
13988
+ });
13989
+ return res.json();
13990
+ }
13991
+ }
13992
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
13993
+ state.feedback && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
13994
+ "div",
13995
+ {
13996
+ className: `px-6 py-3 border-b text-xs flex items-center justify-between gap-3 ${state.feedback.type === "success" ? "bg-emerald-50 border-emerald-200 text-emerald-800" : "bg-rose-50 border-rose-200 text-rose-800"}`,
13997
+ children: [
13998
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
13999
+ state.feedback.type === "success" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.CheckCircle2, { className: "w-4 h-4 text-emerald-600 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.AlertCircle, { className: "w-4 h-4 text-rose-600 shrink-0" }),
14000
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: state.feedback.message })
14001
+ ] }),
14002
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14003
+ "button",
14004
+ {
14005
+ type: "button",
14006
+ onClick: () => state.setFeedback(null),
14007
+ className: "text-slate-400 hover:text-slate-700 cursor-pointer",
14008
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.X, { className: "w-4 h-4" })
14009
+ }
14010
+ )
14011
+ ]
14012
+ }
14013
+ ),
14014
+ state.fetchError && !state.isLoadingTemplates && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "px-6 py-3 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between", children: [
14015
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
14016
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.AlertCircle, { className: "w-4 h-4 text-amber-600 shrink-0" }),
14017
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { children: [
14018
+ "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05D8\u05E2\u05D9\u05E0\u05EA \u05EA\u05D1\u05E0\u05D9\u05D5\u05EA \u05DE-Meta: ",
14019
+ state.fetchError
14020
+ ] })
14021
+ ] }),
14022
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14023
+ "button",
13770
14024
  {
13771
- isScanningPhoneColumns: state.isScanningPhoneColumns,
13772
- targetPhoneOptions: state.targetPhoneOptions,
13773
- phoneColumnId: state.phoneColumnId,
13774
- setPhoneColumnId: state.setPhoneColumnId,
13775
- selectedPhoneOption: state.selectedPhoneOption,
13776
- autoSelectCount: state.autoSelectCount,
13777
- setAutoSelectCount: state.setAutoSelectCount,
13778
- subtableFilterColumn: state.subtableFilterColumn,
13779
- setSubtableFilterColumn: state.setSubtableFilterColumn,
13780
- subtableFilterValue: state.subtableFilterValue,
13781
- setSubtableFilterValue: state.setSubtableFilterValue,
13782
- subtableSendLimit: state.subtableSendLimit,
13783
- setSubtableSendLimit: state.setSubtableSendLimit,
13784
- subtableFilterableColumns: state.subtableFilterableColumns,
13785
- selectedSubtableFilterCol: state.selectedSubtableFilterCol,
13786
- getRelationOptionsForCol: state.getRelationOptionsForCol,
13787
- relationOptions: state.relationOptions,
13788
- enablePostSendAction: state.enablePostSendAction,
13789
- setEnablePostSendAction: state.setEnablePostSendAction,
13790
- postSendActionColumn: state.postSendActionColumn,
13791
- setPostSendActionColumn: state.setPostSendActionColumn,
13792
- postSendActionValue: state.postSendActionValue,
13793
- setPostSendActionValue: state.setPostSendActionValue,
13794
- postSendActionTargetType: state.postSendActionTargetType,
13795
- setPostSendActionTargetType: state.setPostSendActionTargetType,
13796
- postSendActionTargetOptions: state.postSendActionTargetOptions,
13797
- selectedPostSendOption: state.selectedPostSendCol,
13798
- isTestDisabled: state.isTestDisabled,
13799
- testButtonTitle: state.testButtonTitle,
13800
- setIsTestPromptOpen: state.setIsTestPromptOpen,
13801
- isSendDisabled: state.isSendDisabled,
13802
- sendButtonTitle: state.sendButtonTitle,
13803
- handleSendMessages: state.handleSendMessages,
13804
- selectedRowIdsCount: state.selectedRowIds.length,
13805
- finalRecipientCount: state.finalRecipientCount,
13806
- validMainRowsCount: state.validMainRowsCount,
13807
- isSendingBroadcast: state.isSendingBroadcast,
13808
- broadcastProgress: state.broadcastProgress,
13809
- broadcastSummary: state.broadcastSummary,
13810
- clearBroadcastSummary: state.clearBroadcastSummary
14025
+ type: "button",
14026
+ onClick: state.loadTemplates,
14027
+ className: "font-bold underline cursor-pointer",
14028
+ children: "\u05E0\u05E1\u05D4 \u05E9\u05D5\u05D1"
13811
14029
  }
13812
14030
  )
13813
14031
  ] }),
13814
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-full h-[calc(100vh-420px)] min-h-[320px] overflow-hidden border border-slate-200 rounded-2xl shadow-xs bg-white flex flex-col", children: state.isLoadingTableData && state.rawRecords.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex-1 flex flex-col items-center justify-center p-12 text-center text-xs text-slate-400 gap-2", children: [
13815
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Loader2, { className: "w-6 h-6 animate-spin text-emerald-600" }),
13816
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u05D8\u05D5\u05E2\u05DF \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05DE\u05D4\u05D8\u05D1\u05DC\u05D4..." })
13817
- ] }) : state.tableError ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex-1 flex items-center justify-center p-6 text-center text-xs text-rose-600 bg-rose-50 gap-2", children: [
13818
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.AlertCircle, { className: "w-4 h-4 text-rose-500 shrink-0" }),
13819
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: state.tableError })
13820
- ] }) : !(settings == null ? void 0 : settings.tableMetaId) ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex-1 flex items-center justify-center p-10 text-center text-xs text-slate-400", children: "\u05DC\u05D0 \u05E0\u05D1\u05D7\u05E8\u05D4 \u05D8\u05D1\u05DC\u05EA \u05DE\u05E7\u05D5\u05E8 \u05E2\u05D1\u05D5\u05E8 \u05E8\u05DB\u05D9\u05D1 WhatsApp \u05D6\u05D4" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13821
- TableBlockClient,
14032
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-4 flex flex-col gap-4", children: [
14033
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "grid grid-cols-1 lg:grid-cols-12 gap-4 shrink-0 items-stretch", children: [
14034
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14035
+ TemplateSelectionBlock,
14036
+ {
14037
+ selectedTemplate: state.selectedTemplate,
14038
+ selectedTemplateId: state.selectedTemplateId,
14039
+ setSelectedTemplateId: state.setSelectedTemplateId,
14040
+ templates: state.templates,
14041
+ isLoadingTemplates: state.isLoadingTemplates,
14042
+ isDropdownOpen: state.isDropdownOpen,
14043
+ setIsDropdownOpen: state.setIsDropdownOpen,
14044
+ templateBodyText: state.templateBodyText,
14045
+ templateHeaderComp: state.templateHeaderComp,
14046
+ headerMediaUrl: state.headerMediaUrl,
14047
+ handleHeaderMediaUrlChange: state.handleHeaderMediaUrlChange,
14048
+ handleResetHeaderMediaUrl: state.handleResetHeaderMediaUrl,
14049
+ templateVariables: state.templateVariables,
14050
+ variableMapping: state.variableMapping,
14051
+ handleVariableTypeChange: state.handleVariableTypeChange,
14052
+ handleVariableValueChange: state.handleVariableValueChange,
14053
+ textableColumnOptions: state.textableColumnOptions,
14054
+ handleDeleteTemplate: state.handleDeleteTemplate,
14055
+ isDeleting: state.isDeleting,
14056
+ setIsModalOpen: state.setIsModalOpen,
14057
+ setFeedback: state.setFeedback,
14058
+ isUploadingMedia: state.isUploadingMedia,
14059
+ handleFileUpload: state.handleFileUpload
14060
+ }
14061
+ ),
14062
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14063
+ DynamicFiltersBlock,
14064
+ {
14065
+ filterableColumns: state.filterableColumns,
14066
+ filters: state.filters,
14067
+ handleFilterChange: state.handleFilterChange,
14068
+ handleClearFilters: state.handleClearFilters,
14069
+ activeFiltersCount: state.activeFiltersCount,
14070
+ relationOptions: state.relationOptions,
14071
+ getRelationOptionsForCol: state.getRelationOptionsForCol,
14072
+ selectedRowIds: state.selectedRowIds,
14073
+ filteredRecordsCount: state.filteredRecords.length,
14074
+ rawRecordsCount: state.rawRecords.length,
14075
+ loadTableData: state.loadTableData,
14076
+ isLoadingTableData: state.isLoadingTableData
14077
+ }
14078
+ ),
14079
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14080
+ SettingsAndActionsBlock,
14081
+ {
14082
+ isScanningPhoneColumns: state.isScanningPhoneColumns,
14083
+ targetPhoneOptions: state.targetPhoneOptions,
14084
+ phoneColumnId: state.phoneColumnId,
14085
+ setPhoneColumnId: state.setPhoneColumnId,
14086
+ selectedPhoneOption: state.selectedPhoneOption,
14087
+ autoSelectCount: state.autoSelectCount,
14088
+ setAutoSelectCount: state.setAutoSelectCount,
14089
+ subtableFilterColumn: state.subtableFilterColumn,
14090
+ setSubtableFilterColumn: state.setSubtableFilterColumn,
14091
+ subtableFilterValue: state.subtableFilterValue,
14092
+ setSubtableFilterValue: state.setSubtableFilterValue,
14093
+ subtableSendLimit: state.subtableSendLimit,
14094
+ setSubtableSendLimit: state.setSubtableSendLimit,
14095
+ subtableFilterableColumns: state.subtableFilterableColumns,
14096
+ selectedSubtableFilterCol: state.selectedSubtableFilterCol,
14097
+ getRelationOptionsForCol: state.getRelationOptionsForCol,
14098
+ relationOptions: state.relationOptions,
14099
+ enablePostSendAction: state.enablePostSendAction,
14100
+ setEnablePostSendAction: state.setEnablePostSendAction,
14101
+ postSendActionColumn: state.postSendActionColumn,
14102
+ setPostSendActionColumn: state.setPostSendActionColumn,
14103
+ postSendActionValue: state.postSendActionValue,
14104
+ setPostSendActionValue: state.setPostSendActionValue,
14105
+ postSendActionTargetType: state.postSendActionTargetType,
14106
+ setPostSendActionTargetType: state.setPostSendActionTargetType,
14107
+ postSendActionTargetOptions: state.postSendActionTargetOptions,
14108
+ selectedPostSendOption: state.selectedPostSendCol,
14109
+ isTestDisabled: state.isTestDisabled,
14110
+ testButtonTitle: state.testButtonTitle,
14111
+ setIsTestPromptOpen: state.setIsTestPromptOpen,
14112
+ isSendDisabled: state.isSendDisabled,
14113
+ sendButtonTitle: state.sendButtonTitle,
14114
+ handleSendMessages: state.handleSendMessages,
14115
+ selectedRowIdsCount: state.selectedRowIds.length,
14116
+ finalRecipientCount: state.finalRecipientCount,
14117
+ validMainRowsCount: state.validMainRowsCount,
14118
+ isSendingBroadcast: state.isSendingBroadcast,
14119
+ broadcastProgress: state.broadcastProgress,
14120
+ broadcastSummary: state.broadcastSummary,
14121
+ clearBroadcastSummary: state.clearBroadcastSummary
14122
+ }
14123
+ )
14124
+ ] }),
14125
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-full h-[calc(100vh-420px)] min-h-[320px] overflow-hidden border border-slate-200 rounded-2xl shadow-xs bg-white flex flex-col", children: state.isLoadingTableData && state.rawRecords.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex-1 flex flex-col items-center justify-center p-12 text-center text-xs text-slate-400 gap-2", children: [
14126
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Loader2, { className: "w-6 h-6 animate-spin text-emerald-600" }),
14127
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "\u05D8\u05D5\u05E2\u05DF \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05DE\u05D4\u05D8\u05D1\u05DC\u05D4..." })
14128
+ ] }) : state.tableError ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex-1 flex items-center justify-center p-6 text-center text-xs text-rose-600 bg-rose-50 gap-2", children: [
14129
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.AlertCircle, { className: "w-4 h-4 text-rose-500 shrink-0" }),
14130
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: state.tableError })
14131
+ ] }) : !(settings == null ? void 0 : settings.tableMetaId) ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex-1 flex items-center justify-center p-10 text-center text-xs text-slate-400", children: "\u05DC\u05D0 \u05E0\u05D1\u05D7\u05E8\u05D4 \u05D8\u05D1\u05DC\u05EA \u05DE\u05E7\u05D5\u05E8 \u05E2\u05D1\u05D5\u05E8 \u05E8\u05DB\u05D9\u05D1 WhatsApp \u05D6\u05D4" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14132
+ TableBlockClient,
14133
+ {
14134
+ settings: {
14135
+ tableMetaId: settings.tableMetaId,
14136
+ tableId: settings.tableMetaId,
14137
+ title: "",
14138
+ columns: state.tableColumns
14139
+ },
14140
+ data: state.filteredRecords,
14141
+ readOnly: true,
14142
+ selectedRowIds: state.selectedRowIds,
14143
+ onSelectionChange: state.handleSelectionChange,
14144
+ onRowToggle: state.handleRowToggle,
14145
+ executeAction: state.embeddedTableExecuteAction,
14146
+ orgId,
14147
+ componentId: `${componentId || "whatsapp"}-embedded-table`,
14148
+ className: "h-full flex-1 border-0 rounded-2xl shadow-none",
14149
+ rowStatusMap: state.rowStatusMap
14150
+ }
14151
+ ) })
14152
+ ] }),
14153
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14154
+ CreateTemplateModal,
13822
14155
  {
13823
- settings: {
13824
- tableMetaId: settings.tableMetaId,
13825
- tableId: settings.tableMetaId,
13826
- title: "",
13827
- columns: state.tableColumns
14156
+ isOpen: state.isModalOpen,
14157
+ onClose: () => state.setIsModalOpen(false),
14158
+ onSuccess: () => {
14159
+ state.loadTemplates();
13828
14160
  },
13829
- data: state.filteredRecords,
13830
- readOnly: true,
13831
- selectedRowIds: state.selectedRowIds,
13832
- onSelectionChange: state.handleSelectionChange,
13833
- onRowToggle: state.handleRowToggle,
13834
- executeAction: state.embeddedTableExecuteAction,
13835
- orgId,
13836
- componentId: `${componentId || "whatsapp"}-embedded-table`,
13837
- className: "h-full flex-1 border-0 rounded-2xl shadow-none",
13838
- rowStatusMap: state.rowStatusMap
14161
+ existingTemplates: state.templates,
14162
+ existingTemplateNames: state.existingTemplateNames,
14163
+ executeAction,
14164
+ orgId: state.orgId || orgId
13839
14165
  }
13840
- ) })
13841
- ] }),
13842
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13843
- CreateTemplateModal,
13844
- {
13845
- isOpen: state.isModalOpen,
13846
- onClose: () => state.setIsModalOpen(false),
13847
- onSuccess: () => {
13848
- state.loadTemplates();
13849
- },
13850
- existingTemplates: state.templates,
13851
- existingTemplateNames: state.existingTemplateNames,
13852
- executeAction,
13853
- orgId: state.orgId || orgId
13854
- }
13855
- ),
13856
- state.isTestPromptOpen && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13857
- "div",
13858
- {
13859
- className: "fixed inset-0 bg-slate-900/60 backdrop-blur-xs z-50 flex items-center justify-center p-4 overflow-y-auto animate-in fade-in duration-150",
13860
- dir: "rtl",
13861
- onClick: () => {
13862
- state.setIsTestPromptOpen(false);
13863
- state.setTestFeedback(null);
13864
- },
13865
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
13866
- "div",
13867
- {
13868
- className: "bg-white rounded-2xl border border-slate-200 shadow-2xl w-full max-w-md flex flex-col overflow-hidden animate-in zoom-in-95 duration-150",
13869
- role: "dialog",
13870
- "aria-modal": "true",
13871
- "aria-labelledby": "test-modal-title",
13872
- onClick: (e) => e.stopPropagation(),
13873
- children: [
13874
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "px-5 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/70", children: [
13875
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2.5", children: [
13876
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-8 h-8 rounded-lg bg-emerald-100 text-emerald-700 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Phone, { className: "w-4 h-4" }) }),
13877
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
13878
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { id: "test-modal-title", className: "text-sm font-bold text-slate-900", children: "\u05E9\u05DC\u05D9\u05D7\u05EA \u05D4\u05D5\u05D3\u05E2\u05EA \u05D1\u05D3\u05D9\u05E7\u05D4 (\u05D8\u05E1\u05D8)" }),
13879
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-slate-500", children: "\u05D1\u05D3\u05D9\u05E7\u05EA \u05D4\u05EA\u05D1\u05E0\u05D9\u05EA \u05DE\u05D5\u05DC \u05E0\u05DE\u05E2\u05DF \u05D1\u05D5\u05D3\u05D3 \u05DC\u05E4\u05E0\u05D9 \u05E9\u05D9\u05D3\u05D5\u05E8 \u05E8\u05D7\u05D1" })
13880
- ] })
13881
- ] }),
13882
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13883
- "button",
13884
- {
13885
- type: "button",
13886
- disabled: state.isSendingTest,
13887
- onClick: () => {
13888
- if (state.isSendingTest) return;
13889
- state.setIsTestPromptOpen(false);
13890
- state.setTestFeedback(null);
13891
- },
13892
- className: `w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${state.isSendingTest ? "text-slate-300 cursor-not-allowed" : "text-slate-400 hover:text-slate-700 hover:bg-slate-200/50 cursor-pointer"}`,
13893
- title: "\u05E1\u05D2\u05D5\u05E8",
13894
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.X, { className: "w-4 h-4" })
13895
- }
13896
- )
13897
- ] }),
13898
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-5 space-y-4", children: [
13899
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-2.5 bg-slate-50 border border-slate-200/80 rounded-xl flex items-center justify-between text-xs", children: [
13900
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-500 font-medium", children: "\u05EA\u05D1\u05E0\u05D9\u05EA \u05E0\u05D1\u05D7\u05E8\u05EA:" }),
13901
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-bold text-slate-800 font-mono", children: ((_a = state.selectedTemplate) == null ? void 0 : _a.name) || "\u05DC\u05D0 \u05E0\u05D1\u05D7\u05E8\u05D4 \u05EA\u05D1\u05E0\u05D9\u05EA" })
13902
- ] }),
13903
- state.selectedPhoneOption && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-2 bg-emerald-50/50 border border-emerald-200/60 rounded-xl flex items-center justify-between text-[11px]", children: [
13904
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-emerald-800 font-medium", children: "\u05E2\u05DE\u05D5\u05D3\u05EA \u05D9\u05E2\u05D3:" }),
13905
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-bold text-emerald-950 font-mono", children: state.selectedPhoneOption.label })
14166
+ ),
14167
+ state.isTestPromptOpen && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14168
+ "div",
14169
+ {
14170
+ className: "fixed inset-0 bg-slate-900/60 backdrop-blur-xs z-50 flex items-center justify-center p-4 overflow-y-auto animate-in fade-in duration-150",
14171
+ dir: "rtl",
14172
+ onClick: () => {
14173
+ state.setIsTestPromptOpen(false);
14174
+ state.setTestFeedback(null);
14175
+ },
14176
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
14177
+ "div",
14178
+ {
14179
+ className: "bg-white rounded-2xl border border-slate-200 shadow-2xl w-full max-w-md flex flex-col overflow-hidden animate-in zoom-in-95 duration-150",
14180
+ role: "dialog",
14181
+ "aria-modal": "true",
14182
+ "aria-labelledby": "test-modal-title",
14183
+ onClick: (e) => e.stopPropagation(),
14184
+ children: [
14185
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "px-5 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/70", children: [
14186
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2.5", children: [
14187
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-8 h-8 rounded-lg bg-emerald-100 text-emerald-700 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Phone, { className: "w-4 h-4" }) }),
14188
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
14189
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h3", { id: "test-modal-title", className: "text-sm font-bold text-slate-900", children: "\u05E9\u05DC\u05D9\u05D7\u05EA \u05D4\u05D5\u05D3\u05E2\u05EA \u05D1\u05D3\u05D9\u05E7\u05D4 (\u05D8\u05E1\u05D8)" }),
14190
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-slate-500", children: "\u05D1\u05D3\u05D9\u05E7\u05EA \u05D4\u05EA\u05D1\u05E0\u05D9\u05EA \u05DE\u05D5\u05DC \u05E0\u05DE\u05E2\u05DF \u05D1\u05D5\u05D3\u05D3 \u05DC\u05E4\u05E0\u05D9 \u05E9\u05D9\u05D3\u05D5\u05E8 \u05E8\u05D7\u05D1" })
14191
+ ] })
14192
+ ] }),
14193
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14194
+ "button",
14195
+ {
14196
+ type: "button",
14197
+ disabled: state.isSendingTest,
14198
+ onClick: () => {
14199
+ if (state.isSendingTest) return;
14200
+ state.setIsTestPromptOpen(false);
14201
+ state.setTestFeedback(null);
14202
+ },
14203
+ className: `w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${state.isSendingTest ? "text-slate-300 cursor-not-allowed" : "text-slate-400 hover:text-slate-700 hover:bg-slate-200/50 cursor-pointer"}`,
14204
+ title: "\u05E1\u05D2\u05D5\u05E8",
14205
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.X, { className: "w-4 h-4" })
14206
+ }
14207
+ )
13906
14208
  ] }),
13907
- state.templateHeaderComp && (() => {
13908
- const headerFormat = (state.templateHeaderComp.format || "").toUpperCase();
13909
- const docFilename = resolveDocumentFilename(state.templateHeaderComp, state.headerMediaUrl);
13910
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-2.5 bg-slate-50 border border-slate-200/80 rounded-xl flex items-center justify-between text-xs", children: [
13911
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex items-center gap-2 overflow-hidden", children: headerFormat === "IMAGE" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
13912
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-7 h-7 rounded-md overflow-hidden border border-slate-200 shrink-0 bg-slate-100 flex items-center justify-center", children: state.headerMediaUrl && state.headerMediaUrl.startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13913
- "img",
13914
- {
13915
- src: state.headerMediaUrl,
13916
- alt: "\u05EA\u05DE\u05D5\u05E0\u05EA \u05DB\u05D5\u05EA\u05E8\u05EA",
13917
- className: "w-full h-full object-cover",
13918
- onError: (e) => {
13919
- e.currentTarget.style.display = "none";
13920
- }
13921
- }
13922
- ) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Image, { className: "w-3.5 h-3.5 text-emerald-600" }) }),
13923
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-semibold text-slate-800 truncate", children: "\u05EA\u05DE\u05D5\u05E0\u05EA \u05DB\u05D5\u05EA\u05E8\u05EA" })
13924
- ] }) : headerFormat === "DOCUMENT" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
13925
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-7 h-7 rounded-md bg-rose-50 text-rose-600 border border-rose-100 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.FileText, { className: "w-3.5 h-3.5" }) }),
13926
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "overflow-hidden", children: [
13927
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-semibold text-slate-800 block truncate", children: "\u05DE\u05E1\u05DE\u05DA \u05DB\u05D5\u05EA\u05E8\u05EA (PDF)" }),
13928
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-slate-500 font-mono block truncate", title: docFilename, children: docFilename })
13929
- ] })
13930
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
13931
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-7 h-7 rounded-md bg-indigo-50 text-indigo-600 border border-indigo-100 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Video, { className: "w-3.5 h-3.5" }) }),
13932
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-semibold text-slate-800 truncate", children: "\u05E1\u05E8\u05D8\u05D5\u05DF \u05DB\u05D5\u05EA\u05E8\u05EA" })
13933
- ] }) }),
13934
- state.headerMediaUrl && state.headerMediaUrl.startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-emerald-700 bg-emerald-50 border border-emerald-200 px-1.5 py-0.5 rounded font-medium shrink-0", children: "\u05E7\u05D5\u05D1\u05E5 \u05DE\u05E6\u05D5\u05E8\u05E3 \u05EA\u05E7\u05D9\u05DF" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded font-medium shrink-0", children: "\u05E0\u05D3\u05E8\u05E9 \u05E6\u05D9\u05E8\u05D5\u05E3 \u05E7\u05D5\u05D1\u05E5 \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA \u05D6\u05D5" })
13935
- ] });
13936
- })(),
13937
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1.5", children: [
13938
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "text-xs font-semibold text-slate-700 block", children: [
13939
- "\u05DE\u05E1\u05E4\u05E8 \u05D8\u05DC\u05E4\u05D5\u05DF \u05DC\u05D8\u05E1\u05D8 ",
13940
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-rose-500", children: "*" })
14209
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-5 space-y-4", children: [
14210
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-2.5 bg-slate-50 border border-slate-200/80 rounded-xl flex items-center justify-between text-xs", children: [
14211
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-slate-500 font-medium", children: "\u05EA\u05D1\u05E0\u05D9\u05EA \u05E0\u05D1\u05D7\u05E8\u05EA:" }),
14212
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-bold text-slate-800 font-mono", children: ((_a = state.selectedTemplate) == null ? void 0 : _a.name) || "\u05DC\u05D0 \u05E0\u05D1\u05D7\u05E8\u05D4 \u05EA\u05D1\u05E0\u05D9\u05EA" })
13941
14213
  ] }),
13942
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative", children: [
13943
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13944
- "input",
13945
- {
13946
- type: "tel",
13947
- dir: "ltr",
13948
- autoFocus: true,
13949
- disabled: state.isSendingTest,
13950
- value: state.testPhoneNumber,
13951
- onChange: (e) => {
13952
- state.handleTestPhoneChange(e.target.value);
13953
- if (state.testFeedback) state.setTestFeedback(null);
13954
- },
13955
- onKeyDown: (e) => {
13956
- if (e.key === "Enter" && state.testPhoneNumber.trim() && !state.isSendingTest) {
13957
- e.preventDefault();
13958
- state.handleSendTest();
14214
+ state.selectedPhoneOption && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-2 bg-emerald-50/50 border border-emerald-200/60 rounded-xl flex items-center justify-between text-[11px]", children: [
14215
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-emerald-800 font-medium", children: "\u05E2\u05DE\u05D5\u05D3\u05EA \u05D9\u05E2\u05D3:" }),
14216
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-bold text-emerald-950 font-mono", children: state.selectedPhoneOption.label })
14217
+ ] }),
14218
+ state.templateHeaderComp && (() => {
14219
+ const headerFormat = (state.templateHeaderComp.format || "").toUpperCase();
14220
+ const docFilename = resolveDocumentFilename(state.templateHeaderComp, state.headerMediaUrl);
14221
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-2.5 bg-slate-50 border border-slate-200/80 rounded-xl flex items-center justify-between text-xs", children: [
14222
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex items-center gap-2 overflow-hidden", children: headerFormat === "IMAGE" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
14223
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-7 h-7 rounded-md overflow-hidden border border-slate-200 shrink-0 bg-slate-100 flex items-center justify-center", children: state.headerMediaUrl && state.headerMediaUrl.startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14224
+ "img",
14225
+ {
14226
+ src: state.headerMediaUrl,
14227
+ alt: "\u05EA\u05DE\u05D5\u05E0\u05EA \u05DB\u05D5\u05EA\u05E8\u05EA",
14228
+ className: "w-full h-full object-cover",
14229
+ onError: (e) => {
14230
+ e.currentTarget.style.display = "none";
14231
+ }
13959
14232
  }
13960
- },
13961
- placeholder: "\u05DC\u05D3\u05D5\u05D2\u05DE\u05D4: 0501234567",
13962
- className: "w-full h-10 px-3 pr-3 pl-8 text-sm rounded-xl border border-slate-200 bg-white text-slate-900 placeholder:text-slate-400 focus:outline-hidden focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500 transition-all font-mono disabled:opacity-60 disabled:cursor-not-allowed"
13963
- }
13964
- ),
13965
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Phone, { className: "w-4 h-4 text-slate-400 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none" })
14233
+ ) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Image, { className: "w-3.5 h-3.5 text-emerald-600" }) }),
14234
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-800 truncate", children: "\u05EA\u05DE\u05D5\u05E0\u05EA \u05DB\u05D5\u05EA\u05E8\u05EA" })
14235
+ ] }) : headerFormat === "DOCUMENT" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
14236
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-7 h-7 rounded-md bg-rose-50 text-rose-600 border border-rose-100 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.FileText, { className: "w-3.5 h-3.5" }) }),
14237
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "overflow-hidden", children: [
14238
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-800 block truncate", children: "\u05DE\u05E1\u05DE\u05DA \u05DB\u05D5\u05EA\u05E8\u05EA (PDF)" }),
14239
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-[10px] text-slate-500 font-mono block truncate", title: docFilename, children: docFilename })
14240
+ ] })
14241
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
14242
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-7 h-7 rounded-md bg-indigo-50 text-indigo-600 border border-indigo-100 flex items-center justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Video, { className: "w-3.5 h-3.5" }) }),
14243
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-800 truncate", children: "\u05E1\u05E8\u05D8\u05D5\u05DF \u05DB\u05D5\u05EA\u05E8\u05EA" })
14244
+ ] }) }),
14245
+ state.headerMediaUrl && state.headerMediaUrl.startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-[10px] text-emerald-700 bg-emerald-50 border border-emerald-200 px-1.5 py-0.5 rounded font-medium shrink-0", children: "\u05E7\u05D5\u05D1\u05E5 \u05DE\u05E6\u05D5\u05E8\u05E3 \u05EA\u05E7\u05D9\u05DF" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-[10px] text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded font-medium shrink-0", children: "\u05E0\u05D3\u05E8\u05E9 \u05E6\u05D9\u05E8\u05D5\u05E3 \u05E7\u05D5\u05D1\u05E5 \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA \u05D6\u05D5" })
14246
+ ] });
14247
+ })(),
14248
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "space-y-1.5", children: [
14249
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "text-xs font-semibold text-slate-700 block", children: [
14250
+ "\u05DE\u05E1\u05E4\u05E8 \u05D8\u05DC\u05E4\u05D5\u05DF \u05DC\u05D8\u05E1\u05D8 ",
14251
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-rose-500", children: "*" })
14252
+ ] }),
14253
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", children: [
14254
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14255
+ "input",
14256
+ {
14257
+ type: "tel",
14258
+ dir: "ltr",
14259
+ autoFocus: true,
14260
+ disabled: state.isSendingTest,
14261
+ value: state.testPhoneNumber,
14262
+ onChange: (e) => {
14263
+ state.handleTestPhoneChange(e.target.value);
14264
+ if (state.testFeedback) state.setTestFeedback(null);
14265
+ },
14266
+ onKeyDown: (e) => {
14267
+ if (e.key === "Enter" && state.testPhoneNumber.trim() && !state.isSendingTest) {
14268
+ e.preventDefault();
14269
+ state.handleSendTest();
14270
+ }
14271
+ },
14272
+ placeholder: "\u05DC\u05D3\u05D5\u05D2\u05DE\u05D4: 0501234567",
14273
+ className: "w-full h-10 px-3 pr-3 pl-8 text-sm rounded-xl border border-slate-200 bg-white text-slate-900 placeholder:text-slate-400 focus:outline-hidden focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500 transition-all font-mono disabled:opacity-60 disabled:cursor-not-allowed"
14274
+ }
14275
+ ),
14276
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Phone, { className: "w-4 h-4 text-slate-400 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none" })
14277
+ ] }),
14278
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-slate-500 leading-normal", children: "\u05D4\u05D5\u05D3\u05E2\u05EA \u05D4\u05D1\u05D3\u05D9\u05E7\u05D4 \u05EA\u05D9\u05E9\u05DC\u05D7 \u05D9\u05E9\u05D9\u05E8\u05D5\u05EA \u05DC\u05DE\u05E1\u05E4\u05E8 \u05D6\u05D4 \u05DC\u05E6\u05D5\u05E8\u05DA \u05D5\u05D9\u05D3\u05D5\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D5\u05EA \u05EA\u05D5\u05DB\u05DF \u05D4\u05D4\u05D5\u05D3\u05E2\u05D4 \u05D5\u05D4\u05E2\u05D9\u05E6\u05D5\u05D1." })
13966
14279
  ] }),
13967
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-slate-500 leading-normal", children: "\u05D4\u05D5\u05D3\u05E2\u05EA \u05D4\u05D1\u05D3\u05D9\u05E7\u05D4 \u05EA\u05D9\u05E9\u05DC\u05D7 \u05D9\u05E9\u05D9\u05E8\u05D5\u05EA \u05DC\u05DE\u05E1\u05E4\u05E8 \u05D6\u05D4 \u05DC\u05E6\u05D5\u05E8\u05DA \u05D5\u05D9\u05D3\u05D5\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D5\u05EA \u05EA\u05D5\u05DB\u05DF \u05D4\u05D4\u05D5\u05D3\u05E2\u05D4 \u05D5\u05D4\u05E2\u05D9\u05E6\u05D5\u05D1." })
14280
+ state.testFeedback && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 flex items-center gap-2", children: [
14281
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.AlertCircle, { className: "w-4 h-4 text-rose-500 shrink-0" }),
14282
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: state.testFeedback })
14283
+ ] })
13968
14284
  ] }),
13969
- state.testFeedback && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 flex items-center gap-2", children: [
13970
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.AlertCircle, { className: "w-4 h-4 text-rose-500 shrink-0" }),
13971
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: state.testFeedback })
14285
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "px-5 py-3.5 bg-slate-50/70 border-t border-slate-100 flex items-center justify-end gap-2", children: [
14286
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14287
+ "button",
14288
+ {
14289
+ type: "button",
14290
+ disabled: state.isSendingTest,
14291
+ onClick: () => {
14292
+ if (state.isSendingTest) return;
14293
+ state.setIsTestPromptOpen(false);
14294
+ state.setTestFeedback(null);
14295
+ },
14296
+ className: `px-4 py-2 text-xs font-semibold text-slate-600 rounded-xl transition-colors ${state.isSendingTest ? "opacity-50 cursor-not-allowed" : "hover:text-slate-800 hover:bg-slate-200/50 cursor-pointer"}`,
14297
+ children: "\u05D1\u05D9\u05D8\u05D5\u05DC"
14298
+ }
14299
+ ),
14300
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
14301
+ "button",
14302
+ {
14303
+ type: "button",
14304
+ disabled: !state.testPhoneNumber.trim() || state.isSendingTest || state.isTestDisabled,
14305
+ onClick: state.handleSendTest,
14306
+ title: state.testButtonTitle,
14307
+ className: `px-4 py-2 text-xs font-bold rounded-xl transition-all flex items-center gap-1.5 ${!state.testPhoneNumber.trim() || state.isSendingTest || state.isTestDisabled ? "bg-emerald-600/40 text-white/70 cursor-not-allowed" : "bg-emerald-600 hover:bg-emerald-700 active:scale-[0.98] text-white shadow-xs cursor-pointer"}`,
14308
+ children: state.isSendingTest ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
14309
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Loader2, { className: "w-3.5 h-3.5 animate-spin" }),
14310
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "\u05E9\u05D5\u05DC\u05D7..." })
14311
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
14312
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Send, { className: "w-3.5 h-3.5" }),
14313
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "\u05E9\u05DC\u05D7 \u05E2\u05DB\u05E9\u05D9\u05D5" })
14314
+ ] })
14315
+ }
14316
+ )
13972
14317
  ] })
13973
- ] }),
13974
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "px-5 py-3.5 bg-slate-50/70 border-t border-slate-100 flex items-center justify-end gap-2", children: [
13975
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13976
- "button",
13977
- {
13978
- type: "button",
13979
- disabled: state.isSendingTest,
13980
- onClick: () => {
13981
- if (state.isSendingTest) return;
13982
- state.setIsTestPromptOpen(false);
13983
- state.setTestFeedback(null);
13984
- },
13985
- className: `px-4 py-2 text-xs font-semibold text-slate-600 rounded-xl transition-colors ${state.isSendingTest ? "opacity-50 cursor-not-allowed" : "hover:text-slate-800 hover:bg-slate-200/50 cursor-pointer"}`,
13986
- children: "\u05D1\u05D9\u05D8\u05D5\u05DC"
13987
- }
13988
- ),
13989
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
13990
- "button",
13991
- {
13992
- type: "button",
13993
- disabled: !state.testPhoneNumber.trim() || state.isSendingTest || state.isTestDisabled,
13994
- onClick: state.handleSendTest,
13995
- title: state.testButtonTitle,
13996
- className: `px-4 py-2 text-xs font-bold rounded-xl transition-all flex items-center gap-1.5 ${!state.testPhoneNumber.trim() || state.isSendingTest || state.isTestDisabled ? "bg-emerald-600/40 text-white/70 cursor-not-allowed" : "bg-emerald-600 hover:bg-emerald-700 active:scale-[0.98] text-white shadow-xs cursor-pointer"}`,
13997
- children: state.isSendingTest ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
13998
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Loader2, { className: "w-3.5 h-3.5 animate-spin" }),
13999
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u05E9\u05D5\u05DC\u05D7..." })
14000
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
14001
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react14.Send, { className: "w-3.5 h-3.5" }),
14002
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u05E9\u05DC\u05D7 \u05E2\u05DB\u05E9\u05D9\u05D5" })
14003
- ] })
14004
- }
14005
- )
14006
- ] })
14007
- ]
14008
- }
14009
- )
14010
- }
14011
- )
14318
+ ]
14319
+ }
14320
+ )
14321
+ }
14322
+ )
14323
+ ] })
14012
14324
  ]
14013
14325
  }
14014
14326
  );
14015
14327
  }
14016
14328
 
14017
14329
  // src/components/FormBlock/FormBlock.tsx
14018
- var import_react21 = require("react");
14019
- var import_lucide_react15 = require("lucide-react");
14020
- var import_jsx_runtime21 = require("react/jsx-runtime");
14330
+ var import_react24 = require("react");
14331
+ var import_lucide_react17 = require("lucide-react");
14332
+ var import_jsx_runtime24 = require("react/jsx-runtime");
14021
14333
  function FormBlock({ settings: schema, executeAction, componentId, className = "", onSuccess }) {
14022
14334
  const { showError, addToast } = useToast();
14023
- const [formData, setFormData] = (0, import_react21.useState)({});
14024
- const [isSubmitting, setIsSubmitting] = (0, import_react21.useState)(false);
14025
- const [isSubmitted, setIsSubmitted] = (0, import_react21.useState)(false);
14026
- const [columns, setColumns] = (0, import_react21.useState)((schema == null ? void 0 : schema.columns) || []);
14027
- const [isLoadingSchema, setIsLoadingSchema] = (0, import_react21.useState)(false);
14335
+ const [formData, setFormData] = (0, import_react24.useState)({});
14336
+ const [isSubmitting, setIsSubmitting] = (0, import_react24.useState)(false);
14337
+ const [isSubmitted, setIsSubmitted] = (0, import_react24.useState)(false);
14338
+ const [columns, setColumns] = (0, import_react24.useState)((schema == null ? void 0 : schema.columns) || []);
14339
+ const [isLoadingSchema, setIsLoadingSchema] = (0, import_react24.useState)(false);
14028
14340
  const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
14029
- (0, import_react21.useEffect)(() => {
14341
+ (0, import_react24.useEffect)(() => {
14030
14342
  let isMounted = true;
14031
14343
  if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction) {
14032
14344
  setIsLoadingSchema(true);
@@ -14108,21 +14420,21 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
14108
14420
  }
14109
14421
  };
14110
14422
  if (isLoadingSchema) {
14111
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "p-8 flex items-center justify-center gap-2 text-slate-500", children: [
14112
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.Loader2, { className: "w-5 h-5 animate-spin text-brand" }),
14113
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-sm", children: "\u05D8\u05D5\u05E2\u05DF \u05E9\u05D3\u05D5\u05EA \u05D8\u05D5\u05E4\u05E1..." })
14423
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "p-8 flex items-center justify-center gap-2 text-slate-500", children: [
14424
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react17.Loader2, { className: "w-5 h-5 animate-spin text-brand" }),
14425
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-sm", children: "\u05D8\u05D5\u05E2\u05DF \u05E9\u05D3\u05D5\u05EA \u05D8\u05D5\u05E4\u05E1..." })
14114
14426
  ] });
14115
14427
  }
14116
14428
  if (!formColumns || formColumns.length === 0) {
14117
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "p-4 text-center text-slate-500", children: "\u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8\u05D5 \u05E9\u05D3\u05D5\u05EA \u05DC\u05D8\u05D5\u05E4\u05E1 \u05D6\u05D4." });
14429
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "p-4 text-center text-slate-500", children: "\u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8\u05D5 \u05E9\u05D3\u05D5\u05EA \u05DC\u05D8\u05D5\u05E4\u05E1 \u05D6\u05D4." });
14118
14430
  }
14119
14431
  if (isSubmitted) {
14120
14432
  const customMessage = (schema == null ? void 0 : schema.successMessage) || "\u05EA\u05D5\u05D3\u05D4 \u05E8\u05D1\u05D4! \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D4\u05EA\u05E7\u05D1\u05DC\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4.";
14121
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { id: componentId, className: `bg-white p-8 rounded-xl shadow-xs border border-slate-200 text-center dir-rtl ${className}`, children: [
14122
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "w-16 h-16 bg-emerald-50 text-emerald-600 rounded-full flex items-center justify-center mx-auto mb-4 animate-in zoom-in duration-200", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.CheckCircle2, { className: "w-8 h-8" }) }),
14123
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "text-2xl font-bold text-slate-800 mb-2", children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
14124
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-slate-600 text-base max-w-md mx-auto whitespace-pre-wrap", children: customMessage }),
14125
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14433
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { id: componentId, className: `bg-white p-8 rounded-xl shadow-xs border border-slate-200 text-center dir-rtl ${className}`, children: [
14434
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "w-16 h-16 bg-emerald-50 text-emerald-600 rounded-full flex items-center justify-center mx-auto mb-4 animate-in zoom-in duration-200", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react17.CheckCircle2, { className: "w-8 h-8" }) }),
14435
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { className: "text-2xl font-bold text-slate-800 mb-2", children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
14436
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-slate-600 text-base max-w-md mx-auto whitespace-pre-wrap", children: customMessage }),
14437
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
14126
14438
  "button",
14127
14439
  {
14128
14440
  type: "button",
@@ -14133,20 +14445,20 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
14133
14445
  )
14134
14446
  ] });
14135
14447
  }
14136
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { id: componentId, className: `bg-white p-6 rounded-xl shadow-xs border border-slate-200 dir-rtl ${className}`, children: [
14137
- (schema == null ? void 0 : schema.title) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h2", { className: "text-xl font-bold text-slate-800 mb-6", children: schema.title }),
14138
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
14448
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { id: componentId, className: `bg-white p-6 rounded-xl shadow-xs border border-slate-200 dir-rtl ${className}`, children: [
14449
+ (schema == null ? void 0 : schema.title) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h2", { className: "text-xl font-bold text-slate-800 mb-6", children: schema.title }),
14450
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
14139
14451
  formColumns.map((col) => {
14140
14452
  var _a, _b;
14141
14453
  const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
14142
14454
  const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
14143
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
14144
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "text-sm font-semibold text-slate-700", children: [
14455
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
14456
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "text-sm font-semibold text-slate-700", children: [
14145
14457
  col.name,
14146
14458
  " ",
14147
- col.isRequired && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-rose-500", children: "*" })
14459
+ col.isRequired && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-rose-500", children: "*" })
14148
14460
  ] }),
14149
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "border border-slate-200 rounded-lg min-h-[40px] relative", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14461
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "border border-slate-200 rounded-lg min-h-[40px] relative", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
14150
14462
  InputComponent,
14151
14463
  {
14152
14464
  column: col,
@@ -14161,15 +14473,15 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
14161
14473
  ) })
14162
14474
  ] }, col.name);
14163
14475
  }),
14164
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "pt-4 border-t border-slate-100 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
14476
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "pt-4 border-t border-slate-100 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
14165
14477
  "button",
14166
14478
  {
14167
14479
  type: "submit",
14168
14480
  disabled: isSubmitting,
14169
14481
  className: "flex items-center gap-2 px-6 py.2.5 bg-brand hover:bg-brand-hover text-white font-bold rounded-lg shadow-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
14170
14482
  children: [
14171
- isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react15.Loader2, { className: "w-4 h-4 animate-spin" }),
14172
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: isSubmitting ? "\u05E9\u05D5\u05DE\u05E8..." : "\u05E9\u05DC\u05D9\u05D7\u05D4" })
14483
+ isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react17.Loader2, { className: "w-4 h-4 animate-spin" }),
14484
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: isSubmitting ? "\u05E9\u05D5\u05DE\u05E8..." : "\u05E9\u05DC\u05D9\u05D7\u05D4" })
14173
14485
  ]
14174
14486
  }
14175
14487
  ) })