PageSourceSearch

https://www.2ndchair.ai/_app/immutable/nodes/82.D9Mcsahk.js

js 2ndchair.ai collected 2026-10-05 03:04:40 UTC 17,256 bytes, 3 lines download raw bytes

1import"../chunks/BDr9Qe-U.js";import{aH as It,V as St,U as Me,I as Mt,aX as Ct,a0 as tt,az as Ce,a4 as at,w as rt,T as Ee,ab as Et,J as Tt,ak as it,aO as st,aY as ot,Z as nt,_ as Te,q as zt,i as Nt,p as dt,e as ee,f as le,a as ct,c as i,s as n,g as a,r,h as k,u as qt,t as V,d as X,n as ze}from"../chunks/DtoD-Aj8.js";import{s as A}from"../chunks/B0vI6ecX.js";import{i as K}from"../chunks/CXraoGMn.js";import{e as te,i as pe}from"../chunks/CZUKntNu.js";import{c as je,a as v,t as m,b as lt}from"../chunks/BKE8fbE0.js";import{r as De,s as Ot,e as Ne}from"../chunks/B15RWetg.js";import{d as ut}from"../chunks/D072Smu8.js";import{c as Pt,a as jt,b as Dt}from"../chunks/DI_8A-rz.js";import{b as At,i as Rt,s as Ut}from"../chunks/CZKQoqDs.js";import{p as q}from"../chunks/BTyPiaaQ.js";import{S as Bt}from"../chunks/CUevbTIh.js";import{p as Ht}from"../chunks/DOS0WSDT.js";import{d as Ft}from"../chunks/BGoHkC9L.js";import{p as ve}from"../chunks/KlfVgvZx.js";const qe=0,_e=1,Oe=2;function Pe(c,s,u,p,T){Me&&Mt();var _=c,I=It(),R=Nt,C=tt,h,x,S,U=(I?at:rt)(void 0),W=(I?at:rt)(void 0),Y=!1;function B(y,M){Y=!0,M&&(it(O),st(O),ot(R));try{y===qe&&u&&(h?nt(h):h=Ee(()=>u(_))),y===_e&&p&&(x?nt(x):x=Ee(()=>p(_,U))),y!==qe&&h&&Te(h,()=>h=null),y!==_e&&x&&Te(x,()=>x=null),y!==Oe&&S&&Te(S,()=>S=null)}finally{M&&(ot(null),st(null),it(null),zt())}}var O=St(()=>{if(C!==(C=s())){if(Ct(C)){var y=C;Y=!1,y.then(M=>{y===C&&(Ce(U,M),B(_e,!0))},M=>{if(y===C)throw Ce(W,M),B(Oe,!0),W.v}),Me?u&&(h=Ee(()=>u(_))):Et(()=>{Y||B(qe,!0)})}else Ce(U,C),B(_e,!1);return()=>C=tt}});Me&&(_=Tt)}function Jt(c,s){k(s,q([...a(s),""]))}function Lt(c,s,u,p){const T=a(s).filter(_=>_.match(/^([\w!#$%&'*+\-/=?^`{|}~]+\.)*[\w!#$%&'*+\-/=?^`{|}~]+@((((([a-z0-9]{1}[a-z0-9-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?)$/i));if(console.log(a(s),T),T.length===0){alert("Please enter at least one valid email.");return}console.log("Sending invites to:",T),u.onInvitesSubmitted(T),p()}var Vt=m('<button class="text-red-500 hover:text-red-700" title="Remove">&times;</button>'),Wt=m('<div class="flex items-center gap-2"><input type="email" placeholder="[email protected]" class="flex-1 rounded-md border px-3 py-2"> <!></div>'),Yt=m('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="w-full max-w-lg rounded-lg bg-white p-6 shadow-xl"><h2 class="mb-4 text-xl font-semibold">Invite Members to Organization</h2> <div class="max-h-[60vh] space-y-3 overflow-y-auto pr-1"><!> <button class="text-sm text-blue-600 hover:text-blue-800">+ Add another</button></div> <div class="mt-6 flex justify-end gap-3"><button class="rounded border border-gray-300 px-4 py-2">Cancel</button> <button class="rounded bg-green-600 px-4 py-2 text-white hover:bg-green-700">Send Invites</button></div></div></div>');function Zt(c,s){dt(s,!0);let u=ee(q([""])),p=Ht(s,"showModal",15,!1);const T=()=>{p(!1),k(u,q([""]))};function _(h){k(u,q(a(u).filter((x,S)=>S!==h)))}var I=je(),R=le(I);{var C=h=>{var x=Yt(),S=i(x),U=n(i(S),2),W=i(U);te(W,17,()=>a(u),pe,(M,Ae,ae)=>{var Z=Wt(),Q=i(Z);De(Q),Ot(Q,"autocomplete",null);var fe=n(Q,2);{var re=J=>{var ie=Vt();ie.__click=()=>_(ae),v(J,ie)};K(fe,J=>{a(u).length>1&&J(re)})}r(Z),Pt(Q,()=>a(u)[ae],J=>a(u)[ae]=J),v(M,Z)});var Y=n(W,2);Y.__click=[Jt,u],r(U);var B=n(U,2),O=i(B);O.__click=T;var y=n(O,2);y.__click=[Lt,u,s,T],r(B),r(S),r(x),v(h,x)};K(R,h=>{p()&&h(C)})}v(c,I),ct()}ut(["click"]);var Gt=(c,s,u)=>{console.log("On change inside modal",c),s.set(a(u).id,c.currentTarget.value)},Xt=m("<option> </option>"),Kt=m('<div class="flex flex-row justify-stretch rounded border p-4"><div class="shrink-0"><div class="font-semibold"> </div> <div class="mb-2 text-sm whitespace-nowrap text-gray-500"> </div></div> <select class="rounded border-gray-300"><option disabled selected>Select a subscription</option><!></select></div>'),Qt=m('<li><span class="font-semibold"> </span> </li>'),$t=m(`<span>With your current subscriptions, you will need to purchase
2					additional seats.</span> <ul class="px-4"></ul>`,1),ea=(c,s)=>k(s,!1),ta=(c,s,u)=>s(u),aa=m('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/40"><div class="w-full max-w-2xl rounded-xl bg-white p-6 shadow-lg"><h2 class="mb-4 text-lg font-bold">
2Assign Subscriptions</h2> <div class="max-h-[60vh] space-y-4 overflow-y-auto"></div> <!> <div class="mt-6 flex justify-between"><button>Cancel</button> <button class="bg-blue-600 text-white">Continue</button></div></div></div>'),ra=m("<span></span>"),ia=m('<span class="loading loading-spinner loading-sm"></span>'),sa=m('<span class="loading loading-spinner loading-sm"></span>'),oa=(c,s)=>{c.preventDefault(),k(s,!0)},na=c=>(console.log("Purchase"),c),la=c=>{c.preventDefault()},da=(c,s)=>{c.preventDefault(),k(s,!0)},ca=(c,s,u)=>{c.currentTarget.checked?k(s,q(a(u).map(p=>p.user_id))):k(s,q([]))},ua=(c,s)=>{console.log("User:",a(s).full_name,a(s))},va=c=>c.preventDefault(),_a=m("<option disabled>Invited</option>"),pa=m("<select><option>Admin</option><option>Member</option><!></select>"),fa=m('<tr><td class="border-b border-gray-200 px-3 py-3 text-gray-900"><input type="checkbox" class="size-4"></td><td class="w-full max-w-0 cursor-pointer py-3 pr-6 pl-2 text-sm font-medium whitespace-nowrap text-gray-900"><div class="flex items-center space-x-3 lg:pl-2"><a href="" class="truncate hover:text-gray-600"><span> </span></a></div></td><td class="px-6 py-3 text-sm font-medium text-gray-500"><!></td><td class="hidden px-6 py-3 text-left text-sm whitespace-nowrap text-gray-500 md:table-cell"> </td><td class="px-6 py-3 text-right text-sm font-medium whitespace-nowrap"></td></tr>'),ga=m('<tr class="skeleton h-[45px] w-full max-w-0 bg-white bg-linear-105 from-white from-30% via-slate-800/20 via-50% to-white to-70% py-3"><td></td><td class="w-full max-w-0"></td><td></td><td></td><td></td></tr>'),ma=(c,s,u)=>{console.log("Click for SC"),a(s).filter(p=>p.updated_user_role&&p.updated_user_role?.toUpperCase()!==p.user_role).forEach(async p=>await u(p,p.updated_user_role.toUpperCase()))},ba=m(`<div class=" flex h-12 flex-col items-center md:flex-row"><div class=" px-4">You have unsaved role re-assignments. Would you like to
3						save them?</div> <button class="rounded bg-gray-100 px-3 py-2 hover:bg-blue-100">Save Changes</button></div>`),ha=m('<!> <!> <section><h1 class="font-arimo mb-6 text-2xl font-bold">Organization Settings</h1> <div class="my-6 flex flex-col justify-around gap-4 md:flex-row"><div><h2 class="text-2xl font-medium"> </h2> <p> </p></div> <div><h2 class="text-xl font-medium">Billing</h2> <div class="list"><div><span>Total Seats Available: <!></span></div> <div><span>Total Members: <!></span></div> <div><a href="/account/organization/manage/billing" class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-gray-100 px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs ring-1 ring-gray-300 ring-inset hover:bg-blue-200 focus:bg-blue-100">Manage Billing</a></div></div></div></div> <div><div class="flex flex-row justify-between px-4"><h2 class="text-xl">Members</h2> <div class="relative inline-block text-left"><div class="peer"><button type="button" class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-gray-100 px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs ring-1 ring-gray-300 ring-inset hover:bg-blue-200 focus:bg-blue-100" id="menu-button" aria-expanded="true" aria-haspopup="true">Options <svg class="-mr-1 size-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon"><path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd"></path></svg></button></div> <div class="pointer-events-none absolute right-0 z-10 mt-2 w-56 origin-top-right scale-95 divide-y divide-gray-100 rounded-md bg-white opacity-0 shadow-lg ring-1 ring-black/5 transition duration-100 ease-out peer-has-focus-within:pointer-events-auto peer-has-hover:pointer-events-auto peer-has-focus:scale-100 peer-has-focus:opacity-100 peer-has-focus:duration-75 focus:pointer-events-auto focus:outline-hidden active:pointer-events-auto" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1"><div class="py-1" role="none"><a href="#" class="block px-4 py-2 text-sm text-gray-700 peer-has-focus:bg-blue-600 hover:bg-blue-200" role="menuitem" tabindex="-1" id="menu-item-0">
3Assign Subscriptions</a> <a href="/account/organization/manage" class="block px-4 py-2 text-sm text-gray-700 hover:bg-blue-200" role="menuitem" tabindex="-1" id="menu-item-1">Purchase Seats</a></div> <div class="py-1" role="none"><a href="" class="block px-4 py-2 text-sm text-gray-700 hover:bg-blue-200" role="menuitem" tabindex="-1" id="menu-item-2">Invite Members</a></div></div></div></div> <div class="mx-8 max-h-[600px] overflow-y-auto"><table class="min-w-full"><thead class="sticky top-0"><tr class="border-t border-gray-200"><th class="my-auto border-b border-gray-200 bg-gray-50 px-2 pt-1 align-middle text-sm text-gray-900" scope="col"><input type="checkbox" class="size-4.5 rounded-full"></th><th class="border-b border-gray-200 bg-gray-50 py-3 pr-6 pl-2 text-left text-sm font-semibold text-gray-900" scope="col"><span class="lg:pl-2">Name</span></th><th class="border-b border-gray-200 bg-gray-50 px-6 py-3 text-left text-sm font-semibold whitespace-nowrap text-gray-900" scope="col">Account Role</th><th class="hidden border-b border-gray-200 bg-gray-50 px-6 py-3 text-left text-sm font-semibold text-gray-900 md:table-cell" scope="col">Plan</th><th class="border-b border-gray-200 bg-gray-50 py-3 pr-6 text-right text-sm font-semibold text-gray-900" scope="col"></th></tr></thead><tbody class="divide-y divide-gray-100 bg-white"><!></tbody></table> <!></div></div></section>',1);function ja(c,s){dt(s,!0);const u=[];let p=s.data.all_subscriptions?.flatMap(e=>e.items.data.map(t=>({id:t.id,plan_id:t.plan.product,price_id:t.plan.id,quantity:t.quantity,interval:t.plan.interval})))??[],T=p.reduce((e,t)=>e+t.quantity,0),_=ee(q([]));s.data.member_profile_promise?.then(e=>{console.log("prom resolved",e),k(_,q(e))});let I=X(()=>p.map(e=>{let t=a(_).filter(o=>o.assigned_stripe_subscription_id===e.id);return{...e,assignees:t,remaining:e.quantity-t.length}})),R=ee(q([])),C=X(()=>a(R).map(e=>{const t=a(_).find(o=>o.user_id===e);return{name:t.full_name,id:t.user_id,assigned_subscription:t.assigned_stripe_subscription_id}})),h=X(()=>a(R).length==a(_).length),x=ee(!1);qt(()=>{k(x,q(a(h)))});let S=ee(!1);async function U(e){let t=e.map(({planId:l,need:g})=>({price_id:l,quantity:g}));t.forEach(l=>{a(I).find(g=>g.price_id===l.price_id)&&(l.id=a(I).find(g=>g.price_id===l.price_id).id)}),console.log(t);const o=await fetch("/api/org/billing/create_checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lineItems:t,orgId:s.data.orgs[0].org_id,customer_id:s.data.subscription?.stripeSubscription.customer,subscription_id:s.data.subscription?.stripeSubscription.id})}),{d}=await o.json()}async function W(e,t){const{data:o,error:d}=await s.data.supabase.from("organization_membership").select("*").eq("user_id",e.user_id).eq("org_id",e.org_id);if(["MEMBER","ADMIN"].includes(t)){console.log("Updating ",t,e);const{data:l,error:g}=await s.data.supabase.from("organization_membership").update({user_role:t,role_assigned_on:new Date}).eq("user_id",e.user_id).eq("org_id",s.data.orgs[0].org_id).select();g&&console.warn(`Issue while assigning role '${t}' to a user.`),a(_).forEach(f=>{f.user_id===e.user_id&&(f.user_role=t)})}else console.warn(`Cannot assign role '${t}' to a user at this time.`)}async function Y(e){for(const[t,o]of e){console.log("Assign",t,o);let d=a(I).find(f=>f.price_id===o);if(console.log("Match: ",d),!d){console.warn("No matching subscriptions found. Stripe either was not called properly or is itself down.");continue}const{data:l,error:g}=await s.data.supabase.from("organization_membership").update({assigned_stripe_subscription_id:d.id}).eq("user_id",t).eq("org_id",s.data.orgs[0].org_id).select();g&&console.error("Error trying to assign a subscription to a user. Please contact support for further assistance if the problem continues.",g),console.log(l),l&&(a(_).find(f=>f.user_id===t).assigned_stripe_subscription_id=d.id)}}async function B(e){const t=new Map;for(const d of e.values())t.set(d,(t.get(d)??0)+1);const o=[];for(const[d,l]of t.entries()){const g=a(I).filter(f=>f.price_id===d).reduce((f,P)=>f+P.remaining,0);if(g<l){let f=a(I).find(P=>P.price_id===d)?.quantity??0;o.push({planId:d,need:l-g+f})}}if(o.length>0){console.debug("REDIRECT TO STRIPE TO BUY SHORTAGES:",o),await U(o);return}await Y(e),k(S,!1)}let O=[{name:"Professional",product_id:ve[1].stripe_product_id,price_id:ve[1].frequencies?.monthly?.stripe_price_id,billing_interval:"Monthly"},{name:"Professional",product_id:ve[1].stripe_product_id,price_id:ve[1].frequencies?.annually?.stripe_price_id,billing_interval:"Annual"}];function y(e){if(!e)return"None";let t=a(I).find(d=>d.id===e);if(!t)return console.warn("No matching subscription found."),"Subscription";let o=O.find(d=>d.price_id===t.price_id);return`${o.name} (${o.billing_interval})`}let M=new Bt,Ae=X(()=>O.reduce((e,t)=>
3{const o=t.price_id,d=a(I)?.find(l=>l.price_id===o)?.remaining??0;return e[o]=d,e},{})),ae=X(()=>{let e={...a(Ae)};for(const t of M.values())e[t]=(e[t]??0)-1;return e}),Z=X(()=>Object.entries(a(ae)).filter(([e,t])=>t<0).map(([e,t])=>{const o=O.find(d=>d.price_id===e);return{name:`${o.name} (${o.billing_interval})`,missing:-1*t}}));async function Q(e){const t=await fetch("/api/org/members/invite",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({new_member_requests:e,orgId:s.data.orgs[0].org_id})}),{d:o}=await t.json();console.log("Res",o)}let fe=X(()=>a(_).some(e=>e.updated_user_role&&e.updated_user_role?.toUpperCase()!==e.user_role)),re=ee(!1);var J=ha(),ie=le(J);Zt(ie,{onInvitesSubmitted:Q,get showModal(){return a(re)},set showModal(e){k(re,q(e))}});var Re=n(ie,2);{var vt=e=>{var t=aa(),o=i(t),d=n(i(o),2);te(d,23,()=>a(C),j=>j.id,(j,w)=>{var H=Kt(),z=i(H),F=i(z),G=i(F,!0);r(F);var D=n(F,2),se=i(D);r(D),r(z);var N=n(z,2);Rt(N,()=>$0);var de;N.__change=[Gt,M,w];var ce=n(i(N));te(ce,17,()=>O,pe,(L,b)=>{var E=Xt(),oe={},ue=i(E);r(E),V(()=>{oe!==(oe=a(b).price_id)&&(E.value=(E.__value=a(b).price_id)==null?"":a(b).price_id),A(ue,`${a(b).name??""} (${a(b).billing_interval??""})`)}),v(L,E)}),r(N),r(H),V(L=>{A(G,a(w).name),A(se,`Current: ${a(w).assigned_subscription??"None"}`),de!==(de=L)&&(N.value=(N.__value=L)==null?"":L,Ut(N,L))},[()=>M.get(a(w).id)]),v(j,H)}),r(d);var l=n(d,2);{var g=j=>{var w=$t(),H=n(le(w),2);te(H,21,()=>a(Z).filter(z=>z.missing>0),pe,(z,F)=>{var G=Qt(),D=i(G),se=i(D,!0);r(D);var N=n(D);r(G),V(()=>{A(se,a(F).missing),A(N,` of ${a(F).name??""}`)}),v(z,G)}),r(H),v(j,w)};K(l,j=>{a(Z)&&a(Z).some(w=>w.missing>0)&&j(g)})}var f=n(l,2),P=i(f);P.__click=[ea,S];var $=n(P,2);$.__click=[ta,B,M],r(f),r(o),r(t),v(e,t)};K(Re,e=>{a(S)&&e(vt)})}var Ue=n(Re,2),ge=n(i(Ue),2),me=i(ge),be=i(me),_t=i(be,!0);r(be);var Be=n(be,2),pt=i(Be);r(Be),r(me);var He=n(me,2),Fe=n(i(He),2),he=i(Fe),Je=i(he),ft=n(i(Je));Pe(ft,()=>s.data.member_profile_promise,e=>{var t=ia();v(e,t)},(e,t)=>{var o=ra();o.textContent=T,v(e,o)}),r(Je),r(he);var Le=n(he,2),Ve=i(Le),gt=n(i(Ve));Pe(gt,()=>s.data.member_profile_promise,e=>{var t=sa();v(e,t)},e=>{var t=lt();V(()=>A(t,a(_).length)),v(e,t)}),r(Ve),r(Le),ze(2),r(Fe),r(He),r(ge);var We=n(ge,2),xe=i(We),Ye=n(i(xe),2),Ze=n(i(Ye),2),ye=i(Ze),Ge=i(ye);Ge.__click=[oa,S];var mt=n(Ge,2);mt.__click=[na],r(ye);var we=n(ye,2);we.__click=[la];var bt=i(we);bt.__click=[da,re],r(we),r(Ze),r(Ye),r(xe);var Xe=n(xe,2),ke=i(Xe),Ie=i(ke),Ke=i(Ie),Qe=i(Ke),Se=i(Qe);De(Se),Se.__click=[ca,R,_],r(Qe),ze(4),r(Ke),r(Ie);var $e=n(Ie),ht=i($e);Pe(ht,()=>s.data.member_profile_promise,e=>{var t=je(),o=le(t);te(o,16,()=>({length:3}),pe,(d,l)=>{var g=ga();v(d,g)}),v(e,t)},e=>{var t=je(),o=le(t);te(o,17,()=>a(_),d=>d.user_id,(d,l,g)=>{var f=fa(),P=i(f),$=i(P);De($);var j;r(P);var w=n(P);w.__click=[ua,l];var H=i(w),z=i(H);z.__click=[va];var F=i(z),G=i(F,!0);r(F),r(z),r(H),r(w);var D=n(w),se=i(D);{var N=b=>{var E=lt("Owner");v(b,E)},de=b=>{var E=pa(),oe=i(E),ue=n(oe),wt=n(ue);{var kt=ne=>{var et=_a();V(()=>Ne(et,a(l).user_role=="INVITED")),v(ne,et)};K(wt,ne=>{a(l).user_role=="INVITED"&&ne(kt)})}r(E),V(()=>{Ne(oe,a(l).user_role=="ADMIN"),Ne(ue,a(l).user_role=="MEMBER")}),At(E,()=>a(l).updated_user_role,ne=>a(l).updated_user_role=ne),v(b,E)};K(se,b=>{a(l).user_role==="OWNER"?b(N):b(de,!1)})}r(D);var ce=n(D),L=i(ce,!0);r(ce),ze(),r(f),V(b=>{j!==(j=a(l).user_id)&&($.value=($.__value=a(l).user_id)==null?"":a(l).user_id),A(G,a(l).full_name),A(L,b)},[()=>y(a(l).assigned_stripe_subscription_id)]),Dt(u,[],$,()=>(a(l).user_id,a(R)),b=>k(R,b)),v(d,f)}),v(e,t)}),r($e),r(ke);var xt=n(ke,2);{var yt=e=>{var t=ba(),o=n(i(t),2);o.__click=[ma,_,W],r(t),v(e,t)};K(xt,e=>{a(fe)&&e(yt)})}r(Xe),r(We),r(Ue),V(e=>{A(_t,s.data.org_data.org_name),A(pt,`Created: ${e??""}`)},[()=>Ft(s.data.org_data.created_on)]),jt(Se,()=>a(x),e=>k(x,e)),v(c,J),ct()}ut(["change","click"]);export{ja as component};

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.