PageSourceSearch

https://portal.heyfilo.ai/assets/PublishingPage-Cb6op13U.js

js heyfilo.ai collected 2026-10-05 14:28:33 UTC 56,434 bytes, 21 lines download raw bytes

1import{ag as xe,d as ze,A as J,r,g as re,k as z,z as a,x as T,j as e,B as y,H as Xe,J as B,T as Ge,X as H,al as Ve,I as S,t as ue,E as Ze,C as et,q as tt,p as E,P as st,a0 as Ie,au as at,av as rt,aw as Le}from"./index-BIdkve2-.js";import{C as me}from"./ConfirmDialog-WSQPel74.js";import{L as ae}from"./loader-circle-E1TIqegY.js";import{R as Me}from"./rotate-ccw-7r1vtdP8.js";import{C as lt}from"./circle-x-BK6ctuSy.js";import{C as nt}from"./chevron-right-4d9yxbld.js";import{C as it}from"./copy-CaarSlOr.js";import{S as Re}from"./shopping-bag-B64lIAYH.js";import"./triangle-alert-YYr4p_EE.js";/**
2 * @license lucide-react v0.400.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ot=xe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
7 * @license lucide-react v0.400.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const ct=xe("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
12 * @license lucide-react v0.400.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const dt=xe("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
17 * @license lucide-react v0.400.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Fe=xe("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),ut=[{value:"hmac",label:"HMAC Signature (recommended)"},{value:"bearer",label:"Bearer Token"},{value:"api_key",label:"API Key Header"},{value:"none",label:"None"}];function xt({status:s}){const m={healthy:"bg-green-500",degraded:"bg-yellow-500",unhealthy:"bg-red-500",unknown:"bg-gray-400"};return e.jsx("div",{className:`w-2 h-2 rounded-full ${m[s]||m.unknown}`})}function mt({status:s}){const m={success:{className:"bg-green-50 text-green-700",label:"Success"},failed:{className:"bg-red-50 text-red-700",label:"Failed"},retrying:{className:"bg-yellow-50 text-yellow-700",label:"Retrying"},dead:{className:"bg-gray-100 text-gray-700",label:"Dead"},pending:{className:"bg-blue-50 text-blue-700",label:"Pending"}},n=m[s]||m.pending;return e.jsx(B,{className:n.className,children:n.label})}function ht(){const{isReadOnlyTenant:s}=ze(),m=J(),[n,h]=r.useState(!1),[j,C]=r.useState(null),[v,_]=r.useState(null),[N,w]=r.useState(null),{data:k=[],isLoading:D}=re({queryKey:["webhook-connections"],queryFn:async()=>{var l;const c=await T.listConnections();return Array.isArray(c.data)?c.data:((l=c.data)==null?void 0:l.results)??[]}}),{mutate:o,isPending:p}=z({mutationFn:c=>T.deleteConnection(c),onSuccess:()=>{m.invalidateQueries({queryKey:["webhook-connections"]}),a.success("Webhook connection deleted.")},onError:()=>a.error("Failed to delete connection."),onSettled:()=>w(null)});return D?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ae,{className:"h-5 w-5 animate-spin text-claude-text-tertiary"})}):e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-bold text-claude-text-primary mb-3",children:"Connect via API"}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4 text-claude-accent"}),e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:"Publish to custom websites via webhook."})]}),!s&&e.jsxs(y,{size:"sm",onClick:()=>h(!0),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 mr-1"}),"Add"]})]}),k.length===0?e.jsx("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft",children:e.jsxs("div",{className:"flex flex-col items-center py-12",children:[e.jsx("div",{className:"h-10 w-10 rounded-2xl bg-claude-bg-alt flex items-center justify-center mb-3",children:e.jsx(Fe,{className:"h-4 w-4 text-claude-text-tertiary"})}),e.jsx("p",{className:"text-sm text-claude-text-secondary font-medium",children:"No API connections yet"}),e.jsx("p",{className:"text-xs text-claude-text-tertiary mt-1 text-center px-4",children:"Add a connection to publish content to your custom websites."})]})}):e.jsx("div",{className:"space-y-3",children:k.map(c=>e.jsxs("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft p-5 hover:shadow-card transition-shadow",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{status:c.health_status}),e.jsx("h3",{className:"font-medium text-claude-text text-sm truncate",children:c.name})]}),c.is_active?e.jsx(B,{className:"bg-claude-success-light text-claude-success",children:"Active"}):e.jsx(B,{className:"bg-claude-danger-light text-claude-danger",children:"Inactive"})]}),e.jsx("p",{className:"text-xs text-claude-text-tertiary truncate mb-1",children:c.webhook_url}),e.jsxs("p",{className:"text-[11px] text-claude-text-secondary mb-3",children:["Auth: ",e.jsx("span",{className:"font-medium",children:c.auth_type.toUpperCase()})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>C(c),children:[e.jsx(ct,{className:"h-3 w-3 mr-1"}),"Logs"]}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>_(c),children:"Edit"}),e.jsx(y,{size:"sm",variant:"ghost",className:"text-claude-danger hover:bg-claude-danger-light",onClick:()=>w(c),children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]})]})]},c.id))}),!s&&(n||v)&&e.jsx(pt,{connection:v,onClose:()=>{h(!1),_(null)}}),j&&e.jsx(bt,{connection:j,onClose:()=>C(null)}),e.jsx(me,{open:N!==null,title:"Delete this webhook connection?",description:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-claude-text",children:N==null?void 0:N.name})," will stop receiving posts immediately, and any content scheduled to it will fail to deliver. This cannot be undone."]}),confirmLabel:"Delete connection",isLoading:p,onConfirm:()=>N&&o(N.id),onCancel:()=>w(null)})]})}async function Ee(s){try{await navigator.clipboard.writeText(s),a.success("Copied to clipboard")}catch{a.error("Could not copy — copy it manually.")}}function Be({secret:s,justGenerated:m}){const n=`HEYFILO_SECRET=${s}`;return e.jsxs("div",{className:"rounded-xl border border-claude-accent/30 bg-claude-accent/5 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-claude-text",children:[e.jsx(dt,{className:"h-4 w-4 text-claude-accent"}),e.jsx("span",{className:"text-xs font-semibold",children:m?"Your signing secret":"Current signing secret"})]}),e.jsxs("div",{className:"flex items-stretch gap-2",children:[e.jsx("code",{className:"flex-1 break-all rounded-lg bg-claude-bg-alt px-2 py-1.5 text-[11px] text-claude-text font-mono",children:s}),e.jsx("button",{type:"button",className:"shrink-0 px-2 rounded-lg border border-claude-border text-claude-text-secondary hover:bg-claude-bg-alt",onClick:()=>Ee(s),"aria-label":"Copy secret",children:e.jsx(it,{className:"h-3.5 w-3.5"})})]}),e.jsx("button",{type:"button",className:"text-[11px] text-claude-accent-text font-medium hover:underline",onClick:()=>Ee(n),children:"Copy as .env line"}),e.jsxs("p",{className:"text-[11px] text-claude-text-tertiary",children:["Add this to your website (e.g. ",e.jsx("code",{className:"font-mono",children:".env"}),") as"," ",e.jsx("code",{className:"font-mono",children:"HEYFILO_SECRET"}),". Store it now — for security we recommend keeping it only in your app; you can reveal or regenerate it here later."]})]})}function pt({connection:s,onClose:m}){const n=J(),h=!!s,[j,C]=r.useState((s==null?void 0:s.name)||""),[v,_]=r.useState((s==null?void 0:s.webhook_url)||""),[N,w]=r.useState((s==null?void 0:s.auth_type)||"hmac"),[k,D]=r.useState(s!=null&&s.custom_headers?Object.entries(s.custom_headers).map(([d,f])=>({key:d,value:f})):[]),[o,p]=r.useState(null),[c,l]=r.useState(!1),[q,b]=r.useState(null),[P,L]=r.useState(!1),[M,X]=r.useState(!1),[U,G]=r.useState(!1),[W,O]=r.useState(!1),{mutate:he,isPending:V}=z({mutationFn:d=>h?T.updateConnection(s.id,d):T.createConnection(d),onSuccess:d=>{var u;n.invalidateQueries({queryKey:["webhook-connections"]});const f=(u=d==null?void 0:d.data)==null?void 0:u.plain_secret;h?(a.success("Connection updated."),f?b(f):m()):(a.success("Connection created."),f?(b
21(f),L(!0)):m())},onError:d=>{var f,u;a.error(((u=(f=d.response)==null?void 0:f.data)==null?void 0:u.detail)||"Failed to save connection.")}});async function K(){var d,f;if(h){X(!0);try{const{data:u}=await T.revealSecret(s.id);b(u.secret)}catch(u){a.error(((f=(d=u.response)==null?void 0:d.data)==null?void 0:f.detail)||"Could not reveal secret.")}finally{X(!1)}}}async function Z(){var d,f;if(h){G(!0);try{const{data:u}=await T.regenerateSecret(s.id);b(u.secret),a.success("New secret generated. Update it on your website.")}catch(u){a.error(((f=(d=u.response)==null?void 0:d.data)==null?void 0:f.detail)||"Could not regenerate secret.")}finally{G(!1),O(!1)}}}async function le(){var d,f;if(!h){a.error("Save the connection first, then test it.");return}l(!0),p(null);try{const{data:u}=await T.testConnection(s.id);p(u),u.success?a.success(`Test passed! (${u.http_status} in ${u.response_time_ms}ms)`):a.error(`Test failed: HTTP ${u.http_status||"N/A"}`)}catch(u){a.error(((f=(d=u.response)==null?void 0:d.data)==null?void 0:f.detail)||"Test request failed.")}finally{l(!1)}}function ne(d){if(d.preventDefault(),!j.trim())return a.error("Name is required.");if(!v.trim())return a.error("Webhook URL is required.");if(!v.startsWith("http://")&&!v.startsWith("https://"))return a.error("Webhook URL must start with http:// or https://");const f={};k.forEach(I=>{I.key.trim()&&I.value.trim()&&(f[I.key.trim()]=I.value.trim())});const u={name:j.trim(),webhook_url:v.trim(),auth_type:N,custom_headers:f};he(u)}return e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:m,children:[e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:d=>d.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-lg overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-huge",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-6 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-claude-text",children:P?"Connection Created":h?"Edit Webhook Connection":"New Webhook Connection"}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:m,"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:P&&q?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-claude-success",children:[e.jsx(Ve,{className:"h-5 w-5"}),e.jsxs("p",{className:"text-sm font-medium text-claude-text",children:["“",j,"” is connected."]})]}),e.jsx(Be,{secret:q,justGenerated:!0}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx(y,{size:"sm",onClick:m,children:"Done"})})]}):e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Connection Name"}),e.jsx(S,{value:j,onChange:d=>C(d.target.value),placeholder:"e.g. Company Blog, Marketing Site",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Webhook URL"}),e.jsx(S,{value:v,onChange:d=>_(d.target.value),placeholder:"https://yoursite.com/api/heyfilo-webhook",required:!0})]}),e.jsx("div",{children:e.jsx(ue,{label:"Authentication Type",options:ut,value:N,onChange:d=>w(d.target.value)})}),N!=="none"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Signing Secret"}),h?q?e.jsx(Be,{secret:q}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{type:"button",variant:"outline",size:"sm",disabled:M,onClick:K,children:[M?e.jsx(ae,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(Ze,{className:"h-3.5 w-3.5 mr-1"}),"Reveal secret"]}
21),e.jsxs(y,{type:"button",variant:"outline",size:"sm",disabled:U,onClick:()=>O(!0),children:[U?e.jsx(ae,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(Me,{className:"h-3.5 w-3.5 mr-1"}),"Regenerate"]})]}):e.jsx("p",{className:"text-[11px] text-claude-text-tertiary",children:"heyfilo will generate a secure secret when you create this connection. You’ll copy it into your website right after."}),N==="hmac"&&e.jsx("p",{className:"text-[11px] text-claude-text-tertiary mt-2",children:"HMAC-SHA256 signature sent in the X-Heyfilo-Signature header. Your server verifies with this same secret."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary",children:"Custom Headers (optional)"}),e.jsx("button",{type:"button",className:"text-xs text-claude-accent-text font-medium hover:underline",onClick:()=>D([...k,{key:"",value:""}]),children:"+ Add Header"})]}),k.map((d,f)=>e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(S,{className:"flex-1",value:d.key,onChange:u=>{const I=[...k];I[f].key=u.target.value,D(I)},placeholder:"Header name"}),e.jsx(S,{className:"flex-1",value:d.value,onChange:u=>{const I=[...k];I[f].value=u.target.value,D(I)},placeholder:"Value"}),e.jsx("button",{type:"button",className:"p-2 text-claude-text-tertiary hover:text-claude-danger",onClick:()=>D(k.filter((u,I)=>I!==f)),children:e.jsx(H,{className:"w-4 h-4"})})]},f))]}),o&&e.jsxs("div",{className:`rounded-xl border p-3 text-xs ${o.success?"border-green-200 bg-green-50 text-green-800":"border-red-200 bg-red-50 text-red-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.success?e.jsx(et,{className:"h-4 w-4"}):e.jsx(lt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:o.success?"Test Passed":"Test Failed"}),e.jsxs("span",{className:"text-[11px] ml-auto",children:["HTTP ",o.http_status||"N/A"," · ",o.response_time_ms,"ms"]})]}),o.response_body&&e.jsx("pre",{className:"text-[10px] mt-1 max-h-20 overflow-auto whitespace-pre-wrap opacity-80",children:o.response_body.slice(0,300)})]}),e.jsxs("div",{className:"flex gap-3 pt-2 justify-between",children:[e.jsx("div",{children:h&&e.jsxs(y,{type:"button",variant:"outline",size:"sm",disabled:c,onClick:le,children:[c?e.jsx(ae,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(ot,{className:"h-3.5 w-3.5 mr-1"}),"Test Connection"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:m,children:"Cancel"}),e.jsx(y,{type:"submit",size:"sm",disabled:V,children:V?"Saving…":h?"Save":"Create"})]})]})]})})]})}),e.jsx(me,{open:W,title:"Regenerate the signing secret?",description:"The current secret stops working immediately. Any post sent before you update the new secret on your website will be rejected as unsigned.",confirmLabel:"Regenerate secret",isLoading:U,onConfirm:Z,onCancel:()=>O(!1)})]})}function bt({connection:s,onClose:m}){const n=J(),[h,j]=r.useState(""),[C,v]=r.useState(1),[_,N]=r.useState(null),{data:w,isLoading:k}=re({queryKey:["webhook-deliveries",s.id,h,C],queryFn:async()=>{const l={page:String(C),page_size:"20"};return h&&(l.status=h),(await T.listDeliveries(s.id,l)).data}}),{mutate:D}=z({mutationFn:l=>T.retryDelivery(l),onSuccess:()=>{n.invalidateQueries({queryKey:["webhook-deliveries",s.id]}),a.success("Retry queued.")},onError:l=>{var q,b;a.error(((b=(q=l.response)==null?void 0:q.data)==null?void 0:b.detail)||"Retry failed.")}}),o=(w==null?void 0:w.results)||[],p=(w==null?void 0:w.count)||0,c=Math.ceil(p/20);return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:m,children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:l=>l.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-3xl overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-huge",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-6 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-claude-text",children:"Delivery Log"}),e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:s.name})]}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:m,"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsxs("select",{className:"rounded-xl border border-claude-border bg-claude-bg px-3 py-1.5 text-xs",value:h,onChange:l=>{j(l.target.value),v(1)},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"retrying",children:"Retrying"}),e.jsx("option",{value:"dead",children:"Dead"}),e.jsx("option",{value:"pending",children:"Pending"})]}),e.jsxs("span",{className:"text-xs text-claude-text-tertiary self-center ml-auto",children:[p," delivery record",p!==1?"s":""]})]}),k?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ae,{className:"h-5 w-5 animate-spin text-claude-text-tertiary"})}):o.length===0?e.jsx("div",{className:"text-center py-12 text-sm text-claude-text-tertiary",children:"No delivery records foun
21d."}):e.jsx("div",{className:"space-y-2",children:o.map(l=>e.jsxs("div",{className:"rounded-xl border border-claude-border bg-claude-bg-alt/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-claude-bg-alt/50",onClick:()=>N(_===l.id?null:l.id),children:[_===l.id?e.jsx(tt,{className:"h-3.5 w-3.5 text-claude-text-tertiary flex-shrink-0"}):e.jsx(nt,{className:"h-3.5 w-3.5 text-claude-text-tertiary flex-shrink-0"}),e.jsx(mt,{status:l.status}),e.jsxs("span",{className:"text-xs text-claude-text truncate flex-1",children:[l.event_type,l.post_title&&e.jsxs("span",{className:"text-claude-text-tertiary",children:[" — ",l.post_title]})]}),e.jsxs("span",{className:"text-[11px] text-claude-text-tertiary whitespace-nowrap",children:[l.http_status_code&&`HTTP ${l.http_status_code}`,l.attempt_number>1&&` (attempt ${l.attempt_number})`]}),e.jsx("span",{className:"text-[10px] text-claude-text-tertiary whitespace-nowrap",children:new Date(l.created_at).toLocaleString()}),(l.status==="failed"||l.status==="dead")&&e.jsx("button",{type:"button",className:"p-1 rounded text-claude-accent-text hover:bg-claude-accent/10",title:"Retry",onClick:q=>{q.stopPropagation(),D(l.id)},children:e.jsx(Me,{className:"h-3.5 w-3.5"})})]}),_===l.id&&e.jsxs("div",{className:"px-4 pb-3 border-t border-claude-border/50",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 mt-2 text-[11px]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-claude-text-tertiary",children:"Event ID:"})," ",e.jsx("span",{className:"font-mono text-claude-text",children:l.event_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-claude-text-tertiary",children:"Completed:"})," ",e.jsx("span",{className:"text-claude-text",children:l.completed_at?new Date(l.completed_at).toLocaleString():"In progress"})]}),l.next_retry_at&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-claude-text-tertiary",children:"Next retry:"})," ",e.jsx("span",{className:"text-claude-text",children:new Date(l.next_retry_at).toLocaleString()})]})]}),l.error_message&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-[11px] text-claude-text-tertiary",children:"Error:"}),e.jsx("pre",{className:"text-[10px] text-red-700 bg-red-50 rounded-lg p-2 mt-1 max-h-24 overflow-auto whitespace-pre-wrap",children:l.error_message})]}),l.response_body&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-[11px] text-claude-text-tertiary",children:"Response body:"}),e.jsx("pre",{className:"text-[10px] text-claude-text bg-claude-bg rounded-lg p-2 mt-1 max-h-24 overflow-auto whitespace-pre-wrap",children:l.response_body.slice(0,500)})]})]})]},l.id))}),c>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[e.jsx(y,{size:"sm",variant:"outline",disabled:C<=1,onClick:()=>v(C-1),children:"Prev"}),e.jsxs("span",{className:"text-xs text-claude-text-secondary",children:["Page ",C," of ",c]}),e.jsx(y,{size:"sm",variant:"outline",disabled:C>=c,onClick:()=>v(C+1),children:"Next"})]})]})]})})})}const Te="#95BF47",ft={invalid_signature:"Shopify could not be verified (bad signature). Please try connecting again.",state_mismatch:"The connection link expired. Please start again.",shop_mismatch:"The store did not match the one you started with. Please try again.",workspace_not_found:"Your workspace could not be found. Please try again.",token_exchange_failed:"Shopify did not return an access token. Please try again.",no_token:"Shopify did not return an access token. Please try again."};function yt({readOnly:s}){const m=J(),[n,h]=r.useState(!1),[j,C]=r.useState(""),[v,_]=r.useState(!1),[N,w]=r.useState(!1),{data:k}=re({queryKey:["connections"],queryFn:async()=>{const P=(await E.listConnections()).data;return Array.isArray(P)?P:(P==null?void 0:P.results)??[]}}),o=(Array.isArray(k)?k:[]).filter(b=>b.platform==="shopify"),p=o.find(b=>b.is_active)??o[0],c=!!(p!=null&&p.is_active);r.useEffect(()=>{const b=new URLSearchParams(window.location.search),P=b.get("shopify");if(!P)return;P==="connected"?(a.success(`Shopify store connected${b.get("shop")?` — ${b.get("shop")}`:""}
21.`),m.invalidateQueries({queryKey:["connections"]})):P==="error"&&a.error(ft[b.get("reason")||""]||"Could not connect the Shopify store.");const L=new URL(window.location.href);["shopify","shop","reason"].forEach(M=>L.searchParams.delete(M)),window.history.replaceState({},"",L.pathname+L.search)},[m]);const l=z({mutationFn:b=>E.deleteConnection(b),onSuccess:()=>{m.invalidateQueries({queryKey:["connections"]}),a.success("Shopify store disconnected.")},onError:()=>a.error("Could not disconnect this store."),onSettled:()=>w(!1)});async function q(){var b,P;if(!j.trim())return a.error("Enter your Shopify store, e.g. your-store.myshopify.com.");_(!0);try{const{data:L}=await E.shopifyInstall(j.trim());window.location.assign(L.authorize_url)}catch(L){a.error(((P=(b=L.response)==null?void 0:b.data)==null?void 0:P.detail)||"Could not start the Shopify connection."),_(!1)}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft p-5 transition-shadow hover:shadow-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Te}}),e.jsx("h3",{className:"font-medium text-claude-text text-sm",children:"Shopify"})]}),c?e.jsx(B,{className:"bg-claude-success-light text-claude-success",children:"Connected"}):p?e.jsx(B,{className:"bg-claude-danger-light text-claude-danger",children:"Disconnected"}):e.jsx(B,{className:"bg-claude-bg-alt text-claude-text-tertiary",children:"Not connected"})]}),p?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-claude-text-tertiary mb-3 truncate",children:p.display_name}),c&&e.jsx(gt,{store:p,readOnly:s}),!s&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsx("span",{className:"text-xs text-claude-text-tertiary",children:o.length>1?`${o.length} stores connected`:"Store"}),e.jsx(y,{size:"sm",variant:"ghost",type:"button",className:"text-claude-danger hover:bg-claude-danger-light hover:text-claude-danger h-8",onClick:()=>w(!0),children:"Disconnect"})]}),!s&&e.jsx(y,{size:"sm",variant:"outline",className:"w-full mt-2",type:"button",onClick:()=>h(!0),children:"Connect another store"})]}):s?null:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-claude-text-tertiary mb-3",children:"Publish articles to your store's blog. You'll approve heyfilo on Shopify — only blog access is requested."}),e.jsx(y,{size:"sm",className:"w-full",type:"button",onClick:()=>h(!0),children:"Connect"})]})]}),n&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:()=>h(!1),children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:b=>b.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full sm:max-w-md rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-huge",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-claude-border",children:[e.jsxs("h2",{className:"text-lg font-semibold text-claude-text flex items-center gap-2",children:[e.jsx(Re,{className:"w-5 h-5",style:{color:Te}}),"Connect Shopify"]}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:()=>h(!1),"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5",children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Store domain"}),e.jsx(S,{value:j,autoFocus:!0,onChange:b=>C(b.target.value),placeholder:"your-store.myshopify.com",onKeyDown:b=>b.key==="Enter"&&q()}),e.jsxs("p",{className:"text-[11px] text-claude-text-tertiary mt-1.5",children:["Enter the store handle, its ",e.jsx("code",{className:"text-[10px]",children:".myshopify.com"})," domain, or paste the admin URL. You'll be sent to Shopify to approve access."]}),e.jsxs(y,{type:"button",className:"w-full mt-4",onClick:q,disabled:v,children:[e.jsx(Re,{className:"w-4 h-4 mr-1.5"}),v?"Redirecting…":"Continue to Shopify"]})]})]})})}),e.jsx(me,{open:N,title:"Disconnect this Shopify store?",description:e.jsxs(e.Fragment,{children:["Scheduled posts to"," ",e.jsx("span",{className:"font-medium text-claude-text",children:(p==null?void 0:p.display_name)||"this 
21store"})," ","will stop publishing. You can reconnect later, but you will need to reinstall the app on the store."]}),confirmLabel:"Disconnect store",isLoading:l.isPending,onConfirm:()=>p&&l.mutate(p.id),onCancel:()=>w(!1)})]})}function gt({store:s,readOnly:m}){var N,w,k,D;const n=J(),h=String(((N=s.extra_data)==null?void 0:N.blog_id)||""),j=re({queryKey:["shopify-blogs",s.id],queryFn:async()=>(await E.listShopifyBlogs(s.id)).data.blogs,enabled:s.is_active,retry:!1,staleTime:5*60*1e3}),C=z({mutationFn:o=>E.updateConnection(s.id,{extra_data:{blog_id:o.id,blog_handle:o.handle,blog_title:o.title}}),onSuccess:()=>{n.invalidateQueries({queryKey:["connections"]}),a.success("Publish target blog saved.")},onError:o=>{var p,c;return a.error(((c=(p=o.response)==null?void 0:p.data)==null?void 0:c.detail)||"Could not save the blog.")}}),v=j.data||[],_=(D=(k=(w=j.error)==null?void 0:w.response)==null?void 0:k.data)==null?void 0:D.detail;return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-semibold text-claude-text-tertiary uppercase tracking-wider mb-1",children:"Publish to blog"}),j.isLoading?e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:"Loading blogs…"}):_?e.jsx("p",{className:"text-xs text-claude-danger",children:_}):v.length===0?e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:"No blogs yet. Create one in Shopify → Online Store → Blog posts."}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:h,disabled:m||C.isPending,options:[{value:"",label:"Select a blog…"},...v.map(o=>{const p=v.filter(c=>c.title===o.title).length>1;return{value:o.id,label:p&&o.handle?`${o.title} (/${o.handle})`:o.title}})],onChange:o=>{const p=v.find(c=>c.id===o.target.value);p&&C.mutate(p)}}),!h&&e.jsx("p",{className:"text-[11px] text-claude-warning mt-1",children:"Pick a blog before scheduling."})]})]})}function At(){var De;const s=J(),{isReadOnlyTenant:m}=ze(),[n,h]=r.useState(null),[j,C]=r.useState(null),[v,_]=r.useState(""),[N,w]=r.useState(""),[k,D]=r.useState(""),[o,p]=r.useState(""),[c,l]=r.useState(""),[q,b]=r.useState(""),[P,L]=r.useState(""),[M,X]=r.useState(""),[U,G]=r.useState(""),[W,O]=r.useState(""),[he,V]=r.useState([]),[K,Z]=r.useState(""),[le,ne]=r.useState(!1),[d,f]=r.useState(null),[u,I]=r.useState("mailchimp"),[ie,fe]=r.useState(""),oe=Le(),[ce,ye]=r.useState(oe.max),[ge,je]=r.useState(oe.period),[Y,ee]=r.useState(null),[de,ve]=r.useState(oe.max),[Ne,we]=r.useState(oe.period),[R,te]=r.useState(null),[ke,Ce]=r.useState(""),[pe,Se]=r.useState("");function $(){_(""),w(""),D(""),p(""),l(""),b(""),L(""),X(""),G(""),O(""),V([]),Z(""),f(null),I("mailchimp"),fe("");const t=Le();ye(t.max),je(t.period)}const{data:se,isLoading:Ue}=re({queryKey:["connections"],queryFn:async()=>{const i=(await E.listConnections()).data;return Array.isArray(i)?i:(i==null?void 0:i.results)??[]}}),Pe=Array.isArray(se)?se:(se==null?void 0:se.results)??[],Q=Pe.some(t=>t.connection_source==="buffer"&&!!(t.access_token||"").trim()),We=new Set(["youtube","blog"]);async function Ke(){var t,i,g;if(!Q&&!W.trim())return a.error("Enter your Buffer API key once, or connect after another Buffer channel exists.");if(n){ne(!0);try{const{data:x}=await E.listBufferProfiles(W.trim()||void 0);V(x.profiles||[]);const A=((t=x.profiles)==null?void 0:t.length)??0,F=(x.profiles||[]).filter(be=>be.service===n.key).length;f({total:A,matching:F,platformKey:n.key}),A?F||a.error(`No ${n.label} profiles found in this Buffer account.`):a.error("No supported Buffer profiles found.")}catch(x){a.error(((g=(i=x.response)==null?void 0:i.data)==null?void 0:g.detail)||"Failed to load Buffer profiles.")}finally{ne(!1)}}}const{mutate:He,isPending:_e}=z({mutationFn:t=>E.createConnection(t),onSuccess:()=>{s.invalidateQueries({queryKey:["connections"]}),a.success("Platform connected successfully!"),h(null),$()},onError:t=>{var i,g;a.error(((g=(i=t.response)==null?void 0:i.data)==null?void 0:g.detail)||"Failed to connect platform.")}}),{mutate:Oe,isPending:Ye}=z({mutationFn:t=>E.deleteConnection(t),onSuccess:()=>{s.invalidateQueries({queryKey:["connections"]}),a.success("Platform disconnected.")},onError:()=>a.error("Could not disconnect this platform."),onSettled:()=>C(null)}),{mutate:$e,isPending:Ae}=z({mutationFn:({id:t,extra_data:i})=>E.updateConnection(t,{extra_data:i}),onSuccess:()=>{s.invalidateQueries({queryKey:["connections"]}),a.success("Posting limits updated."),ee(null)},onError:t=>{var i,g,x,A;a.error(((g=(i=t.response)==null?void 0:i.data)==null?void 0:g.detail)||((A=(x=t.response)==null?void 0:x.data)==null?void 0:A.extra_data)||"
21Update failed.")}}),{mutate:Qe,isPending:qe}=z({mutationFn:({id:t,data:i})=>E.updateConnection(t,i),onSuccess:()=>{s.invalidateQueries({queryKey:["connections"]}),a.success("Connection updated."),te(null)},onError:t=>{var i,g;a.error(((g=(i=t.response)==null?void 0:i.data)==null?void 0:g.detail)||"Update failed.")}}),Je=t=>{if(t.preventDefault(),!n)return;if(!v.trim())return a.error("Display name is required.");const i={};let g="";const x=n.key,A=["linkedin","instagram","facebook","twitter","youtube"];if(A.includes(x)){if(!Q&&!W.trim())return a.error("Buffer API key is required for the first Buffer channel.");if(!K.trim())return a.error("Buffer profile is required.");i.profile_id=K.trim()}else if(x==="blog"){if(!q.trim())return a.error("Webhook URL is required.");i.webhook_url=q.trim(),P.trim()&&(i.api_key=P.trim())}else if(x==="wordpress"){if(!k.trim()||!o.trim())return a.error("Site URL and username are required.");i.site_url=k.trim(),i.username=o.trim()}else if(x==="facebook"){if(!c.trim())return a.error("Facebook Page ID is required.");i.page_id=c.trim()}else if(x==="instagram"){if(!c.trim())return a.error("Instagram Business account ID is required.");i.ig_user_id=c.trim()}else if(x==="youtube"){if(!k.trim()||!o.trim()||!c.trim())return a.error("Client ID, Client Secret, and Refresh Token are required.");i.client_id=k.trim(),i.client_secret=o.trim(),g=c.trim()}else if(x==="newsletter"){if(u==="mailchimp"&&(!M.trim()||!U.trim()))return a.error("Audience (list) ID and reply-to email are required for Mailchimp.");if(u==="mailchimp")i.list_id=M.trim(),i.reply_to=U.trim();else{if(!ie.trim())return a.error("Publication ID is required for Beehiiv.");i.publication_id=ie.trim()}}if(x!=="blog"&&x!=="youtube"&&!A.includes(x)&&!N.trim())return a.error("Access token or API key is required.");if(ce<1||ce>366)return a.error("Posting frequency must be between 1 and 366.");i.posting_frequency_max=ce,i.posting_frequency_period=ge,He({platform:x,display_name:v.trim(),access_token:A.includes(x)?W.trim()||"":x==="blog"?"":N.trim(),refresh_token:g,connection_source:A.includes(x)?"buffer":"direct",provider:A.includes(x)?"buffer":x==="wordpress"?"wordpress":x==="devto"?"devto":x==="blog"?"blog_webhook":x==="newsletter"?u:"direct",provider_profile_id:A.includes(x)?K.trim():"",provider_account_id:x==="newsletter"&&u==="beehiiv"?ie.trim():"",extra_data:i})};return Ue?e.jsx(st,{}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-semibold text-claude-text tracking-tight",children:"Platform Connections"}),e.jsxs("p",{className:"text-sm text-claude-text-tertiary mt-1",children:["Connect publishing destinations. ",e.jsx("strong",{className:"text-claude-text-secondary",children:"WordPress"}),": site URL, username, and an Application Password (Users → Profile). ",e.jsx("strong",{className:"text-claude-text-secondary",children:"Newsletter"}),": Mailchimp API key, audience List ID, and reply-to email — publishing sends a campaign immediately."," ",e.jsx("strong",{className:"text-claude-text-secondary",children:"Dev.to"}),": API key from Settings → Extensions. Blog/Website uses a ",e.jsx("strong",{className:"text-claude-text-secondary",children:"custom webhook"})," you control."]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[1fr,400px] gap-6 items-start",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-claude-text-secondary mb-3",children:"Platforms"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ie.map(t=>{if(t.key==="shopify")return e.jsx(yt,{readOnly:m},t.key);const i=Pe.filter(F=>F.platform===t.key),g=i.find(F=>F.is_active)??i.sort((F,be)=>F.created_at<be.created_at?1:-1)[0],x=!!(g&&g.is_active),A=We.has(t.key);return e.jsxs("div",{className:["bg-claude-surface rounded-2xl border border-claude-border shadow-soft p-5 transition-shadow",A&&!x?"opacity-70":"hover:shadow-card"].join(" "),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:t.color}}),e.jsx("h3",{className:"font-medium text-claude-text text-sm",children:t.label})]}),x?e.jsx(B,{className:"bg-claude-success-light text-claude-success",children:"Connected"}):g?e.jsx(B,{className:"bg-claude-danger-light text-claude-danger",children:"Disconnected"}):A?e.jsx(B,{className:"bg-claude-warning/10 text-claude-warning",children:"Coming soon"}):e.jsx(B,{className:"bg-claude-bg-alt text-claude-text-tertiary",children:"Not connected"})]}),g?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-claude-text-tertiary mb-2",children:g.display_name}),e.jsxs("p",{className:"text-[11px] text-claude-text-secondary mb-3",children:["Schedule frequency: ",e.jsx("span",{className:"font-medium text-claude-text",children:at(g)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[!m&&e.jsx(y,{size:"sm",variant:"outline",className:"w-full",type:"button",onClick:()=>{Ce(g.display_name||""),Se(""),te(g)},children:"View / Edit details"}),!m&&e.jsx(y,{size:"sm",variant:"outline",className:"w-full",type:"button",onClick:()=>{const F=rt(g);ve(F.max),we(F.period),ee(g)},children:"Edit posting limits"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-bold text-claude-text-tertiary uppercase tracking-wider mb-0.5",children:"Status"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:["w-1.5 h-1.5 rounded-full mr-0.5",x?"bg-claude-success":"bg-claude-danger"].join(" ")}),e.jsx("span",{className:["text-xs font-medium",x?"text-claude-success":"text-claude-danger"].join(" "),children:x?"Active":"Disconnected"})]})]}),!m&&(x?e.jsx(y,{size:"sm",variant:"ghost",className:"text-claude-danger hover:bg-claude-danger-light hover:text-claude-danger h-8",type:"button",onClick:()=>C(g),children:"Disconnect"}):e.jsx(y,{size:"sm",variant:"outline",className:"h-8",type:"button",onClick:()=>{$(),_(g.display_name||t.label),h(t)},children:"Reconnect"}))]})]})]}):m?null:e.jsx("span",{className:"inline-block w-full mt-1",title:A?"Coming soon — this channel is not available yet.":void 0,children:e.jsx(y,{size:"sm",className:"w-full",type:"button",disabled:A,onClick:()=>{A||($(),h(t))},children:"Connect"})})]},t.key)})})]}),e.jsx("div",{children:e.jsx(ht,{})})]}),!m&&n&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:()=>{h(null),$()},children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-huge",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-6 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[e.jsxs("h2",{className:"text-lg font-semibold text-claude-text",children:["Connect ",n.label]}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:()=>{h(null),$()},"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[n.key==="blog"&&e.jsx("p",{className:"text-xs text-claude-text-secondary mb-4 leading-relaxed",children:"Your server receives a JSON payload (title, HTML body, excerpt, tags). Use this for a custom CMS or Zapier webhook — not the same as WordPress (use the WordPress tile for WP REST API)."}),n.key==="newsletter"&&e.jsxs("p",{className:"text-xs text-claude-text-secondary mb-4 leading-relaxed",children:["Mailchimp: create an API key in Account → Extras → API keys. Use an audie
21nce ",e.jsx("strong",{children:"List ID"})," ","(Audience → Settings → Audience name and defaults)."]}),["linkedin","instagram","facebook","twitter","youtube"].includes(n.key)&&e.jsxs("p",{className:"text-xs text-claude-text-secondary mb-4 leading-relaxed",children:["This platform is routed via ",e.jsx("strong",{children:"Buffer"}),"."," ",Q?e.jsx(e.Fragment,{children:"Another channel already uses your workspace Buffer key — load profiles, pick the channel, and connect. You only need to paste the API key once (for the first Buffer channel)."}):e.jsxs(e.Fragment,{children:["Use your Buffer ",e.jsx("strong",{children:"API key"})," from"," ",e.jsx("a",{href:"https://publish.buffer.com/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-claude-accent-text font-medium",children:"Buffer Settings → API"}),". Load channels, pick the matching one, or paste the channel ID manually."]})]}),n.key==="devto"&&e.jsxs("p",{className:"text-xs text-claude-text-secondary mb-4 leading-relaxed",children:["Create an API key under"," ",e.jsx("a",{href:"https://dev.to/settings/extensions",target:"_blank",rel:"noopener noreferrer",className:"text-claude-accent-text font-medium",children:"dev.to → Settings → Extensions"}),". Posts use your content title and body (HTML is converted to text for Dev.to)."]}),n.key==="instagram"&&e.jsxs("p",{className:"text-xs text-amber-800 bg-amber-50 border border-amber-200 rounded-xl px-3 py-2 mb-4",children:["Instagram requires a ",e.jsx("strong",{children:"public image URL"})," when publishing. Set"," ",e.jsx("code",{className:"text-[10px]",children:"PUBLIC_MEDIA_BASE_URL"})," on the API to your reachable backend/media base. Content needs a featured image before publish."]}),e.jsxs("form",{onSubmit:Je,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Display name"}),e.jsx(S,{value:v,onChange:t=>_(t.target.value),placeholder:"e.g. Company Page",required:!0})]}),n.key==="blog"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Webhook URL"}),e.jsx(S,{value:q,onChange:t=>b(t.target.value),placeholder:"https://api.example.com/heyfilo-publish",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"API key (optional)"}),e.jsx(S,{value:P,onChange:t=>L(t.target.value),placeholder:"Bearer token if your endpoint requires it",type:"password"})]})]}),n.key==="wordpress"&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-claude-text-secondary mb-3 leading-relaxed",children:[e.jsx("strong",{className:"text-amber-800",children:"WordPress.com"})," sites (",e.jsx("code",{className:"text-[10px]",children:"*.wordpress.com"}),") are"," ",e.jsx("strong",{children:"not supported"})," here — use ",e.jsx("strong",{children:"self-hosted WordPress.org"})," (your own hosting) where ",e.jsx("code",{className:"text-[10px]",children:"/wp-json/"})," and Application Passwords work. For WordPress.com, use ",e.jsx("strong",{children:"Blog/Website"})," (webhook) or another channel."]}),e.jsxs("p",{className:"text-xs text-claude-text-secondary mb-3 leading-relaxed",children:["Use your site's public URL (must be reachable from this API). Enable"," ",e.jsx("strong",{children:"Application Passwords"})," under Users → Profile. If WordPress runs on"," ",e.jsx("strong",{children:"your PC"})," and heyfilo runs in ",e.jsx("strong",{children:"Docker"}),", do"," ",e.jsx("strong",{children:"not"})," use ",e.jsx("code",{className:"text-[10px]",children:"http://localhost"})," — use"," ",e.jsx("code",{className:"text-[10px]",children:"http://host.docker.internal:PORT"})," (Windows/Mac Docker Desktop) or your LAN/public URL."]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"WordPress site URL"}),e.jsx(S,{value:k,onChange:t=>D(t.target.value),placeholder:"https://yoursite.com or http://host.docker.internal:8080",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Username"}),e.jsx(S,{value:o,onChange:t=>p(t.target.value),placeholder:"WordPress username",required:!0})]})]}),n.key==="newsletter"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Provider"}),e.jsxs("select",{className:"w-full rounded-xl border border-claude-border bg-claude-bg px-3 py-2 text-sm",value:u,onChange:t=>I(t.target.value),children:[e.jsx("option",{value:"mailchimp",children:"Mailchimp"}),e.jsx("option",{value:"beehiiv",children:"Beehiiv"})]})]}),u==="beehiiv"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Publication ID"}),e.jsx(S,{value:ie,onChange:t=>fe(t.target.value),placeholder:"pub_...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:u==="mailchimp"?"Mailchimp API key":"Beehiiv API key"}),e.jsx(S,{value:N,onChange:t=>
21w(t.target.value),type:"password",placeholder:"xxxx-us12",required:!0})]}),u==="mailchimp"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Audience (list) ID"}),e.jsx(S,{value:M,onChange:t=>X(t.target.value),placeholder:"abc123def",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Reply-to email"}),e.jsx(S,{value:U,onChange:t=>G(t.target.value),type:"email",placeholder:"[email protected]",required:!0})]})]})]}),["linkedin","instagram","facebook","twitter","youtube"].includes(n.key)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:["Buffer API key",Q?e.jsx("span",{className:"font-normal text-claude-text-tertiary",children:" (optional — workspace key in use)"}):null]}),e.jsx(S,{type:"password",value:W,onChange:t=>O(t.target.value),placeholder:Q?"Leave blank to reuse workspace key":"From Buffer Settings → API",required:!Q})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(y,{type:"button",size:"sm",variant:"outline",disabled:le,onClick:Ke,children:le?"Loading…":"Load Buffer Profiles"})}),d&&d.platformKey===n.key?e.jsxs("p",{className:"text-[11px] text-claude-text-tertiary -mt-2",children:["Found ",e.jsx("span",{className:"font-medium text-claude-text",children:d.matching})," ",n.label," profile(s)",d.total!==d.matching?e.jsxs(e.Fragment,{children:[" ","(from ",e.jsx("span",{className:"font-medium text-claude-text",children:d.total})," total across Buffer)."]}):"."]}):null,e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Buffer profile"}),e.jsxs("select",{className:"w-full rounded-xl border border-claude-border bg-claude-bg px-3 py-2 text-sm",value:K,onChange:t=>Z(t.target.value),children:[e.jsx("option",{value:"",children:"Select profile (or paste ID below)"}),he.filter(t=>t.service===n.key).map(t=>e.jsx("option",{value:t.id,children:[t.formatted_username||t.service_username||t.id,t.organization_name].filter(Boolean).join(" — ")},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Profile ID (manual)"}),e.jsx(S,{value:K,onChange:t=>Z(t.target.value),placeholder:"Paste from Buffer if the list above is empty"})]})]}),["devto","wordpress"].includes(n.key)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:n.key==="wordpress"?"Application password":n.key==="youtube"?"OAuth access token (short-lived)":n.key==="devto"?"API key":"Access token"}),e.jsx(S,{type:"password",value:N,onChange:t=>w(t.target.value),placeholder:"••••••••••••••••",required:n.key!=="youtube"&&!["linkedin","twitter","facebook","instagram"].includes(n.key)})]}),e.jsxs("div",{className:"rounded-xl border border-claude-border bg-claude-bg-alt/40 p-4 space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-claude-text",children:"Posting frequency (AI schedule)"}),e.jsx("p",{className:"text-[11px] text-claude-text-tertiary leading-relaxed",children:"Used by Automatic publish: caps are prorated to the days you pick (e.g. weekly ≈ max × days ÷ 7). Existing schedules in that range count toward the cap. Default is 7 per week."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Max posts"}),e.jsx(S,{type:"number",min:1,max:366,value:ce,onChange:t=>ye(Number(t.target.value)||1)})]}),e.jsx("div",{children:e.jsx(ue,{label:"Per",options:[{value:"daily",label:"Day"},{value:"weekly",label:"Week"},{value:"monthly",label:"Month (~30d)"}],value:ge,onChange:t=>je(t.target.value)})})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2 justify-end",children:[e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>{h(null),$()},children:"Cancel"}),e.jsx(y,{type:"submit",size:"sm",disabled:_e,children:_e?"Connecting…":"Connect"})]})]})]})]})})}),!m&&Y&&e.jsx("div",{className:"fixed inset-0 z-[60] bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:()=>ee(null),children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-huge",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-6 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-claude-text",children:"Posting limits"}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:()=>ee(null),"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[e.jsxs("p",{className:"text-xs text-claude-text-tertiary mb-4",children:[Y.display_name," (",Y.platform,") — Automatic publish prorates weekly/monthly quotas to your selected dates and subtracts schedules already in that range."]}),e.jsx("div",{className:"rounded-xl border border-claude-border bg-claude-bg-alt/40 p-4 space-y-3 mb-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Max posts"}),e.jsx(S,{type:"number",min:1,max:366,value:de,onChange:t=>ve(Number(t.target.value)||1)})]}),e.jsx("div",{children:e.jsx(ue,{label:"Per",options:[{value:"daily",label:"Day"},{value:"weekly",label:"Week"},{value:"monthly",label:"Month (~30d)"}],value:Ne,onChange:t=>we(t.target.value)})})]})})]}),e.jsxs("div",{className:"sticky bottom-0 z-10 flex flex-col sm:flex-row gap-2 sm:justify-end p-4 sm:p-6 border-t border-claude-border bg-claude-bg-alt/30",children:[e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>ee(null),className:"w-full sm:w-auto",children:"Cancel"}),e.jsx(y,{type:"button",size:"sm",disabled:Ae||de<1||de>366,onClick:()=>{Y&&$e({id:Y.id,extra_data:{...Y.extra_data||{},posting_frequency_max:de,posting_frequency_period:Ne}})},className:"w-full sm:w-auto",children:Ae?"Saving…":"Save"})]})]})})}),!m&&R&&e.jsx("div",{className:"fixed inset-0 z-[60] bg-black/40 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:()=>te(null),children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-claude-surface w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-huge",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-6 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-claude-text",children:"Connection details"}),e.jsx("button",{type:"button",className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt",onClick:()=>te(null),"aria-label":"Close",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6 space-y-4",children:[e.jsxs("dl",{className:"rounded-xl border border-claude-border bg-claude-bg-alt/40 p-4 text-xs space-y-2",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-claude-text-tertiary",children:"Platform"}),e.jsx("dd",{className:"text-claude-text font-medium capitalize",children:R.platform})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-claude-text-tertiary",children:"Status"}),e.jsx("dd",{className:R.is_active?"text-claude-success font-medium":"text-claude-danger font-medium",children:R.is_active?"Active":"Disconnected"})]}),R.connection_source&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-claude-text-tertiary",children:"Source"}),e.jsx("dd",{className:"text-claude-text font-medium capitalize",children:R.connection_source})]}),R.provider_profile_id&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-claude-text-tertiary",children:"Profile ID"}),e.jsx("dd",{className:"text-claude-text font-medium truncate max-w-[60%]",children:R.provider_profile_id})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-claude-text-tertiary",children:"Connected"}),e.jsx("dd",{className:"text-claude-text font-medium",children:new Date(R.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Display name"}),e.jsx(S,{value:ke,onChange:t=>Ce(t.target.value),placeholder:"Connection name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-claude-text-secondary mb-1",children:"Update access token / API key"}
21),e.jsx(S,{type:"password",value:pe,onChange:t=>Se(t.target.value),placeholder:"Leave blank to keep current",autoComplete:"new-password"}),e.jsx("p",{className:"text-[11px] text-claude-text-tertiary mt-1",children:"For security the current token is hidden. Enter a new value only to replace it."})]})]}),e.jsxs("div",{className:"sticky bottom-0 z-10 flex flex-col sm:flex-row gap-2 sm:justify-end p-4 sm:p-6 border-t border-claude-border bg-claude-bg-alt/30",children:[e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>te(null),className:"w-full sm:w-auto",children:"Cancel"}),e.jsx(y,{type:"button",size:"sm",disabled:qe,onClick:()=>{if(!R)return;const t={display_name:ke.trim()||R.display_name};pe.trim()&&(t.access_token=pe.trim()),Qe({id:R.id,data:t})},className:"w-full sm:w-auto",children:qe?"Saving…":"Save"})]})]})})}),e.jsx(me,{open:j!==null,title:"Disconnect this platform?",description:e.jsxs(e.Fragment,{children:["Scheduled posts to"," ",e.jsx("span",{className:"font-medium text-claude-text",children:j?((De=Ie.find(t=>t.key===j.platform))==null?void 0:De.label)||j.platform:""})," ","will stop publishing. You can reconnect later, but you will need to authorise the account again."]}),confirmLabel:"Disconnect",isLoading:Ye,onConfirm:()=>j&&Oe(j.id),onCancel:()=>C(null)})]})}export{At as PublishingPage};

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.