1import{g as j,f as R}from"./vendor-vue-BIDZeepx.js";import{A as H}from"./AsyncState-C1wY1NSf.js";import{S}from"./SectionHeader-60mU8zeF.js";import{C as B}from"./ChromeCard-DkvfllPh.js";import{C as A}from"./ChromeButton-DmiFifbd.js";import{E as O}from"./EmptyState-HBFSUaTT.js";import{u as F,F as G,k as w,G as M,H as J,_ as K}from"./index-BNPflmqD.js";import{k as Q,r as u,c as W,_ as q,C as d,D as r,y as n,Q as c,K as o,z as s,P as L,H as l,G as p,L as g,J as v,u as E}from"./vendor-misc-5pJBpqhN.js";import"./creatorFieldHelp-BrZsjpkG.js";import"./vendor-tanstack-B6ELLr_Q.js";import"./vendor-sentry-84cD2ryj.js";import"./vendor-utils-CxkvrZ9U.js";const U={class:"link-list"},X={class:"meta"},Y={key:1,class:"link-list"},Z=["data-status"],ee={key:0,class:"meta"},te={key:1,class:"meta"},ae={class:"actions"},ne=Q({__name:"AccountAgenciesTab",setup(oe){const m=j(),{user:P,bootstrap:D}=F(),y=u(!0),_=u(null),k=u([]),C=u(null),h=u(null),b=W(()=>{var a;return((a=P.value)==null?void 0:a.pending_agency_roster_invites)??[]}),I={revenue:"Revenue",analytics:"Analytics",content:"Content",audience:"Audience",platforms:"Platforms"};function x(a){const t=a.scopes??{},e=Object.entries(t).filter(([,i])=>i===!0||i==="true").map(([i])=>I[i]??i);return e.length?`Shared: ${e.join(", ")}`:"Default roster analytics scopes"}function z(a){if(!a)return"â";try{return new Date(a).toLocaleDateString()}catch{return a}}async function f(){y.value=!0,_.value=null;try{k.value=await G()}catch(a){_.value=w(a,"Could not load agency connections")}finally{y.value=!1}}async function N(a){try{await J(a),m.success("Invitation accepted"),await D(),await f()}catch(t){m.error(w(t,"Could not accept invitation"))}}function T(a){h.value=a.organization_id}function $(){h.value=null}async function V(a){C.value=a.organization_id;try{await M(a.organization_id),m.success("Agency access revoked â their Book lost visibility immediately"),await f()}catch(t){m.error(w(t,"Could not revoke access"))}finally{C.value=null}}return q(()=>{f()}),(a,t)=>(n(),d(H,{loading:y.value,error:_.value,onRetry:f},{default:r(()=>[b.value.length?(n(),d(B,{key:0},{default:r(()=>[c(S,{title:"Pending invitations"}),t[1]||(t[1]=o("p",{class:"hint"}," Agencies invited you to join their roster. Accept with the email this invite was sent to. ",-1)),o("ul",U,[(n(!0),s(g,null,L(b.value,e=>(n(),s("li",{key:e.invite_id,class:"link-row"},[o("div",null,[o("strong",null,l(e.organization_name),1),o("span",X,"Expires "+l(z(e.expires_at)),1)]),c(A,{variant:"primary",onClick:i=>N(e.invite_id)},{default:r(()=>[...t[0]||(t[0]=[p(" Accept ",-1)])]),_:1},8,["onClick"])]))),128))])]),_:1})):v("",!0),c(B,null,{default:r(()=>[c(S,{title:"Agency connections"}),t[7]||(t[7]=o("p",{class:"hint"}," Organizations you have linked. Revoke access anytime â their Book loses visibility immediately. They will no longer see your shared data. ",-1)),!k.value.length&&!y.value?(n(),d(O,{key:0,title:"No agency connections",description:"When an agency invites you, pending invites appear above. After accepting, manage access here."})):(n(),s("ul",Y,[(n(!0),s(g,null,L(k.value,e=>(n(),s("li",{key:e.link_id,class:"link-row"},[o("div",null,[o("strong",null,l(e.organization_name),1),o("span",{class:"status-pill","data-status":e.status},l(e.status),9,Z),x(e)?(n(),s("p",ee,l(x(e)),1)):v("",!0),e.accepted_at?(n(),s("p",te,"Accepted "+l(z(e.accepted_at)),1)):v("",!0)]),o("div",ae,[e.status==="active"?(n(),d(E(R),{key:0,to:`/portal/${e.organization_id}`,class:"text-link"},{default:r(()=>[...t[2]||(t[2]=[p(" Portal view ",-1)])]),_:1},8,["to"])):v("",!0),c(E(R),{to:"/share-with-agency",class:"text-link"},{default:r(()=>[...t[3]||(t[3]=[p("Connect platforms",-1)])]),_:1}),e.status==="active"?(n(),s(g,{key:1},[h.value===e.organization_id?(n(),s(g,{key:0},[t[5]||(t[5]=o("span",{class:"revoke-confirm-label"},"Revoke access?",-1)),c(A,{variant:"secondary",loading:C.value===e.organization_id,onClick:i=>V(e)},{default:r(()=>[...t[4]||(t[4]=[p(" Confirm ",-1)])]),_:1},8,["loading","onClick"]),o("button",{type:"button",class:"text-link",onClick:$},"Cancel")],64)):(n(),d(A,{key:1,variant:"secondary",onClick:i=>T(e)},{default:r(()=>[...t[6]||(t[6]=[p(" Revoke access ",-1)])]),_:1},8,["onClick"]))],64)):v("",!0)])]))),128))]))]),_:1})]),_:1},8,["loading","error"]))}}),ge=K(ne,[["__scopeId","data-v-13afb768"]]);export{ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.