PageSourceSearch

https://pltt.ai/_next/static/chunks/0uu98u4yd37kp.js

js pltt.ai collected 2026-10-05 15:19:30 UTC 284,447 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,435191,(e,s,t)=>{s.exports={name:"palette-agent-new",version:"0.1.0",private:!0,scripts:{predev:"node scripts/generate-plugin-registry.js && node scripts/build-agent-app-sandbox.mjs",dev:"next dev",prebuild:"node scripts/generate-plugin-registry.js && node scripts/build-agent-app-sandbox.mjs",build:"next build",start:"next start",lint:"eslint",test:"vitest","test:run":"vitest run","sync:runtime":"node scripts/sync-artifact-studio.mjs && node scripts/sync-session-dashboard.mjs"},dependencies:{"@hocuspocus/provider":"4.6.0","@palettelab/sdk":"^0.1.25","@phosphor-icons/react":"^2.1.10","@ssabrojs/hwpxjs":"^0.4.0","@tiptap/extension-collaboration":"3.31.3","@tiptap/extension-image":"^3.31.3","@tiptap/extension-list":"^3.31.3","@tiptap/extension-table":"^3.31.3","@tiptap/extension-text-align":"^3.31.3","@tiptap/pm":"^3.31.3","@tiptap/react":"^3.31.3","@tiptap/starter-kit":"^3.31.3","@tiptap/y-tiptap":"3.0.9","@univerjs/core":"0.25.1","@univerjs/preset-sheets-conditional-formatting":"0.25.1","@univerjs/preset-sheets-core":"0.25.1","@univerjs/preset-sheets-data-validation":"0.25.1","@univerjs/preset-sheets-filter":"0.25.1","@univerjs/preset-sheets-find-replace":"0.25.1","@univerjs/themes":"0.25.1","@xyflow/react":"^12.10.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",docx:"^9.7.1",echarts:"^6.0.0","echarts-for-react":"^3.0.6","emojibase-data":"^17.0.0","framer-motion":"^12.34.3","highlight.js":"^11.12.0","html-to-image":"^1.11.13","html2canvas-pro":"^2.3.0",i18next:"^25.8.18",jspdf:"^4.2.1",katex:"^0.18.7","lucide-react":"^0.563.0",next:"16.3.1","next-themes":"^0.4.6","pdfjs-dist":"^6.2.108",pptxgenjs:"^4.0.1","radix-ui":"^1.4.3",react:"19.2.3","react-dom":"19.2.3","react-force-graph-2d":"^1.29.1","react-i18next":"^16.5.8","react-markdown":"^10.1.0",recharts:"^3.8.0","rehype-katex":"^7.0.1","remark-gfm":"^4.0.1","remark-math":"^6.0.0",sonner:"^2.0.7","tailwind-merge":"^3.4.0",xlsx:"https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz","y-indexeddb":"9.0.12","y-protocols":"1.0.7",yjs:"13.6.32",zustand:"^5.0.12"},devDependencies:{"@tailwindcss/postcss":"^4","@testing-library/jest-dom":"^6.9.1","@testing-library/react":"^16.3.2","@testing-library/user-event":"^14.6.1","@types/node":"^20","@types/react":"^19","@types/react-dom":"^19","babel-plugin-react-compiler":"1.0.0",esbuild:"^0.25.12",eslint:"^9","eslint-config-next":"16.3.1",jsdom:"^26.1.0",shadcn:"^3.8.4",tailwindcss:"^4","tw-animate-css":"^1.4.0",typescript:"^5",vitest:"^4.1.10","vitest-axe":"^0.1.0"},overrides:{"@univerjs/core":{nanoid:"5.1.16"}}}},72664,373375,239616,284765,48396,323240,144966,443961,426971,654590,e=>{"use strict";var s=e.i(884656);e.s(["Box",()=>s.default],72664);var t=e.i(412012);e.s(["ChevronLeft",()=>t.default],373375);var i=e.i(903446);e.s(["Settings",()=>i.default],239616);var n=e.i(44016);e.s(["Settings2",()=>n.default],284765);var a=e.i(843476),l=e.i(500932),r=e.i(154920),o=e.i(271645),c=e.i(846696),d=e.i(209165),u=e.i(975157),m=e.i(964053),p=e.i(774084),h=e.i(643531),x=e.i(664659),g=e.i(655900),b=e.i(541071),j=e.i(107233),v=e.i(367240),f=e.i(555436),y=e.i(37727),w=e.i(702107);e.i(785269);var N=e.i(322831);function S(e){let s=String(e??"").trim().replace("#","");if(6!==s.length)return"#FFFFFF";let t=[0,2,4].map(e=>{let t=parseInt(s.slice(e,e+2),16)/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}),i=.2126*t[0]+.7152*t[1]+.0722*t[2],n=(e,s)=>(Math.max(e,s)+.05)/(Math.min(e,s)+.05);return n(i,.0065)>=n(i,1)?"#171614":"#FFFFFF"}function k(e){let s=0x811c9dc5,t=String(e??"");for(let e=0;e<t.length;e++)s^=t.charCodeAt(e),s=Math.imul(s,0x1000193)>>>0;return s.toString(16).padStart(8,"0").slice(0,6)}let _=["#171717","#34383B","#667076","#9AA09D","#C8C5BB","#E8E4DA","#007EA8"];function C(e){let s,t,i,n=(0,l.c)(12),{title:r,note:o,count:c,actions:d,plainHead:m,children:p,className:h}=e;return n[0]!==h?(s=(0,u.cn)("rlCard",h),n[0]=h,n[1]=s):s=n[1],n[2]!==d||n[3]!==c||n[4]!==o||n[5]!==m||n[6]!==r?(t=(r||o||c||d)&&(0,a.jsxs)("div",{className:(0,u.cn)("rlCardHead",m&&"plain"),children:[r&&(0,a.jsx)("h2",{className:"rlCardTitle",children:r}),o&&(0,a.jsx)("span",{className:"rlCardNote",children:o}),c&&(0,a.jsx)("span",{className:"rlCardCount",children:c}),d]}),n[2]=d,n[3]=c,n[4]=o,n[5]=m,n[6]=r,n[7]=t):t=n[7],n[8]!==p||n[9]!==s||n[10]!==t?(i=(0,a.jsxs)("section",{className:s,children:[t,p]}),n[8]=p,n[9]=s,n[10]=t,n[11]=i):i=n[11],i}function E(e){let s,t,i,n,r=(0,l.c)(11),{label:o,value:c,action:d,tight:m}=e,p=m&&"tight";return r[0]!==p?(s=(0,u.cn)("rlRow",p),r[0]=p,r[1]=s):s=r[1],r[2]!==o?(t=(0,a.jsx)("span",{className:"rlRowKey",children:o}),r[2]=o,r[3]=t):t=r[3],r[4]!==c?(i=(0,a.jsx)("span",{className:"rlRowVal",children:c}),r[4]=c,r[5]=i):i=r[5],r[6]!==d||r[7]!==s||r[8]!==t||r[9]!==i?(n=(0,a.jsxs)("div",{className:s,children:[t,i,d]}),r[6]=d,r[7]=s,r[8]=t,r[9]=i,r[10]=n):n=r[10],n}function T(e){let s,t,i=(0,l.c)(12),{options:n,value:r,onChange:o,ariaLabel:c,disabled:d}=e;if(i[0]!==d||i[1]!==o||i[2]!==n||i[3]!==r){let e;i[5]!==d||i[6]!==o||i[7]!==r?(e=e=>(0,a.jsx)("button",{type:"button","aria-pressed":r===e.id,disabled:d,className:(0,u.cn)("rlSeg",r===e.id&&"on"),onClick:()=>o(e.id),children:e.label},e.id),i[5]=d,i[6]=o,i[7]=r,i[8]=e):e=i[8],s=n.map(e),i[0]=d,i[1]=o,i[2]=n,i[3]=r,i[4]=s}else s=i[4];return i[9]!==c||i[10]!==s?(t=(0,a.jsx)("span",{className:"rlSegWrap",role:"group","aria-label":c,children:s}),i[9]=c,i[10]=s,i[11]=t):t=i[11],t}function P(e){let s,t,i,n,r,c,d,p,h,x,g,b,j=(0,l.c)(28),{title:v,onClose:f,wide:S,children:k}=e,{t:_}=(0,N.useTranslation)(),[C]=(0,o.useState)(U),E=A();j[0]!==f?(s=e=>{e||f()}
1,j[0]=f,j[1]=s):s=j[1],j[2]===Symbol.for("react.memo_cache_sentinel")?(t={display:"contents"},j[2]=t):t=j[2],j[3]===Symbol.for("react.memo_cache_sentinel")?(i={display:"contents"},j[3]=i):i=j[3];let T=S&&"wide";return j[4]!==T?(n=(0,u.cn)("rlModal",T),j[4]=T,j[5]=n):n=j[5],j[6]!==C?(r=e=>{e.preventDefault(),C?.focus()},j[6]=C,j[7]=r):r=j[7],j[8]!==v?(c=(0,a.jsx)(m.Dialog.Title,{asChild:!0,children:(0,a.jsx)("span",{children:v})}),j[8]=v,j[9]=c):c=j[9],j[10]!==_?(d=_("actions.close"),j[10]=_,j[11]=d):d=j[11],j[12]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(y.X,{size:18,strokeWidth:1.6,"aria-hidden":"true"}),j[12]=p):p=j[12],j[13]!==f||j[14]!==d?(h=(0,a.jsx)("button",{type:"button",className:"rlModalX",onClick:f,"aria-label":d,children:p}),j[13]=f,j[14]=d,j[15]=h):h=j[15],j[16]!==h||j[17]!==c?(x=(0,a.jsxs)("div",{className:"rlModalHead",children:[c,h]}),j[16]=h,j[17]=c,j[18]=x):x=j[18],j[19]!==k||j[20]!==E||j[21]!==x||j[22]!==n||j[23]!==r?(g=(0,a.jsx)(w.OverlayPortal,{children:(0,a.jsx)("div",{className:"settingsWrap",style:t,children:(0,a.jsx)("div",{className:"rlSet",style:i,children:(0,a.jsx)(m.Dialog.Overlay,{className:"rlVeil",children:(0,a.jsxs)(m.Dialog.Content,{ref:E,className:n,"aria-describedby":void 0,onCloseAutoFocus:r,children:[x,k]})})})})}),j[19]=k,j[20]=E,j[21]=x,j[22]=n,j[23]=r,j[24]=g):g=j[24],j[25]!==s||j[26]!==g?(b=(0,a.jsx)(m.Dialog.Root,{open:!0,onOpenChange:s,children:g}),j[25]=s,j[26]=g,j[27]=b):b=j[27],b}function U(){return"u"<typeof document?null:document.activeElement}function M(e){return(0,a.jsxs)("span",{className:"rlBullet",children:[(0,a.jsx)("i",{children:"—"}),(0,a.jsx)("span",{children:e})]},e)}function B(e){let s,t,i,n,r,d,u=(0,l.c)(18),{token:m,onDismiss:p}=e,{t:h}=(0,N.useTranslation)(),[x,g]=(0,o.useState)(!1);u[0]!==m?(s=(0,a.jsx)("span",{className:"rlRevealTok",children:m}),u[0]=m,u[1]=s):s=u[1],u[2]!==h||u[3]!==m?(t=async()=>{try{await navigator.clipboard.writeText(m),g(!0),c.toast.success(h("workspaceSettings:copied")),window.setTimeout(()=>g(!1),1800)}catch{g(!1),c.toast.error(h("workspaceSettings:copyFailed"))}},u[2]=h,u[3]=m,u[4]=t):t=u[4];let b=x?"workspaceSettings:copied":"workspaceSettings:copy";return u[5]!==h||u[6]!==b?(i=h(b),u[5]=h,u[6]=b,u[7]=i):i=u[7],u[8]!==t||u[9]!==i?(n=(0,a.jsx)("button",{type:"button",className:"rlBtn sm pri",onClick:t,children:i}),u[8]=t,u[9]=i,u[10]=n):n=u[10],u[11]!==p||u[12]!==h?(r=p&&(0,a.jsx)("button",{type:"button",className:"rlBtn sm",onClick:p,children:h("settingsUi.relay.saved")}),u[11]=p,u[12]=h,u[13]=r):r=u[13],u[14]!==s||u[15]!==n||u[16]!==r?(d=(0,a.jsxs)("div",{className:"rlReveal",children:[s,n,r]}),u[14]=s,u[15]=n,u[16]=r,u[17]=d):d=u[17],d}function $(e){if(!e)return"—";let s=new Date(e);if(Number.isNaN(s.getTime()))return"—";let t=e=>String(e).padStart(2,"0");return`${s.getFullYear()}-${t(s.getMonth()+1)}-${t(s.getDate())} ${t(s.getHours())}:${t(s.getMinutes())}`}function A(){let e,s,t=(0,l.c)(3),[i,n]=(0,o.useState)(null);return t[0]!==i?(e=()=>{if(!i)return;let e=0,s=()=>{for(let s of(e=0,i.querySelectorAll("table.wsMatrix"))){let e=Array.from(s.tHead?.rows[0]?.cells??[],L);for(let t of s.tBodies)for(let s of t.rows)Array.from(s.cells).forEach((s,t)=>{let i=e[t];i?s.dataset.label!==i&&(s.dataset.label=i):s.removeAttribute("data-label")})}};s();let t=new MutationObserver(()=>{e||(e=requestAnimationFrame(s))});return t.observe(i,{childList:!0,subtree:!0,characterData:!0}),()=>{t.disconnect(),cancelAnimationFrame(e)}},s=[i],t[0]=i,t[1]=e,t[2]=s):(e=t[1],s=t[2]),(0,o.useEffect)(e,s),n}function L(e){return e.textContent?.trim()??""}function R(e){return{value:String(e),label:e}}function F(e){let s,t,i,n,r,o,c,d=(0,l.c)(17),{value:m,onChange:h,options:g,label:b,disabled:j,className:v}=e;return d[0]!==v?(s=(0,u.cn)("rlInput rlSelect",v),d[0]=v,d[1]=s):s=d[1],d[2]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(p.Select.Value,{}),d[2]=t):t=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(p.Select.Icon,{asChild:!0,children:(0,a.jsx)(x.ChevronDown,{size:15,"aria-hidden":"true"})}),d[3]=i):i=d[3],d[4]!==b||d[5]!==s?(n=(0,a.jsxs)(p.Select.Trigger,{className:s,"aria-label":b,children:[t,i]}),d[4]=b,d[5]=s,d[6]=n):n=d[6],d[7]!==g?(r=g.map(O),d[7]=g,d[8]=r):r=d[8],d[9]!==r?(o=(0,a.jsx)(w.OverlayPortal,{children:(0,a.jsx)(p.Select.Content,{className:"rlSelectPanel",position:"popper",align:"start",sideOffset:6,collisionPadding:8,children:(0,a.jsx)(p.Select.Viewport,{className:"rlSelectList",children:r})})}),d[9]=r,d[10]=o):o=d[10],d[11]!==j||d[12]!==h||d[13]!==n||d[14]!==o||d[15]!==m?(c=(0,a.jsxs)(p.Select.Root,{value:m,onValueChange:h,disabled:j,children:[n,o]}),d[11]=j,d[12]=h,d[13]=n,d[14]=o,d[15]=m,d[16]=c):c=d[16],c}function O(e){return(0,a.jsxs)(p.Select.Item,{value:e.value,disabled:e.disabled,className:"rlSelectOpt",children:[(0,a.jsx)(p.Select.ItemText,{children:e.label}),(0,a.jsx)(p.Select.ItemIndicator,{asChild:!0,children:(0,a.jsx)(h.Check,{size:15,"aria-hidden":"true"})})]},e.value)}let I=(0,o.createContext)(null);function D(e,s){let t=(0,o.useContext)(I),i=(0,o.useRef)(e);i.current=e,(0,o.useEffect)(()=>(t?.(i.current),()=>t?.(null)),[t,...s])}function H(e){let s,t,i,n=(0,l.c)(7),{value:r,onChange:o,label:c}=e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(f.Search,{size:15,"aria-hidden":"true"}),n[0]=s):s=n[0],n[1]!==o?(t=e=>o(e.target.value),n[1]=o,n[2]=t):t=n[2],n[3]!==c||n[4]!==t||n[5]!==r?(i=(0,a.jsxs)("span",{className:"wsSearch poSearch",children:[s,(0,a.jsx)("input",{type:"search",value:r,"aria-label":c,placeholder:c,onChange:t})]}),n[3]=c,n[4]=t,n[5]=r,n[6]=i):i=n[6],i}e.s(["Bullets",0,function(e){let s,t,i=(0,l.c)(4),{lines:n}=e;return i[0]!==n?(s=n.map(M),i[0]=n,i[1]=s):s=i[1],i[2]!==s?(t=(0,a.jsx)("div",{className:"rlBullets",children:s}),i[2]=s,i[3]=t):t=i[3],t},"Card",0,C,"CreateAction",0,function(e){let s,t,i=(0,l.c)(5),{label:n,onClick:r,disabled:o}=e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(j.Plus,{size:18,"aria-hidden":"true"}),i[0]=s):s=i[0],i[1]!==o||i[2]!==n||i[3]!==r?(t=(0,a.jsxs)("button",{type:"button",className:"wsCreateAction",disabled:o,onClick:r,children:[s,n]}),i[1]=o,i[2]=n,i[3]=r,i[4]=t):t=i[4],t},"DetailRow",0,function(e){let s,t,i,n,r=(0,l.c)(10),{title:o,note:c,action:d}=e;return r[0]!==o?(s=(0,a.jsx)("span",{className:"rlRowT",children:o}),r[0]=o,r[1]=s):s=r[1],r[2]!==c?(t=(0,a.jsx)("span",{className:"rlRowN",children:c}),r[2]=c,r[3]=t):t=r[3],r[4]!==s||r[5]!==t?(i=(0,a.jsxs)("span",{className:"rlRowMain",children:[s,t]}),r[4]=s,r[5]=t,r[6]=i):i=r[6],r[7]!==d||r[8]!==i?(n=(0,a.jsxs)("div",{className:"rlRow",children:[i,d]}),r[7]=d,r[8]=i,r[9]=n):n=r[9],n},"EmptyState",0,function(e){let s,t,i,n=(0,l.c)(8),{title:r,note:o,action:c}=e;return n[0]!==r?(s=(0,a.jsx)("span",{className:"rlEmptyLead",children:r}),n[0]=r,n[1]=s):s=n[1],n[2]!==o?(t=o&&(0,a.jsx)("span",{className:"rlNote",children:o}),n[2]=o,n[3]=t):t=n[3],n[4]!==c||n[5]!==s||n[6]!==t?(i=(0,a.jsxs)("div",{className:"rlEmpty",children:[s,t,c]}),n[4]=c,n[5]=s,n[6]=t,n[7]=i):i=n[7],i},"IconAction",0,function(e){let s,t=(0,l.c)(5),{label:i,onClick:n,disabled:r,children:o}=e;return t[0]!==o||t[1]!==r||t[2]!==i||t[3]!==n?(s=(0,a.jsx)("button",{type:"button",className:"wsIconAction",title:i,"aria-label":i,disabled:r,onClick:n,children:o}),t[0]=o,t[1]=r,t[2]=i,t[3]=n,t[4]=s):s=t[4],s},"MARK_COLORS",0,_,"Mark",0,function(e){let s,t,i,n,r,o=(0,l.c)(17),{size:c,variant:d,color:m,fg:p,children:h,className:x}=e,g=void 0===d?"fill":d;o[0]!==c?(s=({20:8,22:9,24:10,26:11,30:11,32:13,40:13,48:16,76:25,80:26})[c]??11,o[0]=c,o[1]=s):s=o[1];let b=s,j=c<=24?6:c<=32?8:c<=48?10:12;o[2]!==m||o[3]!==p||o[4]!==g?(t="ghost"===g?{background:"var(--rl-surface)",color:"var(--rl-ink)",boxShadow:`inset 0 0 0 1px ${m}`}:"ink"===g?{background:"var(--rl-ink)",color:"var(--rl-page)",boxShadow:`inset 0 -3px 0 ${m}`}:{background:m,color:p||S(m)},o[2]=m,o[3]=p,o[4]=g,o[5]=t):t=o[5];let v=t;return o[6]!==x?(i=(0,u.cn)("rlMark",x),o[6]=x,o[7]=i):i=o[7],o[8]!==b||o[9]!==j||o[10]!==c||o[11]!==v?(n={width:c,height:c,borderRadius:j,fontSize:b,...v},o[8]=b,o[9]=j,o[10]=c,o[11]=v,o[12]=n):n=o[12],o[13]!==h||o[14]!==i||o[15]!==n?(r=(0,a.jsx)("span",{className:i,style:n,children:h}),o[13]=h,o[14]=i,o[15]=n,o[16]=r):r=o[16],r},"MetaRow",0,function(e){let s,t,i=(0,l.c)(5),{count:n,action:r}=e;return i[0]!==n?(s=(0,a.jsx)("span",{children:n}),i[0]=n,i[1]=s):s=i[1],i[2]!==r||i[3]!==s?(t=(0,a.jsxs)("div",{className:"wsMetaRow",children:[s,r]}),i[2]=r,i[3]=s,i[4]=t):t=i[4],t},"Modal",0,P,"OptionCard",0,function(e){let s,t,i,n,r,o,c=(0,l.c)(18),{title:d,desc:m,selected:p,onSelect:h,trailing:x,className:g,disabled:b}=e,j=p&&"on";return c[0]!==g||c[1]!==j?(s=(0,u.cn)("rlOpt",j,g),c[0]=g,c[1]=j,c[2]=s):s=c[2],c[3]===Symbol.for("react.memo_cache_sentinel")?(t={display:"flex",alignItems:"center",gap:8},c[3]=t):t=c[3],c[4]!==d?(i=(0,a.jsx)("span",{className:"rlOptT",children:d}),c[4]=d,c[5]=i):i=c[5],c[6]!==i||c[7]!==x?(n=(0,a.jsxs)("span",{style:t,children:[i,x]}),c[6]=i,c[7]=x,c[8]=n):n=c[8],c[9]!==m?(r=m&&(0,a.jsx)("span",{className:"rlOptD",children:m}),c[9]=m,c[10]=r):r=c[10],c[11]!==b||c[12]!==h||c[13]!==p||c[14]!==s||c[15]!==n||c[16]!==r?(o=(0,a.jsxs)("button",{type:"button","aria-pressed":p,disabled:b,onClick:h,className:s,children:[n,r]}),c[11]=b,c[12]=h,c[13]=p,c[14]=s,c[15]=n,c[16]=r,c[17]=o):o=c[17],o},"PageToolsProvider",0,function(e){let s,t=(0,l.c)(3),{set:i,children:n}=e;return t[0]!==n||t[1]!==i?(s=(0,a.jsx)(I.Provider,{value:i,children:n}),t[0]=n,t[1]=i,t[2]=s):s=t[2],s},"Pager",0,function(e){let s,t,i,n,r,o,c,d,m,p,h,x,g,b,j=(0,l.c)(47),{page:v,pages:f,size:y,onPage:w,onSize:N,labels:S,sizes:k}=e;j[0]!==k?(s=void 0===k?[5,10,20]:k,j[0]=k,j[1]=s):s=j[1];let _=s,C=Math.max(1,Math.min(v-3,f-6));if(j[2]!==C||j[3]!==f){let e;j[5]!==C?(e=(e,s)=>C+s,j[5]=C,j[6]=e):e=j[6],t=Array.from({length:Math.min(7,f)},e),j[2]=C,j[3]=f,j[4]=t}else t=j[4];let E=t,T=S.rows,P=String(y);j[7]!==w||j[8]!==N?(i=e=>{N(Number(e)),w(1)},j[7]=w,j[8]=N,j[9]=i):i=j[9],j[10]!==_?(n=_.map(R),j[10]=_,j[11]=n):n=j[11],j[12]!==P||j[13]!==i||j[14]!==n?(r=(0,a.jsx)(F,{value:P,onChange:i,options:n}),j[12]=P,j[13]=i,j[14]=n,j[15]=r):r=j[15],j[16]!==S.rows||j[17]!==r?(o=(0,a.jsxs)("label",{className:"wsPageSize",children:[T,r]}),j[16]=S.rows,j[17]=r,j[18]=o):o=j[18];let U=v<=1;j[19]!==w||j[20]!==v?(c=()=>w(v-1),j[19]=w,j[20]=v,j[21]=c):c=j[21],j[22]!==S.previous||j[23]!==U||j[24]!==c?(d=(0,a.jsx)("button",{type:"button",className:"rlBtn",disabled:U,onClick:c,children:S.previous}),j[22]=S.previous,j[23]=U,j[24]=c,j[25]=d):d=j[25],j[26]!==E||j[27]!==w||j[28]!==v?(m=E.map(e=>(0,a.jsx)("button",{type:"button",className:(0,u.cn)("rlBtn","wsPageNumber",e===v&&"on"),"aria-current":e===v?"page":void 0,onClick:()=>w(e),children:e},e)),j[26]=E,j[27]=w,j[28]=v,j[29]=m):m=j[29];let M=v>=f;return j[30]!==w||j[31]!==v?(p=()=>w(v+1),j[30]=w,j[31]=v,j[32]=p):p=j[32],j[33]!==S.next||j[34]!==M||j[35]!==p?(h=(0,a.jsx)("button",{type:"button",className:"rlBtn",disabled:M,onClick:p,children:S.next}),j[33]=S.next,j[34]=M,j[35]=p,j[36]=h):h=j[36],j[37]!==d||j[38]!==m||j[39]!==h?(x=(0,a.jsxs)("div",{className:"wsPageButtons",children:[d,m,h]}),j[37]=d,j[38]=m,j[39]=h,j[40]=x):x=j[40],j[41]!==S.status?(g=(0,a.jsx)("span",{children:S.status}),j[41]=S.status,j[42]=g):g=j[42],j[43]!==x||j[44]!==g||j[45]!==o?(b=(0,a.jsxs)("div",{className:"wsPagination",children:[o,x,g]}),j[43]=x,j[44]=g,j[45]=o,j[46]=b):b=j[46],b},"RELAY_PREFS_KEY",0,"palette:settings-relay-v1","ResetAction",0,function(e){let s,t,i=(0,l.c)(5),{label:n,onClick:r,disabled:o}=e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(v.RotateCcw,{size:16,"aria-hidden":"true"}),i[0]=s):s=i[0],i[1]!==o||i[2]!==n||i[3]!==r?(t=(0,a.jsxs)("button",{type:"button",className:"wsResetAction",disabled:o,onClick:r,children:[s,n]}),i[1]=o,i[2]=n,i[3]=r,i[4]=t):t=i[4],t},"RlSelect",0,F,"RoleTag",0,function(e){let s,t,i=(0,l.c)(5),{role:n,label:r}=e,o="owner"===n?"pri":"admin"===n?"info":"";i[0]!==o?(s=(0,u.cn)("rlTag",o),i[0]=o,i[1]=s):s=i[1];let c=r??n;return i[2]!==s||i[3]!==c?(t=(0,a.jsx)("span",{className:s,children:c}),i[2]=s,i[3]=c,i[4]=t):t=i[4],t},"Row",0,E,"RowMenu",0,function(e){let s,t,i,n,r,c,d,m=(0,l.c)(17),{label:p,items:h}=e,[x,g]=(0,o.useState)(null),j=(0,o.useRef)(null),v=(0,o.useRef)(null);if(m[0]!==x?(s=()=>
1{if(!x)return;let e=e=>{let s=e.target;j.current?.contains(s)||v.current?.contains(s)||g(null)},s=e=>{"Escape"===e.key&&g(null)},t=()=>g(null);return document.addEventListener("mousedown",e),document.addEventListener("keydown",s),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",s),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},t=[x],m[0]=x,m[1]=s,m[2]=t):(s=m[1],t=m[2]),(0,o.useEffect)(s,t),!h.length)return null;m[3]!==x||m[4]!==h.length?(i=e=>{if(x)return g(null);let s=e.currentTarget.getBoundingClientRect(),t=40*h.length+12;g({top:s.bottom+4+t<=window.innerHeight?s.bottom+4:Math.max(8,s.top-4-t),right:window.innerWidth-s.right})},m[3]=x,m[4]=h.length,m[5]=i):i=m[5];let f=i,y=!!x;return m[6]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.jsx)(b.MoreHorizontal,{size:17,"aria-hidden":"true"}),m[6]=n):n=m[6],m[7]!==p||m[8]!==y||m[9]!==f?(r=(0,a.jsx)("button",{type:"button",className:"wsIconAction","aria-label":p,"aria-expanded":y,"aria-haspopup":"menu",onClick:f,children:n}),m[7]=p,m[8]=y,m[9]=f,m[10]=r):r=m[10],m[11]!==x||m[12]!==h?(c=x&&(0,a.jsx)(w.OverlayPortal,{children:(0,a.jsx)("div",{className:"settingsWrap",style:{display:"contents"},children:(0,a.jsx)("div",{className:"rlSet",style:{display:"contents"},children:(0,a.jsx)("div",{className:"wsRowMenuPop",role:"menu",ref:v,style:{top:x.top,right:x.right},children:h.map(e=>(0,a.jsx)("button",{type:"button",role:"menuitem",className:(0,u.cn)("wsRowMenuItem",e.danger&&"dan"),onClick:()=>{g(null),e.onSelect()},children:e.label},e.id))})})})}),m[11]=x,m[12]=h,m[13]=c):c=m[13],m[14]!==r||m[15]!==c?(d=(0,a.jsxs)("div",{className:"wsRowMenu",ref:j,children:[r,c]}),m[14]=r,m[15]=c,m[16]=d):d=m[16],d},"SearchField",0,H,"SecretReveal",0,B,"Seg",0,T,"SortHead",0,function(e){let s,t,i,n=(0,l.c)(11),{label:r,active:o,dir:c,onSort:d}=e;if(!d){let e;return n[0]!==r?(e=(0,a.jsx)(a.Fragment,{children:r}),n[0]=r,n[1]=e):e=n[1],e}let m=o&&"asc"===c?g.ChevronUp:x.ChevronDown,p=o&&"on";return n[2]!==p?(s=(0,u.cn)("wsSortHead",p),n[2]=p,n[3]=s):s=n[3],n[4]!==m?(t=(0,a.jsx)(m,{size:13,"aria-hidden":"true"}),n[4]=m,n[5]=t):t=n[5],n[6]!==r||n[7]!==d||n[8]!==s||n[9]!==t?(i=(0,a.jsxs)("button",{type:"button",className:s,onClick:d,children:[r,t]}),n[6]=r,n[7]=d,n[8]=s,n[9]=t,n[10]=i):i=n[10],i},"hash6",0,k,"initialsOf",0,function(e,s){return(e?.trim()||s?.trim()||"?").split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")||"?"},"isHex6",0,function(e){return/^#[0-9A-F]{6}$/.test(String(e??"").toUpperCase())},"markColorFor",0,function(e){return _[parseInt(k(e).slice(0,2),16)%_.length]},"normaliseHexInput",0,function(e){let s=String(e??"").toUpperCase().replace(/[^0-9A-F#]/g,"");return s&&"#"!==s.charAt(0)&&(s=`#${s}`),s.slice(0,7)},"onColor",0,S,"stamp",0,$,"useCellLabels",0,A,"usePageTools",0,D],48396);var z=e.i(13080);function V(){let e,s,t,i,n,a,r,o=(0,l.c)(21),{user:c}=(0,z.useAuth)(),d=c?.org_role??null,u=c?.capabilities,m=c?.direct_capabilities;o[0]!==u?(e=u??[],o[0]=u,o[1]=e):e=o[1],o[2]!==e?(s=new Set(e),o[2]=e,o[3]=s):s=o[3];let p=s;o[4]!==m?(t=m??[],o[4]=m,o[5]=t):t=o[5],o[6]!==t?(i=new Set(t),o[6]=t,o[7]=i):i=o[7];let h=i,x="owner"===d;return o[8]!==p||o[9]!==x?(n=(...e)=>x||e.some(e=>p.has(e)),o[8]=p,o[9]=x,o[10]=n):n=o[10],o[11]!==h||o[12]!==x?(a=e=>x||h.has(e),o[11]=h,o[12]=x,o[13]=a):a=o[13],o[14]!==h||o[15]!==p||o[16]!==x||o[17]!==d||o[18]!==n||o[19]!==a?(r={role:d,isOwner:x,effective:p,direct:h,has:n,canGrant:a},o[14]=h,o[15]=p,o[16]=x,o[17]=d,o[18]=n,o[19]=a,o[20]=r):r=o[20],r}e.s(["usePermissions",0,V],323240);let q=["mcp:tasks.read","mcp:tasks.write","mcp:documents.read","mcp:dataroom.read","mcp:results.read","mcp:apps.call"];async function W(e){let s=await (0,d.apiFetch)(e);if(!s.ok)throw Error(`${e} failed (${s.status})`);return await s.json()}let G=["active","ok","approved","linked"],K=["error","denied","revoked","failed"];function J(e){let s,t,i,n=(0,l.c)(7),{status:r}=e,o=G.includes(r)?"var(--rl-ok-ink)":K.includes(r)?"var(--rl-err-ink)":void 0;return n[0]!==o?(s=o?{color:o,borderColor:o}:void 0,n[0]=o,n[1]=s):s=n[1],n[2]!==r?(t=r.toUpperCase(),n[2]=r,n[3]=t):t=n[3],n[4]!==s||n[5]!==t?(i=(0,a.jsx)("span",{className:"rlTag",style:s,children:t}),n[4]=s,n[5]=t,n[6]=i):i=n[6],i}function Y(e){let s,t=(0,l.c)(2),{children:i}=e;return t[0]!==i?(s=(0,a.jsx)("div",{className:"rlModalLabel",children:i}),t[0]=i,t[1]=s):s=t[1],s}let X={flexBasis:"100%",whiteSpace:"normal"};function Q(){let{t:e}=(0,N.useTranslation)(),[s,t]=(0,o.useState)(!0),[i,n]=(0,o.useState)(!1),[l,m]=(0,o.useState)(null),[p,h]=(0,o.useState)([]),[x,g]=(0,o.useState)(!1),b=(0,o.useCallback)(async()=>{t(!0),n(!1);
1try{let[e,s]=await Promise.all([W("/api/v1/mcp/settings"),W("/api/v1/mcp/approvals?status=pending")]);m(e.external_paused),h(s)}catch{n(!0)}finally{t(!1)}},[]);(0,o.useEffect)(()=>{b()},[b]);let j=async()=>{g(!0);try{let e=await (0,d.apiFetch)("/api/v1/mcp/settings",{method:"PATCH",body:JSON.stringify({external_paused:!l})});e.ok&&m((await e.json()).external_paused),window.dispatchEvent(new Event("palette:mcp-change"))}catch(s){c.toast.error(s instanceof Error?s.message:e("workspaceSettings:saveFailed"))}finally{g(!1)}},v=async(s,t)=>{if(!x){g(!0);try{await (0,d.apiFetch)(`/api/v1/mcp/approvals/${s}/${t}`,{method:"POST",body:"{}"}),b(),window.dispatchEvent(new Event("palette:mcp-change"))}catch(s){c.toast.error(s instanceof Error?s.message:e("workspaceSettings:saveFailed"))}finally{g(!1)}}};return i?(0,a.jsxs)("div",{className:"rlEmpty",role:"alert",children:[e("workspaceSettings:loadFailed"),(0,a.jsx)("button",{className:"rlBtn",onClick:()=>void b(),children:e("workspaceSettings:retry")})]}):s?(0,a.jsx)(r.PaletteLoader,{label:e("workspaceSettings:loading")}):(0,a.jsxs)("div",{className:"rlStack",children:[(0,a.jsx)(C,{title:e("settingsUi.mcpCommand.externalAccess"),count:null===l?"…":l?"PAUSED":"LIVE",actions:(0,a.jsx)("button",{type:"button",className:(0,u.cn)("rlBtn",l?"pri":"dan"),disabled:x||null===l,onClick:j,children:l?"RESUME":e("settingsUi.mcp.pauseAll","Pause all")}),children:(0,a.jsx)("div",{className:"rlHint",children:e("settingsUi.mcpCommand.pauseInboundMcpGatewayChannel")})}),(0,a.jsxs)(C,{title:e("settingsUi.mcpCommand.pendingApprovals"),count:`${p.length}`,children:[0===p.length&&(0,a.jsx)("div",{className:"rlEmpty",children:e("settingsUi.mcpCommand.nothingWaitingOnYou")}),p.map(s=>(0,a.jsxs)("div",{className:"rlListRow",style:{alignItems:"flex-start"},children:[(0,a.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:6},children:[(0,a.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[(0,a.jsx)("span",{className:"rlRowT",children:s.tool}),(0,a.jsx)("span",{className:"rlTag",children:(s.channel??s.requested_by_kind).toUpperCase()})]}),(0,a.jsx)("pre",{style:{margin:0,maxHeight:112,overflow:"auto",padding:"8px 10px",border:"1px solid var(--rl-border)",borderRadius:8,background:"var(--rl-page)",fontFamily:"var(--rl-mono)",fontSize:12,lineHeight:1.6},children:JSON.stringify(s.args_snapshot??{},null,2)}),(0,a.jsxs)("span",{className:"rlRowN",style:{whiteSpace:"normal"},children:["Requested ",new Date(s.created_at).toLocaleString()," · expires"," ",new Date(s.expires_at).toLocaleString()]})]}),(0,a.jsxs)("span",{style:{display:"flex",gap:8,flex:"none"},children:[(0,a.jsxs)("button",{type:"button",className:"rlBtn sm pri",disabled:x,onClick:()=>v(s.id,"approve"),children:["✓ ",e("settingsUi.mcpCommand.approve")]}),(0,a.jsxs)("button",{type:"button",className:"rlBtn sm dan",disabled:x,onClick:()=>v(s.id,"deny"),children:["✕ ",e("settingsUi.mcpCommand.deny")]})]})]},s.id)),(0,a.jsx)("div",{className:"rlHint",children:"Externally-requested actions waiting on an admin decision. They execute from the snapshotted arguments shown here — exactly what you approve runs."})]})]})}function Z(){let{t:e}=(0,N.useTranslation)(),[s,t]=(0,o.useState)(!0),[i,n]=(0,o.useState)(!1),{t:l}=(0,N.useTranslation)("workspaceSettings"),[u,m]=(0,o.useState)(null),[p,h]=(0,o.useState)(!1),[x,g]=(0,o.useState)(""),[b,j]=(0,o.useState)([]),[v,f]=(0,o.useState)(!1),[y,w]=(0,o.useState)({slug:"",name:"",server_url:"",auth_type:"none",token:"",header:"X-API-Key"}),[S,k]=(0,o.useState)(null),[_,E]=(0,o.useState)(null),{has:T}=V(),U=T("mcp.connections.manage"),M=T("mcp.pause"),B=(0,o.useCallback)(async()=>{t(!0),n(!1);try{j(await W("/api/v1/mcp/connectors"))}catch{n(!0)}finally{t(!1)}},[]);(0,o.useEffect)(()=>{B()},[B]);let $=async()=>{if(!p){h(!0),k(null);try{let s={slug:y.slug,name:y.name||y.slug,server_url:y.server_url,auth_type:y.auth_type};"bearer"===y.auth_type&&y.token&&(s.auth_config={token:y.token}),"api_key_header"===y.auth_type&&y.token&&(s.auth_config={header:y.header.trim(),value:y.token}),"none"===y.auth_type&&(s.auth_config={}),u&&delete s.slug,u&&!y.token&&y.auth_type===u.auth_type&&delete s.auth_type;let t=await (0,d.apiFetch)(u?`/api/v1/mcp/connectors/${u.id}`:"/api/v1/mcp/connectors",{method:u?"PATCH":"POST",body:JSON.stringify(s)});if(!t.ok){let s=(await t.json().catch(()=>({}))).detail;
1k("string"==typeof s?s:e("settingsUi.mcp.addConnectorFailed","Failed to add connector"));return}f(!1),w({slug:"",name:"",server_url:"",auth_type:"none",token:"",header:"X-API-Key"}),B(),window.dispatchEvent(new Event("palette:mcp-change"))}catch(e){c.toast.error(e instanceof Error?e.message:l("saveFailed"))}finally{h(!1)}}},A=async(s,t,i)=>{if(!p){h(!0);try{if("discover"===t&&await (0,d.apiFetch)(`/api/v1/mcp/connectors/${s}/discover`,{method:"POST",body:"{}"}),"test"===t){let t=await (0,d.apiFetch)(`/api/v1/mcp/connectors/${s}/test`,{method:"POST",body:"{}"});c.toast[t.ok?"success":"error"](e(t.ok?"settingsUi.mcp.testOk":"settingsUi.mcp.testFailed"))}"delete"===t&&await (0,d.apiFetch)(`/api/v1/mcp/connectors/${s}`,{method:"DELETE"}),"toggle"===t&&i&&await (0,d.apiFetch)(`/api/v1/mcp/connectors/${s}`,{method:"PATCH",body:JSON.stringify({status:"disabled"===i.status?"active":"disabled"})}),B(),window.dispatchEvent(new Event("palette:mcp-change"))}catch(e){c.toast.error(e instanceof Error?e.message:l("saveFailed"))}finally{h(!1)}}};return(D((0,a.jsx)(H,{value:x,label:l("search"),onChange:g}),[x]),i)?(0,a.jsxs)("div",{className:"rlEmpty",role:"alert",children:[e("workspaceSettings:loadFailed"),(0,a.jsx)("button",{className:"rlBtn",onClick:()=>void B(),children:e("workspaceSettings:retry")})]}):s?(0,a.jsx)(r.PaletteLoader,{label:e("workspaceSettings:loading")}):(0,a.jsxs)("div",{className:"rlStack",children:[(0,a.jsxs)(C,{title:e("settingsUi.mcpCommand.connectors"),count:`${b.length}`,actions:(0,a.jsxs)("button",{type:"button",className:"rlBtn pri",onClick:()=>{m(null),k(null),w({slug:"",name:"",server_url:"",auth_type:"none",token:"",header:"X-API-Key"}),f(!0)},children:["+ ",e("settingsUi.mcpCommand.addConnector")]}),children:[0===b.length&&(0,a.jsx)("div",{className:"rlEmpty",children:e("settingsUi.mcpCommand.noExternalMcpServersConnected")}),b.filter(e=>`${e.name} ${e.server_url}`.toLowerCase().includes(x.toLowerCase())).map(s=>(0,a.jsxs)("div",{className:"rlListRow",children:[(0,a.jsx)("span",{className:"rlListName",children:s.name}),(0,a.jsx)(J,{status:s.status}),(0,a.jsxs)("span",{className:"rlListMeta",children:["mcp.",s.slug," · ",s.server_url]}),(0,a.jsx)("button",{type:"button",className:"rlBtn sm",disabled:p||!U,onClick:()=>{m(s),k(null),w({slug:s.slug,name:s.name,server_url:s.server_url,auth_type:s.auth_type,token:"",header:"X-API-Key"}),f(!0)},children:l("edit")}),(0,a.jsx)("button",{type:"button",className:"rlBtn sm",disabled:p||!U,onClick:()=>A(s.id,"test"),children:l("mcp.test")}),(0,a.jsxs)("button",{type:"button",className:"rlBtn sm",disabled:p||!U,onClick:()=>A(s.id,"discover"),children:["↻ ",e("actions.refresh")]}),(0,a.jsx)("button",{type:"button",className:"rlBtn sm",disabled:p||!M,onClick:()=>A(s.id,"toggle",s),children:l("disabled"===s.status?"mcp.enable":"mcp.disable")}),(0,a.jsx)("button",{type:"button",className:"rlBtn sm dan",disabled:p||!U,onClick:()=>E(s),children:e("orgMembers.remove")}),s.last_error&&(0,a.jsx)("span",{className:"rlErr",style:X,children:s.last_error})]},s.id)),(0,a.jsx)("div",{className:"rlHint",children:e("settingsUi.mcp.registerHint","Register an external MCP server (Streamable HTTP). Tools are discovered automatically.")})]}),_&&(0,a.jsx)(P,{title:l("mcp.removeTitle"),onClose:()=>E(null),children:(0,a.jsxs)("div",{className:"rlModalBody",children:[(0,a.jsxs)("div",{className:"wsPermSummary",children:[(0,a.jsx)("strong",{children:_.name}),(0,a.jsx)("span",{className:"rlRowN",children:_.server_url})]}),(0,a.jsx)("p",{className:"rlNote",children:l("mcp.removeConfirm",{name:_.name})}),(0,a.jsxs)("div",{className:"rlModalActions",children:[(0,a.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>E(null),children:l("cancel")}),(0,a.jsx)("button",{type:"button",className:"rlBtn danFill",disabled:p,onClick:()=>{E(null),A(_.id,"delete",_)},children:l("delete")})]})]})}),v&&(0,a.jsx)(P,{title:u?l("mcp.edit"):e("settingsUi.mcpCommand.addMcpConnector"),onClose:()=>{p||(f(!1),w({...y,token:""}))},children:(0,a.jsxs)("div",{className:"rlModalBody",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(Y,{children:e("settingsUi.mcpCommand.slug")}),(0,a.jsx)("input",{className:"rlInput",style:{width:"100%"},placeholder:e("settingsUi.mcpCommand.notion"),value:y.slug,"aria-label":e("settingsUi.mcpCommand.slug"),disabled:!!u,autoFocus:!0,onChange:e=>w({...y,slug:e.target.value})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(Y,{children:e("datasets.measures.name")}
1),(0,a.jsx)("input",{className:"rlInput",style:{width:"100%"},placeholder:e("settingsUi.mcpCommand.notion2"),"aria-label":l("name"),value:y.name,onChange:e=>w({...y,name:e.target.value})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(Y,{children:e("settingsUi.mcpCommand.serverUrl")}),(0,a.jsx)("input",{className:"rlInput",style:{width:"100%"},placeholder:"https://mcp.example.com/mcp","aria-label":e("settingsUi.mcpCommand.serverUrl"),type:"url",value:y.server_url,onChange:e=>w({...y,server_url:e.target.value})})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"wsField",children:[l("mcp.authentication"),(0,a.jsx)(F,{value:y.auth_type,onChange:e=>w({...y,auth_type:e,token:""}),options:[{value:"none",label:l("mcp.noAuth")},{value:"bearer",label:"Bearer token"},{value:"api_key_header",label:"API key"}]})]}),"api_key_header"===y.auth_type&&(0,a.jsxs)("label",{className:"wsField",children:[l("mcp.header"),(0,a.jsx)("input",{className:"rlInput",value:y.header,onChange:e=>w({...y,header:e.target.value})})]}),(0,a.jsx)(Y,{children:l(u?"mcp.keepCredential":"mcp.credential")}),(0,a.jsx)("input",{className:"rlInput",style:{width:"100%"},type:"password","aria-label":l("mcp.credential"),disabled:"none"===y.auth_type,value:y.token,onChange:e=>w({...y,token:e.target.value})})]}),S&&(0,a.jsx)("div",{className:"rlErr",children:S}),(0,a.jsxs)("div",{className:"rlModalActions",children:[(0,a.jsx)("button",{type:"button",className:"rlBtn",disabled:p,onClick:()=>{f(!1),w({...y,token:""})},children:e("actions.cancel")}),(0,a.jsx)("button",{type:"button",className:"rlBtn pri",onClick:$,disabled:p||!y.slug.trim()||!y.server_url.trim()||"none"!==y.auth_type&&!y.token&&(!u||u.auth_type!==y.auth_type)||"api_key_header"===y.auth_type&&!!y.token&&!y.header.trim(),children:u?l("save"):e("settingsUi.mcpCommand.addDiscover")})]})]})})]})}function ee(){let{t:e}=(0,N.useTranslation)(),{t:s}=(0,N.useTranslation)("workspaceSettings"),t=V().has("mcp.tools.manage"),[i,n]=(0,o.useState)(!0),[l,m]=(0,o.useState)(!1),[p,h]=(0,o.useState)([]),[x,g]=(0,o.useState)(!1),b=(0,o.useCallback)(async()=>{n(!0),m(!1);try{h(await W("/api/v1/mcp/catalog?entry_type=tool"))}catch{m(!0)}finally{n(!1)}},[]);(0,o.useEffect)(()=>{b()},[b]);let j=async(s,t)=>{if(!x){g(!0);try{await (0,d.apiFetch)(`/api/v1/mcp/entries/${s}`,{method:"PATCH",body:JSON.stringify(t)}),b(),window.dispatchEvent(new Event("palette:mcp-change"))}catch(s){c.toast.error(s instanceof Error?s.message:e("workspaceSettings:saveFailed"))}finally{g(!1)}}};return l?(0,a.jsxs)("div",{className:"rlEmpty",role:"alert",children:[e("workspaceSettings:loadFailed"),(0,a.jsx)("button",{className:"rlBtn",onClick:()=>void b(),children:e("workspaceSettings:retry")})]}):i?(0,a.jsx)(r.PaletteLoader,{label:e("workspaceSettings:loading")}):(0,a.jsx)("div",{className:"rlStack",children:(0,a.jsxs)(C,{title:e("settingsUi.mcpCommand.toolCatalog"),count:`${p.length}`,children:[0===p.length&&(0,a.jsx)("div",{className:"rlEmpty",children:e("settingsUi.mcpCommand.noToolsCatalogYet")}),p.map(e=>(0,a.jsxs)("div",{className:"rlListRow",children:[(0,a.jsx)("span",{className:"rlListMeta",style:{color:"var(--rl-ink)"},children:e.name}),(0,a.jsx)("span",{className:"rlTag",children:e.source.toUpperCase()}),e.description&&(0,a.jsx)("span",{className:"rlListMeta",children:e.description}),(0,a.jsx)("button",{type:"button",disabled:x||!t,"aria-pressed":e.enabled,className:(0,u.cn)("rlChip","sm",e.enabled&&"on"),onClick:()=>j(e.id,{enabled:!e.enabled}),children:s(e.enabled?"mcp.enabled":"mcp.disabled")}),(0,a.jsx)("button",{type:"button",disabled:x,"aria-pressed":e.expose_external,className:(0,u.cn)("rlChip","sm",e.expose_external&&"on"),onClick:()=>j(e.id,{expose_external:!e.expose_external}),children:e.expose_external?"EXPOSED":"INTERNAL"})]},e.id)),(0,a.jsx)("div",{className:"rlHint",children:"Discovered connector tools and app-provided MCP tools. “Exposed” tools are visible to external MCP clients through the gateway."})]})})}function es(){let{t:e}=(0,N.useTranslation)(),{t:s}=(0,N.useTranslation)("workspaceSettings"),[t,i]=(0,o.useState)(null),n=V().has("mcp.tokens.manage"),[l,m]=(0,o.useState)(!0),[p,h]=(0,o.useState)(!1),[x,g]=(0,o.useState)([]),[b,j]=(0,o.useState)(!1),[v,f]=(0,o.useState)(""),[y,w]=(0,o.useState)(["mcp:tasks.read"]),[S,k]=(0,o.useState)(null),[_,E]=(0,o.useState)(!1),T=(0,o.useCallback)(async()=>{m(!0),h(!1);try{g(await W("/api/v1/mcp/tokens"))}catch{h(!0)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{T()},[T]);let U=async()=>
1{if(!_){E(!0);try{let e=await (0,d.apiFetch)("/api/v1/mcp/tokens",{method:"POST",body:JSON.stringify({name:v.trim(),scopes:y})});e.ok&&(k((await e.json()).token),f(""),T())}catch(s){c.toast.error(s instanceof Error?s.message:e("workspaceSettings:saveFailed"))}finally{E(!1)}}},M=async s=>{if(!_){i(null),E(!0);try{await (0,d.apiFetch)(`/api/v1/mcp/tokens/${s.id}`,{method:"DELETE"}),T()}catch(s){c.toast.error(s instanceof Error?s.message:e("workspaceSettings:saveFailed"))}finally{E(!1)}}},A=x.filter(e=>!e.revoked);return p?(0,a.jsxs)("div",{className:"rlEmpty",role:"alert",children:[e("workspaceSettings:loadFailed"),(0,a.jsx)("button",{className:"rlBtn",onClick:()=>void T(),children:e("workspaceSettings:retry")})]}):l?(0,a.jsx)(r.PaletteLoader,{label:e("workspaceSettings:loading")}):(0,a.jsxs)("div",{className:"rlStack",children:[(0,a.jsxs)(C,{title:e("settingsUi.mcpCommand.tokens"),count:`${A.length} LIVE \xb7 ${x.length} TOTAL`,actions:(0,a.jsxs)("button",{type:"button",className:"rlBtn pri",disabled:!n,onClick:()=>{k(null),j(!0)},children:["+ ",e("settingsUi.mcpCommand.newToken")]}),children:[0===x.length&&(0,a.jsx)("div",{className:"rlEmpty",children:(0,a.jsx)("span",{className:"rlEmptyLead",children:s("mcp.noTokens")})}),x.map(t=>(0,a.jsxs)("div",{className:"rlListRow",style:{opacity:t.revoked?.55:1},children:[(0,a.jsx)("span",{style:{width:7,height:7,flex:"none",borderRadius:"50%",background:t.revoked?"var(--rl-border-strong)":"var(--rl-ok)",animation:t.revoked?void 0:"rlPulse 2s infinite"}}),(0,a.jsx)("span",{className:"rlListName",children:t.name}),t.revoked&&(0,a.jsx)(J,{status:"revoked"}),(0,a.jsxs)("span",{className:"rlListMeta",children:[(0,a.jsxs)("span",{className:"wsPlain",children:["pmcp_",t.token_prefix,"…"]})," · ",t.scopes.join(" · ")," · ",s("mcp.created")," ",$(t.created_at)," · ",s("publishing.expires")," ",$(t.expires_at),t.last_used_at?` \xb7 ${s("publishing.lastUsed")} ${$(t.last_used_at)}`:""]}),!t.revoked&&(0,a.jsx)("button",{type:"button",className:"rlBtn sm dan",disabled:_||!n,onClick:()=>i(t),children:e("developer.revoke")})]},t.id)),(0,a.jsx)("div",{className:"rlHint",children:e("settingsUi.mcpCommand.scopesAreDefaultDenyToken")})]}),t&&(0,a.jsx)(P,{title:s("mcp.revokeTitle"),onClose:()=>i(null),children:(0,a.jsxs)("div",{className:"rlModalBody",children:[(0,a.jsxs)("div",{className:"wsPermSummary",children:[(0,a.jsx)("strong",{children:t.name}),(0,a.jsxs)("span",{className:"rlRowN",children:["pmcp_",t.token_prefix,"…"]})]}),(0,a.jsx)("p",{className:"rlNote",children:s("mcp.revokeConfirm",{name:t.name})}),(0,a.jsxs)("div",{className:"rlModalActions",children:[(0,a.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>i(null),children:s("cancel")}),(0,a.jsx)("button",{type:"button",className:"rlBtn danFill",disabled:_,onClick:()=>void M(t),children:e("developer.revoke")})]})]})}),b&&(0,a.jsx)(P,{title:e("settingsUi.mcpCommand.mintMcpToken"),onClose:()=>{_||(j(!1),k(null))},children:(0,a.jsxs)("div",{className:"rlModalBody",children:[S?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"rlErr",children:e("settingsUi.mcpCommand.copyTokenNowYouWon")}),(0,a.jsx)(B,{token:S})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"rlNote",children:e("settingsUi.mcpCommand.scopesAreDefaultDenyToken")}),(0,a.jsxs)("div",{children:[(0,a.jsx)(Y,{children:e("datasets.measures.name")}),(0,a.jsx)("input",{className:"rlInput",style:{width:"100%"},placeholder:e("settingsUi.mcpCommand.claudeDesktop"),"aria-label":e("workspaceSettings:name"),value:v,autoFocus:!0,onChange:e=>f(e.target.value)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(Y,{children:e("settingsUi.mcpCommand.scopes")}),(0,a.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:q.map(e=>{let s=y.includes(e);return(0,a.jsx)("button",{type:"button","aria-pressed":s,className:(0,u.cn)("rlChip","sm",s&&"on"),onClick:()=>w(s?y.filter(s=>s!==e):[...y,e]),children:e.replace("mcp:","")},e)})})]})]}),(0,a.jsxs)("div",{className:"rlModalActions",children:[(0,a.jsx)("button",{type:"button",className:"rlBtn",disabled:_,onClick:()=>{j(!1),k(null)},children:e("actions.close")}),!S&&(0,a.jsx)("button",{type:"button",className:"rlBtn pri",onClick:U,disabled:_||!v.trim()||0===y.length,children:e("settingsUi.mcpCommand.mint")})]})]})})]})}function et(){let e,s,t,i,n,c,d,u,m,p,h,x,g,b,j,v,f,y,w=(0,l.c)(61),{t:S}=(0,N.useTranslation)(),{t:k}=(0,N.useTranslation)("workspaceSettings"),[_,E]=(0,o.useState)(!0),[P,U]=(0,o.useState)(!1);w[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],w[0]=e):e=w[0];let[M,B]=(0,o.useState)(e),[$,A]=(0,o.useState)("");w[1]!==$?(s=async()=>{E(!0),U(!1);let e=$?`?direction=${$}`:"";await W(`/api/v1/mcp/audit${e}`).then(B).catch(()=>U(!0)).finally(()=>E(!1))},w[1]=$,w[2]=s):s=w[2];let L=s;if(w[3]!==L?(t=()=>{L()},i=[L],w[3]=L,w[4]=t,w[5]=i):(t=w[4],i=w[5]),(0,o.useEffect)(t,i),P){let e,s,t,i,n;return w[6]!==S?(e=S("workspaceSettings:loadFailed"),w[6]=S,w[7]=e):e=w[7],w[8]!==L?(s=()=>void L(),w[8]=L,w[9]=s):s=w[9],w[10]!==S?(t=S("workspaceSettings:retry"),w[10]=S,w[11]=t):t=w[11],w[12]!==s||w[13]!==t?(i=(0,a.jsx)("button",{className:"rlBtn",onClick:s,children:t}),w[12]=s,w[13]=t,w[14]=i):i=w[14],w[15]!==e||w[16]!==i?(n=(0,a.jsxs)("div",{className:"rlEmpty",role:"alert",children:[e,i]}),w[15]=e,w[16]=i,w[17]=n):n=w[17],n}if(_){let e,s;return w[18]!==S?(e=S("workspaceSettings:loading"),w[18]=S,w[19]=e):e=w[19],w[20]!==e?(s=(0,a.jsx)(r.PaletteLoader,{label:e}),w[20]=e,w[21]=s):s=w[21],s}w[22]!==S?(n=S("settingsUi.mcpCommand.auditTrail"),w[22]=S,w[23]=n):n=w[23];let R=`${M.length}`;if(w[24]===Symbol.for("react.memo_cache_sentinel")?(c={id:"",label:"ALL"},w[24]=c):c=w[24],w[25]!==k?(d=k("mcp.inbound"),w[25]=k,w[26]=d):d=w[26],w[27]!==d?(u={id:"inbound",label:d},w[27]=d,w[28]=u):u=w[28],w[29]!==k?(m=k("mcp.outbound"),w[29]=k,w[30]=m):m=w[30],w[31]!==m?(p={id:"outbound",label:m},w[31]=m,w[32]=p):p=w[32],w[33]!==p||w[34]!==u?(h=[c,u,p],w[33]=p,w[34]=u,w[35]=h):h=w[35],w[36]!==S?(x=S("settingsUi.mcpCommand.direction"),w[36]=S,w[37]=x):x=w[37],w[38]!==$||w[39]!==h||w[40]!==x?(g=(0,a.jsx)(T,{options:h,value:$,onChange:A,ariaLabel:x}),w[38]=$,w[39]=h,w[40]=x,w[41]=g):g=w[41],w[42]!==M.length||w[43]!==S?(b=0===M.length&&(0,a.jsx)("div",{className:"rlEmpty",children:S("settingsUi.mcpCommand.noMcpActivityYet")}),w[42]=M.length,w[43]=S,w[44]=b):b=w[44],w[45]!==M||w[46]!==k){let e;w[48]!==k?(e=e=>(0,a.jsxs)("div",{className:"rlListRow",style:{minHeight:36,padding:"6px 14px"},children:[(0,a.jsx)(J,{status:e.status}),(0,a.jsx)("span",{className:"rlListMeta",style:{color:"var(--rl-ink)"},children:e.target}),(0,a.jsx)("span",{className:"rlTag",children:k("inbound"===e.direction?"mcp.inbound":"mcp.outbound")}),e.channel&&(0,a.jsx)("span",{className:"rlTag",children:e.channel.toUpperCase()}),(0,a.jsxs)("span",{className:"rlRowN",style:{flex:"none"},children:[null!=e.latency_ms?`${e.latency_ms}
1ms \xb7 `:"",new Date(e.occurred_at).toLocaleString()]})]},e.id),w[48]=k,w[49]=e):e=w[49],j=M.map(e),w[45]=M,w[46]=k,w[47]=j}else j=w[47];return w[50]!==S?(v=S("settingsUi.mcpCommand.everyMcpToolCallPayload"),w[50]=S,w[51]=v):v=w[51],w[52]!==v?(f=(0,a.jsx)("div",{className:"rlHint",children:v}),w[52]=v,w[53]=f):f=w[53],w[54]!==g||w[55]!==b||w[56]!==j||w[57]!==f||w[58]!==n||w[59]!==R?(y=(0,a.jsx)("div",{className:"rlStack",children:(0,a.jsxs)(C,{title:n,count:R,actions:g,children:[b,j,f]})}),w[54]=g,w[55]=b,w[56]=j,w[57]=f,w[58]=n,w[59]=R,w[60]=y):y=w[60],y}function ei(e){return["error","failed","denied"].includes(e.status)}function en(e){return e.enabled}e.s(["McpCommandCenter",0,function(){let e,s,t,i,n,r,c,d,u,m,p,h,x=(0,l.c)(27),{t:g}=(0,N.useTranslation)("workspaceSettings"),[b,j]=(0,o.useState)("connections");x[0]===Symbol.for("react.memo_cache_sentinel")?(e=["—","—","—","—","—"],x[0]=e):e=x[0];let[v,f]=(0,o.useState)(e);x[1]!==g?(s=()=>{let e=!1,s=async()=>{let s=await Promise.allSettled([W("/api/v1/mcp/connectors"),W("/api/v1/mcp/catalog?entry_type=tool"),W("/api/v1/mcp/settings"),W("/api/v1/mcp/approvals?status=pending"),W("/api/v1/mcp/audit")]);e||f(s.map((e,s)=>"rejected"===e.status?"—":2===s?g(e.value.external_paused?"mcp.paused":"models.active"):1===s?e.value.filter(en).length:4===s?e.value.filter(ei).length:e.value.length))};return s(),window.addEventListener("palette:mcp-change",s),()=>{e=!0,window.removeEventListener("palette:mcp-change",s)}},x[1]=g,x[2]=s):s=x[2],x[3]!==g||x[4]!==b?(t=[b,g],x[3]=g,x[4]=b,x[5]=t):t=x[5],(0,o.useEffect)(s,t),x[6]===Symbol.for("react.memo_cache_sentinel")?(i=["connections","tools","external","approvals","failures"],x[6]=i):i=x[6];let y=i;return x[7]===Symbol.for("react.memo_cache_sentinel")?(n={gridTemplateColumns:"repeat(5, minmax(0, 1fr))"},x[7]=n):n=x[7],x[8]!==v||x[9]!==g?(r=(0,a.jsx)("div",{className:"rlTiles",style:n,children:y.map((e,s)=>(0,a.jsxs)("div",{className:"rlTile",children:[(0,a.jsx)("span",{className:"rlTileK",children:g(`mcp.${e}`)}),(0,a.jsx)("div",{className:"rlTileV",children:v[s]})]},e))}),x[8]=v,x[9]=g,x[10]=r):r=x[10],x[11]===Symbol.for("react.memo_cache_sentinel")?(c=["connections","external","activity"],x[11]=c):c=x[11],x[12]!==g||x[13]!==b?(d=(0,a.jsx)("div",{className:"wsTabRow",children:(0,a.jsx)("div",{className:"wsActions",children:c.map(e=>(0,a.jsx)("button",{className:`rlBtn ${b===e?"pri":""}`,"aria-pressed":b===e,onClick:()=>j(e),children:g(`mcp.${e}`)},e))})}),x[12]=g,x[13]=b,x[14]=d):d=x[14],x[15]!==b?(u="connections"===b&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Z,{}),(0,a.jsx)(ee,{})]}),x[15]=b,x[16]=u):u=x[16],x[17]!==b?(m="external"===b&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Q,{}),(0,a.jsx)(es,{})]}),x[17]=b,x[18]=m):m=x[18],x[19]!==b?(p="activity"===b&&(0,a.jsx)(et,{}),x[19]=b,x[20]=p):p=x[20],x[21]!==p||x[22]!==r||x[23]!==d||x[24]!==u||x[25]!==m?(h=(0,a.jsxs)("div",{className:"rlStack",children:[r,d,u,m,p]}),x[21]=p,x[22]=r,x[23]=d,x[24]=u,x[25]=m,x[26]=h):h=x[26],h}],144966);var ea=e.i(815330),el=e.i(331991),er=e.i(813610),eo=e.i(315865),ec=e.i(553011),ed=e.i(146212),eu=e.i(209881),em=e.i(487486),ep=e.i(519455),eh=e.i(515288),ex=e.i(776639),eg=e.i(793479),eb=e.i(699375),ej=e.i(30728),ev=e.i(529682);let ef=["google","slack","telegram","notion","meta"],ey={google:er.GoogleLogo,slack:ed.SlackLogo,telegram:eu.TelegramLogo,notion:function(e){let s,t,i=(0,l.c)(3),{size:n}=e,r=void 0===n?24:n;return i[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)("path",{d:"M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466l1.823 1.447zm.793 3.08v
113.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.98.327-.98.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952l1.448.327s0 .84-1.168.84l-3.222.186c-.093-.187 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933l3.222-.187z"}),i[0]=s):s=i[0],i[1]!==r?(t=(0,a.jsx)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s}),i[1]=r,i[2]=t):t=i[2],t},meta:eo.MetaLogo};function ew(e){let s,t,i=(0,l.c)(15),{tools:n,canToggle:r,busy:o,onToggleTool:c}=e,{t:d}=(0,N.useTranslation)();if(0===n.length){let e,s;return i[0]!==d?(e=d("settingsUi.serviceConnections.noToolsDeclaredProvider"),i[0]=d,i[1]=e):e=i[1],i[2]!==e?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e}),i[2]=e,i[3]=s):s=i[3],s}if(i[4]!==o||i[5]!==r||i[6]!==c||i[7]!==n){let e;i[9]!==o||i[10]!==r||i[11]!==c?(e=e=>(0,a.jsxs)("div",{className:(0,u.cn)("rounded-md border bg-background p-2.5",(!e.scope_granted||!e.enabled)&&"opacity-50"),children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs font-medium",children:e.name}),e.mutating&&(0,a.jsx)(em.Badge,{variant:"outline",className:"border-amber-300 text-amber-800 dark:border-amber-800 dark:text-amber-200",children:"write"}),!e.scope_granted&&(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"scope not granted"}),r?(0,a.jsx)(eb.Switch,{checked:e.enabled,disabled:o,onCheckedChange:s=>c(e.name,s),"aria-label":`Enable ${e.name}`}):e.enabled?null:(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"disabled"})]}),(0,a.jsx)("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description})]},e.name),i[9]=o,i[10]=r,i[11]=c,i[12]=e):e=i[12],s=n.map(e),i[4]=o,i[5]=r,i[6]=c,i[7]=n,i[8]=s}else s=i[8];return i[13]!==s?(t=(0,a.jsx)("div",{className:"space-y-1.5",children:s}),i[13]=s,i[14]=t):t=i[14],t}function eN(e){let s,t,i,n,r,c,d,m,p,h,x,g,b,j,v,f,y,w,S,k,_,C,E,T,P=(0,l.c)(96),{connection:U,busy:M,actionError:B,testResult:$,onConnect:A,onConnectToken:L,onTest:R,onDisconnect:F,onToggleTool:O,onToggleWrites:I}=e,{t:D}=(0,N.useTranslation)(),[H,z]=(0,o.useState)(!1),[V,q]=(0,o.useState)(""),W=(0,ej.useIsOwnerOrAdmin)(),G=ey[U.icon]??ec.Plugs,K="connected"===U.status,J=K||"error"===U.status||"expired"===U.status,Y="coming_soon"===U.status,X="bot_token"===U.auth_type,Q=null!==M,Z=W&&J,ee=Y&&"opacity-70";P[0]!==ee?(s=(0,u.cn)(ee),P[0]=ee,P[1]=s):s=P[1],P[2]!==G?(t=(0,a.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg border bg-muted/40",children:(0,a.jsx)(G,{size:22,weight:"fill"})}),P[2]=G,P[3]=t):t=P[3];let es=U.display_name;if(P[4]!==U.status){var et;et=U.status,i=(0,a.jsx)(em.Badge,{variant:"connected"===et?"default":"error"===et||"expired"===et?"destructive":"secondary",children:"coming_soon"===et?"coming soon":et}),P[4]=U.status,P[5]=i}else i=P[5];P[6]!==U.display_name||P[7]!==i?(n=(0,a.jsxs)(eh.CardTitle,{className:"flex flex-wrap items-center gap-2 text-base",children:[es," ",i]}),P[6]=U.display_name,P[7]=i,P[8]=n):n=P[8],P[9]!==Y||P[10]!==K||P[11]!==U.account_label||P[12]!==J||P[13]!==D?(r=K&&U.account_label?U.account_label:Y?"Not available yet":K?"Connected":J?U.account_label??D("settingsUi.connections.needsAttention","Connection needs attention"):"Not connected",P[9]=Y,P[10]=K,P[11]=U.account_label,P[12]=J,P[13]=D,P[14]=r):r=P[14],P[15]!==r?(c=(0,a.jsx)(eh.CardDescription,{className:"mt-0.5",children:r}),P[15]=r,P[16]=c):c=P[16],P[17]!==n||P[18]!==c?(d=(0,a.jsxs)("div",{className:"min-w-0",children:[n,c]}),P[17]=n,P[18]=c,P[19]=d):d=P[19],P[20]!==t||P[21]!==d?(m=(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[t,d]}),P[20]=t,P[21]=d,P[22]=m):m=P[22],P[23]!==M||P[24]!==Y||P[25]!==K||P[26]!==J||P[27]!==Q||P[28]!==X||P[29]!==A||P[30]!==F||P[31]!==R||P[32]!==D?(p=!Y&&(0,a.jsxs)("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[!K&&!X&&(0,a.jsx)(ep.Button,{size:"sm",disabled:Q,onClick:A,children:"connect"===M?"Redirecting...":J?"Reconnect":"Connect"}),J&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ep.Button,{size:"sm",variant:"outline",disabled:Q,onClick:R,children:"test"===M?"Testing...":"Test"}),(0,a.jsx)(ep.Button,{size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",disabled:Q,onClick:F,children:D("messages:builder.config.services.disconnect")})]})]}),P[23]=M,P[24]=Y,P[25]=K,P[26]=J,P[27]=Q,P[28]=X,P[29]=A,P[30]=F,P[31]=R,P[32]=D,P[33]=p):p=P[33],P[34]!==Y||P[35]!==D?(h=Y&&(0,a.jsx)(ep.Button,{size:"sm",variant:"outline",disabled:!0,children:D("settingsUi.serviceConnections.comingSoon")}),P[34]=Y,P[35]=D,P[36]=h):h=P[36],P[37]!==m||P[38]!==p||P[39]!==h?(x=(0,a.jsxs)(eh.CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-3",children:[m,p,h]}),P[37]=m,P[38]=p,P[39]=h,P[40]=x):x=P[40],P[41]!==V||P[42]!==M||P[43]!==Y||P[44]!==K||P[45]!==Q||P[46]!==X||P[47]!==L||P[48]!==D?(g=X&&!K&&!Y&&(0,a.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),V.trim()&&(L(V.trim()),q(""))},children:[(0,a.jsx)(eg.Input,{value:V,onChange:e=>q(e.target.value),type:"password",placeholder:D("settingsUi.serviceConnections.botTokenFromBotfather"),className:"h-8 max-w-sm font-mono text-xs"}),(0,a.jsx)(ep.Button,{size:"sm",type:"submit",disabled:Q||!V.trim(),children:"connect"===M?"Connecting...":"Connect"})]}),P[41]=V,P[42]=M,P[43]=Y,P[44]=K,P[45]=Q,P[46]=X,P[47]=L,P[48]=D,P[49]=g):g=P[49],P[50]!==U.connected_at||P[51]!==U.connected_by_name||P[52]!==U.granted_scopes||P[53]!==J?(b=J&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[U.granted_scopes.length," scope",1===U.granted_scopes.length?"":"s"," granted",U.connected_by_name?` \xb7 connected by ${U.connected_by_name}`:"",U.connected_at?` \xb7 ${new Date(U.connected_at).toLocaleStr
1ing()}`:""]}),P[50]=U.connected_at,P[51]=U.connected_by_name,P[52]=U.granted_scopes,P[53]=J,P[54]=b):b=P[54],P[55]!==U.last_error?(j=U.last_error&&(0,a.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:U.last_error}),P[55]=U.last_error,P[56]=j):j=P[56],P[57]!==$?(v=$&&(0,a.jsx)("p",{className:(0,u.cn)("text-xs",$.ok?"text-emerald-700 dark:text-emerald-300":"text-destructive"),children:$.ok?`Test passed${$.account_label?` \xb7 ${$.account_label}`:""} \xb7 ${new Date($.checked_at).toLocaleTimeString()}`:"Test failed — check the connection or reconnect."}),P[57]=$,P[58]=v):v=P[58],P[59]!==B?(f=B&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:B}),P[59]=B,P[60]=f):f=P[60],P[61]===Symbol.for("react.memo_cache_sentinel")?(y=()=>z(ek),P[61]=y):y=P[61],P[62]!==H?(w=H?(0,a.jsx)(el.CaretUp,{size:13}):(0,a.jsx)(ea.CaretDown,{size:13}),P[62]=H,P[63]=w):w=P[63];let ei=1===U.tools.length?"":"s";return P[64]!==U.tools.length||P[65]!==w||P[66]!==ei?(S=(0,a.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",onClick:y,children:[w,U.tools.length," tool",ei]}),P[64]=U.tools.length,P[65]=w,P[66]=ei,P[67]=S):S=P[67],P[68]!==Z||P[69]!==U.allow_mutating_tools||P[70]!==U.tools||P[71]!==Q||P[72]!==I||P[73]!==D?(k=Z&&U.tools.some(eS)&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[D("messages:builder.config.services.allowWrites"),(0,a.jsx)(eb.Switch,{checked:U.allow_mutating_tools,disabled:Q,onCheckedChange:I})]}),P[68]=Z,P[69]=U.allow_mutating_tools,P[70]=U.tools,P[71]=Q,P[72]=I,P[73]=D,P[74]=k):k=P[74],P[75]!==S||P[76]!==k?(_=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[S,k]}),P[75]=S,P[76]=k,P[77]=_):_=P[77],P[78]!==Z||P[79]!==U.tools||P[80]!==Q||P[81]!==O||P[82]!==H?(C=H&&(0,a.jsx)(ew,{tools:U.tools,canToggle:Z,busy:Q,onToggleTool:O}),P[78]=Z,P[79]=U.tools,P[80]=Q,P[81]=O,P[82]=H,P[83]=C):C=P[83],P[84]!==g||P[85]!==b||P[86]!==j||P[87]!==v||P[88]!==f||P[89]!==_||P[90]!==C?(E=(0,a.jsxs)(eh.CardContent,{className:"space-y-3 pt-0",children:[g,b,j,v,f,_,C]}),P[84]=g,P[85]=b,P[86]=j,P[87]=v,P[88]=f,P[89]=_,P[90]=C,P[91]=E):E=P[91],P[92]!==x||P[93]!==s||P[94]!==E?(T=(0,a.jsxs)(eh.Card,{className:s,children:[x,E]}),P[92]=x,P[93]=s,P[94]=E,P[95]=T):T=P[95],T}function eS(e){return e.mutating}function ek(e){return!e}e.s(["ServiceConnections",0,function(){let{t:e}=(0,N.useTranslation)(),{connections:s,loading:t,error:i,refetch:n,connect:l,disconnect:r,test:c,connectWithToken:d,updateToolSettings:m}=(0,ev.useServiceConnections)(),[p,h]=(0,o.useState)([]),[x,g]=(0,o.useState)(null),[b,j]=(0,o.useState)({}),[v,f]=(0,o.useState)({}),[y,w]=(0,o.useState)(null);function S(e,s){j(t=>{let i={...t};return s?i[e]=s:delete i[e],i})}async function k(s){g({provider:s,action:"connect"}),S(s,null);try{await l(s)}catch(t){S(s,t instanceof Error?t.message:e("settingsUi.connections.startFailed","Unable to start connect")),g(null)}}async function _(s,t){g({provider:s,action:"connect"}),S(s,null);try{await d(s,t)}catch(t){S(s,t instanceof Error?t.message:e("settingsUi.connections.connectFailed","Unable to connect"))}finally{g(null)}}async function C(s,t){g({provider:s,action:"tools"}),S(s,null);try{await m(s,t)}catch(t){S(s,t instanceof Error?t.message:e("settingsUi.connections.updateToolsFailed","Unable to update tools"))}finally{g(null)}}async function E(s){g({provider:s,action:"test"}),S(s,null);try{let e=await c(s);f(t=>({...t,[s]:e}))}catch(t){S(s,t instanceof Error?t.message:e("settingsUi.connections.testFailed","Test failed"))}finally{g(null)}}async function T(){if(!y)return;let s=y.provider;g({provider:s,action:"disconnect"}),S(s,null);try{await r(s),f(e=>{let t={...e};return delete t[s],t}),w(null)}catch(t){S(s,t instanceof Error?t.message:e("settingsUi.connections.disconnectFailed","Unable to disconnect")),w(null)}finally{g(null)}}return(0,o.useEffect)(()=>{let e=new URL(window.location.href),s=[];for(let t of ef){let i=e.searchParams.get(t);("connected"===i||"denied"===i||"error"===i)&&(s.push({provider:t,outcome:i}),e.searchParams.delete(t))}0!==s.length&&(h(s),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`),n())},[n]),(0,a.jsxs)("div",{className:"space-y-4",children:[p.map(e=>{var t,i,n;let l;return(0,a.jsx)("div",{className:(0,u.cn)("rounded-md border px-3 py-2 text-sm","connected"===(t=e.outcome)?"border-emerald-300 bg-emerald-50 text-emerald-900 dark:border-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-100":"error"===t?"border-destructive/40 bg-destructive/10 text-destructive":"border-border bg-muted/40 text-muted-foreground"),children:(l=e.provider,i=s.find(e=>e.provider===l)?.display_name??l,"connected"===(n=e.outcome)?`${i} connected successfully.`:"denied"===n?`${i} authorisation was cancelled — nothing was connected.`:`${i} connection failed. Try again or check the provider configuration.`)},e.provider)}),(0,a.jsx)(eh.Card,{children:(0,a.jsxs)(eh.CardHeader,{children:[(0,a.jsx)(eh.CardTitle,{className:"text-base",children:e("settingsUi.serviceConnections.serviceConnections")}),(0,a.jsx)(eh.CardDescription,{children:"Connect your external service accounts for this organisation. Your agents and loops use these connections to call provider tools — tokens never leave the backend."})]})}),t&&(0,a.jsx)(eh.Card,{children:(0,a.jsx)(eh.CardContent,{className:"py-8 text-center text-sm text-muted-foreground",children:e("appStore:ui.loadingConnections")})}),!t&&i&&(0,a.jsx)(eh.Card,{children:(0,a.jsx)(eh.CardContent,{className:"py-8 text-center text-sm text-destructive",children:i})}),!t&&!i&&0===s.length&&(0,a.jsx)(eh.Card,{children:(0,a.jsx)(eh.CardContent,{className:"py-8 text-center text-sm text-muted-foreground",children:e("settingsUi.serviceConnections.noServiceProvidersAreConfigured")})}),s.map(e=>
1(0,a.jsx)(eN,{connection:e,busy:x?.provider===e.provider?x.action:null,actionError:b[e.provider],testResult:v[e.provider],onConnect:()=>void k(e.provider),onConnectToken:s=>void _(e.provider,s),onTest:()=>void E(e.provider),onDisconnect:()=>w(e),onToggleTool:(s,t)=>{let i=new Set(e.tools.filter(e=>!e.enabled).map(e=>e.name));t?i.delete(s):i.add(s),C(e.provider,{disabled_tools:[...i]})},onToggleWrites:s=>void C(e.provider,{allow_mutating_tools:s})},e.provider)),(0,a.jsx)(ex.Dialog,{open:!!y,onOpenChange:e=>{e||x?.action==="disconnect"||w(null)},children:(0,a.jsxs)(ex.DialogContent,{className:"sm:max-w-md",children:[(0,a.jsxs)(ex.DialogHeader,{children:[(0,a.jsxs)(ex.DialogTitle,{children:["Disconnect ",y?.display_name]}),(0,a.jsxs)(ex.DialogDescription,{children:["Agents and loops will immediately lose access to"," ",y?.display_name??"this service"," tools for your account in this organisation. You can reconnect at any time."]})]}),y?.account_label&&(0,a.jsxs)("p",{className:"rounded-md border bg-muted/40 px-3 py-2 text-sm",children:[e("settingsUi.serviceConnections.connectedAccount")," ",(0,a.jsx)("span",{className:"font-medium",children:y.account_label})]}),(0,a.jsxs)(ex.DialogFooter,{children:[(0,a.jsx)(ep.Button,{variant:"outline",disabled:x?.action==="disconnect",onClick:()=>w(null),children:e("actions.cancel")}),(0,a.jsx)(ep.Button,{variant:"destructive",disabled:x?.action==="disconnect",onClick:()=>void T(),children:x?.action==="disconnect"?"Disconnecting...":"Disconnect"})]})]})})]})}],443961);let e_={billing:{title:"SUBSCRIPTION & BILLING",sub:"View your current plan and usage, and manage your subscription."},workspace:{title:"WORKSPACE",sub:"Manage the basic settings of the current workspace."},notifications:{title:"NOTIFICATIONS",sub:"Configure notifications for key workspace events."},security:{title:"SECURITY",sub:"Manage workspace login, session, and access security policies."},publishing:{title:"PUBLISHING",sub:"Manage publishing credentials for your apps."},storage:{title:"STORAGE",sub:"Review stored data and export your workspace."},profile:{title:"PROFILE",sub:"Your account · name · contact"},org:{title:"WORKSPACE",sub:"Select · registry · switch"},members:{title:"MEMBERS",sub:"Invite · roles · search"},teams:{title:"TEAMS",sub:"Create teams · assign members"},perm:{title:"PERMISSIONS",sub:"Permissions by role"},lang:{title:"LANGUAGE",sub:"Interface language — bilingual doctrine"},models:{title:"MODELS",sub:"Bring your own LLM · keys · local runtimes"},general:{title:"GENERAL",sub:"Notifications · secure"},mcp:{title:"MCP",sub:"External servers · access tokens"},dev:{title:"DEVELOPER",sub:"Publish tokens"},data:{title:"DATA & STORAGE",sub:"Storage · export · tokens"},apps:{title:"APPS",sub:"Installed apps · permissions"},connect:{title:"CONNECT",sub:"Connector status — live"},about:{title:"ABOUT",sub:"Version · runtime · account"}},eC={profile:"workspace",org:"workspace",general:"notifications",dev:"publishing",data:"storage",organisation:"workspace",ws:"workspace",desktop:"apps",noti:"notifications",language:"lang",model:"models",llm:"models",connections:"connect",developer:"publishing",account:"profile",global:"about",permissions:"perm"};e.s(["NAV_GROUPS",0,[{group:"WORKSPACE",items:[{id:"workspace",label:"Workspace"},{id:"billing",label:"Subscription & billing"}]},{group:"MEMBER MANAGEMENT",items:[{id:"members",label:"Members"},{id:"teams",label:"Teams"},{id:"perm",label:"Permissions"}]},{group:"ENVIRONMENT",items:[{id:"notifications",label:"Notifications"},{id:"security",label:"Security"}]},{group:"SYSTEM",items:[{id:"models",label:"Models"},{id:"mcp",label:"MCP"},{id:"publishing",label:"Publishing"},{id:"storage",label:"Storage"}]}],"SECTION_CAPABILITIES",0,{billing:["billing.subscription.view"],members:["members.view"],teams:["teams.view"],perm:["permissions.view","permissions.member-role.manage","permissions.team.manage","permissions.user.manage"],notifications:["notifications.workspace.view"],security:["security.workspace.view"],mcp:["mcp.settings.view"],publishing:["developer.tokens.view"],dev:["developer.tokens.view"],storage:["storage.view"],data:["storage.view"]},"SECTION_META",0,e_,"SECTION_STORAGE_KEY",0,"palette:settings-active-section","resolveSection",0,function(e){return e?eC[e]?eC[e]:Object.prototype.hasOwnProperty.call(e_,e??"")?e:null:null}],426971);var eE=e.i(247167),eT=e.i(363178),eP=e.i(435191);let eU=eE.default.env.NEXT_PUBLIC_PALETTE_OS_VERSION??eP.default.version;function eM(e){return(0,a.jsxs)("div",{className:"rlTile",children:[(0,a.jsx)("div",{className:"rlTileK",children:e.k}),(0,a.jsx)("div",{className:"rlTileV",style:{fontSize:18},children:e.v})]},e.k)}e.s(["AboutSection",0,function(){let e,s,t,i,n,r,c,u,m,p,h,x,g,b,j,v,f,y,w,S,k,_,T,P,U,M,B,$,A,L,R,F,O,I,D,H,V,q,W,G,K,J,Y,X,Q,Z,ee,es,et,ei,en,ea,el,er,eo,ec,ed,eu,em,ep,eh,ex,eg,eb,ej=(0,l.c)(149),{t:ev}=(0,N.useTranslation)(),{user:ef,orgs:ey}=(0,z.useAuth)(),{theme:ew}=(0,eT.useTheme)();ej[0]===Symbol.for("react.memo_cache_sentinel")?(e={origin:"—",userAgent:"—"},ej[0]=e):e=ej[0];let[eN,eS]=(0,o.useState)(e);if(ej[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{eS({origin:window.location.origin,userAgent:window.navigator.userAgent})},t=[],ej[1]=s,ej[2]=t):(s=ej[1],t=ej[2]),(0,o.useEffect)(s,t),ef?.organization_id,ej[3]!==ey||ej[4]!==ef?.organization_id){let e;ej[6]!==ef?.organization_id?(e=e=>e.id===ef?.organization_id,ej[6]=ef?.organization_id,ej[7]=e):e=ej[7],i=ey.find(e),ej[3]=ey,ej[4]=ef?.organization_id,ej[5]=i}else i=ej[5];let ek=i,e_=ef?.preferred_theme??ef?.org_theme??"palette-os";ej[8]===Symbol.for("react.memo_cache_sentinel")?(n={k:"OS VERSION",v:`v${eU}`},ej[8]=n):n=ej[8];
1let eC=String(e_);ej[9]!==eC?(r=eC.toUpperCase(),ej[9]=eC,ej[10]=r):r=ej[10],ej[11]!==r?(c={k:"ACTIVE SHELL",v:r},ej[11]=r,ej[12]=c):c=ej[12];let eE=String(ew??"system");ej[13]!==eE?(u=eE.toUpperCase(),ej[13]=eE,ej[14]=u):u=ej[14],ej[15]!==u?(m={k:"COLOR MODE",v:u},ej[15]=u,ej[16]=m):m=ej[16],ej[17]!==m||ej[18]!==c?(p=[n,c,m],ej[17]=m,ej[18]=c,ej[19]=p):p=ej[19];let eB=p;ej[20]===Symbol.for("react.memo_cache_sentinel")?(h={gridTemplateColumns:"repeat(3, minmax(0,1fr))",marginBottom:16},ej[20]=h):h=ej[20],ej[21]!==eB?(x=(0,a.jsx)("div",{className:"rlTiles",style:h,children:eB.map(eM)}),ej[21]=eB,ej[22]=x):x=ej[22],ej[23]===Symbol.for("react.memo_cache_sentinel")?(g={display:"grid",gridTemplateColumns:"repeat(auto-fit,minmax(min(320px,100%),1fr))",gap:16,alignItems:"start"},ej[23]=g):g=ej[23],ej[24]!==ev?(b=ev("settingsUi.about.runtime"),ej[24]=ev,ej[25]=b):b=ej[25],ej[26]!==ev?(j=ev("settingsUi.about.frontend"),ej[26]=ev,ej[27]=j):j=ej[27],ej[28]===Symbol.for("react.memo_cache_sentinel")?(v={fontFamily:"var(--rl-mono)",fontSize:11},ej[28]=v):v=ej[28],ej[29]!==eN.origin?(f=(0,a.jsx)("span",{style:v,children:eN.origin}),ej[29]=eN.origin,ej[30]=f):f=ej[30],ej[31]!==j||ej[32]!==f?(y=(0,a.jsx)(E,{label:j,value:f,tight:!0}),ej[31]=j,ej[32]=f,ej[33]=y):y=ej[33],ej[34]!==ev?(w=ev("settingsUi.about.api"),ej[34]=ev,ej[35]=w):w=ej[35],ej[36]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)("span",{style:{fontFamily:"var(--rl-mono)",fontSize:11},children:d.BASE}),ej[36]=S):S=ej[36],ej[37]!==w?(k=(0,a.jsx)(E,{label:w,value:S,tight:!0}),ej[37]=w,ej[38]=k):k=ej[38],ej[39]!==ev?(_=ev("settingsUi.about.package"),ej[39]=ev,ej[40]=_):_=ej[40],ej[41]===Symbol.for("react.memo_cache_sentinel")?(T=(0,a.jsx)("span",{style:{fontFamily:"var(--rl-mono)",fontSize:11},children:`${eP.default.name} ${eP.default.version}`}),ej[41]=T):T=ej[41],ej[42]!==_?(P=(0,a.jsx)(E,{label:_,value:T,tight:!0}),ej[42]=_,ej[43]=P):P=ej[43],ej[44]!==ev?(U=ev("settingsUi.about.nextJs"),ej[44]=ev,ej[45]=U):U=ej[45],ej[46]===Symbol.for("react.memo_cache_sentinel")?(M=(0,a.jsx)("span",{style:{fontFamily:"var(--rl-mono)",fontSize:11},children:eP.default.dependencies.next}),ej[46]=M):M=ej[46],ej[47]!==U?(B=(0,a.jsx)(E,{label:U,value:M,tight:!0}),ej[47]=U,ej[48]=B):B=ej[48],ej[49]!==ev?($=ev("settingsUi.about.doc"),ej[49]=ev,ej[50]=$):$=ej[50],ej[51]===Symbol.for("react.memo_cache_sentinel")?(A={fontFamily:"var(--rl-mono)",fontSize:11},ej[51]=A):A=ej[51],ej[52]!==ev?(L=ev("settingsUi.about.rlOs208Rev1"),ej[52]=ev,ej[53]=L):L=ej[53],ej[54]!==L?(R=(0,a.jsx)("span",{style:A,children:L}),ej[54]=L,ej[55]=R):R=ej[55],ej[56]!==$||ej[57]!==R?(F=(0,a.jsx)(E,{label:$,value:R,tight:!0}),ej[56]=$,ej[57]=R,ej[58]=F):F=ej[58],ej[59]!==ev?(O=ev("settingsUi.about.browser"),ej[59]=ev,ej[60]=O):O=ej[60],ej[61]===Symbol.for("react.memo_cache_sentinel")?(I={fontSize:10.5,whiteSpace:"normal"},ej[61]=I):I=ej[61],ej[62]!==eN.userAgent?(D=(0,a.jsx)("span",{style:I,children:eN.userAgent}),ej[62]=eN.userAgent,ej[63]=D):D=ej[63],ej[64]!==O||ej[65]!==D?(H=(0,a.jsx)(E,{label:O,value:D,tight:!0}),ej[64]=O,ej[65]=D,ej[66]=H):H=ej[66],ej[67]!==b||ej[68]!==y||ej[69]!==k||ej[70]!==P||ej[71]!==B||ej[72]!==F||ej[73]!==H?(V=(0,a.jsxs)(C,{title:b,plainHead:!0,children:[y,k,P,B,F,H]}),ej[67]=b,ej[68]=y,ej[69]=k,ej[70]=P,ej[71]=B,ej[72]=F,ej[73]=H,ej[74]=V):V=ej[74],ej[75]!==ev?(q=ev("settingsUi.about.account"),ej[75]=ev,ej[76]=q):q=ej[76],ej[77]!==ev?(W=ev("settingsUi.about.name"),ej[77]=ev,ej[78]=W):W=ej[78];let e$=ef?.name??"—";ej[79]!==W||ej[80]!==e$?(G=(0,a.jsx)(E,{label:W,value:e$,tight:!0}),ej[79]=W,ej[80]=e$,ej[81]=G):G=ej[81],ej[82]!==ev?(K=ev("settingsUi.about.email"),ej[82]=ev,ej[83]=K):K=ej[83];let eA=ef?.email??"—";ej[84]!==K||ej[85]!==eA?(J=(0,a.jsx)(E,{label:K,value:eA,tight:!0}),ej[84]=K,ej[85]=eA,ej[86]=J):J=ej[86],ej[87]!==ev?(Y=ev("settingsUi.about.organisation"),ej[87]=ev,ej[88]=Y):Y=ej[88],ej[89]!==ek?.name||ej[90]!==ev||ej[91]!==ef?.company_name?(X=ek?.name??ef?.company_name??ev("settingsUi.about.notAssigned"),ej[89]=ek?.name,ej[90]=ev,ej[91]=ef?.company_name,ej[92]=X):X=ej[92],ej[93]!==Y||ej[94]!==X?(Q=(0,a.jsx)(E,{label:Y,value:X,tight:!0}),ej[93]=Y,ej[94]=X,ej[95]=Q):Q=ej[95],ej[96]!==ev?(Z=ev("settingsUi.about.role"),ej[96]=ev,ej[97]=Z):Z=ej[97];let eL=ef?.org_role??"member";ej[98]!==eL?(ee=eL.toUpperCase(),ej[98]=eL,ej[99]=ee):ee=ej[99],ej[100]!==Z||ej[101]!==ee?(es=(0,a.jsx)(E,{label:Z,value:ee,tight:!0}
1),ej[100]=Z,ej[101]=ee,ej[102]=es):es=ej[102],ej[103]!==ev?(et=ev("settingsUi.about.status"),ej[103]=ev,ej[104]=et):et=ej[104],ej[105]!==ev||ej[106]!==ef?.is_active?(ei=ev(ef?.is_active?"pagesUi.page.active":"settingsUi.about.inactive"),ej[105]=ev,ej[106]=ef?.is_active,ej[107]=ei):ei=ej[107],ej[108]!==et||ej[109]!==ei?(en=(0,a.jsx)(E,{label:et,value:ei,tight:!0}),ej[108]=et,ej[109]=ei,ej[110]=en):en=ej[110],ej[111]!==ev?(ea=ev("settingsUi.about.userId"),ej[111]=ev,ej[112]=ea):ea=ej[112],ej[113]===Symbol.for("react.memo_cache_sentinel")?(el={fontFamily:"var(--rl-mono)",fontSize:10.5,whiteSpace:"normal",wordBreak:"break-all"},ej[113]=el):el=ej[113];let eR=ef?.id;return ej[114]!==eR?(er=(0,a.jsx)("span",{style:el,children:eR}),ej[114]=eR,ej[115]=er):er=ej[115],ej[116]!==ea||ej[117]!==er?(eo=(0,a.jsx)(E,{label:ea,value:er,tight:!0}),ej[116]=ea,ej[117]=er,ej[118]=eo):eo=ej[118],ej[119]!==ev?(ec=ev("settingsUi.about.created"),ej[119]=ev,ej[120]=ec):ec=ej[120],ej[121]!==ef?(ed=ef?.created_at?new Date(ef.created_at).toLocaleString():"—",ej[121]=ef,ej[122]=ed):ed=ej[122],ej[123]!==ec||ej[124]!==ed?(eu=(0,a.jsx)(E,{label:ec,value:ed,tight:!0}),ej[123]=ec,ej[124]=ed,ej[125]=eu):eu=ej[125],ej[126]!==ev?(em=ev("settingsUi.about.lastLogin"),ej[126]=ev,ej[127]=em):em=ej[127],ej[128]!==ef?(ep=ef?.last_login_at?new Date(ef.last_login_at).toLocaleString():"—",ej[128]=ef,ej[129]=ep):ep=ej[129],ej[130]!==em||ej[131]!==ep?(eh=(0,a.jsx)(E,{label:em,value:ep,tight:!0}),ej[130]=em,ej[131]=ep,ej[132]=eh):eh=ej[132],ej[133]!==q||ej[134]!==G||ej[135]!==J||ej[136]!==Q||ej[137]!==es||ej[138]!==en||ej[139]!==eo||ej[140]!==eu||ej[141]!==eh?(ex=(0,a.jsxs)(C,{title:q,plainHead:!0,children:[G,J,Q,es,en,eo,eu,eh]}),ej[133]=q,ej[134]=G,ej[135]=J,ej[136]=Q,ej[137]=es,ej[138]=en,ej[139]=eo,ej[140]=eu,ej[141]=eh,ej[142]=ex):ex=ej[142],ej[143]!==V||ej[144]!==ex?(eg=(0,a.jsxs)("div",{style:g,children:[V,ex]}),ej[143]=V,ej[144]=ex,ej[145]=eg):eg=ej[145],ej[146]!==x||ej[147]!==eg?(eb=(0,a.jsxs)("div",{children:[x,eg]}),ej[146]=x,ej[147]=eg,ej[148]=eb):eb=ej[148],eb}],654590)},595938,173096,860643,284980,119266,e=>{"use strict";var s=e.i(843476),t=e.i(154920),i=e.i(271645);e.i(785269);var n=e.i(322831),a=e.i(627542),l=e.i(846696),r=e.i(372428),o=e.i(13080),c=e.i(915089),d=e.i(843932),u=e.i(48396),m=e.i(729914),p=e.i(799064);function h({data:e,onBack:d,onReload:x,onPending:g}){let{t:b,i18n:j}=(0,n.useTranslation)("workspaceSettings"),v=j.language,[f,y]=(0,i.useState)(null),[w,N]=(0,i.useState)(!1),[S,k]=(0,i.useState)(0),[_,C]=(0,i.useState)(e.plan.plan_type),[E,T]=(0,i.useState)(null),[P,U]=(0,i.useState)(null),[M,B]=(0,i.useState)(!1),[$,A]=(0,i.useState)(!1),[L,R]=(0,i.useState)(null),[F,O]=(0,i.useState)(!1),[I,D]=(0,i.useState)(0),H=(0,i.useRef)(!1),z=(0,i.useRef)(!1),{user:V}=(0,o.useAuth)(),q="pending"===e.subscription.status&&!e.subscription.self_serve&&"personal"===e.plan.plan_type,W="free"===e.plan.id||q,G=W?_:e.plan.plan_type,K=e.permissions.change_plan,J="cancel_to_free"===e.subscription.scheduled_change_type,Y=`palette:plan-selection:${V?.id??""}:${e.organization_id}:draft`;(0,i.useEffect)(()=>{T(null),U(null)},[e.plan.id,e.subscription.cycle_ends_at,K]),(0,i.useEffect)(()=>{let e=!0;return N(!1),(0,c.billing)("plans").then(s=>{e&&y(s)}).catch(()=>{e&&N(!0)}),()=>{e=!1}},[S]);let X=(f?.plans??[]).filter(e=>e.plan_type===G&&(W||"company"===e.plan_type||"free"!==e.id)),Q=e.plan.price_cents??0,Z=(0,i.useCallback)(async e=>{if(K&&!M&&!$){T(e),U(null),B(!0);try{U(await (0,c.billing)("subscription/quote",{method:"POST",body:JSON.stringify({plan_id:e.id})}))}catch(e){T(null),l.toast.error(b(`subscription.errors.${e instanceof c.BillingError?e.code:"billing_request_failed"}`,{defaultValue:b("subscription.errors.billing_request_failed")}))}finally{B(!1)}}},[K,M,$,b]);async function ee(){if(E&&!M&&!$&&K&&e.permissions.payment){A(!0);try{sessionStorage.setItem(Y,E.id);let{url:e}=await (0,c.billing)("payment-portal",{method:"POST",body:JSON.stringify({return_to:"plans"})});window.location.assign(e)}catch(e){sessionStorage.removeItem(Y),l.toast.error(b(`subscription.errors.${e instanceof c.BillingError?e.code:"billing_request_failed"}`,{defaultValue:b("subscription.errors.billing_request_failed")}))}finally{A(!1)}}}(0,i.useEffect)(()=>
1{if(!f||!K||M||H.current)return;H.current=!0;let s=sessionStorage.getItem(Y);sessionStorage.removeItem(Y);let t=f.plans.find(t=>t.id===s&&t.active&&"personal"===t.plan_type&&t.id!==e.plan.id&&"free"!==t.id);t&&Z(t)},[f,K,M,Y,e.plan.id,Z]),(0,i.useEffect)(()=>{if(!E||!K||!e.permissions.view)return;let s=!0;return R(null),O(!1),(0,c.billing)("payment-methods").then(e=>{s&&R(e.items)}).catch(()=>{s&&O(!0)}),()=>{s=!1}},[E,K,e.permissions.view,e.organization_id,I]);let es=L?.find(e=>e.default);async function et(){if(!E||!P||!K||$||z.current)return;z.current=!0,B(!0);let s=null;try{let t=`palette:subscription-purchase:${V?.id??""}:${e.organization_id}:${E.id}`;s=sessionStorage.getItem(t)??crypto.randomUUID(),sessionStorage.setItem(t,s);let i=await (0,c.billing)("subscription/change",{method:"POST",body:JSON.stringify({plan_id:E.id,request_id:s})});if(s=i.request_id??s,sessionStorage.setItem(t,s),i.checkout_url&&"pending"===i.status)return void window.location.assign(i.checkout_url);if(!["paid","recorded"].includes(i.status)){if(!["new","creating","pending"].includes(i.status)){sessionStorage.removeItem(t),l.toast.error(b("refunded"===i.status?"subscription.paymentRefunded":["failed","expired","abandoned"].includes(i.status)?"subscription.checkoutNotCompleted":"subscription.paymentReview"));return}l.toast.message(b(i.kind&&"subscribe"!==i.kind?"subscription.changePending":"subscription.paymentPending")),g(s,!0);return}sessionStorage.removeItem(t),l.toast.success(b(`subscription.done.${i.kind}`,{plan:(0,c.planName)(b,E),date:(0,r.formatDate)(i.effective_at??null,v)})),T(null),U(null),(0,r.notifySubscriptionChanged)(),x(),"downgrade"!==i.kind&&d()}catch(e){l.toast.error(b(`subscription.errors.${e instanceof c.BillingError?e.code:"billing_request_failed"}`,{defaultValue:b("subscription.errors.billing_request_failed")})),s&&e instanceof c.BillingError&&(0===e.status||e.status>=500)&&"subscription_payments_unavailable"!==e.code&&g(s,!0)}finally{z.current=!1,B(!1)}}let ei=(0,s.jsx)("div",{className:`sbPlanGrid sbPanel ${G}`,children:X.map(t=>{let i="company"===t.plan_type?{label:b("subscription.contactSales"),kind:"contact"}:q&&t.id===e.plan.id?{label:b("subscription.completePayment"),kind:"subscribe"}:t.id===e.plan.id?{label:b("subscription.currentPlanTag"),kind:"current"}:W?{label:b("free"===t.id?"subscription.startFree":"subscription.subscribe"),kind:"subscribe"}:(t.price_cents??0)>Q?{label:b("subscription.upgrade"),kind:"upgrade"}:{label:b("subscription.downgrade"),kind:"downgrade"},n="personal"===G&&f?.recommended_plan_id===t.id&&t.id!==e.plan.id;return(0,s.jsx)(p.PlanCard,{plan:t,locale:v,className:`${"current"===i.kind?"current":""} ${n?"recommended":""}`,badges:(0,s.jsxs)(s.Fragment,{children:["current"===i.kind&&(0,s.jsx)("span",{className:"sbTag current",children:b("subscription.currentPlanTag")}),n&&(0,s.jsx)("span",{className:"sbTag recommended",children:b("subscription.recommended")})]}),children:"contact"===i.kind?(0,s.jsx)("button",{className:"rlBtn",onClick:()=>(0,c.openContactSales)(f?.contact_sales_url??e.contact_sales_url),children:i.label}):"current"===i.kind?(0,s.jsx)("button",{className:"rlBtn",disabled:!0,children:i.label}):(0,s.jsx)("button",{className:`rlBtn ${"downgrade"===i.kind?"":"pri"}`,disabled:!K||M||J&&!W,onClick:()=>void Z(t),children:i.label})},t.id)})});return(0,s.jsxs)(a.Tabs.Root,{className:"rlStack",value:G,onValueChange:e=>C(e),children:[(0,s.jsxs)("div",{className:"sbBreadcrumb",children:[(0,s.jsxs)("button",{type:"button",className:"rlBtn sm",onClick:d,children:["← ",b("subscription.planUsage")]}),(0,s.jsx)("span",{children:b("subscription.planSelection")})]}),(0,s.jsx)(m.ScheduledBanner,{data:e}),W&&(0,s.jsx)(a.Tabs.List,{className:"wsTabs sbTabs","aria-label":b("subscription.planSelection"),children:["personal","company"].map(e=>(0,s.jsx)(a.Tabs.Trigger,{value:e,className:`wsTab ${G===e?"on":""}`,children:b(`subscription.category.${e}`)},e))}),w&&(0,s.jsxs)("div",{className:"rlHint",role:"alert",children:[b("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>k(e=>e+1),children:b("retry")})]}),!f&&!w&&(0,s.jsx)(t.PaletteLoader,{label:b("loading")}),!K&&"personal"===G&&(0,s.jsx)("p",{className:"rlNote",children:b("subscription.ownerOnly")}),K&&J&&!W&&(0,s.jsx)("p",{className:"rlNote",role:"status",children:b("subscription.resumeToChangePlan")}),W?["personal","company"].map(e=>(0,s.jsx)(a.Tabs.Content,{value:e,children:G===e&&ei},e)):ei,"company"===G&&(0,s.jsx)("p",{className:"rlNote",children:b("subscription.companyNote")}),E&&K&&(0,s.jsx)(u.Modal,{title:b(`subscription.modal.${P?.kind??"loading"}`),onClose:()=>{$||(T(null),U(null))},children:(0,s.jsx)("div",{className:"rlModalBody",children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sbLimits",children:["subscribe"!==P.kind&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.currentPlan")}),(0,s.jsxs)("strong",{children:[(0,c.planName)(b,P.current_plan)," · ",(0,r.formatUsd)(P.current_monthly_price_cents,v)]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.targetPlan")}),(0,s.jsxs)("strong",{children:[(0,c.planName)(b,P.target_plan)," · ",(0,r.formatUsd)(P.target_monthly_price_cents,v)," ",b("subscription.perMonthShort")]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.monthlyCredits")}),(0,s.jsx)("strong",{children:"subscribe"===P.kind?(0,r.formatCredits)(P.credits.target_limit,v):`${(0,r.formatCredits)(P.credits.current_limit,v)} → ${(0,r.formatCredits)(P.credits.target_limit,v)}`})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.storage")}),(0,s.jsx)("strong",{children:"subscribe"===P.kind?(0,r.formatBytes)(P.storage.target_limit_bytes):`${(0,r.formatBytes)((P.current_plan.storage_gb??0)*0x40000000)} → ${(0,r.formatBytes)(P.storage.target_limit_bytes)}`})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.topup")}),(0,s.jsx)("strong",{children:P.target_plan.topup_allowed?b("subscription.available"):b("subscription.notAvailable")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.effectiveAt")}),(0,s.jsx)("strong",{children:"downgrade"===P.kind?b("subscription.nextCycle",{date:(0,r.formatDate)(P.effective_at,v)}):b("subscription.immediately")})]}),"upgrade"===P.kind&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.proratedCharge")}
1),(0,s.jsxs)("strong",{children:[(0,r.formatUsd)(P.prorated_charge_cents,v)," ",(0,s.jsx)("em",{className:"sbEstimate",children:b("subscription.estimate")})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.nextBillingAmount")}),(0,s.jsxs)("strong",{children:[(0,r.formatUsd)(P.next_billing_amount_cents,v)," · ",(0,r.formatDate)(P.next_billing_at,v)]})]}),"downgrade"!==P.kind&&"free"!==P.target_plan.id&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.paymentMethod")}),F?(0,s.jsxs)("span",{role:"alert",children:[b("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn sm",onClick:()=>D(e=>e+1),children:b("retry")})]}):null===L?(0,s.jsx)("span",{role:"status",children:b("loading")}):(0,s.jsx)("strong",{children:es?`${es.brand??es.type}${es.last4?` •••• ${es.last4}`:""}`:b("subscription.paymentAtCheckout")}),e.permissions.payment&&(0,s.jsx)("button",{type:"button",className:"rlBtn sm",disabled:M||$,onClick:()=>void ee(),children:b($?"billing.opening":"subscription.changePaymentMethod")})]})]}),"upgrade"===P.kind&&(0,s.jsxs)("div",{className:"sbCreditsAfter",children:[(0,s.jsx)("p",{children:b("subscription.upgradeUsageKept")}),(0,s.jsxs)("div",{className:"sbLimits compact",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.currentUsage")}),(0,s.jsx)("strong",{children:(0,r.formatCredits)(P.credits.monthly_used,v)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.limitAfter",{plan:(0,c.planName)(b,P.target_plan)})}),(0,s.jsx)("strong",{children:(0,r.formatCredits)(P.credits.target_limit,v)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.availableAfter")}),(0,s.jsx)("strong",{children:(0,r.formatCredits)(P.credits.available_after,v)})]})]})]}),"downgrade"===P.kind&&(0,s.jsx)("p",{className:"rlNote",children:b("subscription.downgradeKeepsPlan",{date:(0,r.formatDate)(P.effective_at,v)})}),P.storage.will_exceed_target_limit&&(0,s.jsx)("p",{className:"rlNote sbNote danger",children:b("subscription.storageWillExceed")}),!P.payment_available&&"downgrade"!==P.kind&&(0,s.jsx)("p",{className:"rlNote sbNote danger",children:b("subscription.errors.subscription_payments_unavailable")}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",disabled:$,onClick:()=>{T(null),U(null)},children:b("cancel")}),(0,s.jsx)("button",{className:"rlBtn pri",disabled:M||$||!K||!P.payment_available&&"downgrade"!==P.kind,onClick:()=>void et(),children:"subscribe"===P.kind?b("free"===P.target_plan.id?"subscription.startFree":"subscription.subscribe"):"upgrade"===P.kind?b("subscription.upgrade"):b("subscription.scheduleDowngrade")})]})]}):(0,s.jsx)(t.PaletteLoader,{label:b("loading")})})})]})}let x=["plan","billing","plans","credit-history","subscription-history"],g=new Set(["new","creating","pending"]),b=new Set(["failed","expired","abandoned","refunded"]);e.s(["BillingSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),{data:u,loading:p,error:j,reload:v}=(0,r.useSubscription)(),{user:f}=(0,o.useAuth)(),[y,w]=(0,i.useState)("plan"),[N,S]=(0,i.useState)(null),[k,_]=(0,i.useState)(null),[C,E]=(0,i.useState)(null),[T,P]=(0,i.useState)(null),[U,M]=(0,i.useState)(!1),[B,$]=(0,i.useState)(null),A=B?null:u?.subscription.pending_request_id,[L,R]=(0,i.useState)(0),F=(0,i.useRef)(!1),O=(0,i.useRef)(null),[I,D]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=new URL(window.location.href);e.searchParams.has("customer_session_token")&&(e.searchParams.delete("customer_session_token"),window.history.replaceState(null,"",e.toString()));let s=()=>{let e;w((e=new URLSearchParams(window.location.search).get("tab"),x.includes(e)?e:"plan")),$(new URLSearchParams(window.location.search).get("subscription"))};return s(),window.addEventListener("popstate",s),()=>window.removeEventListener("popstate",s)},[]),(0,i.useEffect)(()=>{A&&$(A)},[A]),(0,i.useEffect)(()=>{let e;if(S(null),_(null),E(null),P(null),D(!1),u?.organization_id&&O.current!==u.organization_id){let e=null!==O.current;if(O.current=u.organization_id,e){F.current=!1;let e=new URL(window.location.href);e.searchParams.delete("subscription"),window.history.replaceState(null,"",e.toString()),$(A??null);return}}if(!B||!/^[0-9a-f-]{36}
1$/i.test(B)||!u?.permissions.change_plan)return;let s=u.organization_id,t=!0,i=0;async function n(){try{let a=await (0,c.billing)(`subscription/purchases/${B}`);if(!t)return;if(F.current&&a.checkout_url&&g.has(a.status)){F.current=!1,window.location.assign(a.checkout_url);return}if(g.has(a.status)||(F.current=!1),S(a.status),_(a.kind??null),E(a.plan_id??null),P(a.checkout_url??null),D(!1),!["new","creating","pending"].includes(a.status))for(let e of[a.plan_id,a.kind]){if(!e)continue;let t=`palette:subscription-purchase:${f?.id??""}:${s}:${e}`;sessionStorage.getItem(t)===B&&sessionStorage.removeItem(t)}if(["paid","recorded"].includes(a.status)){if((0,r.notifySubscriptionChanged)(),await v(!0),!t)return;let e=new URL(window.location.href);e.searchParams.delete("subscription"),window.history.replaceState(null,"",e.toString())}else["new","creating","pending"].includes(a.status)&&(++i<40?e=setTimeout(n,3e3):D(!0))}catch(s){if(!t)return;if(s instanceof c.BillingError&&404===s.status){let e=new URL(window.location.href);e.searchParams.delete("subscription"),window.history.replaceState(null,"",e.toString()),$(null);return}S("error"),D(!0),s instanceof c.BillingError&&(0===s.status||s.status>=500||429===s.status)&&++i<40&&(e=setTimeout(n,3e3))}}return n(),()=>{t=!1,clearTimeout(e)}},[v,B,A,L,u?.organization_id,u?.permissions.change_plan,f?.id]);let H=e=>{w(e);let s=new URL(window.location.href);"plan"===e?s.searchParams.delete("tab"):s.searchParams.set("tab",e),window.history.replaceState(null,"",s.toString())},z=(e,s=!1)=>{F.current=s;let t=new URL(window.location.href);t.searchParams.set("subscription",e),window.history.replaceState(null,"",t.toString()),$(e),R(e=>e+1),H("plan")},V=async()=>{if(!C||U)return;M(!0);let s=`palette:subscription-purchase:${f?.id??""}:${u?.organization_id}:${C}`,t=sessionStorage.getItem(s)??crypto.randomUUID();sessionStorage.setItem(s,t);try{let e=await (0,c.billing)("subscription/change",{method:"POST",body:JSON.stringify({plan_id:C,request_id:t})});if(sessionStorage.setItem(s,e.request_id??t),e.checkout_url)return void window.location.assign(e.checkout_url);z(e.request_id??t,!0)}catch(s){l.toast.error(e(`subscription.errors.${s instanceof c.BillingError?s.code:"billing_request_failed"}`,{defaultValue:e("subscription.errors.billing_request_failed")})),s instanceof c.BillingError&&(0===s.status||s.status>=500)&&z(t,!0)}finally{M(!1)}};return!u&&p?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):u?u.permissions.view?"plans"===y?(0,s.jsx)(h,{data:u,onBack:()=>H("plan"),onReload:()=>void v(!0),onPending:z}):"credit-history"===y?(0,s.jsx)(d.HistoryPage,{kind:"credit",enabled:u.permissions.history,onBack:()=>H("billing")}):"subscription-history"===y?(0,s.jsx)(d.HistoryPage,{kind:"subscription",enabled:u.permissions.history,onBack:()=>H("billing")}):(0,s.jsxs)(a.Tabs.Root,{className:"rlStack",value:y,onValueChange:e=>H(e),children:[N&&(0,s.jsxs)("div",{className:"rlHint",role:"status",children:[e("paid"===N?"subscription.paymentConfirmed":"recorded"===N?"subscription.changeConfirmed":"paid_conflict"===N?"subscription.paymentNotApplied":"refunded"===N?"subscription.paymentRefunded":g.has(N)?k&&"subscribe"!==k?"subscription.changePending":"subscription.paymentPending":b.has(N)?"subscription.checkoutNotCompleted":"subscription.paymentReview"),T&&g.has(N)&&(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>window.location.assign(T),children:e("subscription.completePayment")}),I&&(0,s.jsx)("button",{className:"rlBtn",onClick:()=>{F.current=!1,R(e=>e+1)},children:e("retry")}),b.has(N)&&C&&u.permissions.change_plan&&(0,s.jsx)("button",{className:"rlBtn pri",disabled:U,onClick:()=>void V(),children:e("subscription.startNewCheckout")})]}),j&&(0,s.jsx)("div",{className:"rlHint",role:"alert",children:e("billing.loadError")}),(0,s.jsx)(a.Tabs.List,{className:"wsTabs sbTabs","aria-label":e("nav.billing"),children:["plan","billing"].map(t=>(0,s.jsx)(a.Tabs.Trigger,{value:t,className:`wsTab ${y===t?"on":""}`,children:e("plan"===t?"subscription.planUsage":"subscription.billingCredits")},t))}),(0,s.jsx)(a.Tabs.Content,{value:"plan",children:(0,s.jsx)(m.PlanUsage,{data:u,onViewPlans:()=>H("plans"),onReload:()=>void v(!0),onPending:z})}),(0,s.jsx)(a.Tabs.Content,{value:"billing",children:(0,s.jsx)(d.CreditsBilling,{data:u,onViewPlans:()=>H("plans"),onHistory:e=>H("credit"===e?"credit-history":"subscription-history")})})]}):(0,s.jsx)("div",{className:"rlHint",role:"alert",children:e("subscription.viewDenied")}):(0,s.jsxs)("div",{className:"rlHint",role:"alert",children:[e("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void v(!0),children:e("retry")})]})}],595938);var j=e.i(364203),v=e.i(175813),f=e.i(422187),y=e.i(242636),w=e.i(35185),N=e.i(161652),S=e.i(345526),k=e.i(571300),_=e.i(955946),C=e.i(30728),E=e.i(234170),T=e.i(209165),P=e.i(519455),U=e.i(776639),M=e.i(975157),B=e.i(500932);function $(e){let t,i,n,a=(0,B.c)(7),{label:l,value:r}=e;return a[0]!==l?(t=(0,s.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l}),a[0]=l,a[1]=t):t=a[1],a[2]!==r?(i=(0,s.jsx)("div",{className:"min-w-0 text-sm text-foreground",children:r}),a[2]=r,a[3]=i):i=a[3],a[4]!==t||a[5]!==i?(n=(0,s.jsxs)("div",{className:"grid grid-cols-[170px_1fr] gap-4 border-b border-border/60 py-3 last:border-0",children:[t,i]}
1),a[4]=t,a[5]=i,a[6]=n):n=a[6],n}function A(e){return e.split(/[:._-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function L(e){let s=e.toLowerCase();return/(delete|write|admin|token|secret|webhook|purge)/.test(s)?"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100":/(read|view|list)/.test(s)?"border-emerald-300 bg-emerald-50 text-emerald-900 dark:border-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-100":"border-border bg-muted text-muted-foreground"}function R(e){return"string"==typeof e?{target:e,required:!0,reason:""}:e}function F(e){return"string"==typeof e?e:e.topic??e.name??"event"}e.s(["AppsSection",0,function(){let{t:e}=(0,n.useTranslation)(),{installedApps:a,uninstall:l,loading:r}=(0,S.useInstalledApps)(),o=(0,k.useAppsById)(),{catalog:c,loading:d}=(0,_.useAppFullCatalog)(),u=(0,C.useIsOwnerOrAdmin)(),m=(0,E.useWindowManagerOptional)(),[p,h]=(0,i.useState)(null),[x,g]=(0,i.useState)(null),[b,B]=(0,i.useState)(null),[O,I]=(0,i.useState)(null),[D,H]=(0,i.useState)(null),[z,V]=(0,i.useState)(null),[q,W]=(0,i.useState)([]),G=(0,i.useMemo)(()=>Object.fromEntries(c.map(e=>[e.id,e])),[c]),K=(0,i.useMemo)(()=>a.map(e=>{let s=o[e],t=G[e];return s?{...s,permissions:t?.permissions??s.permissions??[],storeScope:t?.store_scope??s.storeScope,provides:t?.provides??s.provides,requires:t?.requires??s.requires,consumes:t?.consumes??s.consumes}:t?{id:t.id,name:t.name,tagline:t.tagline,description:t.description,category:"Productivity",route:`/apps/${t.id}`,gradient:{bg:t.gradient_bg,text:t.gradient_text},icon:t.Icon,developer:t.developer,version:"",rating:0,reviews:0,storeScope:t.store_scope,permissions:t.permissions??[],provides:t.provides,requires:t.requires,consumes:t.consumes}:null}).filter(e=>!!e),[o,G,a]),J=K.find(e=>e.id===p)??K[0]??null;async function Y(e,s,t){if(J&&u){V(`${e}:${s}`);try{let i=await (0,T.apiFetch)(`/api/v1/app-installs/${J.id}/cross-app-grants`,{method:"PATCH",body:JSON.stringify({[e]:{[s]:t}})});if(i.ok){let e=await i.json();H(s=>({services:e.services??s?.services??{},events:e.events??s?.events??{},declared:s?.declared??{services:[],events:[]}}))}}finally{V(null)}}}function X(e){m?m.openWindow(e):window.location.assign(e)}function Q(e){I(null),g(e)}async function Z(){if(x){I(null),B(x.id);try{await l(x.id),h(e=>e===x.id?null:e),g(null)}catch(s){I(s instanceof Error?s.message:e("settingsUi.apps.uninstallFailed","Unable to uninstall app"))}finally{B(null)}}}return(0,i.useEffect)(()=>{let e=!1;if((H(null),J)&&(J.consumes?.services?.length??0)+(J.consumes?.events?.length??0))return(0,T.apiFetch)(`/api/v1/app-installs/${J.id}/cross-app-grants`).then(e=>e.ok?e.json():null).then(s=>{e||H(s)}).catch(()=>{e||H(null)}),()=>{e=!0}},[J?.id]),(0,i.useEffect)(()=>{let e=!1;if(W([]),J)return(0,T.apiFetch)(`/api/v1/os-broker/audit?app_id=${encodeURIComponent(J.id)}&limit=10`).then(e=>e.ok?e.json():[]).then(s=>{e||W(s)}).catch(()=>{e||W([])}),()=>{e=!0}},[J?.id]),(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("section",{className:"rounded-lg border bg-card p-5",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-base font-semibold",children:e("settingsUi.apps.installedApps")}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e("settingsUi.apps.reviewAppsInstalledOrganisationInspect")})]}),(0,s.jsxs)(P.Button,{variant:"outline",className:"shrink-0 gap-2",onClick:()=>X("/app-store"),children:[(0,s.jsx)(w.Storefront,{size:16}),e("shortcuts.actions.appStore")]})]}),O&&(0,s.jsx)("div",{className:"mt-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:O}),!u&&(0,s.jsx)("div",{className:"mt-4 rounded-md border bg-muted/40 px-3 py-2 text-sm text-muted-foreground",children:e("settingsUi.apps.onlyOrganisationOwnersAdminsCan")})]}),(r||d)&&(0,s.jsx)(t.PaletteLoader,{label:e("settingsUi.apps.loadingInstalledApps")}),!r&&!d&&0===K.length&&(0,s.jsxs)("section",{className:"rounded-lg border bg-card p-8 text-center",children:[(0,s.jsx)(w.Storefront,{size:34,className:"mx-auto text-muted-foreground"}),(0,s.jsx)("h2",{className:"mt-3 text-base font-semibold",children:e("settingsUi.apps.noAppsInstalled")}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e("settingsUi.apps.installOrganisationAppsFromApp")}),(0,s.jsxs)(P.Button,{className:"mt-4 gap-2",onClick:()=>X("/app-store"),children:[(0,s.jsx)(j.ArrowSquareOut,{size:16}),e("shortcuts.actions.openAppStore")]})]}),K.length>0&&(0,s.jsxs)("div",{className:"grid gap-5 xl:grid-cols-[1fr_360px]",children:[(0,s.jsx)("section",{className:"space-y-3",children:K.map((t,i)=>{let n=t.icon,a=t.permissions??[],l=J?.id===t.id;return(0,s.jsx)("div",{className:(0,M.cn)("rounded-lg border bg-card p-4 transition-colors",l?"border-primary/70 ring-2 ring-primary/15":"hover:border-primary/40"),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-start",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>h(t.id),className:"flex min-w-0 flex-1 items-start gap-3 text-left",children:[(0,s.jsx)("span",{className:"flex size-12 shrink-0 items-center justify-center rounded-xl shadow-sm",style:{background:t.gradient.bg,color:t.gradient.text},children:(0,s.jsx)(n,{size:24,weight:"fill"})}),(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",children:t.name}),(0,s.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:"company"===t.storeScope?"Company":"App"})]}),(0,s.jsx)("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:t.tagline||t.description}),(0,s.jsxs)("span",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.slice(0,3).map(e=>(0,s.jsx)("span",{className:(0,M.cn)("rounded-full border px-2 py-0.5 text-[11px]",L(e)),children:A(e)},e)),a.length>3&&(0,s.jsxs)("span",{className:"rounded-full border bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:["+",a.length-3]}),0===a.length&&(0,s.jsx)("span",{className:"rounded-full border bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:e("settingsUi.apps.noDeclaredOsPermissions")})]})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 md:justify-end",children:[(0,s.jsxs)(P.Button,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>X(t.route),children:[(0,s.jsx)(j.ArrowSquareOut,{size:15}),e("notifications.open")]}),(0,s.jsxs)(P.Button,{size:"sm",variant:l?"default":"outline",className:"gap-2",onClick:()=>h(t.id),children:[(0,s.jsx)(y.SlidersHorizontal,{size:15}),e("actions.manage")]}),(0,s.jsxs)(P.Button,{size:"sm",variant:"outline",className:"gap-2 text-destructive hover:text-destructive",disabled:b===t.id,onClick:()=>
1Q(t),children:[(0,s.jsx)(N.Trash,{size:15}),b===t.id?"Removing...":"Uninstall"]})]})]})},t.id)})}),J&&(0,s.jsxs)("section",{className:"h-fit rounded-lg border bg-card p-5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-xl",style:{background:J.gradient.bg,color:J.gradient.text},children:(0,s.jsx)(J.icon,{size:22,weight:"fill"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"truncate text-base font-semibold",children:J.name}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:J.description||J.tagline})]})]}),(0,s.jsxs)("div",{className:"mt-5",children:[(0,s.jsx)($,{label:e("settingsUi.apps.appId"),value:(0,s.jsx)("span",{className:"break-all font-mono text-xs",children:J.id})}),(0,s.jsx)($,{label:e("nav.developer"),value:J.developer||"Unknown"}),(0,s.jsx)($,{label:e("settingsUi.apps.version"),value:J.version||e("settingsUi.apps.notProvided","Not provided")}),(0,s.jsx)($,{label:e("settingsUi.apps.permissions"),value:function(e){if(0===e.length)return"No declared OS permissions";let s=e.filter(e=>/(delete|write|admin|token|secret|webhook|purge)/i.test(e)).length;return s>0?`${e.length} declared, ${s} elevated`:`${e.length} declared`}(J.permissions??[])})]}),(0,s.jsxs)("div",{className:"mt-5",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[(0,s.jsx)(f.ShieldCheck,{size:16}),e("settingsUi.apps.declaredPermissions")]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:(J.permissions??[]).length?(J.permissions??[]).map(e=>(0,s.jsx)("span",{className:(0,M.cn)("rounded-full border px-2.5 py-1 text-xs",L(e)),children:A(e)},e)):(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:e("settingsUi.apps.appHasNoManifestDeclared")})})]}),(0,s.jsxs)("div",{className:"mt-5",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[(0,s.jsx)(y.SlidersHorizontal,{size:16}),e("settingsUi.apps.appAppCommunication")]}),(0,s.jsxs)("div",{className:"space-y-3 rounded-md border bg-muted/20 p-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:e("settingsUi.apps.provides")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(J.provides?.services??[]).map(e=>(0,s.jsx)("span",{className:"rounded-full border bg-background px-2 py-0.5 text-[11px]",children:e.id},`service:${e.id}`)),(J.provides?.events??[]).map(e=>(0,s.jsx)("span",{className:"rounded-full border bg-background px-2 py-0.5 text-[11px]",children:F(e)},`event:${F(e)}`)),!(J.provides?.services?.length||J.provides?.events?.length)&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e("settingsUi.apps.appDoesNotExposeBroker")})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:e("settingsUi.apps.consumes")}),(0,s.jsx)("div",{className:"mt-2 space-y-2",children:[...J.consumes?.services??[],...J.consumes?.events??[]].length?(0,s.jsxs)(s.Fragment,{children:[(J.consumes?.services??[]).map(t=>{let i=R(t),n=D?.services?.[i.target]!==!1;return(0,s.jsxs)("div",{className:"rounded-md border bg-background p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"break-all font-mono text-[11px]",children:i.target}),(0,s.jsx)(P.Button,{size:"sm",variant:n?"outline":"default",disabled:!u||z===`services:${i.target}`,onClick:()=>Y("services",i.target,!n),children:n?"Granted":e("developer.revoked")})]}),i.reason&&(0,s.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:i.reason})]},`consume-service:${i.target}`)}),(J.consumes?.events??[]).map(t=>{let i=R(t),n=D?.events?.[i.target]!==!1;return(0,s.jsxs)("div",{className:"rounded-md border bg-background p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"break-all font-mono text-[11px]",children:i.target}),(0,s.jsx)(P.Button,{size:"sm",variant:n?"outline":"default",disabled:!u||z===`events:${i.target}`,onClick:()=>Y("events",i.target,!n),children:n?"Granted":e("developer.revoked")})]}),i.reason&&(0,s.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:i.reason})]},`consume-event:${i.target}`)})]}):(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e("settingsUi.apps.app
1DoesNotConsumeOther")})})]})]})]}),(0,s.jsxs)("div",{className:"mt-5",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[(0,s.jsx)(v.Code,{size:16}),e("settingsUi.apps.recentAppAppTraces")]}),(0,s.jsx)("div",{className:"space-y-2 rounded-md border bg-muted/20 p-3",children:q.length?q.map(e=>(0,s.jsxs)("div",{className:"rounded-md border bg-background p-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"break-all font-mono text-[11px]",children:e.target}),(0,s.jsx)("span",{className:(0,M.cn)("rounded-full px-2 py-0.5 text-[11px] uppercase","ok"===e.status?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-800"),children:e.status})]}),(0,s.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.kind,"number"==typeof e.latency_ms?` \xb7 ${e.latency_ms}ms`:""," · ",new Date(e.occurred_at).toLocaleString()]}),e.error&&(0,s.jsx)("div",{className:"mt-1 text-xs text-destructive",children:e.error})]},e.id)):(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e("settingsUi.apps.noBrokerCallsRecordedApp")})})]}),(0,s.jsxs)("div",{className:"mt-5 grid gap-2",children:[(0,s.jsxs)(P.Button,{className:"justify-center gap-2",onClick:()=>X(J.route),children:[(0,s.jsx)(j.ArrowSquareOut,{size:16}),e("componentsUi.chatActionCards.openApp")]}),(0,s.jsxs)(P.Button,{variant:"outline",className:"justify-center gap-2 text-destructive hover:text-destructive",disabled:b===J.id,onClick:()=>Q(J),children:[(0,s.jsx)(N.Trash,{size:16}),b===J.id?"Removing...":e("settingsUi.apps.uninstallApp","Uninstall app")]})]})]})]}),(0,s.jsx)(U.Dialog,{open:!!x,onOpenChange:e=>{e||b||g(null)},children:(0,s.jsxs)(U.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsxs)(U.DialogHeader,{children:[(0,s.jsx)(U.DialogTitle,{children:e("settingsUi.apps.uninstallApp")}),(0,s.jsx)(U.DialogDescription,{children:e("settingsUi.apps.removeAppFromOrganisationDesktop")})]}),x&&(0,s.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-4",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-xl",style:{background:x.gradient.bg,color:x.gradient.text},children:(0,s.jsx)(x.icon,{size:22,weight:"fill"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate text-sm font-semibold",children:x.name}),(0,s.jsx)("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e("settingsUi.apps.existingAppDataIsKept")})]})]}),(0,s.jsx)("div",{className:"mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:e("settingsUi.apps.willImmediatelyRemoveAppShortcut")})]}),(0,s.jsxs)(U.DialogFooter,{children:[(0,s.jsx)(P.Button,{variant:"outline",disabled:!!b,onClick:()=>g(null),children:e("actions.cancel")}),(0,s.jsxs)(P.Button,{variant:"destructive",className:"gap-2",disabled:!x||!!b,onClick:Z,children:[(0,s.jsx)(N.Trash,{size:16}),b?"Uninstalling...":e("settingsUi.apps.uninstallApp","Uninstall app")]})]})]})})]})}],173096);var O=e.i(323240);let I=["drive","sessions","knowledge","tasks"],D={drive:[],sessions:[],knowledge:[],tasks:[]},H={drive:"/api/v1/data-rooms",sessions:"/api/v1/general-chat/threads",knowledge:"/api/v1/okg/concepts",tasks:"/api/v1/tasks"};e.s(["DataSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),{user:a}=(0,o.useAuth)(),{has:c}=(0,O.usePermissions)(),{data:d}=(0,r.useSubscription)(),[m,p]=(0,i.useState)(D),[h,x]=(0,i.useState)(!0),[g,b]=(0,i.useState)(!1),[j,v]=(0,i.useState)(!1),[f,y]=(0,i.useState)(null),[w,N]=(0,i.useState)(""),[S,k]=(0,i.useState)(0),[_,C]=(0,i.useState)(null),E=c("storage.export"),P=c("storage.delete"),U=a?.organization_id?`palette:storage-last-export:${a.organization_id}`:null,M=(0,i.useCallback)(async()=>{x(!0),b(!1);try{let e=async e=>{let s=await (0,T.apiFetch)(e);if(!s.ok)throw Error();return s.json()},[s,t,i]=await Promise.all([e(H.drive),e(H.sessions),e(H.tasks)]),n=[];for(let s=0;;s+=2e3){let t=await e(`${H.knowledge}?limit=2000&offset=${s}`);if(!Array.isArray(t.concepts)||t.total>5e4)throw Error();if(n.push(...t.concepts),n.length>=t.total)break;if(!t.concepts.length)throw Error()}p({drive:s,sessions:t,tasks:i,knowledge:n})}catch{b(!0)}finally{x(!1)}},[]);(0,i.useEffect)(()=>{M()},[M]),(0,i.useEffect)(()=>
1{if(U)try{C(localStorage.getItem(U))}catch{}},[U]);let B=m.drive.every(e=>null!=e.storage_bytes)?m.drive.reduce((e,s)=>e+(s.storage_bytes??0),0):null,$={drive:m.drive.reduce((e,s)=>e+s.files_count,0),sessions:m.sessions.length,knowledge:m.knowledge.length,tasks:m.tasks.length};function A(e){let s=("drive"===e?m.drive:m[e]).map(e=>e.updated_at).filter(Boolean).sort().pop();return s?(0,u.stamp)(s):"—"}function L(s){return 0===s?"0 MB":null==s?e("storage.unknown"):new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(s/1024/1024)+" MB"}function R(e){return"drive"===e?m.drive.filter(e=>"owner"===e.my_permission):"tasks"===e?m.tasks.filter(e=>!["running","in_progress","queued"].includes(e.status??"")):"knowledge"===e?m.knowledge.filter(e=>e.owner_user_id===a?.id||"personal"!==e.tier):m.sessions}async function F(){if(!f||!P||j||"DELETE"!==w)return;v(!0),k(0);let s=0;try{for(let e of f.rows){let t=await (0,T.apiFetch)(`${H[f.kind]}/${encodeURIComponent(String(e.id))}`,{method:"DELETE"});if(!t.ok&&404!==t.status)throw Error();k(++s)}l.toast.success(e("storage.deleted",{count:s})),y(null)}catch{l.toast.error(e("storage.deletePartial",{count:s})),y(null)}finally{await M(),v(!1)}}async function z(){if(!j&&!g&&!h&&E){v(!0);try{let s=new Date().toISOString(),t=new Blob([JSON.stringify({exported_at:s,workspace_id:a?.organization_id,scope:e("storage.scope"),...m},null,2)],{type:"application/json"}),i=URL.createObjectURL(t),n=document.createElement("a");n.href=i,n.download=`palette-workspace-${a?.organization_id}-${s.slice(0,10)}.json`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3),C(s);try{U&&localStorage.setItem(U,s)}catch{}l.toast.success(e("storage.exported"))}catch{l.toast.error(e("storage.partial"))}finally{v(!1)}}}if(h&&!j)return(0,s.jsx)(t.PaletteLoader,{label:e("loading")});if(g)return(0,s.jsx)(u.Card,{title:e("loadFailed"),children:(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void M(),children:e("retry")})})});let V=d?.storage.used_bytes??B,q=d?.storage.limit_bytes??null,W=null!=V&&null!=q?Math.max(0,q-V):null,G=null!=V&&q?Math.min(1,V/q):null;return(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)(u.Card,{title:e("storage.title"),plainHead:!0,children:[(0,s.jsx)("div",{className:"wsStorageTiles",children:[{label:e("storage.knownUsage"),value:L(V)},{label:e("storage.available"),value:null==W?e("storage.unlimited"):L(W)},{label:e("storage.capacity"),value:null==q?e("storage.unlimited"):L(q)}].map(e=>(0,s.jsxs)("div",{className:"rlTile",children:[(0,s.jsx)("span",{className:"rlTileK",children:e.label}),(0,s.jsx)("div",{className:"rlTileV",children:e.value})]},e.label))}),(0,s.jsxs)("div",{className:"wsMeterHead",children:[(0,s.jsx)("h3",{children:e("storage.usageRate")}),(0,s.jsx)("strong",{children:null==G?e("storage.unknown"):`${(100*G).toFixed(1)}%`})]}),null!=G&&(0,s.jsx)("div",{className:"wsMeter",children:(0,s.jsx)("i",{style:{width:`${Math.max(2,100*G)}%`}})}),(0,s.jsxs)("div",{className:"wsMeterFoot",children:[(0,s.jsx)("span",{children:e("storage.usedOf",{used:L(V),defaultValue:L(V)})}),(0,s.jsx)("span",{children:null==q?e("storage.unlimited"):L(q)})]}),(0,s.jsxs)("div",{className:"rlHint wsMeterNote",children:[e("storage.updated")," · ",A("drive")]})]}),(0,s.jsx)(u.Card,{title:e("storage.breakdown"),plainHead:!0,children:(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:e("name")}),(0,s.jsx)("th",{children:e("description")}),(0,s.jsx)("th",{children:e("storage.items")}),(0,s.jsx)("th",{children:e("storage.usage")}),(0,s.jsx)("th",{children:e("storage.updated")}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:I.map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"row",children:e(`storage.${t}`)}),(0,s.jsx)("td",{children:e(`storage.${t}Desc`)}),(0,s.jsx)("td",{children:$[t]}),(0,s.jsx)("td",{children:"drive"===t?L(B):e("storage.unknown")}),(0,s.jsx)("td",{children:A(t)}),(0,s.jsx)("td",{className:"wsRowEnd",children:(0,s.jsx)("button",{className:"rlBtn",disabled:!P||j||!R(t).length,onClick:()=>{y({kind:t,rows:R(t).slice(0,200)}),N(""),k(0)},children:e("storage.deleteData")})})]},t))})]})})}),(0,s.jsxs)(u.Card,{title:e("storage.manage"),plainHead:!0,children:[(0,s.jsx)(u.DetailRow,{title:e("storage.export"),note:e("storage.exportHint"),action:(0,s.jsx)("button",{className:"rlBtn",disabled:j||!E,onClick:()=>void z(),children:e("storage.export")})}),(0,s.jsx)("div",{className:"rlHint",children:_?e("storage.lastExport",{at:(0,u.stamp)(_)}):e("storage.neverExported")})]}),f&&(0,s.jsx)(u.Modal,{title:e("storage.deleteTitle",{name:e(`storage.${f.kind}`)}),onClose:()=>{j||y(null)},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{e.preventDefault(),F()},children:[(0,s.jsx)("p",{children:e("storage.deleteConfirm",{name:e(`storage.${f.kind}`),count:f.rows.length})}),"drive"===f.kind&&(0,s.jsx)("p",{className:"rlNote",children:e("storage.deleteDriveHint")}),"knowledge"===f.kind&&(0,s.jsx)("p",{className:"rlNote",children:e("storage.deleteKnowledgeHint")}),(0,s.jsx)("p",{className:"rlNote",children:e("storage.batchHint")}),(0,s.jsxs)("label",{className:"wsField",children:[e("storage.typeDelete"),(0,s.jsx)("input",{className:"rlInput",value:w,disabled:j,onChange:e=>N(e.target.value),autoFocus:!0})]}),j&&(0,s.jsxs)("p",{role:"status",children:[S," / ",f.rows.length]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",type:"button",disabled:j,onClick:()=>y(null),children:e("cancel")}),(0,s.jsx)("button",{className:"rlBtn danFill",disabled:j||"DELETE"!==w,children:e("delete")})]})]})})]})}],860643),e.s(["DeveloperSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),{tokens:a,loading:r,error:o,refetch:c,create:d,revoke:m,rename:p,rotate:h}=function(){let[e,s]=(0,i.useState)([]),[t,n]=(0,i.useState)(!0),[a,l]=(0,i.useState)(!1),r=(0,i.useCallback)(async()=>{n(!0),l(!1);try{let e=await (0,T.apiFetch)("/api/v1/developer/publish-tokens");if(!e.ok)throw Error("Could not load publishing credentials");s(await e.json())}catch{l(!0)}finally{n(!1)}},[]),o=(0,i.useCallback)(async(e,s=90)=>{let t=await (0,T.apiFetch)("/api/v1/developer/publish-tokens",{method:"POST",body:JSON.stringify({name:e,expires_in_days:s})}),i=await t.json();if(!t.ok)throw Error(i.detail||"Could not create publishing credential");return await r(),i},[r]),c=(0,i.useCallback)(async e=>{if(!(await (0,T.apiFetch)(`/api/v1/developer/publish-tokens/${e}`,{method:"DELETE"})).ok)throw Error("Could not revoke publishing credential");await r()},[r]);return(0,i.useEffect)(()=>{r()},[r]),{tokens:e,loading:t,error:a,create:o,revoke:c,rename:async(e,s)=>{let t=await (0,T.apiFetch)(`/api/v1/developer/publish-tokens/${e}`,{method:"PATCH",body:JSON.stringify({name:s})}),i=await t.json();if(!t.ok)throw Error(i.detail||"Could not rename publishing credential");await r()},rotate:async e=>{let s=await (0,T.apiFetch)(`/api/v1/developer/publish-tokens/${e}/rotate`,{method:"POST"}),t=await s.json();if(!s.ok)throw Error(t.detail||"Could not rotate publishing credential");return await r(),t},refetch:r}}(),x=(0,O.usePermissions)().has("developer.tokens.manage"),[g,b]=(0,i.useState)(null),[j,v]=(0,i.useState)(null),[f,y]=(0,i.useState)(""),[w,N]=(0,i.useState)(""),[S,k]=(0,i.useState)(null),[_,C]=(0,i.useState)(1),[E,P]=(0,i.useState)(10),[U,M]=(0,i.useState)(!1),B=a.filter(e=>!e.revoked).filter(e=>e.name.toLowerCase().includes(w.toLowerCase())),$=Math.max(1,Math.ceil(B.length/E)),A=Math.min(_,$),L=B.slice((A-1)*E,A*E),R=""!==w.trim();function F(e,s=null){v(s),y(s?.name??""),b(e)}async function I(){if(!U&&x){M(!0);try{let s=f.trim();"create"===g?k({token:(await d(s)).token,name:s}):j&&"edit"===g?await p(j.id,s):j&&"rotate"===g?k({token:(await h(j.id)).token,name:j.name}):j&&"delete"===g&&await m(j.id),b(null),l.toast.success(e("create"===g?"publishing.createdToast":"edit"===g?"publishing.updatedToast":"rotate"===g?"publishing.regeneratedToast":"publishing.deletedToast"))}catch(s){l.toast.error(s instanceof Error?s.message:e("saveFailed"))}finally{M(!1)}}}return(0,u.usePageTools)((0,s.jsxs)(s.Fragment,{children:[!x&&(0,s.jsx)("span",{className:"wsReadOnly",children:e("publishing.ownerOnly")}),(0,s.jsx)(u.CreateAction,{label:e("publishing.new"),disabled:!x,onClick:()=>F("create")}),(0,s.jsx)(u.SearchField,{value:w,label:e("publishing.searchLabel"),onChange:e=>{N(e),C(1)}})]}),[w,x]),(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)(u.Card,{plainHead:!0,children:[r?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):o?(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void c(),children:e("retry")})}):L.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(u.SortHead,{label:e("publishing.name")})}),(0,s.jsx)("th",{children:(0,s.jsx)(u.SortHead,{label:e("publishing.token")})}),(0,s.jsx)("th",{children:(0,s.jsx)(u.SortHead,{label:e("publishing.created")})}),(0,s.jsx)("th",{children:(0,s.jsx)(u.SortHead,{label:e("publishing.lastUsed")})}),(0,s.jsx)("th",{children:(0,s.jsx)(u.SortHead,{label:e("publishing.expires")})}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:L.map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("strong",{children:t.name})}),(0,s.jsxs)("td",{className:"mono",children:[t.token_prefix,"…"]}),(0,s.jsx)("td",{children:(0,u.stamp)(t.created_at)}),(0,s.jsx)("td",{children:t.last_used_at?(0,u.stamp)(t.last_used_at):e("publishing.never")}),(0,s.jsx)("td",{children:(0,u.stamp)(t.expires_at)}),(0,s.jsx)("td",{className:"wsRowEnd",children:x?(0,s.jsx)(u.RowMenu,{label:e("actions"),items:[{id:"edit",label:e("edit"),onSelect:()=>F("edit",t)},{id:"rotate",label:e("publishing.regenerate"),onSelect:()=>F("rotate",t)},{id:"delete",label:e("delete"),danger:!0,onSelect:()=>F("delete",t)}]}):(0,s.jsx)("span",{className:"wsRowNone",children:"-"})})]},t.id))})]})}):(0,s.jsx)(u.EmptyState,{title:e(R?"noResults":"publishing.empty"),note:e(R?"noResultsHint":"publishing.emptyHint"),action:!R&&x?(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>F("create"),children:e("publishing.new")}):void 0}),(0,s.jsx)(u.Pager,{page:A,pages:$,size:E,onPage:C,onSize:P,labels:{rows:e("rowsPerPage"),status:e("page",{page:A,total:$}),previous:e("previous"),next:e("next")}})]}),g&&(0,s.jsx)(u.Modal,{title:e("create"===g?"publishing.new":"edit"===g?"publishing.edit":"rotate"===g?"publishing.regenerate":"publishing.deleteTitle"),onClose:()=>{U||b(null)},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{e.preventDefault(),I()},children:["create"===g||"edit"===g?(0,s.jsxs)("label",{className:"wsField",children:[e("publishing.name"),(0,s.jsx)("input",{className:"rlInput",autoFocus:!0,required:!0,maxLength:50,value:f,onChange:e=>y(e.target.value)}),(0,s.jsxs)("span",{className:"wsCounter",children:[f.length,"/",50]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:j?.name}),(0,s.jsxs)("span",{className:"rlRowN",children:[j?.token_prefix,"…"]})]}),(0,s.jsx)("p",{className:"rlNote",children:e("rotate"===g?"publishing.regenerateConfirm":"publishing.deleteConfirm",{name:j?.name})})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",type:"button",disabled:U,onClick:()=>b(null),children:e("cancel")}),(0,s.jsx)("button",{className:`rlBtn ${"delete"===g||"rotate"===g?"danFill":"pri"}`,disabled:U||("create"===g||"edit"===g)&&!f.trim(),children:e(U?"saving":"delete"===g?"delete":"rotate"===g?"publishing.regenerate":"save")})]})]})}),S&&(0,s.jsx)(u.Modal,{title:e("publishing.secret"),onClose:()=>k(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:S.name}),(0,s.jsx)("span",{className:"rlRowN",children:e("publishing.name")})]}),(0,s.jsx)("p",{className:"rlNote",children:e("publishing.secretHint")}),(0,s.jsx)(u.SecretReveal,{token:S.token}),(0,s.jsx)("div",{className:"rlModalActions",children:(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>k(null),children:e("close")})})]})})]})}],284980);let z={profGlyph:"",profColor:"",profMark:"fill",orgGlyph:{},orgColor:{},orgFg:{},orgMark:"fill",permOv:{},permEdit:!1,teamScopes:{},voice:"cove",voiceModel:"live",voiceSpeed:"instant",voiceDetect:"auto",generalTab:"noti",skin:""};function V(){try{let e=window.localStorage.getItem(u.RELAY_PREFS_KEY);if(!e)return z;let s=JSON.parse(e);if(!s||"object"!=typeof s)return z;return{...z,...s}}catch{return z}}let q="palette:settings-relay-change";e.s(["useRelayPrefs",0,function(){let e,s,t,n,a,l=(0,B.c)(6),[r,o]=(0,i.useState)(z);l[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{o(V());let e=()=>
1o(V());return window.addEventListener(q,e),window.addEventListener("storage",e),()=>{window.removeEventListener(q,e),window.removeEventListener("storage",e)}},s=[],l[0]=e,l[1]=s):(e=l[0],s=l[1]),(0,i.useEffect)(e,s),l[2]===Symbol.for("react.memo_cache_sentinel")?(t=e=>{o(s=>{let t={...s,...e};try{window.localStorage.setItem(u.RELAY_PREFS_KEY,JSON.stringify(t))}catch{}return window.dispatchEvent(new Event(q)),t})},l[2]=t):t=l[2];let c=t;l[3]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{try{window.localStorage.removeItem(u.RELAY_PREFS_KEY)}catch{}o(z),window.dispatchEvent(new Event(q))},l[3]=n):n=l[3];let d=n;return l[4]!==r?(a={prefs:r,patch:c,reset:d},l[4]=r,l[5]=a):a=l[5],a}],119266)},843932,729914,e=>{"use strict";var s=e.i(843476),t=e.i(500932),i=e.i(154920),n=e.i(271645);e.i(785269);var a=e.i(322831),l=e.i(627542),r=e.i(846696),o=e.i(13080),c=e.i(48396),d=e.i(372428),u=e.i(915089),m=e.i(643531),p=e.i(299023),h=e.i(434163);function x(e){let i,n,l,r,o,c,m=(0,t.c)(40),{data:p}=e,{t:h,i18n:x}=(0,a.useTranslation)("workspaceSettings"),g=p.subscription;if("company"===p.plan.plan_type&&"active"===g.status&&g.scheduled_seats&&g.scheduled_seats_at){let e,t,i,n,a,l;m[0]!==g.scheduled_seats||m[1]!==h?(e=Object.entries(g.scheduled_seats).map(e=>{let[s,t]=e;return`${(0,u.planName)(h,{id:s})} \xd7 ${t}`}),m[0]=g.scheduled_seats,m[1]=h,m[2]=e):e=m[2];let r=e.join(" + ");return m[3]!==h?(t=h("subscription.scheduledSeatsTitle"),m[3]=h,m[4]=t):t=m[4],m[5]!==t?(i=(0,s.jsx)("strong",{children:t}),m[5]=t,m[6]=i):i=m[6],m[7]!==x.language||m[8]!==r||m[9]!==g.scheduled_seats_at||m[10]!==h?(n=h("subscription.scheduledSeatsBody",{seats:r,date:(0,d.formatDate)(g.scheduled_seats_at,x.language)}),m[7]=x.language,m[8]=r,m[9]=g.scheduled_seats_at,m[10]=h,m[11]=n):n=m[11],m[12]!==n?(a=(0,s.jsx)("span",{children:n}),m[12]=n,m[13]=a):a=m[13],m[14]!==i||m[15]!==a?(l=(0,s.jsxs)("div",{className:"sbScheduled",role:"status",children:[i,a]}),m[14]=i,m[15]=a,m[16]=l):l=m[16],l}if(!g.scheduled_change_type)return null;if(m[17]!==p.plan||m[18]!==x.language||m[19]!==g.scheduled_change_at||m[20]!==g.scheduled_change_type||m[21]!==g.scheduled_plan_id||m[22]!==g.scheduled_plan_name||m[23]!==h){let e,t=(0,d.formatDate)(g.scheduled_change_at,x.language),a="cancel_to_free"===g.scheduled_change_type;n="sbScheduled",l="status",m[28]!==a||m[29]!==h?(e=a?h("subscription.scheduledCancelTitle"):h("subscription.scheduledDowngradeTitle"),m[28]=a,m[29]=h,m[30]=e):e=m[30],m[31]!==e?(r=(0,s.jsx)("strong",{children:e}),m[31]=e,m[32]=r):r=m[32],i=a?h("subscription.scheduledCancelBody",{plan:(0,u.planName)(h,p.plan),date:t}):h("subscription.scheduledDowngradeBody",{plan:(0,u.planName)(h,p.plan),next:(0,u.planName)(h,{id:g.scheduled_plan_id??"",name:g.scheduled_plan_name??""}),date:t}),m[17]=p.plan,m[18]=x.language,m[19]=g.scheduled_change_at,m[20]=g.scheduled_change_type,m[21]=g.scheduled_plan_id,m[22]=g.scheduled_plan_name,m[23]=h,m[24]=i,m[25]=n,m[26]=l,m[27]=r}else i=m[24],n=m[25],l=m[26],r=m[27];return m[33]!==i?(o=(0,s.jsx)("span",{children:i}),m[33]=i,m[34]=o):o=m[34],m[35]!==n||m[36]!==l||m[37]!==r||m[38]!==o?(c=(0,s.jsxs)("div",{className:n,role:l,children:[r,o]}),m[35]=n,m[36]=l,m[37]=r,m[38]=o,m[39]=c):c=m[39],c}function g(e){let i,n,a,l,r=(0,t.c)(27),{value:o,max:c,state:d,label:u,ring:m,caption:p}=e;r[0]!==c||r[1]!==o?(i=c?Math.min(100,Math.round(o/c*100)):0,r[0]=c,r[1]=o,r[2]=i):i=r[2];let h=i;r[3]!==u||r[4]!==h?(n={role:"progressbar","aria-label":u,"aria-valuenow":h,"aria-valuemin":0,"aria-valuemax":100},r[3]=u,r[4]=h,r[5]=n):n=r[5];let x=n;if(m){let e,t,i,n,a,l,o=2*Math.PI*42,u=`sbRing ${d}`;r[6]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)("circle",{cx:"50",cy:"50",r:42}),r[6]=e):e=r[6];let m=o*(1-h/100);r[7]!==m?(t=(0,s.jsxs)("svg",{viewBox:"0 0 100 100","aria-hidden":"true",children:[e,(0,s.jsx)("circle",{cx:"50",cy:"50",r:42,strokeDasharray:o,strokeDashoffset:m})]}),r[7]=m,r[8]=t):t=r[8];let g=null===c?"—":`${h}%`;return r[9]!==g?(i=(0,s.jsx)("strong",{children:g}),r[9]=g,r[10]=i):i=r[10],r[11]!==p?(n=p&&(0,s.jsx)("span",{children:p}),r[11]=p,r[12]=n):n=r[12],r[13]!==i||r[14]!==n?(a=(0,s.jsxs)("div",{className:"sbRingValue",children:[i,n]}),r[13]=i,r[14]=n,r[15]=a):a=r[15],r[16]!==x||r[17]!==a||r[18]!==u||r[19]!==t?(l=(0,s.jsxs)("div",{className:u,...x,children:[t,a]}),r[16]=x,r[17]=a,r[18]=u,r[19]=t,r[20]=l):l=r[20],l}let g=`sbProgress ${d}`,b=`${h}%`;return r[21]!==b?(a=(0,s.jsx)("span",{style:{width:b}}),r[21]=b,r[22]=a):a=r[22],r[23]!==x||r[24]!==g||r[25]!==a?(l=(0,s.jsx)("div",{className:g,...x,children:a}),r[23]=x,r[24]=g,r[25]=a,r[26]=l):l=r[26],l}e.s(["PlanUsage",0,function({data:e,onViewPlans:t,onReload:i,onPending:l}){let{t:b,i18n:j}=(0,a.useTranslation)("workspaceSettings"),v=j.language,{user:f}=(0,o.useAuth)(),{plan:y,limits:w,usage:N,subscription:S,storage:k,permissions:_}=e,C="free"===y.id,E="company"===y.plan_type,T="enterprise"===y.id,[P,U]=(0,n.use
1State)(null),[M,B]=(0,n.useState)(!1),$=_.cancel&&!C&&(!E||!!S.self_serve),A="pending"===S.status;(0,n.useEffect)(()=>{U(null)},[y.id,$]);let L=N.pool_state??N.usage_state,R=E?N.seat:null,F=null===w.price_cents?b("subscription.negotiated"):b("subscription.perMonth",{amount:(0,d.formatUsd)(w.price_cents,v)}),O=E&&S.seats?Object.entries(S.seats).map(([e,s])=>`${(0,u.planName)(b,{id:e})} \xd7 ${s}`).join(" + "):String(w.seats),I=N.monthly_limit,D=N.monthly_remaining??0,H=N.rollover+N.welcome_balance+(N.topup_usable?N.topup_balance:0),z="active"===S.status?function(e,s,t=Date.now()){let i=Date.parse(e),n=Date.parse(s);if(!Number.isFinite(i)||!Number.isFinite(n)||n<=i)return null;let a=Math.max(1,Math.round((n-i)/864e5)),l=Math.min(a,Math.max(1,Math.floor((t-i)/864e5)+1));return{day:l,total:a,pct:Math.round(l/a*100)}}(S.cycle_started_at,S.cycle_ends_at):null,V=A||"exhausted"===L||"expired"===L?null:"topup"===L?N.rollover>0?"rollover":N.welcome_balance>0?"welcome":"topup":"allowance",q=[{id:"allowance",label:E?b("subscription.creditPool"):b("subscription.monthlyCredits"),amount:(0,d.formatCredits)(Math.max(0,D),v),off:!1},{id:"rollover",label:b("subscription.rollover"),amount:(0,d.formatCredits)(N.rollover,v),off:0===w.rollover_months&&0===N.rollover},{id:"welcome",label:b("subscription.welcomeCredits"),amount:(0,d.formatCredits)(N.welcome_balance,v),off:!1},{id:"topup",label:b("subscription.topupBalance"),amount:(0,d.formatCredits)(N.topup_balance,v),off:!N.topup_usable}],W=T&&null===I?{tone:"",text:b("subscription.enterpriseUsage")}:A?{tone:"warning",text:b("subscription.pendingNote")}:"expired"===L?{tone:"danger",text:b("subscription.expiredNote")}:"exhausted"===L?{tone:"danger",text:C?b("subscription.exhaustedFree"):b("subscription.exhaustedPaid",{plan:(0,u.planName)(b,y)})}:"topup"===L?{tone:"warning",text:b("subscription.topupInUse",{amount:(0,d.formatCredits)(H,v)})}:"warning"===L?{tone:"warning",text:C?b("subscription.warningFree"):b("subscription.remaining",{amount:(0,d.formatCredits)(D,v)})}:{tone:"",text:b("subscription.remaining",{amount:(0,d.formatCredits)(D,v)})};async function G(s,t){if(M||!$)return;B(!0);let n=null;try{let a=s.endsWith("/revert")?"revert_cancel":"cancel",o=`palette:subscription-purchase:${f?.id??""}:${e.organization_id}:${a}`;n=sessionStorage.getItem(o)??crypto.randomUUID(),sessionStorage.setItem(o,n);let c=await (0,u.billing)(s,{method:"POST",body:JSON.stringify({request_id:n})});if(c.status&&["new","creating","pending"].includes(c.status)){U(null),l(n);return}if(sessionStorage.removeItem(o),c.status&&"recorded"!==c.status)return void r.toast.error(b("subscription.paymentReview"));r.toast.success(b(t)),U(null),(0,d.notifySubscriptionChanged)(),i()}catch(e){r.toast.error(b(`subscription.errors.${e instanceof u.BillingError?e.code:"billing_request_failed"}`,{defaultValue:b("subscription.errors.billing_request_failed")})),n&&e instanceof u.BillingError&&(0===e.status||e.status>=500)&&(U(null),l(n))}finally{B(!1)}}return(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsx)(x,{data:e}),(0,s.jsx)(h.MemberLimitNotice,{data:e}),(0,s.jsx)(c.Card,{title:b(A?"subscription.targetPlan":"subscription.currentPlan"),plainHead:!0,className:"sbHero",children:(0,s.jsxs)("div",{className:"sbHeroPanel sbPanel",children:[(0,s.jsxs)("div",{className:"sbPlanHead",children:[(0,s.jsxs)("div",{className:"sbPlanId",children:[(0,s.jsxs)("div",{className:"sbPlanName",children:[(0,u.planName)(b,y)," ",(0,s.jsx)("span",{className:`sbBadge ${S.status}`,children:b(`subscription.status.${S.status}`)})]}),(0,s.jsx)("div",{className:"sbPlanPrice",children:F}),E&&(0,s.jsxs)("div",{className:"rlNote",children:[S.contract_name?`${S.contract_name} \xb7 `:"",b("subscription.nextBilling",{date:(0,d.formatDate)(S.next_billing_at,v)})]}),!E&&!C&&(0,s.jsx)("div",{className:"rlNote",children:b("subscription.nextBilling",{date:(0,d.formatDate)(S.next_billing_at,v)})}),C&&(0,s.jsx)("div",{className:"rlNote",children:b("subscription.freeRenews",{date:(0,d.formatDate)(S.cycle_ends_at,v)})})]}),(0,s.jsx)("div",{className:"sbPlanActions",children:A?(0,s.jsxs)(s.Fragment,{children:[S.pending_request_id&&(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>l(S.pending_request_id,!0),children:b("subscription.completePayment")}),E?!S.pending_request_id&&(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>(0,u.openContactSales)(e.contact_sales_url),children:b("subscription.contactSales")}):(0,s.jsx)("button",{className:`rlBtn ${S.pending_request_id?"":"pri"}`,disabled:!_.change_plan,title:_.change_plan?void 0:b("subscription.ownerOnly"),onClick:t,children:b(S.pending_request_id?"subscription.changePlan":"subscription.completePayment")})]}):E&&S.self_serve?(0,s.jsx)("button",{className:"rlBtn",onClick:()=>U("manage"),children:b("subscription.manageSubscription")}):E?(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>(0,u.openContactSales)(e.contact_sales_url),children:b("subscription.contactSales")}):C?(0,s.jsx)("button",{className:"rlBtn pri",onClick:t,children:b("subscription.viewPlans")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{className:"rlBtn pri",disabled:!_.change_plan,title:_.change_plan?void 0:b("subscription.ownerOnly"),onClick:t,children:b("subscription.changePlan")}),(0,s.jsx)("button",{className:"rlBtn",onClick:()=>U("manage"),children:b("subscription.manageSubscription")})]})})]}),z&&(0,s.jsxs)("div",{className:"sbCycle",children:[(0,s.jsx)("div",{className:"sbCycleBar",role:"progressbar","aria-label":b("subscription.cycleProgress"),"aria-valuenow":z.pct,"aria-valuemin":0,"aria-valuemax":100,children:(0,s.jsx)("span",{style:{width:`${z.pct}%`}})}),(0,s.jsxs)("div",{className:"sbCycleLabel",children:[(0,s.jsx)("span",{children:b("subscription.cycleDay",{day:z.day,total:z.total})}),(0,s.jsx)("span",{children:b("subscription.renewsOn",{date:(0,d.formatDate)(S.cycle_ends_at,v)})})]})]}),(0,s.jsxs)("div",{className:"sbMetrics",children:[(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:E?b("subscription.creditPool"):b("subscription.monthlyCredits")}),(0,s.jsx)("strong",{children:null===I?b("subscription.negotiated"):(0,d.formatCredits)(I,v)})]}),(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:C?b("subscription.welcomeCredits"):b("subscription.topupBalance")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(C?N.welcome_balance:N.topup_balance,v)})]}),(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:b("subscription.seats")}),(0,s.jsx)("strong",{className:E&&S.seats?"sbSmall":void 0,children:O})]}),(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:E?b("subscription.storagePool"):b("subscription.storage")}),(0,s.jsx)("strong",{children:null===w.storage_gb?b("subscription.negotiated"):(0,d.formatBytes)(0x40000000*w.storage_gb)})]})]})]})}),(0,s.jsx)(c.Card,{title:b("subscription.usage"),note:b("subscription.usageNote"),plainHead:!0,children:(0,s.jsxs)("div",{className:"sbUsage wsPadded",children:[(0,s.jsxs)("article",{className:`sbUsageCard sbUsageMain sbPanel ${W.tone}`,children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:E?b("subscription.poolUsage"):b("subscription.monthlyUsage")}),(0,s.jsx)("span",{children:null===I?b("subscription.negotiated"):`${(0,d.formatCredits)(N.monthly_used,v)} / ${(0,d.formatCredits)(I,v)}`})]}),(0,s.jsxs)("div",{className:"sbGauge",children:[(0,s.jsx)(g,{ring:!0,value:N.monthly_used,max:I,state:L,label:b(E?"subscription.poolUsage":"subscription.monthlyUsage"),caption:b("subscription.used")}),(0,s.jsxs)("div",{className:"sbGaugeSide",children:[(0,s.jsx)("div",{className:"sbGaugeBig",children:null===I?b("subscription.negotiated"):(0,d.formatCredits)(Math.max(0,D),v)}),(0,s.jsx)("div",{className:"sbK",children:b("subscription.left")}),(0,s.jsx)("div",{className:"sbProgressLabel",children:(0,s.jsx)("span",{children:b("subscription.renewsOn",{date:(0,d.formatDate)(S.cycle_ends_at,v)})})})]})]}),(0,s.jsx)("p",{className:`rlNote sbNote ${W.tone}`,children:W.text}),null!==I&&(0,s.jsx)("ol",{className:"sbOrder","aria-label":b("subscription.usageOrder"),children:q.map(e=>(0,s.jsxs)("li",{className:`${e.id===V?"on":""} ${e.off?"off":""}`,"aria-current":e.id===V?"step":void 0,children:[(0,s.jsxs)("span",{className:"sbOrderK",children:[e.label,e.id===V&&(0,s.jsx)("em",{children:b("subscription.now")})]}),(0,s.jsx)("strong",{children:e.amount})]},e.id))})]}),(0,s.jsxs)("div",{className:"sbUsageGrid",children:[R&&(0,s.jsxs)("article",{className:"sbUsageCard sbPanel",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:b("subscription.yourSeat")}),(0,s.jsx)("span",{children:`${(0,d.formatCredits)(R.used,v)} / ${(0,d.formatCredits)(R.credits,v)}`})]}),(0,s.jsx)(g,{value:R.used,max:R.credits,state:N.usage_state,label:b("subscription.yourSeat")}),(0,s.jsx)("p",{className:`rlNote sbNote ${"exhausted"===N.usage_state?"danger":"topup"===N.usage_state?"warning":""}`,children:b("exhausted"===N.usage_state?"subscription.seatExhaustedNote":"topup"===N.usage_state?"subscription.seatTopupNote":"subscription.seatNote",{amount:(0,d.formatCredits)(R.left,v),credits:(0,d.formatCredits)(R.credits,v)})})]}),C&&N.welcome_balance>0&&(0,s.jsxs)("article",{className:"sbUsageCard sbPanel",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:b("subscription.welcomeCredits")}),(0,s.jsx)("span",{children:(0,d.formatCredits)(N.welcome_balance,v)})]}),(0,s.jsx)(g,{value:N.welcome_balance,max:Math.max(N.welcome_balance,100),state:"normal",label:b("subscription.welcomeCredits")}),(0,s.jsx)("p",{className:"rlNote sbNote",children:b("subscription.welcomeNote")})]}),!C&&(N.rollover>0||N.topup_balance>0||N.welcome_balance>0)&&(0,s.jsxs)("article",{className:"sbUsageCard sbPanel",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:b("subscription.extraCredits")}),(0,s.jsx)("span",{children:(0,d.formatCredits)(H,v)})]}),(0,s.jsxs)("ul",{className:"sbBreakdown",children:[N.rollover>0&&(0,s.jsx)("li",{children:b("subscription.rolloverLine",{amount:(0,d.formatCredits)(N.rollover,v)})}),N.welcome_balance>0&&(0,s.jsx)("li",{children:b("subscription.welcomeLine",{amount:(0,d.formatCredits)(N.welcome_balance,v)})}),N.topup_balance>0&&(0,s.jsx)("li",{children:b(N.topup_usable?"subscription.topupLine":"subscription.topupLockedLine",{amount:(0,d.formatCredits)(N.topup_balance,v)})})]}),(0,s.jsx)("p",{className:"rlNote sbNote",children:b("subscription.extraNote")})]}),C&&N.topup_balance>0&&(0,s.jsxs)("article",{className:"sbUsageCard sbPanel",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:b("subscription.topupBalance")}),(0,s.jsx)("span",{children:(0,d.formatCredits)(N.topup_balance,v)})]}),(0,s.jsx)("p",{className:"rlNote sbNote warning",children:b("subscription.topupPreserved")})]}),(0,s.jsxs)("article",{className:"sbUsageCard sbPanel",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:b("subscription.storageUsage")}),(0,s.jsxs)("span",{children:[(0,d.formatBytes)(k.used_bytes),null!==k.limit_bytes?` / ${(0,d.formatBytes)(k.limit_bytes)}`:""]})]}),(0,s.jsx)(g,{value:k.used_bytes,max:k.limit_bytes,state:k.over_limit?"exhausted":"normal",label:b("subscription.storage")}),(0,s.jsx)("p",{className:`rlNote sbNote ${!k.upload_allowed?"danger":""}`,children:k.over_limit?b("subscription.storageOverLimit"):k.upload_allowed?b("subscription.storageOk"):b("expired"===S.status?"subscription.expiredToast":"subscription.storageUploadBlocked")}),!!k.reserved_bytes&&(0,s.jsx)("p",{className:"rlNote sbNote",children:b("subscription.storagePending",{amount:(0,d.formatBytes)(k.reserved_bytes)})})]})]})]})}),(0,s.jsx)(c.Card,{title:b("subscription.planLimits"),plainHead:!0,children:(0,s.jsxs)("div",{className:"sbLimits sbLimitGrid wsPadded",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:E?b("subscription.creditPool"):b("subscription.monthlyCredits")}),(0,s.jsx)("strong",{children:null===I?b("subscription.negotiated"):(0,d.formatCredits)(I,v)})]}),C&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.welcomeCredits")}),(0,s.jsx)("strong",{children:b("subscription.welcomeOnce")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.seats")}),(0,s.jsx)("strong",{children:O})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.storage")}),(0,s.jsx)("strong",{children:null===w.storage_gb?b("subscription.negotiated"):(0,d.formatBytes)(0x40000000*w.storage_gb)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.topup")}),(0,s.jsxs)("strong",{className:w.topup_allowed&&!E?"sbYes":E?"":"sbNo",children:[!E&&(w.topup_allowed?(0,s.jsx)(m.Check,{size:13,"aria-hidden":"true"}):(0,s.jsx)(p.Minus,{size:13,"aria-hidden":"true"})),w.topup_allowed&&!E?b("subscription.available"):E?b("subscription.contactSales"):b("subscription.notAvailable")]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.rollover")}),(0,s.jsxs)("strong",{className:w.rollover_months>0?"sbYes":"sbNo",children:[w.rollover_months>0?(0,s.jsx)(m.Check,{size:13,"aria-hidden":"true"}):(0,s.jsx)(p.Minus,{size:13,"aria-hidden":"true"}),w.rollover_months>0?b("subscription.rolloverMonths",{count:w.rollover_months}):b("subscription.none")]})]})]})}),"manage"===P&&(0,s.jsx)(c.Modal,{title:b("subscription.manageSubscription"),onClose:()=>U(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("div",{className:"sbLimits",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.currentPlan")}),(0,s.jsx)("strong",{children:(0,u.planName)(b,y)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.status.label")}),(0,s.jsx)("strong",{children:b(`subscription.status.${S.status}`)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.billingPeriodEnd")}),(0,s.jsx)("strong",{children:(0,d.formatDate)(S.cycle_ends_at,v)})]}),S.scheduled_change_type&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.scheduledChange")}),(0,s.jsx)("strong",{children:"cancel_to_free"===S.scheduled_change_type?b("subscription.switchToFree",{date:(0,d.formatDate)(S.scheduled_change_at,v)}):b("subscription.changeTo",{plan:(0,u.planName)(b,{id:S.scheduled_plan_id??"",name:S.scheduled_plan_name??""}),date:(0,d.formatDate)(S.scheduled_change_at,v)})})]})]}),!_.cancel&&(0,s.jsx)("p",{className:"rlNote",children:b("subscription.ownerOnlyCancel")}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>U(null),children:b("close")}),(0,s.jsx)("button",{className:"rlBtn",disabled:!_.change_plan,onClick:()=>{U(null),t()},children:b("subscription.changePlan")}),"cancel_to_free"===S.scheduled_change_type?(0,s.jsx)("button",{className:"rlBtn pri",disabled:!_.cancel||M,onClick:()=>void G("subscription/cancel/revert","subscription.cancelReverted"),children:b("subscription.revertCancel")}):(0,s.jsx)("button",{className:"rlBtn dan",disabled:!_.cancel,onClick:()=>U("cancel"),children:b("subscription.cancelSubscription")})]})]})}),"cancel"===P&&$&&(0,s.jsx)(c.Modal,{title:b("subscription.cancelConfirmTitle"),onClose:()=>U(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("div",{className:"sbLimits",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.currentPlan")}),(0,s.jsx)("strong",{children:(0,u.planName)(b,y)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.billingPeriodEnd")}),(0,s.jsx)("strong",{children:(0,d.formatDate)(S.cycle_ends_at,v)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:b("subscription.freeFrom")}),(0,s.jsx)("strong",{children:(0,d.formatDate)(S.cycle_ends_at,v)})]})]}),(0,s.jsxs)("ul",{className:"sbBullets",children:[(0,s.jsx)("li",{children:b("subscription.cancelKeepsBenefits",{date:(0,d.formatDate)(S.cycle_ends_at,v)})}),(0,s.jsx)("li",{children:b("subscription.cancelTopupLocked")}),null!==k.limit_bytes&&(0,s.jsx)("li",{children:b("subscription.cancelStorageWarning")}),(0,s.jsx)("li",{children:b("subscription.cancelRevertHint")})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>U("manage"),children:b("cancel")}),(0,s.jsx)("button",{className:"rlBtn danFill",disabled:M||!$,onCli
1ck:()=>void G("subscription/cancel","subscription.cancelScheduled"),children:b("subscription.confirmCancel")})]})]})})]})},"Progress",0,g,"ScheduledBanner",0,x],729914);let b=new Set(["trial","purchase","released"]);function j(e,s,i,l,r,o){let c,m,p,h,x,g=(0,t.c)(19),b=void 0===i?1:i,j=void 0===l?3:l,v=void 0===r?"":r,f=void 0===o?"all":o,{t:y,i18n:w}=(0,a.useTranslation)("workspaceSettings"),[N,S]=(0,n.useState)(null),[k,_]=(0,n.useState)(!1),[C,E]=(0,n.useState)(0);g[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],g[0]=c):c=g[0];let[T,P]=(0,n.useState)(c),U=(0,n.useRef)(0);g[1]!==s||g[2]!==w.language||g[3]!==e||g[4]!==b||g[5]!==v||g[6]!==j||g[7]!==f||g[8]!==y?(m=async()=>{let t=U.current=U.current+1;if(!s){S([]),E(0);return}S(null),_(!1);try{let s=new URLSearchParams({page:String(b),limit:String(j),q:v,status:f}),i=await (0,u.billing)(`purchases/${e}?${s}`);if(t!==U.current)return;let n=(e,s)=>new Intl.NumberFormat(w.language,{style:"currency",currency:s}).format(e/100);S(i.items.map(s=>({id:s.id,date:s.created_at,kind:e,primary:"credit"===e?y("subscription.creditsAmount",{amount:(0,d.formatCredits)(s.credits,w.language)}):(0,u.planName)(y,{id:s.plan_id??"",name:s.plan_name??void 0}),amount:n(s.amount_cents,s.currency),method:s.payment_method??"—",status:s.status,transactionId:s.transaction_id??s.id,receipt:s.receipt_available,tax:n(s.tax_cents,s.currency),refunded:n(s.refunded_cents,s.currency)}))),E(i.total),P(i.statuses)}catch{t===U.current&&(_(!0),S([]))}},g[1]=s,g[2]=w.language,g[3]=e,g[4]=b,g[5]=v,g[6]=j,g[7]=f,g[8]=y,g[9]=m):m=g[9];let M=m;return g[10]!==M?(p=()=>(M(),()=>{U.current=U.current+1}),h=[M],g[10]=M,g[11]=p,g[12]=h):(p=g[11],h=g[12]),(0,n.useEffect)(p,h),g[13]!==k||g[14]!==M||g[15]!==N||g[16]!==T||g[17]!==C?(x={rows:N,error:k,total:C,statuses:T,reload:M},g[13]=k,g[14]=M,g[15]=N,g[16]=T,g[17]=C,g[18]=x):x=g[18],x}function v(e){let i,n,l=(0,t.c)(7),{status:r}=e,{t:o}=(0,a.useTranslation)("workspaceSettings"),c=`sbTag status ${r}`,d=`subscription.purchaseStatus.${r}`;return l[0]!==r||l[1]!==o||l[2]!==d?(i=o(d,{defaultValue:r}),l[0]=r,l[1]=o,l[2]=d,l[3]=i):i=l[3],l[4]!==c||l[5]!==i?(n=(0,s.jsx)("span",{className:c,children:i}),l[4]=c,l[5]=i,l[6]=n):n=l[6],n}function f(e){let i,n,l,r,o,d,u,m,p,h,x,g,b,j=(0,t.c)(37),{rows:f,onSelect:y,compact:w}=e,{t:N}=(0,a.useTranslation)("workspaceSettings");if(j[0]!==N?(i=N("subscription.date"),j[0]=N,j[1]=i):i=j[1],j[2]!==i?(n=(0,s.jsx)("th",{children:i}),j[2]=i,j[3]=n):n=j[3],j[4]!==N?(l=N("subscription.item"),j[4]=N,j[5]=l):l=j[5],j[6]!==l?(r=(0,s.jsx)("th",{children:l}),j[6]=l,j[7]=r):r=j[7],j[8]!==N?(o=N("subscription.amount"),j[8]=N,j[9]=o):o=j[9],j[10]!==o?(d=(0,s.jsx)("th",{children:o}),j[10]=o,j[11]=d):d=j[11],j[12]!==w||j[13]!==N?(u=!w&&(0,s.jsx)("th",{children:N("subscription.paymentMethod")}),j[12]=w,j[13]=N,j[14]=u):u=j[14],j[15]!==N?(m=N("subscription.status.label"),j[15]=N,j[16]=m):m=j[16],j[17]!==m?(p=(0,s.jsx)("th",{children:m}),j[17]=m,j[18]=p):p=j[18],j[19]!==n||j[20]!==r||j[21]!==d||j[22]!==u||j[23]!==p?(h=(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[n,r,d,u,p]})}),j[19]=n,j[20]=r,j[21]=d,j[22]=u,j[23]=p,j[24]=h):h=j[24],j[25]!==w||j[26]!==y||j[27]!==f){let e;j[29]!==w||j[30]!==y?(e=e=>(0,s.jsxs)("tr",{className:"sbClickable",tabIndex:0,onClick:()=>y(e),onKeyDown:s=>{("Enter"===s.key||" "===s.key)&&(s.preventDefault(),y(e))},children:[(0,s.jsx)("td",{children:(0,c.stamp)(e.date)}),(0,s.jsx)("td",{children:e.primary}),(0,s.jsx)("td",{children:e.amount}),!w&&(0,s.jsx)("td",{children:e.method}),(0,s.jsx)("td",{children:(0,s.jsx)(v,{status:e.status})})]},e.id),j[29]=w,j[30]=y,j[31]=e):e=j[31],x=f.map(e),j[25]=w,j[26]=y,j[27]=f,j[28]=x}else x=j[28];return j[32]!==x?(g=(0,s.jsx)("tbody",{children:x}),j[32]=x,j[33]=g):g=j[33],j[34]!==h||j[35]!==g?(b=(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[h,g]})}),j[34]=h,j[35]=g,j[36]=b):b=j[36],b}function y({row:e,onClose:t}){let{t:i}=(0,a.useTranslation)("workspaceSettings"),[l,o]=(0,n.useState)(!1),[d,m]=(0,n.use
1State)(!1);async function p(){o(!0),m(!1);try{let s=await (0,u.billing)(`orders/${encodeURIComponent(e.transactionId)}/receipt`);"ready"===s.status&&s.url?window.location.assign(s.url):m(!0)}catch{r.toast.error(i("subscription.receiptError"))}finally{o(!1)}}return(0,s.jsx)(c.Modal,{title:i("credit"===e.kind?"subscription.creditDetail":"subscription.paymentDetail"),onClose:t,children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("div",{className:"sbLimits",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.status.label")}),(0,s.jsx)("strong",{children:(0,s.jsx)(v,{status:e.status})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.date")}),(0,s.jsx)("strong",{children:(0,c.stamp)(e.date)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.item")}),(0,s.jsx)("strong",{children:e.primary})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.amount")}),(0,s.jsx)("strong",{children:e.amount})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.tax")}),(0,s.jsx)("strong",{children:e.tax})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.refundedAmount")}),(0,s.jsx)("strong",{children:e.refunded})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.paymentMethod")}),(0,s.jsx)("strong",{children:e.method})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:i("subscription.transactionId")}),(0,s.jsx)("strong",{className:"sbMono",children:e.transactionId})]})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:t,children:i("close")}),(0,s.jsx)("button",{className:"rlBtn",disabled:!e.receipt||l,title:e.receipt?void 0:i("subscription.receiptUnavailable"),onClick:()=>void p(),children:i(l?"loading":"subscription.downloadReceipt")})]}),d&&(0,s.jsx)("p",{role:"status",className:"rlHint",children:i("subscription.receiptPreparing")})]})})}e.s(["CreditsBilling",0,function({data:e,onViewPlans:m,onHistory:p}){let{t:h,i18n:x}=(0,a.useTranslation)("workspaceSettings"),{user:v}=(0,o.useAuth)(),w=x.language,{plan:N,usage:S,permissions:k}=e,_="free"===N.id,C="company"===N.plan_type,E=!_&&!C&&k.topup&&e.limits.topup_allowed&&"active"===e.subscription.status,[T,P]=(0,n.useState)(()=>"payment"===new URLSearchParams(window.location.search).get("subtab")?"payment":"credits"),[U,M]=(0,n.useState)(null),[B,$]=(0,n.useState)([]),[A,L]=(0,n.useState)(!1),[R,F]=(0,n.useState)(!1),[O,I]=(0,n.useState)(!1),[D,H]=(0,n.useState)(null),[z,V]=(0,n.useState)(!1),[q,W]=(0,n.useState)(0),[G,K]=(0,n.useState)(null),[J,Y]=(0,n.use
1State)(null),[X,Q]=(0,n.useState)(!1),[Z,ee]=(0,n.useState)(null),es=(0,n.useRef)(!1),et=`palette:credit-purchase:${v?.id??""}:${e.organization_id}`,ei=j("credit",!_&&!C&&k.history),en=function(e,s){let i,a,l,r,o=(0,t.c)(9),[c,d]=(0,n.useState)(null),[m,p]=(0,n.useState)(!1);o[0]!==e?(i=async()=>{if(!e)return void d([]);d(null),p(!1);try{d(await (0,u.billing)("transactions?limit=50"))}catch{p(!0),d([])}},o[0]=e,o[1]=i):i=o[1];let h=i;return o[2]!==h?(a=()=>{h()},l=[h],o[2]=h,o[3]=a,o[4]=l):(a=o[3],l=o[4]),(0,n.useEffect)(a,l),o[5]!==m||o[6]!==h||o[7]!==c?(r={rows:c,error:m,reload:h},o[5]=m,o[6]=h,o[7]=c,o[8]=r):r=o[8],r}(!_&&!C&&k.history,e.organization_id),[ea,el]=(0,n.useState)(!1),er=j("subscription",!_&&!C&&k.history),eo=ei.reload,ec=en.reload;(0,n.useEffect)(()=>{E||K(null)},[E]),(0,n.useEffect)(()=>{if(_||C||!k.view)return;let e=!0;return H(null),V(!1),(0,u.billing)("payment-methods").then(s=>{e&&H(s.items)}).catch(()=>{e&&V(!0)}),()=>{e=!1}},[_,C,k.view,e.organization_id,q]);let ed=e=>`${e.brand??e.type}${e.last4?` •••• ${e.last4}`:""}`,eu=D?.find(e=>e.default),em=(0,n.useCallback)(async()=>{L(!1);try{let[e,s]=await Promise.all([(0,u.billing)("balance"),(0,u.billing)("packs")]);M(e),$(s);let t=sessionStorage.getItem(`${et}:draft`);t&&E&&(K(s.find(e=>
1e.id===t)??null),P("credits"),sessionStorage.removeItem(`${et}:draft`))}catch{L(!0)}},[et,E]),ep=(0,n.useCallback)(async e=>{try{let s=await (0,u.billing)(`topups/${encodeURIComponent(e)}`);if(Y(s),Q(!1),u.EMPTY_PACK_STATUSES.has(s.status)){sessionStorage.removeItem(et);let e=new URL(window.location.href);e.searchParams.delete("topup"),window.history.replaceState(null,"",e.toString()),await em(),await eo(),await ec(),(0,d.notifySubscriptionChanged)()}}catch(e){if(e instanceof u.BillingError&&404===e.status){let e=new URL(window.location.href);e.searchParams.delete("topup"),window.history.replaceState(null,"",e.toString()),Y(null),Q(!1);return}Q(!0)}},[em,et,eo,ec]);(0,n.useEffect)(()=>{em();let e=new URLSearchParams(window.location.search).get("topup");e&&/^[0-9a-f-]{36}$/i.test(e)&&ep(e)},[em,ep]);let eh=J?.id,ex=!!J&&["creating","pending"].includes(J.status);async function eg(e){if(!es.current&&E&&!A&&U?.payments_enabled&&U.can_purchase&&U.topup_allowed){es.current=!0,F(!0),Q(!1);try{let s=sessionStorage.getItem(et),t=s?JSON.parse(s):null,i=t?.pack===e.id?t:{id:crypto.randomUUID(),pack:e.id};sessionStorage.setItem(et,JSON.stringify(i));let n=s=>(0,u.billing)("topups",{method:"POST",body:JSON.stringify({request_id:s,pack:e.id})}),a=await n(i.id);if(i===t&&u.EMPTY_PACK_STATUSES.has(a.status)){let s={id:crypto.randomUUID(),pack:e.id};sessionStorage.setItem(et,JSON.stringify(s)),a=await n(s.id)}K(null),Y(a),a.checkout_url&&["creating","pending"].includes(a.status)?window.location.assign(a.checkout_url):await ep(a.id)}catch(e){Q(!0),r.toast.error(h(`subscription.errors.${e instanceof u.BillingError?e.code:"billing_request_failed"}`,{defaultValue:h("subscription.errors.billing_request_failed")}))}finally{es.current=!1,F(!1)}}}async function eb(){if(!O&&!_&&!C&&k.payment){I(!0);try{G&&sessionStorage.setItem(`${et}:draft`,G.id);let{url:e}=await (0,u.billing)("payment-portal",{method:"POST"});window.location.assign(e)}catch(e){sessionStorage.removeItem(`${et}:draft`),r.toast.error(h(`subscription.errors.${e instanceof u.BillingError?e.code:"billing_request_failed"}`,{defaultValue:h("subscription.errors.billing_request_failed")}))}finally{I(!1)}}}if((0,n.useEffect)(()=>{let e;if(!eh||!ex)return;let s=0,t=!0;async function i(){await ep(eh),t&&++s<40&&(e=setTimeout(i,3e3))}return e=setTimeout(i,3e3),()=>{t=!1,clearTimeout(e)}},[eh,ex,ep]),C)return(0,s.jsx)(c.Card,{title:h("subscription.companyBillingTitle"),plainHead:!0,children:(0,s.jsx)(c.EmptyState,{title:h("subscription.companyBillingLead"),note:h("subscription.companyBillingHint"),action:(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>(0,u.openContactSales)(e.contact_sales_url),children:h("subscription.contactSales")})})});if(_)return(0,s.jsxs)(c.Card,{title:h("subscription.freeBillingTitle"),plainHead:!0,children:[(0,s.jsx)(c.EmptyState,{title:h("subscription.freeBillingLead"),note:h("subscription.freeBillingHint"),action:(0,s.jsx)("button",{className:"rlBtn pri",onClick:m,children:h("subscription.viewPlans")})}),S.topup_balance>0&&(0,s.jsx)("p",{className:"rlHint",role:"status",children:h("subscription.topupPreservedLong",{amount:(0,d.formatCredits)(S.topup_balance,w)})})]});let ej=B.find(e=>2500===e.price_cents)?.id??null,ev=S.available??0,ef=ea?en.rows??[]:(en.rows??[]).slice(0,3),ey=e=>k.history?null===e.rows?(0,s.jsx)(i.PaletteLoader,{label:h("loading")}):e.error?(0,s.jsxs)("div",{className:"rlHint",role:"alert",children:[h("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void e.reload(),children:h("retry")})]}):0===e.rows.length?(0,s.jsx)(c.EmptyState,{title:h("subscription.noHistory"),note:h("subscription.noHistoryHint")}):(0,s.jsx)(f,{rows:e.rows.slice(0,3),onSelect:ee,compact:!0}):(0,s.jsx)("div",{className:"rlEmpty",children:h("subscription.historyPermission")});return(0,s.jsxs)(l.Tabs.Root,{className:"rlStack",value:T,onValueChange:e=>P(e),children:[(0,s.jsx)(l.Tabs.List,{className:"wsTabs sbTabs","aria-label":h("subscription.billingCredits"),children:["credits","payment"].map(e=>(0,s.jsx)(l.Tabs.Trigger,{value:e,className:`wsTab ${T===e?"on":""}`,children:h(`subscription.tab.${e}`)},e))}),A&&(0,s.jsxs)("div",{className:"rlHint",role:"alert",children:[h("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void em(),children:h("retry")})]}),(0,s.jsx)(l.Tabs.Content,{value:"credits",children:(0,s.jsxs)("div",{className:"rlStack sbOverview",children:[(0,s.jsxs)("section",{className:"sbMetrics sbSummary sbPanel","aria-label":h("billing.title"),children:[(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:h("subscription.available")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(ev,w)}),(0,s.jsx)("small",{children:h("subscription.creditsUnit")})]}),(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:h("subscription.monthlyUsage")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(S.monthly_used,w)}),(0,s.jsx)("small",{children:h("subscription.creditsUnit")})]}),(0,s.jsxs)("div",{className:"sbMetric",children:[(0,s.jsx)("span",{children:h("subscription.topupBalance")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(S.topup_balance,w)}),(0,s.jsx)("small",{children:h("subscription.creditsUnit")})]})]}),(0,s.jsxs)("section",{className:"sbMonth","aria-label":h("subscription.monthlyUsage"),children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:h("subscription.monthlyUsage")}),(0,s.jsx)("strong",{children:S.monthly_limit?`${Math.min(100,Math.round(S.monthly_used/S.monthly_limit*100))}%`:"—"})]}),(0,s.jsx)(g,{value:S.monthly_used,max:S.monthly_limit,state:S.usage_state,label:h("subscription.monthlyUsage")}),(0,s.jsxs)("div",{className:"sbProgressLabel",children:[(0,s.jsxs)("span",{children:[(0,d.formatCredits)(S.monthly_used,w)," ",h("subscription.used")]}),(0,s.jsx)("span",{children:h("subscription.limitOf",{amount:(0,d.formatCredits)(S.monthly_limit,w)})})]})]}),(0,s.jsxs)("section",{className:"sbHistory","aria-label":h("billing.history"),children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:h("billing.history")}),k.history&&!ea&&(en.rows?.length??0)>3&&(0,s.jsx)("button",{type:"button",className:"sbLink",onClick:()=>el(!0),children:h("subscription.viewAll")})]}),k.history?null===en.rows?(0,s.jsx)(i.PaletteLoader,{label:h("loading")}):en.error?(0,s.jsxs)("div",{className:"rlHint",role:"alert",children:[h("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void en.reload(),children:h("retry")})]}):0===en.rows.length?(0,s.jsx)(c.EmptyState,{title:h("billing.empty"),note:h("subscription.noHistoryHint")}):(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix sbLedger",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:h("subscription.date")}),(0,s.jsx)("th",{children:h("billing.activity")}),(0,s.jsx)("th",{children:h("subscription.classification")}),(0,s.jsx)("th",{children:h("billing.amount")}),(0,s.jsx)("th",{children:h("subscription.status.label")})]})}),(0,s.jsx)("tbody",{children:ef.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,c.stamp)(e.created_at)}),(0,s.jsx)("td",{children:(0,s.jsx)("strong",{children:h(`billing.kind.${e.kind}`,{defaultValue:e.kind})})}),(0,s.jsx)("td",{children:"usage"===e.kind?h("subscription.ledgerUse"):b.has(e.kind)?h("subscription.ledgerCharge"):h(`billing.kind.${e.kind}`,{defaultValue:e.kind})}),(0,s.jsxs)("td",{className:`sbAmount ${e.credits>0?"positive":""}`,children:[e.credits>0?"+":e.credits<0?"-":"",(0,d.formatCredits)(Math.abs(e.credits),w)]}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"sbTag status paid",children:h("subscription.purchaseStatus.paid")})})]},e.id))})]})}):(0,s.jsx)("div",{className:"rlEmpty",children:h("subscription.historyPermission")}),ea&&(0,s.jsx)("p",{className:"rlHint",children:h("billing.recent")}
1)]})]})}),(0,s.jsx)(l.Tabs.Content,{value:"payment",children:(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)(c.Card,{title:h("subscription.buyCredits"),note:h("subscription.topupRate"),plainHead:!0,children:[E?(0,s.jsxs)(s.Fragment,{children:[U&&!U.payments_enabled&&(0,s.jsx)("div",{className:"rlHint",children:h("billing.unavailable")}),U||A?!A&&0===B.length&&(0,s.jsx)("p",{className:"rlHint",children:h("billing.noPacks")}):(0,s.jsx)("p",{className:"rlHint",role:"status",children:h("loading")}),(0,s.jsx)("div",{className:"sbTopupGrid sbPanel",children:B.map(e=>(0,s.jsxs)("article",{className:`sbPack ${e.id===ej?"recommended":""}`,children:[e.id===ej&&(0,s.jsx)("span",{className:"sbTag recommended",children:h("subscription.recommended")}),(0,s.jsx)("div",{className:"sbPackCredits",children:h("subscription.creditsAmount",{amount:(0,d.formatCredits)(e.credits,w)})}),(0,s.jsx)("div",{className:"sbPackPrice",children:(0,d.formatUsd)(e.price_cents,w)}),(0,s.jsx)("button",{className:"rlBtn pri",disabled:R||A||!U?.payments_enabled||!U.can_purchase||!U.topup_allowed,onClick:()=>K(e),children:h("subscription.buy")})]},e.id))}),(0,s.jsx)("p",{className:"rlHint",children:h("billing.checkoutHint")})]}):(0,s.jsx)("div",{className:"rlEmpty",children:h("pending"===e.subscription.status?"subscription.pendingNote":"active"!==e.subscription.status?"subscription.expiredNote":e.limits.topup_allowed?"subscription.ownerOnlyTopup":"subscription.notAvailable")}),X&&(0,s.jsx)("p",{className:"rlHint",role:"alert",children:h("billing.paymentError")}),J&&(0,s.jsxs)("div",{className:"rlHint",role:"status",children:[h(`billing.status.${J.status}`,{defaultValue:h("billing.status.pending")})," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void ep(J.id),children:h("billing.refresh")})]})]}),(0,s.jsx)(c.Card,{title:h("subscription.topupBalanceTitle"),note:h("subscription.topupOrder"),plainHead:!0,children:(0,s.jsx)("div",{className:"wsPadded",children:(0,s.jsxs)("div",{className:"sbBalance",children:[(0,s.jsx)("span",{children:h("subscription.topupBalance")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(S.topup_balance,w)})]})})}),(0,s.jsx)(c.Card,{title:h("subscription.paymentMethod"),plainHead:!0,children:(0,s.jsxs)("div",{className:"sbPaymentRow wsPadded",children:[(0,s.jsxs)("div",{children:[z?(0,s.jsxs)("p",{role:"alert",children:[h("billing.loadError")," ",(0,s.jsx)("button",{className:"rlBtn",onClick:()=>W(e=>e+1),children:h("retry")})]}):null===D?(0,s.jsx)("p",{role:"status",children:h("loading")}):0===D.length?(0,s.jsx)("p",{children:h("subscription.noPaymentMethod")}):D.map(e=>(0,s.jsxs)("div",{className:"sbPaymentMethod",children:[(0,s.jsx)("strong",{children:ed(e)}),e.exp_month&&e.exp_year&&(0,s.jsxs)("span",{children:[" · ",String(e.exp_month).padStart(2,"0"),"/",e.exp_year]}),e.default&&(0,s.jsx)("span",{className:"sbTag",children:h("subscription.defaultMethod")})]},e.id)),(0,s.jsx)("div",{className:"rlNote",children:h("subscription.paymentMethodNote")})]}),k.payment&&(0,s.jsx)("button",{className:"rlBtn",disabled:O,onClick:()=>void eb(),children:h(O?"billing.opening":"subscription.manage")})]})}),(0,s.jsx)(c.Card,{title:h("subscription.recentCredits"),actions:k.history&&(0,s.jsx)("button",{className:"rlBtn sm",onClick:()=>p("credit"),children:h("subscription.viewAll")}),plainHead:!0,children:ey(ei)}),(0,s.jsx)(c.Card,{title:h("subscription.recentPayments"),actions:k.history&&(0,s.jsx)("button",{className:"rlBtn sm",onClick:()=>p("subscription"),children:h("subscription.viewAll")}),plainHead:!0,children:ey(er)})]})}),G&&E&&(0,s.jsx)(c.Modal,{title:h("subscription.buyCredits"),onClose:()=>K(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"sbLead",children:h("subscription.buyConfirm",{amount:(0,d.formatCredits)(G.credits,w)})}),(0,s.jsx)("p",{className:"rlNote",children:h("subscription.topupOrder")}),(0,s.jsxs)("div",{className:"sbLimits",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:h("subscription.creditsToBuy")}),(0,s.jsx)("strong",{children:(0,d.formatCredits)(G.credits,w)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:h("subscription.amount")}),(0,s.jsx)("strong",{children:(0,d.formatUsd)(G.price_cents,w)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{children:h("subscription.paymentMethod")}),(0,s.jsx)("strong",{children:eu?ed(eu):h("subscription.paymentAtCheckout")}),k.payment&&(0,s.jsx)("button",{type:"button",className:"rlBtn sm",disabled:O,onClick:()=>void eb(),children:h("subscription.changePaymentMethod")})]})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>K(null),children:h("cancel")}),(0,s.jsx)("button",{className:"rlBtn pri",disabled:R||A||!U?.payments_enabled||!U.can_purchase||!U.topup_allowed,onClick:()=>void eg(G),children:h(R?"billing.opening":"subscription.buy")})]})]})}),Z&&(0,s.jsx)(y,{row:Z,onClose:()=>ee(null)})]})},"HistoryPage",0,function(e){let l,r,o,d,u,m,p,h,x,g,b,v,w,N,S,k,_,C,E,T,P,U,M,B,$,A,L,R=(0,t.c)(88),{kind:F,enabled:O,onBack:I}=e,{t:D}
1=(0,a.useTranslation)("workspaceSettings"),[H,z]=(0,n.useState)(""),[V,q]=(0,n.useState)("all"),[W,G]=(0,n.useState)(1),[K,J]=(0,n.useState)(10),[Y,X]=(0,n.useState)(null),{rows:Q,error:Z,total:ee,statuses:es,reload:et}=j(F,O,W,K,H,V),ei=Math.max(1,Math.ceil(ee/K));R[0]!==Q?(l=Q??[],R[0]=Q,R[1]=l):l=R[1];let en=l;R[2]!==H||R[3]!==V?(r=H.trim().length>0||"all"!==V,R[2]=H,R[3]=V,R[4]=r):r=R[4];let ea=r;if(R[5]!==W||R[6]!==ei?(o=()=>{W>ei&&G(ei)},d=[W,ei],R[5]=W,R[6]=ei,R[7]=o,R[8]=d):(o=R[7],d=R[8]),(0,n.useEffect)(o,d),!O){let e,t,i,n;return R[9]!==D?(e=D("subscription.historyPermission"),R[9]=D,R[10]=e):e=R[10],R[11]!==D?(t=D("subscription.billingCredits"),R[11]=D,R[12]=t):t=R[12],R[13]!==I||R[14]!==t?(i=(0,s.jsx)("button",{className:"rlBtn",onClick:I,children:t}),R[13]=I,R[14]=t,R[15]=i):i=R[15],R[16]!==e||R[17]!==i?(n=(0,s.jsxs)("div",{role:"alert",className:"rlHint",children:[e," ",i]}),R[16]=e,R[17]=i,R[18]=n):n=R[18],n}R[19]!==D?(u=D("subscription.billingCredits"),R[19]=D,R[20]=u):u=R[20],R[21]!==I||R[22]!==u?(m=(0,s.jsxs)("button",{type:"button",className:"rlBtn sm",onClick:I,children:["← ",u]}),R[21]=I,R[22]=u,R[23]=m):m=R[23];let el="credit"===F?"subscription.creditHistory":"subscription.paymentHistory";if(R[24]!==D||R[25]!==el?(p=D(el),R[24]=D,R[25]=el,R[26]=p):p=R[26],R[27]!==p?(h=(0,s.jsx)("span",{children:p}),R[27]=p,R[28]=h):h=R[28],R[29]!==m||R[30]!==h?(x=(0,s.jsxs)("div",{className:"sbBreadcrumb",children:[m,h]}),R[29]=m,R[30]=h,R[31]=x):x=R[31],R[32]!==D?(g=D("subscription.searchHistory"),R[32]=D,R[33]=g):g=R[33],R[34]===Symbol.for("react.memo_cache_sentinel")?(b=e=>{z(e),G(1)},R[34]=b):b=R[34],R[35]!==H||R[36]!==g?(v=(0,s.jsx)(c.SearchField,{value:H,label:g,onChange:b}),R[35]=H,R[36]=g,R[37]=v):v=R[37],R[38]!==D?(w=D("subscription.status.label"),R[38]=D,R[39]=w):w=R[39],R[40]===Symbol.for("react.memo_cache_sentinel")?(N=e=>{q(e),G(1)},R[40]=N):N=R[40],R[41]!==D?(S=D("all"),R[41]=D,R[42]=S):S=R[42],R[43]!==S?(k={value:"all",label:S},R[43]=S,R[44]=k):k=R[44],R[45]!==es||R[46]!==D||R[47]!==k){let e;R[49]!==D?(e=e=>({value:e,label:D(`subscription.purchaseStatus.${e}`,{defaultValue:e})}
1),R[49]=D,R[50]=e):e=R[50],_=[k,...es.map(e)],R[45]=es,R[46]=D,R[47]=k,R[48]=_}else _=R[48];return R[51]!==V||R[52]!==w||R[53]!==_?(C=(0,s.jsx)(c.RlSelect,{label:w,value:V,onChange:N,options:_}),R[51]=V,R[52]=w,R[53]=_,R[54]=C):C=R[54],R[55]!==et?(E=()=>void et(),R[55]=et,R[56]=E):E=R[56],R[57]!==D?(T=D("retry"),R[57]=D,R[58]=T):T=R[58],R[59]!==E||R[60]!==T?(P=(0,s.jsx)("button",{className:"rlBtn",onClick:E,children:T}),R[59]=E,R[60]=T,R[61]=P):P=R[61],R[62]!==v||R[63]!==C||R[64]!==P?(U=(0,s.jsxs)("div",{className:"wsToolbar wsPadded",children:[v,C,P]}),R[62]=v,R[63]=C,R[64]=P,R[65]=U):U=R[65],R[66]!==Z||R[67]!==ea||R[68]!==Q||R[69]!==D||R[70]!==en?(M=null===Q?(0,s.jsx)(i.PaletteLoader,{label:D("loading")}):Z?(0,s.jsx)("div",{className:"rlEmpty",role:"alert",children:D("billing.loadError")}):0===en.length?(0,s.jsx)(c.EmptyState,{title:D(ea?"noResults":"subscription.noHistory"),note:D(ea?"noResultsHint":"subscription.noHistoryHint")}):(0,s.jsx)(f,{rows:en,onSelect:X}),R[66]=Z,R[67]=ea,R[68]=Q,R[69]=D,R[70]=en,R[71]=M):M=R[71],R[72]!==W||R[73]!==ei||R[74]!==K||R[75]!==D||R[76]!==ee?(B=ee>0&&(0,s.jsx)(c.Pager,{page:W,pages:ei,size:K,onPage:G,onSize:e=>{J(e),G(1)},labels:{rows:D("rowsPerPage"),status:D("page",{page:W,pages:ei}),previous:D("previous"),next:D("next")}}),R[72]=W,R[73]=ei,R[74]=K,R[75]=D,R[76]=ee,R[77]=B):B=R[77],R[78]!==U||R[79]!==M||R[80]!==B?($=(0,s.jsxs)(c.Card,{plainHead:!0,children:[U,M,B]}),R[78]=U,R[79]=M,R[80]=B,R[81]=$):$=R[81],R[82]!==Y?(A=Y&&(0,s.jsx)(y,{row:Y,onClose:()=>X(null)}),R[82]=Y,R[83]=A):A=R[83],R[84]!==x||R[85]!==$||R[86]!==A?(L=(0,s.jsxs)("div",{className:"rlStack",children:[x,$,A]}),R[84]=x,R[85]=$,R[86]=A,R[87]=L):L=R[87],L}],843932)},799064,e=>{"use strict";var s=e.i(843476),t=e.i(500932);e.i(785269);var i=e.i(322831),n=e.i(915089),a=e.i(372428);e.s(["PlanCard",0,function(e){let l,r,o,c,d,u,m,p,h,x,g,b,j,v,f,y,w,N,S,k,_,C,E,T,P,U,M,B,$,A,L=(0,t.c)(90),{plan:R,locale:F,className:O,badges:I,children:D}=e,{t:H}=(0,i.useTranslation)("workspaceSettings"),z="company"===R.plan_type,V=z&&"enterprise"!==R.id,q=`sbPlanCard ${void 0===O?"":O}`;return L[0]!==q?(l=q.trim(),L[0]=q,L[1]=l):l=L[1],L[2]!==R||L[3]!==H?(r=(0,n.planName)(H,R),L[2]=R,L[3]=H,L[4]=r):r=L[4],L[5]!==r?(o=(0,s.jsx)("h3",{children:r}),L[5]=r,L[6]=o):o=L[6],L[7]!==I||L[8]!==o?(c=(0,s.jsxs)("header",{children:[o,I]}),L[7]=I,L[8]=o,L[9]=c):c=L[9],L[10]!==F||L[11]!==R||L[12]!==H?(d=(0,n.planPrice)(H,R,F),L[10]=F,L[11]=R,L[12]=H,L[13]=d):d=L[13],L[14]!==d?(u=(0,s.jsx)("div",{className:"sbPlanCardPrice",children:d}),L[14]=d,L[15]=u):u=L[15],L[16]!==z||L[17]!==V||L[18]!==H?(m=H(V?"subscription.creditsPerSeat":z?"subscription.creditPool":"subscription.monthlyCredits"),L[16]=z,L[17]=V,L[18]=H,L[19]=m):m=L[19],L[20]!==m?(p=(0,s.jsx)("dt",{children:m}),L[20]=m,L[21]=p):p=L[21],L[22]!==F||L[23]!==R.monthly_credits||L[24]!==H?(h=null===R.monthly_credits?H("subscription.negotiated"):(0,a.formatCredits)(R.monthly_credits,F),L[22]=F,L[23]=R.monthly_credits,L[24]=H,L[25]=h):h=L[25],L[26]!==h?(x=(0,s.jsx)("dd",{children:h}),L[26]=h,L[27]=x):x=L[27],L[28]!==p||L[29]!==x?(g=(0,s.jsxs)("div",{children:[p,x]}),L[28]=p,L[29]=x,L[30]=g):g=L[30],L[31]!==z||L[32]!==V||L[33]!==H?(b=H(V?"subscription.storagePerSeat":z?"subscription.storagePool":"subscription.storage"),L[31]=z,L[32]=V,L[33]=H,L[34]=b):b=L[34],L[35]!==b?(j=(0,s.jsx)("dt",{children:b}),L[35]=b,L[36]=j):j=L[36],L[37]!==R.storage_gb||L[38]!==H?(v=null===R.storage_gb?H("subscription.negotiated"):(0,a.formatBytes)(0x40000000*R.storage_gb),L[37]=R.storage_gb,L[38]=H,L[39]=v):v=L[39],L[40]!==v?(f=(0,s.jsx)("dd",{children:v}),L[40]=v,L[41]=f):f=L[41],L[42]!==j||L[43]!==f?(y=(0,s.jsxs)("div",{children:[j,f]}),L[42]=j,L[43]=f,L[44]=y):y=L[44],L[45]!==H?(w=H("subscription.seats"),L[45]=H,L[46]=w):w=L[46],L[47]!==w?(N=(0,s.jsx)("dt",{children:w}),L[47]=w,L[48]=N):N=L[48],L[49]!==R.seat_max||L[50]!==R.seat_min||L[51]!==H?(S=null===R.seat_max?H("subscription.seatsPlus",{count:R.seat_min}):R.seat_min===R.seat_max?R.seat_min:`${R.seat_min}–${R.seat_max}`,L[49]=R.seat_max,L[50]=R.seat_min,L[51]=H,L[52]=S):S=L[52],L[53]!==S?(k=(0,s.jsx)("dd",{children:S}),L[53]=S,L[54]=k):k=L[54],L[55]!==N||L[56]!==k?(_=(0,s.jsxs)("div",{children:[N,k]}),L[55]=N,L[56]=k,L[57]=_):_=L[57],L[58]!==H?(C=H("subscription.topup"),L[58]=H,L[59]=C):C=L[59],L[60]!==C?(E=(0,s.jsx)("dt",{children:C}),L[60]=C,L[61]=E):E=L[61],L[62]!==z||L[63]!==R.topup_allowed||L[64]!==H?(T=H(z?"subscription.contactSales":R.topup_allowed?"subscription.available":"subscription.notAvailable"),L[62]=z,L[63]=R.topup_allowed,L[64]=H,L[65]=T):T=L[65],L[66]!==T?(P=(0,s.jsx)("dd",{children:T}),L[66]=T,L[67]=P):P=L[67],L[68]!==E||L[69]!==P?(U=(0,s.jsxs)("div",{children:[E,P]}),L[68]=E,L[69]=P,L[70]=U):U=L[70],L[71]!==R.rollover_months||L[72]!==H?(M=R.rollover_months>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{children:H("subscription.rollover")}),(0,s.jsx)("dd",{children:H("subscription.rolloverMonths",{count:R.rollover_months})})]}),L[71]=R.rollover_months,L[72]=H,L[73]=M):M=L[73],L[74]!==R.id||L[75]!==H?(B="free"===R.id&&(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{children:H("subscription.welcomeCredits")}),(0,s.jsx)("dd",{children:H("subscription.welcomeOnce")})]}),L[74]=R.id,L[75]=H,L[76]=B):B=L[76],L[77]!==g||L[78]!==y||L[79]!==_||L[80]!==U||L[81]!==M||L[82]!==B?($=(0,s.jsxs)("dl",{className:"sbPlanCardMetrics",children:[g,y,_,U,M,B]}),L[77]=g,L[78]=y,L[79]=_,L[80]=U,L[81]=M,L[82]=B,L[83]=$):$=L[83],L[84]!==D||L[85]!==l||L[86]!==$||L[87]!==c||L[88]!==u?(A=(0,s.jsxs)("article",{className:l,children:[c,u,$,D]}),L[84]=D,L[85]=l,L[86]=$,L[87]=c,L[88]=u,L[89]=A):A=L[89],A}])},915089,e=>{"use strict";var s=e.i(209165),t=e.i(372428);
1class i extends Error{code;status;constructor(e,s){super(e),this.code=e,this.status=s}}async function n(e,t){let n;try{n=await (0,s.apiFetch)(`/api/v1/billing/${e}`,t)}catch(e){throw new i("object"==typeof e.detail&&e.detail?.code?e.detail.code:"billing_request_failed",e.status??0)}if(!n.ok)throw new i("billing_request_failed",n.status);return n.json()}let a=new Set(["paid","refunded","partially_refunded","failed","expired"]);e.s(["BillingError",0,i,"EMPTY_PACK_STATUSES",0,a,"billing",0,n,"openContactSales",0,function(e){window.open(e,"_blank","noopener,noreferrer")},"planName",0,function(e,s){return s?e(`plans.${s.id}`,{defaultValue:s.name??s.id}):e("plans.free",{defaultValue:"Free"})},"planPrice",0,function(e,s,i){if(null===s.price_cents)return e("subscription.negotiated");let n=(0,t.formatUsd)(s.price_cents,i);return e("company"===s.plan_type&&"enterprise"!==s.id?"subscription.perSeatMonth":"subscription.perMonth",{amount:n})}])},816245,476405,879002,150646,286536,77705,e=>{"use strict";var s=e.i(843476),t=e.i(500932),i=e.i(271645),n=e.i(40807),a=e.i(975157),l=e.i(48396),r=e.i(119266),o=e.i(71647);e.i(785269);var c=e.i(322831);let d=[{id:"noti",label:"Notifications"}],u=["rowPalette","rowExternalLlms","rowExternalMcp","rowExternalConnectors"],m=[{id:"low",label:"LOW",value:.25},{id:"med",label:"MED",value:.45},{id:"high",label:"HIGH",value:.75},{id:"max",label:"MAX",value:1}];function p(){return(0,n.getNotificationSoundPreferences)()}e.s(["GeneralSection",0,function(){let e,h,x,g,b,j,v,f,y,w,N=(0,t.c)(30),{t:S}=(0,c.useTranslation)(),{prefs:k,patch:_}=(0,r.useRelayPrefs)(),{secure:C,orgSecure:E,ownSecure:T,ownLocked:P,canManageOrg:U,busy:M,setOrgSecure:B,setOwnSecure:$}=(0,o.useSecureMode)(),[A,L]=(0,i.useState)(p);N[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=()=>L((0,n.getNotificationSoundPreferences)());return e(),window.addEventListener(n.NOTIFICATION_SOUND_CHANGE_EVENT,e),window.addEventListener("storage",e),()=>{window.removeEventListener(n.NOTIFICATION_SOUND_CHANGE_EVENT,e),window.removeEventListener("storage",e)}},h=[],N[0]=e,N[1]=h):(e=N[0],h=N[1]),(0,i.useEffect)(e,h),N[2]===Symbol.for("react.memo_cache_sentinel")?(x=(e,s)=>{let t=(0,n.setNotificationSoundPreferences)(e);L(t),void 0!==s&&s&&t.enabled&&(0,n.previewNotificationSound)(t)},N[2]=x):x=N[2];let R=x,F=k.generalTab||"noti";if(N[3]===Symbol.for("react.memo_cache_sentinel")?(g={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",rowGap:8,marginBottom:14,maxWidth:940,borderBottom:"1px solid var(--rl-border-strong)",paddingBottom:10},N[3]=g):g=N[3],N[4]!==_||N[5]!==S||N[6]!==F?(b=d.map(e=>(0,s.jsx)("button",{type:"button","aria-pressed":F===e.id,onClick:()=>_({generalTab:e.id}),className:(0,a.cn)("rlBtn","md",F===e.id&&"pri"),style:{height:28},children:S(`settingsUi.general.tabs.${e.id}`,{defaultValue:e.label})},e.id)),N[4]=_,N[5]=S,N[6]=F,N[7]=b):b=N[7],N[8]!==S?(j=S("settingsUi.general.newSettingGroupsWillLine"),N[8]=S,N[9]=j):j=N[9],N[10]!==j?(v=(0,s.jsx)("span",{className:"rlCardNote",children:j}),N[10]=j,N[11]=v):v=N[11],N[12]!==b||N[13]!==v?(f=(0,s.jsxs)("div",{style:g,children:[b,v]}),N[12]=b,N[13]=v,N[14]=f):f=N[14],N[15]!==U||N[16]!==E||N[17]!==P||N[18]!==T||N[19]!==C||N[20]!==M||N[21]!==B||N[22]!==$||N[23]!==A||N[24]!==S||N[25]!==F){var O;let e;y="noti"===F&&(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)(l.Card,{title:S("settingsUi.general.notificationSound"),note:S("settingsUi.general.playShortSoundWhenLive"),actions:(0,s.jsx)("button",{type:"button",className:"rlBtn md",style:{marginLeft:"auto"},onClick:()=>{let e=A.enabled?A:(0,n.setNotificationSoundPreferences)({enabled:!0});L(e),(0,n.previewNotificationSound)(e)},children:"▶ TEST"}),children:[(0,s.jsxs)("div",{className:"rlGrid2",style:{padding:14},children:[(0,s.jsx)(l.OptionCard,{title:S("settingsUi.general.soundOn"),desc:S("settingsUi.general.playToneEveryNewNotification"),selected:A.enabled,onSelect:()=>R({enabled:!0},!0)}),(0,s.jsx)(l.OptionCard,{title:S("settingsUi.general.soundOff"),desc:S("settingsUi.general.badgesToastsOnlyNoAudio"),selected:!A.enabled,onSelect:()=>R({enabled:!1})})]}),(0,s.jsxs)("div",{className:"rlRow",children:[(0,s.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:600},children:S("settingsUi.general.tone")}),(0,s.jsx)("span",{className:"rlStepN",style:{flex:"none"},children:(e=n.NOTIFICATION_SOUND_TONES.find(e=>e.id===A.tone))?S(`settingsUi.general.toneLabel.${e.id}`,{defaultValue:e.label}):A.tone}),(0,s.jsx)("span",{style:{marginLeft:"auto"},children:(0,s.jsx)(l.Seg,{ariaLabel:S("settingsUi.general.toneAria","Notification tone"),value:A.tone,onChange:e=>R({tone:e,enabled:!0},!0),options:n.NOTIFICATION_SOUND_TONES.map(e=>({id:e.id,label:S(`settingsUi.general.toneShort.${e.id}`,{defaultValue:e.label.replace(/-style|\s*chime|\s*tri-tone/gi,"").trim().toUpperCase()||e.id.toUpperCase()})}))})})]}),(0,s.jsxs)("div",{className:"rlRow",children:[(0,s.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:600},children:S("settingsUi.general.volume")}),(0,s.jsxs)("span",{className:"rlStepN",style:{flex:"none"},children:[Math.round(100*A.volume),"%"]}),(0,s.jsx)("span",{style:{marginLeft:"auto"},children:(0,s.jsx)(l.Seg,{ariaLabel:S("settingsUi.general.volumeAria","Notification volume"),value:(O=A.volume,m.reduce((e,s)=>Math.abs(s.value-O)<Math.abs(e.value-O)?s:e,m[1]).id),onChange:e=>{let s=m.find(s=>
1s.id===e);s&&R({volume:s.value,enabled:!0},!0)},options:m.map(e=>({id:e.id,label:S(`settingsUi.general.volumeLevel.${e.id}`,{defaultValue:e.label})}))})})]}),(0,s.jsxs)("div",{className:"rlHint",children:[S("settingsUi.general.audioUnlockHint","Browsers need one click before audio can play — press TEST once after signing in if the first alert is silent.")," ",S("settingsUi.general.storedInThisBrowser","This preference is stored in this browser.")]})]}),(0,s.jsxs)(l.Card,{title:S("settingsUi.general.secure"),note:S("settingsUi.general.secureNote"),actions:(0,s.jsx)("span",{className:"rlTag",style:{marginLeft:"auto"},children:C?S("settingsUi.general.secureStatusSecure"):S("settingsUi.general.secureStatusStandard")}),children:[(0,s.jsxs)("div",{className:"rlGrid2",style:{padding:14},children:[(0,s.jsx)(l.OptionCard,{title:S("settingsUi.general.standard"),desc:S("settingsUi.general.externalModelsConnectorsMcpAllowed"),selected:!C,disabled:P||M,onSelect:()=>$(!1)}),(0,s.jsx)(l.OptionCard,{title:S("settingsUi.general.secureOption"),desc:S("settingsUi.general.onlyPaletteLlmAiTech"),selected:C,disabled:P||M,onSelect:()=>$(!0)})]}),(0,s.jsx)(l.DetailRow,{title:S("settingsUi.general.secureOrgWide","Whole workspace"),note:U?S("settingsUi.general.secureOrgWideNote","Forces SECURE on every member. Owners and admins only."):S("settingsUi.general.secureAdminOnly"),action:(0,s.jsx)(l.Seg,{ariaLabel:S("settingsUi.general.secureOrgWide","Whole workspace"),options:[{id:"off",label:S("settingsUi.general.standard")},{id:"on",label:S("settingsUi.general.secureOption")}],value:E?"on":"off",disabled:!U||M,onChange:e=>B("on"===e)})}),u.map(e=>{let t="rowPalette"===e||!C;return(0,s.jsx)(l.DetailRow,{title:(0,s.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:9},children:[(0,s.jsx)("span",{className:(0,a.cn)("rlSelDot",t&&"on"),style:{width:8,height:8}}),S(`settingsUi.general.${e}`)]}),note:"",action:(0,s.jsx)("span",{className:"rlTag",children:t?S("settingsUi.general.allowed"):S("settingsUi.general.blocked")})},e)}),(0,s.jsxs)("div",{className:"rlHint",children:[S("settingsUi.general.secureHint"),P?` ${S("settingsUi.general.secureOrgLocked","SECURE is on for the whole workspace, so your own switch cannot turn it off.")}`:T?` ${S("settingsUi.general.secureOwnOn","SECURE is on for your account only — it does not change what your teammates can use.")}`:""]})]})]}),N[15]=U,N[16]=E,N[17]=P,N[18]=T,N[19]=C,N[20]=M,N[21]=B,N[22]=$,N[23]=A,N[24]=S,N[25]=F,N[26]=y}else y=N[26];return N[27]!==f||N[28]!==y?(w=(0,s.jsxs)("div",{children:[f,y]}),N[27]=f,N[28]=y,N[29]=w):w=N[29],w}],816245);var h=e.i(452726);let x=[{id:"ko",desc:"Korean body text · English signatures (labels, buttons, tags) are kept"},{id:"en",desc:"English across every surface — labels, body and document output"},{id:"ja",desc:"Japanese body text · English signatures (labels, buttons, tags) are kept"}],g={ko:"ko-KR",en:"en-US",ja:"ja-JP"},b=[{id:"cove",name:"Cove",tone:"Calm and direct",from:"#DDE4FB",to:"#8FA6F5"},{id:"ember",name:"Ember",tone:"Warm and unhurried",from:"#F7DFCF",to:"#E0885A"},{id:"slate",name:"Slate",tone:"Dry and precise",from:"#DCE1E4",to:"#6E7A82"},{id:"fern",name:"Fern",tone:"Bright and brief",from:"#D7EADD",to:"#5B9E72"}],j=[{id:"live",label:"Live"},{id:"pro",label:"Advanced"},{id:"std",label:"Standard"}],v=[{id:"instant",label:"Instant"},{id:"balanced",label:"Balanced"},{id:"careful",label:"Careful"}],f=[{id:"auto",label:"Auto"},{id:"ui",label:"UI language"}];e.s(["LanguageSection",0,function(){let{t:e}=(0,c.useTranslation)(),{i18n:t}=(0,c.useTranslation)(),{prefs:n,patch:o}=(0,r.useRelayPrefs)(),[d,u]=(0,i.useState)(""),m=(0,h.normalizeLanguage)(t.language),p=b.find(e=>e.id===n.voice)??b[0];return(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)(l.Card,{title:e("settingsUi.language.interfaceLanguage"),count:"AUTO-SAVED",plainHead:!0,children:[(0,s.jsx)("div",{style:{padding:"12px 14px",display:"grid",gridTemplateColumns:"repeat(auto-fit,minmax(240px,1fr))",gap:10},children:x.map(i=>(0,s.jsx)(l.OptionCard,{title:h.LANGUAGE_LABELS[i.id].native,desc:e(`settingsUi.lang.langDesc.${i.id}`,{defaultValue:i.desc}),selected:m===i.id,onSelect:()=>{var e;return e=i.id,void((0,h.setManualLanguageOverride)(e),t.changeLanguage(e),window.dispatchEvent(new Event("palette:language-change")))},trailing:(0,s.jsx)("span",{className:(0,a.cn)("rlSelDot",m===i.id&&"on")})},i.id))}),(0,s.jsx)("div",{className:"rlHint",children:e("settingsUi.lang.bilingualDoctrine","Interface language — English for signatures (tags, titles, labels, buttons), your chosen language for body. Signatures persist across language changes.")})]}),(0,s.jsxs)(l.Card,{title:e("settingsUi.language.voice"),note:e("settingsUi.language.voiceAgentsSpeakWith"),actions:(0,s.jsxs)(s.Fragment,{children:[d&&(0,s.jsx)("span",{className:"rlOk",children:d}),(0,s.jsx)("button",{type:"button",className:"rlBtn md",style:{marginLeft:d?void 0:"auto"},onClick:()=>{u(`${p.name} preview playing…`);try{let s=new SpeechSynthesisUtterance(e("settingsUi.lang.voicePreview","Palette Agent voice preview."));s.lang=g[m],s.rate="instant"===n.voiceSpeed?1.1:"careful"===n.voiceSpeed?.85:1,s.onend=()=>u(""),window.speechSynthesis?.cancel(),window.speechSynthesis?.speak(s)}catch{u("Voice preview is not available in this browser")}window.setTimeout(()=>u(""),4e3)},children:"▶ PREVIEW"})]}),children:[(0,s.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(178px,1fr))",gap:10,padding:14},children:b.map(t=>{let i=n.voice===t.id;return(0,s.jsxs)("button",{type:"button","aria-pressed":i,onClick:()=>o({voice:t.id}),className:(0,a.cn)("rlOpt",i&&"on"),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 11px",borderRadius:11}
1,children:[(0,s.jsx)("span",{style:{width:34,height:34,flex:"none",borderRadius:"50%",background:`linear-gradient(140deg,${t.from} 0%,${t.to} 100%)`,boxShadow:"inset 0 0 0 1px rgba(23,23,23,.06)"}}),(0,s.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[i&&(0,s.jsx)("span",{className:"rlFieldLabel",style:{fontSize:10},children:t.name}),(0,s.jsx)("span",{style:{fontSize:12.5,fontWeight:600,lineHeight:1.5},children:e(`settingsUi.lang.voiceTone.${t.id}`,{defaultValue:t.tone})})]}),(0,s.jsx)("span",{className:(0,a.cn)("rlSelDot",i&&"on"),style:{width:8,height:8}})]},t.id)})}),[{label:e("settingsUi.lang.voiceModel","Model"),options:j,value:n.voiceModel,key:"voiceModel"},{label:e("settingsUi.lang.voiceResponse","Response"),options:v,value:n.voiceSpeed,key:"voiceSpeed"},{label:e("settingsUi.lang.voiceRecognition","Recognition"),options:f,value:n.voiceDetect,key:"voiceDetect"}].map(t=>{let i;return(0,s.jsxs)("div",{className:"rlRow",children:[(0,s.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:600},children:t.label}),(0,s.jsx)("span",{className:"rlStepN",style:{flex:"none"},children:(i=t.options.find(e=>e.id===t.value)??t.options[0],e(`settingsUi.lang.voiceOptions.${i.id}`,{defaultValue:i.label}))}),(0,s.jsx)("span",{style:{marginLeft:"auto"},children:(0,s.jsx)(l.Seg,{ariaLabel:t.label,value:t.value,onChange:e=>o({[t.key]:e}),options:t.options.map(s=>({...s,label:e(`settingsUi.lang.voiceOptions.${s.id}`,{defaultValue:s.label})}))})})]},t.key)})]})]})}],476405);var y=e.i(154920),w=e.i(768214),w=w,N=e.i(827330);e.s(["UserPlus",()=>N.default],879002);var N=N,S=e.i(846696),k=e.i(13080),_=e.i(752270),C=e.i(762603),E=e.i(372428),T=e.i(209165),P=e.i(323240);let U=["admin","member"];e.s(["MembersSection",0,function(){let{t:e}=(0,c.useTranslation)("workspaceSettings"),{user:t}=(0,k.useAuth)(),{members:n,loading:a,error:r,refetch:o,inviteMember:d,updateRole:u,removeMember:m}=(0,C.useOrgMembers)(),{sentInvitations:p,cancelInvitation:h,refetch:x}=(0,_.useInvitations)(),[g,b]=(0,i.useState)(""),[j,v]=(0,i.useState)("all"),[f,M]=(0,i.useState)(1),[B,$]=(0,i.useState)(10),[A,L]=(0,i.useState)(null),[R,F]=(0,i.useState)(null),[O,I]=(0,i.useState)(null),[D,H]=(0,i.useState)(""),[z,V]=(0,i.useState)("member"),[q,W]=(0,i.useState)(!1),{has:G}=(0,P.usePermissions)(),K=G("members.invite"),J=G("members.roles.change"),Y=G("members.remove"),X=K||J||Y,{data:Q}=(0,E.useSubscription)(),Z=Q?.limits.seats??null,ee=null!==Z&&n.length>=Z,es=Q?.permissions.change_plan??!1,et=ee&&(0,s.jsxs)("div",{className:"rlBanner",role:"alert",children:[(0,s.jsx)("span",{className:"rlBannerText",children:e("members.seatsFull",{used:n.length,limit:Z})}),es&&(0,s.jsxs)("button",{type:"button",className:"rlBtn sm",onClick:()=>{let e=new URL(window.location.href);e.searchParams.set("section","billing"),window.history.pushState(null,"",`${e.pathname}${e.search}`),window.dispatchEvent(new Event("palette:locationchange"))},children:[e("members.upgradePlan")," →"]})]}),ei=n.filter(e=>("all"===j||e.role===j)&&`${e.name} ${e.email}`.toLowerCase().includes(g.toLowerCase())),en=Math.max(1,Math.ceil(ei.length/B)),ea=Math.min(f,en),el=ei.slice((ea-1)*B,ea*B),er=""!==g.trim()||"all"!==j,eo=p.filter(e=>"pending"===e.status||"expired"===e.status),ec=e=>"expired"===e.status||Date.parse(e.expires_at)<Date.now();async function ed(){if(!q&&X&&("invite"!==A||!ee)){W(!0);try{if("invite"===A&&(await d({email:D.trim(),role:z}),await x(!0)),"role"===A&&R&&await u(R.id,z),"remove"===A&&R&&await m(R.id),"cancel"===A&&O&&await h(O.id),"resend"===A&&O){let s=await (0,T.apiFetch)(`/api/v1/invitations/${O.id}/resend`,{method:"POST"});if(!s.ok){let t=await s.json().catch(()=>({}));throw Error(t.detail||e("saveFailed"))}await x(!0)}S.toast.success(e("invite"===A||"resend"===A?"members.inviteSent":"remove"===A?"members.removed":"cancel"===A?"members.invitationCancelled":"members.roleSaved")),L("cancel"===A||"resend"===A?"invitations":null)}catch(s){S.toast.error(s instanceof Error?s.message:e("saveFailed"))}finally{W(!1)}}}let eu=()=>{H(""),V("member"),L("invite")};return(0,l.usePageTools)((0,s.jsxs)(s.Fragment,{children:[!X&&(0,s.jsx)("span",{className:"wsReadOnly",children:e("readOnly")}),(0,s.jsx)(l.IconAction,{label:`${e("members.invitations")} (${eo.length})`,disabled:!K,onClick:()=>L("invitations"),children:(0,s.jsx)(w.default,{size:17,"aria-hidden":"true"})}),(0,s.jsx)(l.IconAction,{label:e("members.invite"),disabled:!K,onClick:eu,children:(0,s.jsx)(N.default,{size:17,"aria-hidden":"true"})}),(0,s.jsx)(l.SearchField,{value:g,label:e("members.searchLabel"),onChange:e=>{b(e),M(1)}})]}),[g,eo.length,K,X]),(0,s.jsxs)("div",{className:"rlStack",children:[et,(0,s.jsx)(l.MetaRow,{count:er?e("members.filtered",{count:ei.length,total:n.length}):e("members.count",{count:n.length})}),(0,s.jsxs)(l.Card,{plainHead:!0,children:[a?(0,s.jsx)(y.PaletteLoader,{label:e("loading")}):r?(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void o(),children:e("retry")})}):el.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix wsPeople",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(l.SortHead,{label:`${e("name")} / ${e("members.email")}`})}),(0,s.jsx)("th",{children:(0,s.jsx)(l.SortHead,{label:e("members.teams")})}),(0,s.jsx)("th",{children:(0,s.jsx)(l.SortHead,{label:e("members.role")})}),(0,s.jsx)("th",{children:(0,s.jsx)(l.SortHead,{label:e("members.joined"),active:!0,dir:"asc"})}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:el.map(i=>
1{let n=i.id===t?.id,a=i.teams?.map(e=>e.name)??[],r=!n&&"owner"!==i.role;return(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsxs)("span",{className:"wsPerson",children:[(0,s.jsx)(l.Mark,{size:32,color:"var(--os-accent)",children:(0,l.initialsOf)(i.name,i.email).slice(0,1)}),(0,s.jsxs)("span",{className:"wsPersonCopy",children:[(0,s.jsxs)("span",{className:"wsPersonName",children:[i.name||i.email,n&&(0,s.jsx)("em",{children:e("members.you")})]}),(0,s.jsx)("span",{className:"wsPersonMail",children:i.email})]})]})}),(0,s.jsx)("td",{children:a.length?(0,s.jsxs)(s.Fragment,{children:[a[0],a.length>1&&(0,s.jsxs)("span",{className:"wsPersonMore",children:[" +",a.length-1]})]}):"–"}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"owner"===i.role?"wsRoleOwner":void 0,children:e(`permissions.role_${i.role}`,{defaultValue:i.role})})}),(0,s.jsx)("td",{children:(0,l.stamp)(i.joined_at)}),(0,s.jsx)("td",{className:"wsRowEnd",children:r?(0,s.jsx)(l.RowMenu,{label:e("actions"),items:[...J?[{id:"role",label:e("members.changeRole"),onSelect:()=>{F(i),V(i.role),L("role")}}]:[],...Y?[{id:"remove",label:e("members.removeAction"),danger:!0,onSelect:()=>{F(i),L("remove")}}]:[]]}):(0,s.jsx)("span",{className:"wsRowNone",children:"-"})})]},i.id)})})]})}):(0,s.jsx)(l.EmptyState,{title:e(er?"noResults":"members.empty"),note:e(er?"noResultsHint":"members.emptyHint"),action:!er&&K?(0,s.jsx)("button",{className:"rlBtn pri",onClick:eu,children:e("members.invite")}):void 0}),(0,s.jsx)(l.Pager,{page:ea,pages:en,size:B,onPage:M,onSize:$,labels:{rows:e("rowsPerPage"),status:e("page",{page:ea,total:en}),previous:e("previous"),next:e("next")}})]}),A&&(0,s.jsx)(l.Modal,{wide:"invite"===A||"invitations"===A,title:e("invite"===A?"members.invite":"role"===A?"members.changeRole":"invitations"===A?"members.invitations":"resend"===A?"members.resend":"cancel"===A?"members.cancelInvitation":"members.removeTitle"),onClose:()=>{q||L(null)},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{e.preventDefault(),ed()},children:["invite"===A&&(0,s.jsxs)(s.Fragment,{children:[et,(0,s.jsxs)("div",{className:"wsCompose",children:[(0,s.jsxs)("label",{className:"wsField wsComposeRole",children:[e("members.role"),(0,s.jsx)(l.RlSelect,{value:z,onChange:V,options:U.map(s=>({value:s,label:e(`permissions.role_${s}`)}))})]}),(0,s.jsxs)("label",{className:"wsField wsComposeMail",children:[e("members.email"),(0,s.jsx)("input",{className:"rlInput",type:"email",required:!0,maxLength:254,placeholder:e("members.emailPlaceholder"),value:D,onChange:e=>H(e.target.value),autoFocus:!0})]}),(0,s.jsx)("button",{className:"rlBtn pri wsComposeGo",disabled:q||ee||!D.trim(),children:e(q?"saving":"members.invite")})]}),(0,s.jsx)("p",{className:"rlNote",children:e("members.expiryNotice")})]}),"role"===A&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:R?.name}),(0,s.jsx)("span",{className:"rlRowN",children:R?.email})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("members.role"),(0,s.jsx)(l.RlSelect,{value:z,onChange:V,options:[...U,..."viewer"===z?["viewer"]:[]].map(s=>({value:s,label:e(`permissions.role_${s}`,{defaultValue:s})}))})]})]}),"remove"===A&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:R?.name}),(0,s.jsx)("span",{className:"rlRowN",children:R?.email})]}),(0,s.jsx)("p",{className:"rlNote",children:e("members.removeDescription")})]}),("cancel"===A||"resend"===A)&&(0,s.jsx)("p",{children:e(`members.${A}Confirm`,{name:O?.email})}),"invitations"===A&&(eo.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:e("members.email")}),(0,s.jsx)("th",{children:e("members.role")}),(0,s.jsx)("th",{children:e("members.status")}),(0,s.jsx)("th",{children:e("members.invitedAt")}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:eo.map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:t.email}),(0,s.jsx)("td",{children:(0,s.jsx)(l.RoleTag,{role:t.role,label:e(`permissions.role_${t.role}`,{defaultValue:t.role})})}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:`rlTag ${ec(t)?"dan":"info"}`,children:e(ec(t)?"members.expired":"members.pending")})}),(0,s.jsx)("td",{children:(0,l.stamp)(t.created_at)}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{className:"wsActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>{I(t),L("resend")},children:e("members.resend")}),(0,s.jsx)("button",{type:"button",className:"rlBtn dan",onClick:()=>{I(t),L("cancel")},children:e(ec(t)?"delete":"cancel")})]})})]},t.id))})]})}):(0,s.jsx)(l.EmptyState,{title:e("members.noInvitations"),note:e("members.noInvitationsHint")})),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",disabled:q,onClick:()=>L(null),children:e("invitations"===A?"close":"cancel")}),"invitations"!==A&&"invite"!==A&&(0,s.jsx)("button",{className:`rlBtn ${"remove"===A||"cancel"===A?"danFill":"pri"}`,disabled:q,children:e(q?"saving":"resend"===A?"members.resend":"remove"===A?"members.removeAction":"cancel"===A?"members.cancelInvitation":"save")})]})]})})]})}],150646);var M=e.i(187942);e.s(["Eye",()=>M.default],286536);var B=e.i(211749);e.s(["EyeOff",()=>B.default],77705)},196857,711819,295699,788699,979069,767900,e=>{"use strict";var s=e.i(843476),t=e.i(154920),i=e.i(271645);e.i(785269);var n=e.i(322831),a=e.i(286536),l=e.i(77705),r=e.i(846696),o=e.i(209165),c=e.i(798921),d=e.i(48396),u=e.i(500932),m=e.i(71647),p=e.i(323240),h=e.i(13080);function x(e,s){let{user:t}=(0,h.useAuth)(),n=t?.organization_id?`palette:workspace-draft:${t.id}:${t.organization_id}:${e}`:null,[a,l]=(0,i.useState)({key:null,value:s});return(0,i.useEffect)(()=>{let e=()=>{let e=s;try{let t=n&&localStorage.getItem(n);if(t){let i=JSON.parse(t);e=function e(s,t){if(Array.isArray(s))return Array.isArray(t)?t:s;if(s&&"object"==typeof s){if(!t||"object"!=typeof t||Array.isArray(t))return s;let i=Object.entries(s);return i.length?Object.fromEntries(i.map(([s,i])=>[s,e(i,t[s])])):t}return typeof t==typeof s?t:s}(s,i)}}catch{}l({key:n,value:e})};return e(),window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[n,s]),{value:a.key===n?a.value:s,save:function(e){if(!n)throw Error("No workspace selected");localStorage.setItem(n,JSON.stringify(e)),l({key:n,value:e}),window.dispatchEvent(new Event("palette:settings-relay-change"))},ready:!!n&&a.key===n}}let g=["membersTeams","permissions","security","agentsTasks","system"],b=["inApp","email"],j={channels:{inApp:!0,email:!0},events:Object.fromEntries(g.map(e=>[e,{inApp:!0,email:"agentsTasks"!==e}]))},v={sessionHours:24,autoLogout:!0,concurrent:!0,ipRestriction:!1,rules:[],recommendTwoFactor:!0,requireTwoFactor:!1,newDeviceAlert:!0},f=[1,8,24,168],y=["paletteLlm","externalLlm","externalMcp","externalConnector","mcpToken","publishingToken","newConnection","newToken"];function w(e){let t,i,n,a=(0,u.c)(9),{label:l,checked:r,disabled:o,onChange:c}=e;return a[0]!==r||a[1]!==c?(t=()=>c(!r),a[0]=r,a[1]=c,a[2]=t):t=a[2],a[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("span",{}),a[3]=i):i=a[3],a[4]!==r||a[5]!==o||a[6]!==l||a[7]!==t?(n=(0,s.jsx)("button",{type:"button",role:"switch","aria-label":l,"aria-checked":r,disabled:o,className:"wsToggle",onClick:t,children:i}),a[4]=r,a[5]=o,a[6]=l,a[7]=t,a[8]=n):n=a[8],n}function N(e){return e&&"string"==typeof e.id&&"string"==typeof e.address&&"string"==typeof e.description}e.s(["NotificationsSection",0,function(){let e,t,a,l,o,c,m,h,v,f,y,N,S,k,_,C,E,T,P,U,M,B=(0,u.c)(59),{t:$}=(0,n.useTranslation)("workspaceSettings"),{has:A}=(0,p.usePermissions)(),{value:L,save:R,ready:F}=x("notifications",j),[O,I]=(0,i.useState)(!1);B[0]!==A||B[1]!==F?(e=F&&A("notifications.workspace.manage"),B[0]=A,B[1]=F,B[2]=e):e=B[2];let D=e;B[3]!==D||B[4]!==R||B[5]!==$?(t=function(e,s){if(D)try{R(e),r.toast.success($(void 0===s?"notifications.updated":s))}catch{r.toast.error($("saveFailed"))}},B[3]=D,B[4]=R,B[5]=$,B[6]=t):t=B[6];let H=t;B[7]!==$?(a=$("reset"),B[7]=$,B[8]=a):a=B[8];let z=!D;return B[9]===Symbol.for("react.memo_cache_sentinel")?(l=()=>I(!0),B[9]=l):l=B[9],B[10]!==a||B[11]!==z?(o=(0,s.jsx)(d.ResetAction,{label:a,disabled:z,onClick:l}),B[10]=a,B[11]=z,B[12]=o):o=B[12],B[13]!==D?(c=[D],B[13]=D,B[14]=c):c=B[14],(0,d.usePageTools)(o,c),B[15]!==$?(m=$("notifications.title"),B[15]=$,B[16]=m):m=B[16],B[17]!==$?(h=$("notifications.events"),B[17]=$,B[18]=h):h=B[18],B[19]!==h?(v=(0,s.jsx)("th",{"aria-label":h}),B[19]=h,B[20]=v):v=B[20],B[21]!==$?(f=b.map(e=>(0,s.jsx)("th",{children:$(`notifications.${e}`)},e)),B[21]=$,B[22]=f):f=B[22],B[23]!==f||B[24]!==v?(y=(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[v,f]})}),B[23]=f,B[24]=v,B[25]=y):y=B[25],B[26]!==$?(N=$("notifications.events"),B[26]=$,B[27]=N):N=B[27],B[28]!==N?(S=(0,s.jsx)("th",{scope:"row",children:N}),B[28]=N,B[29]=S):S=B[29],B[30]!==D||B[31]!==$||B[32]!==H||B[33]!==L?(k=b.map(e=>(0,s.jsx)("td",{children:(0,s.jsx)(w,{label:`${$("notifications.events")}
1 \xb7 ${$(`notifications.${e}`)}`,checked:!!L.channels[e],disabled:!D,onChange:s=>H({...L,channels:{...L.channels,[e]:s}})})},e)),B[30]=D,B[31]=$,B[32]=H,B[33]=L,B[34]=k):k=B[34],B[35]!==S||B[36]!==k?(_=(0,s.jsxs)("tr",{className:"wsMatrixMaster",children:[S,k]}),B[35]=S,B[36]=k,B[37]=_):_=B[37],B[38]!==D||B[39]!==$||B[40]!==H||B[41]!==L?(C=g.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"row",children:$(`notifications.${e}`)}),b.map(t=>(0,s.jsx)("td",{children:(0,s.jsx)(w,{label:`${$(`notifications.${e}`)} \xb7 ${$(`notifications.${t}`)}`,checked:!!L.events[e]?.[t],disabled:!D||!L.channels[t],onChange:s=>H({...L,events:{...L.events,[e]:{...L.events[e],[t]:s}}})})},t))]},e)),B[38]=D,B[39]=$,B[40]=H,B[41]=L,B[42]=C):C=B[42],B[43]!==_||B[44]!==C?(E=(0,s.jsxs)("tbody",{children:[_,C]}),B[43]=_,B[44]=C,B[45]=E):E=B[45],B[46]!==y||B[47]!==E?(T=(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[y,E]})}),B[46]=y,B[47]=E,B[48]=T):T=B[48],B[49]!==T||B[50]!==m?(P=(0,s.jsx)(d.Card,{title:m,plainHead:!0,children:T}),B[49]=T,B[50]=m,B[51]=P):P=B[51],B[52]!==O||B[53]!==$||B[54]!==H?(U=O&&(0,s.jsx)(d.Modal,{title:$("notifications.resetTitle"),onClose:()=>I(!1),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{children:$("notifications.resetConfirm")}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>I(!1),children:$("cancel")}),(0,s.jsx)("button",{className:"rlBtn danFill",onClick:()=>{H(j,"notifications.resetDone"),I(!1)},children:$("reset")})]})]})}),B[52]=O,B[53]=$,B[54]=H,B[55]=U):U=B[55],B[56]!==P||B[57]!==U?(M=(0,s.jsxs)("div",{className:"rlStack",children:[P,U]}),B[56]=P,B[57]=U,B[58]=M):M=B[58],M},"PolicyToggle",0,w,"SecuritySection",0,function(){let e,t,a,l,o,c,h,g,b,j,S,k,_,C,E,T,P,U,M,B,$,A,L,R,F,O,I,D,H,z,V,q,W,G,K,J,Y,X,Q,Z,ee,es,et,ei,en,ea,el,er,eo,ec,ed,eu,em=(0,u.c)(151),{t:ep}=(0,n.useTranslation)("workspaceSettings"),{has:eh}=(0,p.usePermissions)(),{value:ex,save:eg,ready:eb}=x("security",v),ej=(0,m.useSecureMode)(),[ev,ef]=(0,i.useState)(null);em[0]===Symbol.for("react.memo_cache_sentinel")?(e={id:"",address:"",description:"",createdAt:""},em[0]=e):e=em[0];let[ey,ew]=(0,i.useState)(e),[eN,eS]=(0,i.useState)(""),[ek,e_]=(0,i.useState)(24);em[1]!==eh||em[2]!==eb?(t=eb&&eh("security.workspace.manage"),em[1]=eh,em[2]=eb,em[3]=t):t=em[3];let eC=t,eE=Array.isArray(ex.rules)?ex.rules.filter(N):[];em[4]!==eC||em[5]!==eg||em[6]!==ep||em[7]!==ex?(a=function(e,s){if(eC)try{eg({...ex,...e}),r.toast.success(ep(void 0===s?"saved":s)),ef(null),eS("")}catch{r.toast.error(ep("saveFailed"))}},em[4]=eC,em[5]=eg,em[6]=ep,em[7]=ex,em[8]=a):a=em[8];let eT=a;em[9]!==eC||em[10]!==ep||em[11]!==eT||em[12]!==ex?(l=function(e){return(0,s.jsx)(d.DetailRow,{title:ep(`security.${e}`),note:ep(`security.${e}Hint`),action:(0,s.jsx)(w,{label:ep(`security.${e}`),checked:!!ex[e],disabled:!eC||"recommendTwoFactor"===e&&ex.requireTwoFactor,onChange:s=>eT({[e]:s,..."requireTwoFactor"===e&&s?{recommendTwoFactor:!0}:{}})})},e)},em[9]=eC,em[10]=ep,em[11]=eT,em[12]=ex,em[13]=l):l=em[13];let eP=l;em[14]!==ep?(o=e=>168===e?ep("security.days",{count:7}):ep("security.hours",{count:e}),em[14]=ep,em[15]=o):o=em[15];let eU=o;em[16]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{ew({id:"",address:"",description:"",createdAt:""}),eS(""),ef("ip")},em[16]=c):c=em[16];let eM=c;em[17]!==ep?(h=ep("security.resetData"),em[17]=ep,em[18]=h):h=em[18];let eB=!eC;em[19]===Symbol.for("react.memo_cache_sentinel")?(g=()=>ef("reset"),em[19]=g):g=em[19],em[20]!==h||em[21]!==eB?(b=(0,s.jsx)(d.ResetAction,{label:h,disabled:eB,onClick:g}),em[20]=h,em[21]=eB,em[22]=b):b=em[22],em[23]!==eC?(j=[eC],em[23]=eC,em[24]=j):j=em[24],(0,d.usePageTools)(b,j),em[25]!==ep?(S=ep("security.sessions"),em[25]=ep,em[26]=S):S=em[26],em[27]!==ep?(k=ep("security.expiration"),em[27]=ep,em[28]=k):k=em[28],em[29]!==ep?(_=ep("security.expirationHint"),em[29]=ep,em[30]=_):_=em[30],em[31]!==eU||em[32]!==ex.sessionHours?(C=eU(ex.sessionHours),em[31]=eU,em[32]=ex.sessionHours,em[33]=C):C=em[33],em[34]!==C?(E=(0,s.jsx)("span",{children:C}),em[34]=C,em[35]=E):E=em[35];let e$=!eC;em[36]!==ex.sessionHours?(T=()=>{e_(ex.sessionHours),ef("session")},em[36]=ex.sessionHours,em[37]=T):T=em[37],em[38]!==ep?(P=ep("change"),em[38]=ep,em[39]=P):P=em[39],em[40]!==e$||em[41]!==T||em[42]!==P?(U=(0,s.jsx)("button",{className:"rlBtn",disabled:e$,onClick:T,children:P}),em[40]=e$,em[41]=T,em[42]=P,em[43]=U):U=em[43],em[44]!==E||em[45]!==U?(M=(0,s.jsxs)("div",{className:"wsActions",children:[E,U]}),em[44]=E,em[45]=U,em[46]=M):M=em[46],em[47]!==k||em[48]!==_||em[49]!==M?(B=(0,s.jsx)(d.DetailRow,{title:k,note:_,action:M}),em[47]=k,em[48]=_,em[49]=M,em[50]=B):B=em[50],em[51]!==eP?($=eP("autoLogout"),A=eP("concurrent"),em[51]=eP,em[52]=$,em[53]=A):($=em[52],A=em[53]),em[54]!==S||em[55]!==B||em[56]!==$||em[57]!==A?(L=(0,s.jsxs)(d.Card,{title:S,plainHead:!0,children:[B,$,A]}
1),em[54]=S,em[55]=B,em[56]=$,em[57]=A,em[58]=L):L=em[58];let eA=d.Card;em[59]!==ep?(R=ep("security.access"),em[59]=ep,em[60]=R):R=em[60],em[61]!==eP?(F=eP("ipRestriction"),em[61]=eP,em[62]=F):F=em[62];let eL=ex.ipRestriction&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsToolbar wsPadded",children:[(0,s.jsx)("span",{className:"rlNote",children:ep("security.ruleCount",{count:eE.length})}),(0,s.jsx)("button",{className:"rlBtn",disabled:!eC,onClick:eM,children:ep("security.addIp")})]}),eE.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:ep("security.ipAddress")}),(0,s.jsx)("th",{children:ep("description")}),(0,s.jsx)("th",{children:ep("security.added")}),(0,s.jsx)("th",{"aria-label":ep("actions")})]})}),(0,s.jsx)("tbody",{children:eE.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("strong",{children:e.address})}),(0,s.jsx)("td",{children:e.description||"–"}),(0,s.jsx)("td",{children:(0,d.stamp)(e.createdAt)}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{className:"wsActions",children:[(0,s.jsx)("button",{className:"rlBtn",disabled:!eC,onClick:()=>{ew({...e,createdAt:e.createdAt??""}),eS(""),ef("ip")},children:ep("edit")}),(0,s.jsx)("button",{className:"rlBtn dan",disabled:!eC,onClick:()=>{ew({...e,createdAt:e.createdAt??""}),ef("delete")},children:ep("delete")})]})})]},e.id))})]})}):(0,s.jsx)(d.EmptyState,{title:ep("security.noRules"),note:ep("security.noRulesHint"),action:eC?(0,s.jsx)("button",{className:"rlBtn",onClick:eM,children:ep("security.addIp")}):void 0})]});em[63]!==eA||em[64]!==R||em[65]!==F||em[66]!==eL?(O=(0,s.jsxs)(eA,{title:R,plainHead:!0,children:[F,eL]}),em[63]=eA,em[64]=R,em[65]=F,em[66]=eL,em[67]=O):O=em[67],em[68]!==ep?(I=ep("security.policies"),em[68]=ep,em[69]=I):I=em[69],em[70]!==eP?(D=eP("recommendTwoFactor"),H=eP("requireTwoFactor"),z=eP("newDeviceAlert"),em[70]=eP,em[71]=D,em[72]=H,em[73]=z):(D=em[71],H=em[72],z=em[73]),em[74]!==I||em[75]!==D||em[76]!==H||em[77]!==z?(V=(0,s.jsxs)(d.Card,{title:I,plainHead:!0,children:[D,H,z]}),em[74]=I,em[75]=D,em[76]=H,em[77]=z,em[78]=V):V=em[78],em[79]!==ep?(q=ep("security.secureMode"),em[79]=ep,em[80]=q):q=em[80],em[81]!==ep?(W=ep("security.enforced"),em[81]=ep,em[82]=W):W=em[82],em[83]!==ep?(G=ep("security.workspaceSecure"),em[83]=ep,em[84]=G):G=em[84],em[85]!==ep?(K=ep("security.workspaceSecureHint"),em[85]=ep,em[86]=K):K=em[86],em[87]!==ep?(J=ep("security.workspaceSecure"),em[87]=ep,em[88]=J):J=em[88];let eR=!ej.canManageOrg||ej.busy;em[89]!==ej.orgSecure||em[90]!==ej.setOrgSecure||em[91]!==J||em[92]!==eR?(Y=(0,s.jsx)(w,{label:J,checked:ej.orgSecure,disabled:eR,onChange:ej.setOrgSecure}),em[89]=ej.orgSecure,em[90]=ej.setOrgSecure,em[91]=J,em[92]=eR,em[93]=Y):Y=em[93],em[94]!==G||em[95]!==K||em[96]!==Y?(X=(0,s.jsx)(d.DetailRow,{title:G,note:K,action:Y}),em[94]=G,em[95]=K,em[96]=Y,em[97]=X):X=em[97],em[98]!==ep?(Q=ep("security.personalSecure"),em[98]=ep,em[99]=Q):Q=em[99];let eF=ej.ownLocked?"security.forced":"security.personalSecureHint";em[100]!==ep||em[101]!==eF?(Z=ep(eF),em[100]=ep,em[101]=eF,em[102]=Z):Z=em[102],em[103]!==ep?(ee=ep("security.personalSecure"),em[103]=ep,em[104]=ee):ee=em[104];let eO=ej.ownLocked||ej.busy;return em[105]!==ej.secure||em[106]!==ej.setOwnSecure||em[107]!==ee||em[108]!==eO?(es=(0,s.jsx)(w,{label:ee,checked:ej.secure,disabled:eO,onChange:ej.setOwnSecure}),em[105]=ej.secure,em[106]=ej.setOwnSecure,em[107]=ee,em[108]=eO,em[109]=es):es=em[109],em[110]!==Q||em[111]!==Z||em[112]!==es?(et=(0,s.jsx)(d.DetailRow,{title:Q,note:Z,action:es}),em[110]=Q,em[111]=Z,em[112]=es,em[113]=et):et=em[113],em[114]!==ep?(ei=ep("security.policySummary"),em[114]=ep,em[115]=ei):ei=em[115],em[116]!==ei?(en=(0,s.jsx)("div",{className:"wsPolicyHead",children:ei}),em[116]=ei,em[117]=en):en=em[117],em[118]!==ej.secure||em[119]!==ep?(ea=y.map(e=>{let t="paletteLlm"===e||!ej.secure;return(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"row",children:ep(`security.policy_${e}`)}),(0,s.jsx)("td",{className:"wsPolicyState",children:(0,s.jsx)("span",{className:`rlTag ${t?"":"dan"}`,children:ep(t?"security.allowed":"security.restricted")})})]},e)}),em[118]=ej.secure,em[119]=ep,em[120]=ea):ea=em[120],em[121]!==ea?(el=(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsx)("table",{className:"wsMatrix",children:(0,s.jsx)("tbody",{children:ea})})}),em[121]=ea,em[122]=el):el=em[122],em[123]!==ep?(er=ep("security.connectionsNote"),em[123]=ep,em[124]=er):er=em[124],em[125]!==er?(eo=(0,s.jsx)("div",{className:"rlHint",children:er}),em[125]=er,em[126]=eo):eo=em[126],em[127]!==q||em[128]!==W||em[129]!==X||em[130]!==et||em[131]!==en||em[132]!==el||em[133]!==eo?(ec=(0,s.jsxs)(d.Card,{title:q,note:W,plainHead:!0,children:[X,et,en,el,eo]}),em[127]=q,em[128]=W,em[129]=X,em[130]=et,em[131]=en,em[132]=el,em[133]=eo,em[134]=ec):ec=em[134],em[135]!==eC||em[136]!==ek||em[137]!==ev||em[138]!==ey||em[139]!==eN||em[140]!==eE||em[141]!==eU||em[142]!==ep||em[143]!==eT?(ed=ev&&(0,s.jsx)(d.Modal,{title:ep("session"===ev?"security.expiration":"ip"===ev?ey.id?"security.editIp":"security.addIp":"reset"===ev?"security.resetData":"security.deleteIpTitle"),onClose:()=>{ef(null),eS("")},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{if(e.preventDefault(),"session"===ev)eT({sessionHours:ek},"security.sessionSaved");else if("reset"===ev)eT(v,"security.resetDone");else if("delete"===ev)eT({rules:eE.filter(e=>e.id!==ey.id)},"security.ipDeleted");else{let e=ey.address.trim();if(!e)return void eS(ep("security.ipRequired"));if(!function(e){let[s,t,...i]=e.trim().split("/");if(i.length||""===t||void 0!==t&&!/^\d{1,3}$/.test(t))return!1;if(s.includes(":")){try{new URL(`http://[${s}]/`)}catch{return!1}return void 0===t||128>=Number(t)}return/^\d{1,3}(\.\d{1,3}){3}$/.test(s)&&s.split(".").every(e=>255>=Number(e)&&String(Number(e))===e)&&(void 0===t||32>=Number(t))}(e))return void eS(ep("security.invalidIp"));if(eE.some(s=>s.id!==ey.id&&s.address===e))return void eS(ep("security.duplicateIp"));let s={...ey,address:e,description:ey.description.trim(),id:ey.id||crypto.randomUUID(),createdAt:ey.createdAt||new Date().toISOString()};eT({rules:ey.id?eE.map(e=>e.id===ey.id?s:e):[...eE,s]},ey.id?"security.ipUpdated":"security.ipAdded")}},children:["session"===ev&&(0,s.jsxs)("label",{className:"wsField",children:[ep("security.expiration"),(0,s.jsx)(d.RlSelect,{value:String(ek),onChange:e=>e_(Number(e)),options:f.map(e=>({value:String(e),label:eU(e)}))})]}),"ip"===ev&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("label",{className:"wsField",children:[ep("security.ipAddress"),(0,s.jsx)("input",{className:"rlInput",maxLength:64,value:ey.address,placeholder:"192.168.1.0/24",onChange:e=>{ew({...ey,address:e.target.value}),eS("")},"aria-invalid":!!eN||void 0,autoFocus:!0}),eN?(0,s.jsx)("span",{className:"wsFieldError",children:eN}):(0,s.jsx)("span",{className:"rlNote",children:ep("security.ipHint")})]}),(0,s.jsxs)("label",{className:"wsField",children:[ep("description"),(0,s.jsx)("input",{className:"rlInput",maxLength:100,value:ey.description,onChange:e=>ew({...ey,description:e.target.value})}),(0,s.jsxs)("span",{className:"wsCounter",children:[ey.description.length,"/",100]})]})]}),"delete"===ev&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:ey.address}),ey.description&&(0,s.jsx)("span",{className:"rlRowN",children:ey.description})]}),(0,s.jsx)("p",{className:"rlNote",children:ep("security.deleteConfirm",{address:ey.address})})]}),"reset"===ev&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{children:ep("security.resetConfirm")}),(0,s.jsx)("p",{className:"rlNote",children:ep("security.resetNotice")})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>{ef(null),eS("")},children:ep("cancel")}),(0,s.jsx)("button",{type:"submit",className:`rlBtn ${"delete"===ev||"reset"===ev?"danFill":"pri"}`,disabled:!eC,children:ep("reset"===ev?"reset":"delete"===ev?"delete":"save")})]})]})}),em[135]=eC,em[136]=ek,em[137]=ev,em[138]=ey,em[139]=eN,em[140]=eE,em[141]=eU,em[142]=ep,em[143]=eT,em[144]=ed):ed=em[144],em[145]!==L||em[146]!==O||em[147]!==V||em[148]!==ec||em[149]!==ed?(eu=(0,s.jsxs)("div",{className:"rlStack",children:[L,O,V,ec,ed]}),em[145]=L,em[146]=O,em[147]=V,em[148]=ec,em[149]=ed,em[150]=eu):eu=em[150],eu}],711819);let S=[{id:"openai",label:"OpenAI"},{id:"anthropic",label:"Anthropic"},{id:"openai_compatible",label:"OpenAI-compatible"}
1],k={name:"",kind:"openai",models:"",apiKey:"",baseUrl:"",active:!0};e.s(["ModelsSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),[u,m]=(0,i.useState)([]),[p,h]=(0,i.useState)(!0),[x,g]=(0,i.useState)(!1),[b,j]=(0,i.useState)(""),[v,f]=(0,i.useState)("all"),[y,N]=(0,i.useState)("all"),[_,C]=(0,i.useState)(1),[E,T]=(0,i.useState)(10),[P,U]=(0,i.useState)(null),[M,B]=(0,i.useState)(null),[$,A]=(0,i.useState)(k),[L,R]=(0,i.useState)(!1),[F,O]=(0,i.useState)(!1),I=(0,i.useCallback)(async()=>{h(!0),g(!1);try{let e=await (0,o.apiFetch)("/api/v1/llm-providers");if(!e.ok)throw Error();m(await e.json())}catch{g(!0)}finally{h(!1)}},[]);async function D(s,t,i){let n=await (0,o.apiFetch)(s,{method:t,...i?{body:JSON.stringify(i)}:{}});if(!n.ok){let s=await n.json().catch(()=>({}));throw Error("string"==typeof s.detail?s.detail:e("saveFailed"))}(0,c.invalidateByoProviders)(),await I()}async function H(s,t){if(!F){O(!0);try{await s(),U(null),A(k),r.toast.success(e(t))}catch(s){r.toast.error(s instanceof Error?s.message:e("saveFailed"))}finally{O(!1)}}}function z(e){B(e),R(!1),A(e?{name:e.name,kind:e.kind,models:e.models.join(", "),apiKey:"",baseUrl:e.base_url??"",active:"inactive"!==e.status}:k),U("edit")}(0,i.useEffect)(()=>{I()},[I]);let V=u.filter(e=>("all"===v||e.kind===v)&&("all"===y||"active"===y==("inactive"!==e.status))&&`${e.name} ${e.kind} ${e.models.join(" ")}`.toLowerCase().includes(b.toLowerCase())),q=Math.max(1,Math.ceil(V.length/E)),W=Math.min(_,q),G=V.slice((W-1)*E,W*E),K=""!==b.trim()||"all"!==v||"all"!==y;return(0,d.usePageTools)((0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.RlSelect,{label:e("models.filter"),value:v,onChange:e=>{f(e),C(1)},options:[{value:"all",label:e("all")},...Array.from(new Set([...S.map(e=>e.id),...u.map(e=>e.kind)])).map(e=>({value:e,label:e}))]}),(0,s.jsx)(d.RlSelect,{label:e("models.statusFilter"),value:y,onChange:e=>{N(e),C(1)},options:[{value:"all",label:e("all")},{value:"active",label:e("models.active")},{value:"inactive",label:e("models.inactive")}]}),(0,s.jsx)(d.CreateAction,{label:e("models.add"),onClick:()=>z(null)}),(0,s.jsx)(d.SearchField,{value:b,label:e("models.searchLabel"),onChange:e=>{j(e),C(1)}})]}),[b,v,y,u.length]),(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsx)(d.MetaRow,{count:e("models.count",{count:u.length})}),(0,s.jsxs)(d.Card,{plainHead:!0,children:[p?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):x?(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void I(),children:e("retry")})}):G.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("models.model")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("models.provider")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("members.status")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("models.default")})}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:G.map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("strong",{children:t.name}),(0,s.jsx)("div",{className:"rlRowN",children:t.models.join(", ")||"—"}),t.last_error&&(0,s.jsx)("div",{className:"rlRowN",children:t.last_error})]}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"rlTag info",children:t.kind})}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{className:"wsActions",children:[(0,s.jsx)(w,{label:`${t.name} \xb7 ${e("models.active")}`,checked:"inactive"!==t.status,disabled:F,onChange:e=>void H(()=>D(`/api/v1/llm-providers/${t.id}`,"PATCH",{is_active:e}),e?"models.activated":"models.deactivated")}),(0,s.jsx)("span",{className:"rlRowN",children:e("inactive"!==t.status?"models.active":"models.inactive")})]})}),(0,s.jsx)("td",{children:t.is_default?(0,s.jsx)("span",{className:"rlTag pri",children:e("models.default")}):(0,s.jsx)("button",{className:"rlBtn",disabled:F||"inactive"===t.status||!t.models.length,onClick:()=>void H(()=>D(`/api/v1/llm-providers/${t.id}`,"PATCH",{is_default:!0,default_model:t.default_model||t.models[0]}),"models.defaultSet"),children:e("models.setDefault")})}),(0,s.jsx)("td",{className:"wsRowEnd",children:(0,s.jsx)(d.RowMenu,{label:e("actions"),items:[{id:"edit",label:e("edit"),onSelect:()=>z(t)},{id:"delete",label:e("delete"),danger:!0,onSelect:()=>{B(t),U("delete")}}]})})]},t.id))})]})}):(0,s.jsx)(d.EmptyState,{title:e(K?"noResults":"models.empty"),note:e(K?"noResultsHint":"models.emptyHint"),action:K?void 0:(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>z(null),children:e("models.add")})}),(0,s.jsx)(d.Pager,{page:W,pages:q,size:E,onPage:C,onSize:T,labels:{rows:e("rowsPerPage"),status:e("page",{page:W,total:q}),previous:e("previous"),next:e("next")}})]}),P&&(0,s.jsx)(d.Modal,{title:e("delete"===P?"models.deleteTitle":M?"models.edit":"models.add"),onClose:()=>{F||(U(null),A(k))},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{if(e.preventDefault(),"delete"===P&&M)return void H(()=>D(`/api/v1/llm-providers/${M.id}`,"DELETE"),"models.deleted");let s=Array.from(new Set($.models.split(/[,\n]/).map(e=>
1e.trim()).filter(Boolean)));s.length&&$.name.trim()&&H(()=>D(M?`/api/v1/llm-providers/${M.id}`:"/api/v1/llm-providers",M?"PATCH":"POST",{name:$.name.trim(),...!M?{kind:$.kind}:{},models:s,default_model:s.includes(M?.default_model??"")?M?.default_model:s[0],is_active:$.active,...$.apiKey.trim()?{api_key:$.apiKey.trim()}:{},..."openai_compatible"===$.kind?{base_url:$.baseUrl.trim()}:{}}),M?"models.updated":"models.added")},children:["delete"===P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:M?.name}),(0,s.jsx)("span",{className:"rlRowN",children:M?.models.join(", ")})]}),(0,s.jsx)("p",{className:"rlNote",children:e("models.deleteConfirm",{name:M?.name})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("label",{className:"wsField",children:[e("name"),(0,s.jsx)("input",{className:"rlInput",required:!0,maxLength:80,autoFocus:!0,value:$.name,onChange:e=>A({...$,name:e.target.value})})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("models.provider"),(0,s.jsx)(d.RlSelect,{disabled:!!M,value:$.kind,onChange:e=>A({...$,kind:e}),options:[...S.map(e=>({value:e.id,label:e.label})),...M&&(0,c.isDeviceKind)(M.kind)?[{value:M.kind,label:M.kind}]:[]]})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("models.model"),(0,s.jsx)("input",{className:"rlInput",required:!0,maxLength:1e4,value:$.models,onChange:e=>A({...$,models:e.target.value})}),(0,s.jsx)("span",{className:"rlNote",children:e("models.modelHint")})]}),"openai_compatible"===$.kind&&(0,s.jsxs)("label",{className:"wsField",children:[e("models.url"),(0,s.jsx)("input",{className:"rlInput",type:"url",required:!0,maxLength:500,value:$.baseUrl,onChange:e=>A({...$,baseUrl:e.target.value})})]}),!(0,c.isDeviceKind)($.kind)&&(0,s.jsxs)("label",{className:"wsField",children:[e("models.key"),(0,s.jsxs)("span",{className:"wsSecretField",children:[(0,s.jsx)("input",{className:"rlInput",type:L?"text":"password",autoComplete:"new-password",required:!M,maxLength:4e3,value:$.apiKey,onChange:e=>A({...$,apiKey:e.target.value})}),(0,s.jsx)("button",{type:"button",className:"rlBtn sm","aria-label":e(L?"models.hideKey":"models.showKey"),onClick:()=>R(!L),children:L?(0,s.jsx)(l.EyeOff,{size:14}):(0,s.jsx)(a.Eye,{size:14})})]}),M&&(0,s.jsx)("small",{children:e("models.keyHint")})]}),(0,s.jsxs)("div",{className:"wsFormRow wsPadded",style:{padding:0},children:[(0,s.jsx)("span",{className:"rlFieldLabel",children:e("models.active")}),(0,s.jsx)(w,{label:e("models.active"),checked:$.active,onChange:e=>A({...$,active:e})})]})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",type:"button",disabled:F,onClick:()=>{U(null),A(k)},children:e("cancel")}),(0,s.jsx)("button",{className:`rlBtn ${"delete"===P?"danFill":"pri"}`,disabled:F,children:e(F?"saving":"delete"===P?"delete":"save")})]})]})})]})}],196857);var _=e.i(517302),_=_,C=e.i(581418),E=e.i(975157),T=e.i(762603),P=e.i(569552);let U=[{id:"workspace.manage",section:"workspace",locked:!1},{id:"workspace.delete",section:"workspace",locked:!0},{id:"members.view",section:"members",locked:!1},{id:"members.invite",section:"members",locked:!1},{id:"members.roles.change",section:"members",locked:!1},{id:"members.remove",section:"members",locked:!1},{id:"members.ownership.transfer",section:"members",locked:!0},{id:"teams.view",section:"teams",locked:!1},{id:"teams.edit",section:"teams",locked:!1},{id:"teams.members.manage",section:"teams",locked:!1},{id:"teams.delete",section:"teams",locked:!1},{id:"permissions.view",section:"permissions",locked:!1},{id:"permissions.member-role.manage",section:"permissions",locked:!1},{id:"permissions.team.manage",section:"permissions",locked:!1},{id:"permissions.user.manage",section:"permissions",locked:!1},{id:"l2.connect",section:"apps",locked:!1},{id:"l2.pause",section:"apps",locked:!1},{id:"l2.user-access.manage",section:"apps",locked:!1},{id:"l2.team-access.manage",section:"apps",locked:!1},{id:"l2.remove",section:"apps",locked:!0},{id:"drive.create",section:"drive",locked:!1},{id:"drive.workspace.view",section:"drive",locked:!1},{id:"notifications.workspace.view",section:"notifications",locked:!1},{id:"notifications.workspace.manage",section:"notifications",locked:!1},{id:"security.workspace.view",section:"security",locked:!1},{id:"security.workspace.manage",section:"security",locked:!1},{id:"model.policy.view",section:"model",locked:!1},{id:"model.policy.manage",section:"model",locked:!1},{id:"mcp.settings.view",section:"mcp",locked:!1},{id:"mcp.connections.manage",section:"mcp",locked:!1},{id:"mcp.tools.manage",section:"mcp",locked:!1},{id:"mcp.actions.approve",section:"mcp",locked:!1},{id:"mcp.pause",section:"mcp",locked:!1},{id:"mcp.activity.view",section:"mcp",locked:!1},{id:"mcp.tokens.manage",section:"mcp",locked:!0},{id:"developer.tokens.view",section:"developer",locked:!1},{id:"developer.tokens.manage",section:"developer",locked:!0},{id:"storage.view",section:"storage",locked:!1},{id:"storage.export",section:"storage",locked:!0},{id:"storage.delete",section:"storage",locked:!0},{id:"storage.reset",section:"storage",locked:!0},{id:"audit.workspace.view",section:"audit",locked:!1},{id:"audit.workspace.export",section:"audit",locked:!0},{id:"billing.subscription.view",section:"billing",locked:!1},{id:"billing.history.view",section:"billing",locked:!1},{id:"billing.plan.change",section:"billing",locked:!0},{id:"billing.subscription.cancel",section:"billing",locked:!0}
1,{id:"billing.topup.purchase",section:"billing",locked:!0},{id:"billing.payment.manage",section:"billing",locked:!0}],M=Array.from(new Set(U.map(e=>e.section))),B=new Set(U.filter(e=>e.locked).map(e=>e.id));U.filter(e=>!e.locked).map(e=>e.id);let $=["permissions.view","permissions.member-role.manage","permissions.team.manage","permissions.user.manage"];var A=e.i(402389);async function L(e,s){let t=await (0,o.apiFetch)(e,s);if(!t.ok){let e=await t.json().catch(()=>({}));throw Error("string"==typeof e.detail?e.detail:A.default.t("workspaceSettings:permissions.saveFailed"))}return t.json()}let R=[10,25,50];function F(e){let t,a,l,r,o,c,m,h,x,g,b,j,v,f,y,N,S,k,C,T,P,$,A,L,R,F,D,H,z=(0,u.c)(119),{target:V,state:q,teams:W,busy:G,onClose:K,onRole:J,onSave:Y}=e,{t:X}=(0,n.useTranslation)("workspaceSettings"),Q=(0,p.usePermissions)();z[0]!==q.roles||z[1]!==q.teams||z[2]!==q.users||z[3]!==V.id||z[4]!==V.kind||z[5]!==V.member||z[6]!==V.team?(t="roles"===V.kind?q.roles[V.id]:"teams"===V.kind?q.teams[String(V.team.id)]??[]:q.users[V.member.id]??[],z[0]=q.roles,z[1]=q.teams,z[2]=q.users,z[3]=V.id,z[4]=V.kind,z[5]=V.member,z[6]=V.team,z[7]=t):t=z[7];let Z=t,[ee,es]=(0,i.useState)(Z),[et,ei]=(0,i.useState)(null);if(z[8]!==Z?(a=()=>{es(Z)},l=[Z],z[8]=Z,z[9]=a,z[10]=l):(a=z[9],l=z[10]),(0,i.useEffect)(a,l),z[11]!==ee||z[12]!==Z)r=ee.length===Z.length&&[...ee].sort().every((e,s)=>e===[...Z].sort()[s]),z[11]=ee,z[12]=Z,z[13]=r;else r=z[13];let en=!r;z[14]!==en||z[15]!==K||z[16]!==J?(o=e=>{en?ei(e):"close"===e?K():J(e)},z[14]=en,z[15]=K,z[16]=J,z[17]=o):o=z[17];let ea=o;z[18]!==K||z[19]!==J||z[20]!==et?(c=()=>{ei(null),"close"===et?K():et&&J(et)},z[18]=K,z[19]=J,z[20]=et,z[21]=c):c=z[21];let el=c,er="roles"===V.kind&&"owner"===V.id,eo="roles"===V.kind&&("owner"===V.id||"admin"===V.id&&!Q.isOwner);z[22]!==q.roles||z[23]!==V.kind||z[24]!==V.member?(m="users"===V.kind?"owner"===V.member.role?U.map(I):q.roles[V.member.role]??[]:[],z[22]=q.roles,z[23]=V.kind,z[24]=V.member,z[25]=m):m=z[25],z[26]!==m?(h=new Set(m),z[26]=m,z[27]=h):h=z[27];let ec=h;if(z[28]!==G||z[29]!==ea||z[30]!==Q||z[31]!==er||z[32]!==ee||z[33]!==ec||z[34]!==eo||z[35]!==q.teams||z[36]!==X||z[37]!==V||z[38]!==W){let e,t,i=new Map;if("users"===V.kind){for(let e of W)if(e.members.some(e=>e.user_id===V.member.id))for(let s of q.teams[String(e.id)]??[])i.set(s,[...i.get(s)??[],e.name])}z[50]!==X?(e=e=>X(`capabilities.${e}`,{defaultValue:e}),z[50]=X,z[51]=e):e=z[51];let n=e,a="roles"===V.kind?"permissions.roles":"teams"===V.kind?"permissions.teamModal":"permissions.userModal";z[52]!==X||z[53]!==a?(t=X(a),z[52]=X,z[53]=a,z[54]=t):t=z[54];let l=t;x=d.Modal,S=l,z[55]!==ea?(k=()=>ea("close"),z[55]=ea,z[56]=k):k=z[56],b="rlModalBody wsPermModal",z[57]!==ea||z[58]!==X||z[59]!==V.id||z[60]!==V.kind?(j="roles"===V.kind&&(0,s.jsx)("div",{style:{display:"flex"},children:(0,s.jsx)(d.Seg,{ariaLabel:X("members.role"),value:V.id,onChange:ea,options:["owner","admin","member"].map(e=>({id:e,label:X(`permissions.role_${e}`)}))})}),z[57]=ea,z[58]=X,z[59]=V.id,z[60]=V.kind,z[61]=j):j=z[61],z[62]!==X||z[63]!==V.id||z[64]!==V.kind?(v="roles"===V.kind&&(0,s.jsxs)("div",{className:"wsPermIntro",children:[(0,s.jsx)("strong",{children:X(`permissions.role_${V.id}`)}),(0,s.jsx)("p",{className:"rlNote",children:X(`permissions.roleHint_${V.id}`)})]}),z[62]=X,z[63]=V.id,z[64]=V.kind,z[65]=v):v=z[65],z[66]!==X||z[67]!==V.kind||z[68]!==V.team?(f="teams"===V.kind&&(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:V.team.name}),V.team.description&&(0,s.jsx)("span",{className:"rlNote",children:V.team.description}),(0,s.jsx)("span",{className:"rlRowN",children:X("teams.count",{count:V.team.members.length})})]}),z[66]=X,z[67]=V.kind,z[68]=V.team,z[69]=f):f=z[69],z[70]!==X||z[71]!==V.kind||z[72]!==V.member?(y="users"===V.kind&&(0,s.jsxs)("div",{className:"wsPermSummary wsUserCell",children:[(0,s.jsx)(d.Mark,{size:40,color:(0,d.markColorFor)(V.member.email),children:(V.member.name||V.member.email).slice(0,1).toUpperCase()}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:V.member.name}),(0,s.jsx)("div",{className:"rlRowN",children:V.member.email}),(0,s.jsxs)("div",{className:"wsActions",style:{marginTop:6},children:[(0,s.jsx)("span",{className:"rlTag",children:X(`permissions.role_${V.member.role}`,{defaultValue:V.member.role})}),V.member.teams?.map(O)]})]})]}),z[70]=X,z[71]=V.kind,z[72]=V.member,z[73]=y):y=z[73],z[74]!==X||z[75]!==V.kind?(N="roles"!==V.kind&&(0,s.jsx)("p",{className:"rlNote",children:X("teams"===V.kind?"permissions.teamModalHint":"permissions.userModalHint")}),z[74]=X,z[75]=V.kind,z[76]=N):N=z[76],C="wsPermList",g=M.map(e=>(0,s.jsxs)("section",{className:"wsPermSection","aria-labelledby":`perm-${e}`,children:[(0,s.jsx)("h3",{id:`perm-${e}`,children:X(`permissions.section_${e}`)}),U.filter(s=>s.section===e).map(e=>{let t=B.has(e.id),a=ec.has(e.id),l=i.get(e.id),r=!t&&!Q.canGrant(e.id),o=a||!!l,c=er||o||ee.includes(e.id),d=G||eo||t||o||r,u=a&&l?X("permissions.allowedByRoleTeam",{role:X(`permissions.role_${V.member.role}`),team:l[0]}):a?X("permissions.allowedByRole",{role:X(`permissions.role_${V.member.role}`)}):l?X("permissions.allowedByTeam",{team:l.length>1?`${l[0]} +${l.length-1}`:l[0]}):r?X("permissions.scopeExceeded"):null;return(0,s.jsxs)("div",{className:"wsPermRow",children:[(0,s.jsxs)("span",{className:(0,E.cn)("wsPermLabel",!d&&!t&&!er&&"click"),onClick:()=>{d||t||er||es(s=>s.includes(e.id)?s.filter(s=>
1s!==e.id):[...s,e.id])},children:[n(e.id),u&&(0,s.jsx)("small",{children:u})]}),t?(0,s.jsxs)("span",{className:"wsPermLock",children:[(0,s.jsx)(_.default,{size:12,"aria-hidden":"true"}),X("permissions.ownerOnly")]}):er?(0,s.jsx)("span",{className:"wsPermLock",children:X("permissions.allowed")}):(0,s.jsx)(w,{label:n(e.id),checked:c,disabled:d,onChange:s=>es(t=>s?[...t,e.id]:t.filter(s=>s!==e.id))})]},e.id)})]},e)),z[28]=G,z[29]=ea,z[30]=Q,z[31]=er,z[32]=ee,z[33]=ec,z[34]=eo,z[35]=q.teams,z[36]=X,z[37]=V,z[38]=W,z[39]=x,z[40]=g,z[41]=b,z[42]=j,z[43]=v,z[44]=f,z[45]=y,z[46]=N,z[47]=S,z[48]=k,z[49]=C}else x=z[39],g=z[40],b=z[41],j=z[42],v=z[43],f=z[44],y=z[45],N=z[46],S=z[47],k=z[48],C=z[49];z[77]!==g||z[78]!==C?(T=(0,s.jsx)("div",{className:C,children:g}),z[77]=g,z[78]=C,z[79]=T):T=z[79],z[80]!==el||z[81]!==et||z[82]!==X?(P=et&&(0,s.jsx)(d.Modal,{title:X("unsavedTitle"),onClose:()=>ei(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:X("unsavedDescription")}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>ei(null),children:X("continueEditing")}),(0,s.jsx)("button",{className:"rlBtn danFill",onClick:el,children:X("leaveWithoutSaving")})]})]})}),z[80]=el,z[81]=et,z[82]=X,z[83]=P):P=z[83],z[84]!==ea?($=()=>ea("close"),z[84]=ea,z[85]=$):$=z[85];let ed=er?"close":"cancel";return z[86]!==X||z[87]!==ed?(A=X(ed),z[86]=X,z[87]=ed,z[88]=A):A=z[88],z[89]!==G||z[90]!==$||z[91]!==A?(L=(0,s.jsx)("button",{className:"rlBtn",disabled:G,onClick:$,children:A}),z[89]=G,z[90]=$,z[91]=A,z[92]=L):L=z[92],z[93]!==G||z[94]!==en||z[95]!==Y||z[96]!==er||z[97]!==ee||z[98]!==eo||z[99]!==X?(R=!er&&(0,s.jsx)("button",{className:"rlBtn pri",disabled:G||eo||!en,onClick:()=>Y(ee),children:X(G?"saving":"save")}),z[93]=G,z[94]=en,z[95]=Y,z[96]=er,z[97]=ee,z[98]=eo,z[99]=X,z[100]=R):R=z[100],z[101]!==L||z[102]!==R?(F=(0,s.jsxs)("div",{className:"rlModalActions",children:[L,R]}),z[101]=L,z[102]=R,z[103]=F):F=z[103],z[104]!==b||z[105]!==j||z[106]!==v||z[107]!==f||z[108]!==y||z[109]!==N||z[110]!==T||z[111]!==P||z[112]!==F?(D=(0,s.jsxs)("div",{className:b,children:[j,v,f,y,N,T,P,F]}),z[104]=b,z[105]=j,z[106]=v,z[107]=f,z[108]=y,z[109]=N,z[110]=T,z[111]=P,z[112]=F,z[113]=D):D=z[113],z[114]!==x||z[115]!==S||z[116]!==k||z[117]!==D?(H=(0,s.jsx)(x,{title:S,onClose:k,children:D}),z[114]=x,z[115]=S,z[116]=k,z[117]=D,z[118]=H):H=z[118],H}function O(e){return(0,s.jsx)("span",{className:"rlTag",children:e.name},e.id)}function I(e){return e.id}e.s(["PermissionsSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),a=(0,p.usePermissions)(),{state:l,loading:c,error:u,refetch:m,setRole:x,setTeam:g,setUser:b,reset:j}=function(){let{user:e,refreshUser:s}=(0,h.useAuth)(),[t,n]=(0,i.useState)(null),[a,l]=(0,i.useState)(!0),[r,c]=(0,i.useState)(null),d=e?.organization_id,u=(0,i.useCallback)(async()=>{l(!0),c(null);try{let e=await (0,o.apiFetch)("/api/v1/org/permissions");if(!e.ok){c(e.status),n(null);return}n(await e.json())}catch{c(0),n(null)}finally{l(!1)}},[]);async function m(e,t){let i=await L(e,t?{method:"PUT",body:JSON.stringify({capabilities:t})}:{method:"POST"});return n(i),await s(),window.dispatchEvent(new Event("palette:settings-relay-change")),i}return(0,i.useEffect)(()=>{d&&u()},[u,d]),{state:t,loading:a,error:r,refetch:u,setRole:(e,s)=>m(`/api/v1/org/permissions/roles/${e}`,s),setTeam:(e,s)=>m(`/api/v1/org/permissions/teams/${e}`,s),setUser:(e,s)=>m(`/api/v1/org/permissions/users/${e}`,s),reset:()=>m("/api/v1/org/permissions/reset")}}(),{teams:v,loading:f}=(0,P.useOrgTeams)(),{members:y,loading:w}=(0,T.useOrgMembers)(),N=a.has("permissions.team.manage"),S=a.has("permissions.user.manage"),k=a.isOwner||a.has("permissions.member-role.manage"),_=a.has(...$),[E,U]=(0,i.useState)(N||!S?"teams":"users"),[M,B]=(0,i.useState)(""),[A,O]=(0,i.useState)("all"),[I,D]=(0,i.useState)(10),[H,z]=(0,i.useState)(1),[V,q]=(0,i.useState)(null),[W,G]=(0,i.useState)(!1),[K,J]=(0,i.useState)(!1),Y=(e,s)=>l?.[e]?.[s]??[],X=v.filter(e=>`${e.name} ${e.description??""}`.toLowerCase().includes(M.toLowerCase())),Q=y.filter(e=>"owner"!==e.role&&("all"===A||e.role===A)&&`${e.name} ${e.email}`.toLowerCase().includes(M.toLowerCase())),Z="teams"===E?X:Q,ee=Math.max(1,Math.ceil(Z.length/I)),es=Math.min(H,ee),et="teams"===E?f:w;async function ei(s,t){if(!K){J(!0);try{await s(),r.toast.success(e(t)),q(null),G(!1)}catch(s){r.toast.error(s instanceof Error?s.message:e("permissions.saveFailed"))}finally{J(!1)}}}return((0,d.usePageTools)((0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.IconAction,{label:e("permissions.roles"),disabled:!k,onClick:()=>q({kind:"roles",id:a.isOwner?"admin":"member"}),children:(0,s.jsx)(C.ShieldCheck,{size:17,"aria-hidden":"true"})}),(0,s.jsx)(d.ResetAction,{label:e("permissions.reset"),disabled:!a.isOwner,onClick:()=>G(!0)}),(0,s.jsx)(d.SearchField,{value:M,label:e("teams"===E?"permissions.teamSearch":"permissions.userSearch"),onChange:e=>{B(e),z(1)}})]}),[M,E,k,a.isOwner]),_)?c?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):null===u&&l?(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsx)("div",{className:"wsTabs",role:"tablist",children:["team
1s","users"].map(t=>(0,s.jsx)("button",{role:"tab","aria-selected":E===t,className:`wsTab ${E===t?"on":""}`,onClick:()=>{U(t),B(""),z(1)},children:e(`permissions.${t}`)},t))}),(0,s.jsx)(d.MetaRow,{count:e("teams"===E?"permissions.teamCount":"permissions.userCount",{count:Z.length}),action:"users"===E?(0,s.jsx)(d.RlSelect,{label:e("members.role"),value:A,onChange:e=>{O(e),z(1)},options:["all","admin","member"].map(s=>({value:s,label:"all"===s?e("all"):e(`permissions.role_${s}`)}))}):void 0}),(0,s.jsxs)(d.Card,{plainHead:!0,children:[et?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):Z.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("teams"===E?"permissions.team":"permissions.user")})}),"teams"===E?(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("permissions.members")})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("members.role")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("permissions.team")})})]}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("permissions.additional")})}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:"teams"===E?X.slice((es-1)*I,es*I).map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("strong",{children:t.name}),t.description&&(0,s.jsx)("div",{className:"rlRowN",children:t.description})]}),(0,s.jsx)("td",{children:e("teams.count",{count:t.members.length})}),(0,s.jsx)("td",{children:Y("teams",String(t.id)).length||e("permissions.none")}),(0,s.jsx)("td",{className:"wsRowEnd",children:(0,s.jsx)("button",{className:"rlBtn",disabled:!N,onClick:()=>q({kind:"teams",team:t}),children:e("permissions.configure")})})]},t.id)):Q.slice((es-1)*I,es*I).map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsxs)("div",{className:"wsUserCell",children:[(0,s.jsx)(d.Mark,{size:30,color:(0,d.markColorFor)(t.email),children:(t.name||t.email).slice(0,1).toUpperCase()}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:t.name||t.email}),(0,s.jsx)("div",{className:"rlRowN",children:t.email})]})]})}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"rlTag",children:e(`permissions.role_${t.role}`,{defaultValue:t.role})})}),(0,s.jsx)("td",{children:t.teams?.length?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"rlTag",children:t.teams[0].name}),t.teams.length>1&&(0,s.jsxs)("span",{className:"rlRowN",children:[" +",t.teams.length-1]})]}):"–"}),(0,s.jsx)("td",{children:Y("users",t.id).length||e("permissions.none")}),(0,s.jsx)("td",{className:"wsRowEnd",children:(0,s.jsx)("button",{className:"rlBtn",disabled:!S||"admin"===t.role&&!a.isOwner,onClick:()=>q({kind:"users",member:t}),children:e("permissions.configure")})})]},t.id))})]})}):(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("span",{className:"rlEmptyLead",children:e(M||"all"!==A?"permissions.noResults":"teams"===E?"permissions.noTeams":"permissions.noUsers")})}),(0,s.jsx)(d.Pager,{page:es,pages:ee,size:I,onPage:z,onSize:D,sizes:R,labels:{rows:e("permissions.rowsPerPage"),status:e("page",{page:es,total:ee}),previous:e("previous"),next:e("next")}})]}),V&&(0,s.jsx)(F,{target:V,state:l,teams:v,busy:K,onClose:()=>{K||q(null)},onRole:e=>q({kind:"roles",id:e}),onSave:e=>"roles"===V.kind&&"owner"!==V.id?ei(()=>x(V.id,e),"permissions.roleSaved"):"teams"===V.kind?ei(()=>g(V.team.id,e),"permissions.teamSaved"):"users"===V.kind?ei(()=>b(V.member.id,e),"permissions.userSaved"):void 0}),W&&(0,s.jsx)(d.Modal,{title:e("permissions.reset"),onClose:()=>G(!1),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:e("permissions.resetConfirm")}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",disabled:K,onClick:()=>G(!1),children:e("cancel")}),(0,s.jsx)("button",{className:"rlBtn danFill",disabled:K,onClick:()=>void ei(j,"permissions.resetDone"),children:e("reset")})]})]})})]}):(0,s.jsx)(d.Card,{title:e(403===u?"permissions.accessDenied":"loadFailed"),plainHead:!0,children:(0,s.jsx)("div",{className:"rlEmpty",children:403===u?(0,s.jsx)("span",{className:"rlEmptyLead",children:e("permissions.accessDeniedHint")}):(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void m(),children:e("retry")})})}):(0,s.jsx)(d.Card,{title:e("permissions.accessDenied"),plainHead:!0,children:(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("span",{className:"rlEmptyLead",children:e("permissions.accessDeniedHint")})})})}],295699);var D=e.i(360200);e.s(["Pencil",()=>D.default],788699);var D=D,H=e.i(119266);let z=["mentions","workDone","shares","permissions","system"],V=["inApp","email"],q={channels:{inApp:!0,email:!0},events:Object.fromEntries(z.map(e=>[e,{inApp:!0,email:"system"!==e}]))};function W(){let e="u"<typeof navigator?"":navigator.userAgent;return{browser:/Edg\//.test(e)?"Edge":/OPR\//.test(e)?"Opera":/Chrome\//.test(e)?"Chrome":/Firefox\//.test(e)?"Firefox":/Safari\//.test(e)?"Safari":"Browser",os:/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/iPhone|iPad/.test(e)?"iOS":/Mac OS/.test(e)?"macOS":/Linux/.test(e)?"Linux":"—"}}function G(e){let s=e??{};return{channels:{...q.channels,..."object"==typeof s.channels&&s.channels?s.channels:{}},events:Object.fromEntries(z.map(e=>[e,{...q.events[e],...s.events?.[e]??{}}]))}}e.s(["ProfileSection",0,function(){let{t:e}=(0,n.useTranslation)(),{t:t}=(0,n.useTranslation)("workspaceSettings"),{user:a,updateProfile:l,logout:c,refreshUser:m,leaveOrg:p}=(0,h.useAuth)(),{members:x}=(0,T.useOrgMembers)(),{prefs:g,patch:b}=(0,H.useRelayPrefs)(),j=function(e){let s,t,i=(0,u.c)(18),{user:n,orgs:a}=(0,h.useAuth)(),{prefs:l}=(0,H.useRelayPrefs)();i[0]!==a||i[1]!==n?(s=a.length?a:n?.organization_id?[{id:n.organization_id,name:n.company_name??"Workspace",slug:"",theme_id:"",logo_url:n.org_logo??null}]:[],i[0]=a,i[1]=n,i[2]=s):s=i[2];let r=s;if(i[3]!==e||i[4]!==r||i[5]!==l.orgColor||i[6]!==l.orgFg||i[7]!==l.orgGlyph||i[8]!==n?.org_role||i[9]!==n?.organization_id){let s;i[11]!==e||i[12]!==l.orgColor||i[13]!==l.orgFg||i[14]!==l.orgGlyph||i[15]!==n?.org_role||i[16]!==n?.organization_id?(s=s=>{let t=String(s.id),i=s.id===n?.organization_id,a=s.name||"Workspace";return{id:s.id,name:a,slug:s.slug??"",hash:(0,d.hash6)(s.slug||a),role:(s.role??(i?n?.org_role:null))?.toUpperCase()??"MEMBER",glyph:(l.orgGlyph[t]||a.trim().charAt(0)||"W").toUpperCase().slice(0,2),color:l.orgColor[t]||(0,d.markColorFor)(s.slug||a),fg:l.orgFg[t]||"",members:i?e??null:null,isActive:i,logoUrl:s.logo_url??null}},i[11]=e,i[12]=l.orgColor,i[13]=l.orgFg,i[14]=l.orgGlyph,i[15]=n?.org_role,i[16]=n?.organization_id,i[17]=s):s=i[17],t=r.map(s),i[3]=e,i[4]=r,i[5]=l.orgColor,i[6]=l.orgFg,i[7]=l.orgGlyph,i[8]=n?.org_role,i[9]=n?.organization_id,i[10]=t}else t=i[10];return t}(x.length||null),[v,f]=(0,i.useState)("security"),[y,N]=(0,i.useState)(null),[S,k]=(0,i.useState)(a?.name??""),[_,C]=(0,i.useState)(a?.company_type??""),[P,U]=(0,i.useState)(""),[M,B]=(0,i.useState)(!1),[$,A]=(0,i.useState)(!1),[L,R]=(0,i.useState)(!1),[F,O]=(0,i.useState)(!1),[I,q]=(0,i.useState)(null),[K,J]=(0,i.useState)(()=>G(a?.notification_prefs));(0,i.useEffect)(()=>{k(a?.name??""),C(a?.company_type??"")},[a?.company_type,a?.name]),(0,i.useEffect)(()=>{J(G(a?.notification_prefs))}
1,[a?.notification_prefs]);let Y=(g.profGlyph||(0,d.initialsOf)(a?.name,a?.email)).slice(0,1),X=g.profColor||"#007EA8",Q=g.profMark,Z=a?.login_method==="google",ee=async s=>{try{await l(s),r.toast.success(t("saved"))}catch(s){r.toast.error(s instanceof Error?s.message:e("settingsUi.profile.saveFailed","Could not save your profile"))}},es=(0,i.useCallback)(async e=>{J(e);try{if(!(await (0,o.apiFetch)("/api/v1/auth/notification-prefs",{method:"PATCH",body:JSON.stringify({notification_prefs:e})})).ok)throw Error();await m(),r.toast.success(t("profile.notificationsSaved"))}catch{r.toast.error(t("saveFailed")),J(G(a?.notification_prefs))}},[m,a?.notification_prefs,t]);async function et(){if(!L&&a?.email){R(!0);try{await (0,o.apiFetch)("/api/v1/auth/forgot-password",{method:"POST",body:JSON.stringify({email:a.email})}),r.toast.success(t("profile.resetSent")),A(!1)}catch{r.toast.error(t("saveFailed"))}finally{R(!1)}}}async function ei(e){if(!L){R(!0);try{await p(e.id),q(null)}catch(e){r.toast.error(e instanceof Error?e.message:t("saveFailed"))}finally{R(!1)}}}let en=(0,d.isHex6)(P);return(0,s.jsxs)("div",{className:"rlStack accPage",children:[(0,s.jsxs)("div",{className:"wsProfileEditor",children:[(0,s.jsx)("div",{className:"wsProfileLogo",children:(0,s.jsxs)("button",{type:"button",className:"wsProfileLogoTrigger",onClick:()=>N("appearance"),"aria-label":e("settingsUi.profile.color"),children:[(0,s.jsx)(d.Mark,{size:76,variant:Q,color:X,children:Y}),(0,s.jsx)("span",{className:"wsProfileLogoEdit","aria-hidden":"true",children:(0,s.jsx)(D.default,{size:14})})]})}),(0,s.jsxs)("div",{className:"wsProfileCopy",children:[(0,s.jsx)("button",{type:"button",className:"wsProfileName",onClick:()=>N("name"),children:(0,s.jsx)("strong",{children:a?.name||a?.email||"—"})}),(0,s.jsx)("span",{className:"wsProfileId",children:a?.company_type||e("settingsUi.profile.founderDesignerOperator")})]})]}),(0,s.jsx)("div",{className:"wsTabs",role:"tablist",children:["security","workspace","notifications"].map(e=>(0,s.jsx)("button",{role:"tab","aria-selected":v===e,className:(0,E.cn)("wsTab",v===e&&"on"),onClick:()=>f(e),children:t(`profile.tab_${e}`,{defaultValue:e})},e))}),"notifications"===v&&(0,s.jsx)(d.Card,{plainHead:!0,children:(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{"aria-label":t("profile.personalEvents")}),V.map(e=>(0,s.jsx)("th",{children:t(`notifications.${e}`)},e))]})}),(0,s.jsxs)("tbody",{children:[(0,s.jsxs)("tr",{className:"wsMatrixMaster",children:[(0,s.jsx)("th",{scope:"row",children:t("profile.personalEvents")}),V.map(e=>(0,s.jsx)("td",{children:(0,s.jsx)(w,{label:`${t("profile.personalEvents")} \u00b7 ${t(`notifications.${e}`)}`,checked:K.channels[e],onChange:s=>void es({...K,channels:{...K.channels,[e]:s}})})},e))]}),z.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"row",children:t(`profile.event_${e}`)}),V.map(i=>(0,s.jsx)("td",{children:(0,s.jsx)(w,{label:`${t(`profile.event_${e}`)} \u00b7 ${t(`notifications.${i}`)}`,checked:K.events[e][i],disabled:!K.channels[i],onChange:s=>void es({...K,events:{...K.events,[e]:{...K.events[e],[i]:s}}})})},i))]},e))]})]})})}),"security"===v&&(0,s.jsx)(d.Card,{plainHead:!0,children:(0,s.jsxs)("div",{className:"accSecurity",children:[(0,s.jsx)(d.DetailRow,{title:t("profile.loginMethod"),note:a?.email??"—",action:(0,s.jsx)("span",{className:"rlTag",children:t(Z?"profile.loginGoogle":"profile.loginEmail")})}),!Z&&(0,s.jsx)(d.DetailRow,{title:e("settingsUi.profile.password"),note:t("profile.passwordDescription"),action:(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>A(!0),children:t("reset")})}),!Z&&(0,s.jsx)(d.DetailRow,{title:(0,s.jsxs)(s.Fragment,{children:[e("settingsUi.profile.twoFactor")," ",(0,s.jsx)("span",{className:"rlTag",children:t("profile.twoFactorOff")})]}),note:t("profile.twoFactorOffDescription"),action:(0,s.jsx)("button",{type:"button",className:"rlBtn",disabled:!0,title:e("settingsUi.profile.notAvailableYet"),children:e("settingsUi.profile.setUp")})}),(0,s.jsx)(d.DetailRow,{title:t("profile.devices"),note:t("profile.deviceSummaryOne"),action:(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>O(!0),children:t("profile.manage")})})]})}),"workspace"===v&&(0,s.jsxs)(d.Card,{plainHead:!0,children:[(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix accMemberships",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:t("profile.workspaceListName")}
1),(0,s.jsx)("th",{children:t("profile.workspaceListMembers")}),(0,s.jsx)("th",{children:t("profile.workspaceListRole")}),(0,s.jsx)("th",{"aria-label":t("actions")})]})}),(0,s.jsx)("tbody",{children:j.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"row",children:(0,s.jsx)("strong",{children:e.name})}),(0,s.jsx)("td",{children:null==e.members?"—":t("profile.memberCount",{count:e.members})}),(0,s.jsx)("td",{children:(0,s.jsxs)("span",{className:"accTags",children:[e.isActive&&(0,s.jsx)("span",{className:"rlTag",children:t("profile.current")}),(0,s.jsx)(d.RoleTag,{role:e.role.toLowerCase(),label:t(`permissions.role_${e.role.toLowerCase()}`,{defaultValue:e.role})})]})}),(0,s.jsx)("td",{className:"wsRowEnd",children:"OWNER"===e.role?(0,s.jsx)("span",{className:"wsRowNone",children:"-"}):(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>q(e),children:t("workspace.leaveAction")})})]},e.id))})]})}),!j.length&&(0,s.jsx)("div",{className:"rlEmpty",children:e("settingsUi.profile.noOrganisationOnAccountYet")})]}),"name"===y&&(0,s.jsx)(d.Modal,{title:e("settingsUi.profile.identity"),onClose:()=>N(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("label",{className:"wsField",children:[e("settingsUi.profile.name"),(0,s.jsx)("input",{className:"rlInput",value:S,maxLength:50,autoFocus:!0,onChange:e=>k(e.target.value),onBlur:()=>{S!==(a?.name??"")&&ee({name:S})}})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("settingsUi.profile.title"),(0,s.jsx)("input",{className:"rlInput",value:_,maxLength:50,placeholder:e("settingsUi.profile.founderDesignerOperator"),onChange:e=>C(e.target.value),onBlur:()=>{_!==(a?.company_type??"")&&ee({company_type:_})}})]}),(0,s.jsx)("div",{className:"rlModalActions",children:(0,s.jsx)("button",{type:"button",className:"rlBtn pri",onClick:()=>N(null),children:t("save")})})]})}),"appearance"===y&&(0,s.jsx)(d.Modal,{title:e("settingsUi.profile.color"),onClose:()=>N(null),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("div",{className:"wsSwatchRow",children:d.MARK_COLORS.map(e=>(0,s.jsx)("button",{type:"button",title:e,"aria-label":`Mark colour ${e}`,"aria-pressed":X.toUpperCase()===e,onClick:()=>b({profColor:e}),className:(0,E.cn)("wsSwatch",X.toUpperCase()===e&&"on"),style:{background:e,color:(0,d.onColor)(e)},children:Y},e))}),(0,s.jsxs)("span",{className:"rlGroupBox",children:[(0,s.jsx)("span",{className:"sw",style:{background:en?P:X,color:(0,d.onColor)(en?P:X)},children:Y}),(0,s.jsx)("input",{value:P,onChange:e=>U((0,d.normaliseHexInput)(e.target.value)),placeholder:"#171717",maxLength:7,"aria-label":e("settingsUi.profile.customMarkColour")}),(0,s.jsx)("button",{type:"button",className:"apply",disabled:!en,onClick:()=>{en&&(b({profColor:P}),U(""))},children:e("settingsUi.profile.apply")})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("settingsUi.profile.mark"),(0,s.jsx)(d.Seg,{ariaLabel:e("settingsUi.profile.markVariant","Mark variant"),value:Q,onChange:e=>b({profMark:e}),options:[{id:"fill",label:"Fill"},{id:"ghost",label:"Ghost"},{id:"ink",label:"Ink"}]})]}),(0,s.jsx)("div",{className:"rlModalActions",children:(0,s.jsx)("button",{type:"button",className:"rlBtn pri",onClick:()=>N(null),children:t("save")})})]})}),I&&(0,s.jsx)(d.Modal,{title:t("workspace.leave"),onClose:()=>{L||q(null)},children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:t("workspace.leaveConfirm",{name:I.name})}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",disabled:L,onClick:()=>q(null),children:t("cancel")}),(0,s.jsx)("button",{type:"button",className:"rlBtn danFill",disabled:L,onClick:()=>void ei(I),children:t("workspace.leaveAction")})]})]})}),$&&(0,s.jsx)(d.Modal,{title:e("settingsUi.profile.password"),onClose:()=>{L||A(!1)},children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:t("profile.resetDescription")}),(0,s.jsxs)("label",{className:"wsField",children:[e("settingsUi.profile.email"),(0,s.jsx)("input",{className:"rlInput",value:a?.email??"",readOnly:!0})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",disabled:L,onClick:()=>A(!1),children:t("cancel")}),(0,s.jsx)("button",{type:"button",className:"rlBtn pri",disabled:L,onClick:()=>void et(),children:t("profile.send")})]})]})}),F&&(0,s.jsx)(d.Modal,{title:t("profile.devicesTitle"),onClose:()=>O(!1),children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:t("profile.deviceSummaryOne")}),(0,s.jsxs)("div",{className:"accDevice",children:[(0,s.jsxs)("div",{className:"accDeviceHead",children:[(0,s.jsx)("strong",{children:W().browser}),(0,s.jsx)("span",{className:"rlTag pri",children:t("profile.currentDevice")})]}),(0,s.jsx)("span",{className:"rlNote",children:W().os}
1),(0,s.jsxs)("span",{className:"rlNote",children:[t("profile.currentActivity"),a?.last_login_at?` \u00b7 ${t("profile.signedIn")} ${(0,d.stamp)(a.last_login_at)}`:""]})]}),(0,s.jsx)("p",{className:"rlNote",children:t("profile.noOtherDevices")}),(0,s.jsx)("div",{className:"rlModalActions",children:(0,s.jsx)("button",{type:"button",className:"rlBtn dan",onClick:()=>{O(!1),B(!0)},children:t("profile.logoutThisDevice")})})]})}),M&&(0,s.jsxs)(d.Modal,{title:e("settingsUi.profile.signOut"),onClose:()=>B(!1),children:[(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("div",{style:{fontSize:14.5,fontWeight:700,letterSpacing:"-0.02em"},children:e("settingsUi.profile.signOutPaletteOs")}),(0,s.jsx)(d.Bullets,{lines:[e("settingsUi.profile.signOutLine1","This browser session ends and you return to the login screen."),e("settingsUi.profile.signOutLine2","Running agents and scheduled loops keep running on the server."),e("settingsUi.profile.signOutLine3","Nothing is deleted — sign back in to pick up where you left off.")]})]}),(0,s.jsxs)("div",{className:"rlModalActions",style:{padding:"14px 18px 16px"},children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",onClick:()=>B(!1),children:e("paletteOs:settings.actions.cancel")}),(0,s.jsx)("button",{type:"button",className:"rlBtn danFill",onClick:()=>void c(),children:e("settingsUi.profile.signOut")})]})]})]})}],979069);var K=e.i(879002);e.s(["TeamsSection",0,function(){let{t:e}=(0,n.useTranslation)("workspaceSettings"),{has:a}=(0,p.usePermissions)(),{members:l}=(0,T.useOrgMembers)(),{teams:o,loading:c,createTeam:u,updateTeam:m,deleteTeam:h,updateTeamMembers:x}=(0,P.useOrgTeams)(),[g,b]=(0,i.useState)(""),[j,v]=(0,i.useState)(""),[f,y]=(0,i.useState)(1),[w,N]=(0,i.useState)(10),[S,k]=(0,i.useState)(null),[_,C]=(0,i.useState)(null),[E,U]=(0,i.useState)(""),[M,B]=(0,i.useState)(""),[$,A]=(0,i.useState)([]),[L,R]=(0,i.useState)(!1),F=a("teams.edit"),O=a("teams.members.manage"),I=a("teams.delete"),D=F||O||I,H=o.filter(e=>`${e.name} ${e.description??""}`.toLowerCase().includes(g.toLowerCase())),z=Math.max(1,Math.ceil(H.length/w)),V=Math.min(f,z),q=H.slice((V-1)*w,V*w),W=""!==g.trim();function G(e,s=null){C(s),U(s?.name??""),B(s?.description??""),A(s?.members.map(e=>e.user_id)??[]),v(""),k(e)}async function J(){if(D&&!L){R(!0);try{if("edit"===S){if(!E.trim())return;let e={name:E.trim(),description:M.trim()||null};_?await m(_.id,e):await u(e)}else _&&"delete"===S?await h(_.id):_&&"members"===S&&await x(_.id,$.map(e=>({user_id:e,role:_.members.find(s=>s.user_id===e)?.role??"member"})));k(null),r.toast.success(e("delete"===S?"teams.deleted":"members"===S?"teams.membersSaved":_?"teams.updated":"teams.created"))}catch(s){r.toast.error(s instanceof Error?s.message:e("saveFailed"))}finally{R(!1)}}}return(0,d.usePageTools)((0,s.jsxs)(s.Fragment,{children:[!D&&(0,s.jsx)("span",{className:"wsReadOnly",children:e("readOnly")}),(0,s.jsx)(d.IconAction,{label:e("teams.create"),disabled:!F,onClick:()=>G("edit"),children:(0,s.jsx)(K.UserPlus,{size:17,"aria-hidden":"true"})}),(0,s.jsx)(d.SearchField,{value:g,label:e("teams.searchLabel"),onChange:e=>{b(e),y(1)}})]}),[g,F,D]),(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsx)(d.MetaRow,{count:W?e("teams.filtered",{count:H.length,total:o.length}):e("teams.total",{count:o.length})}),(0,s.jsxs)(d.Card,{plainHead:!0,children:[c?(0,s.jsx)(t.PaletteLoader,{label:e("loading")}):q.length?(0,s.jsx)("div",{className:"wsMatrixScroll",children:(0,s.jsxs)("table",{className:"wsMatrix",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("teams.team")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("description")})}),(0,s.jsx)("th",{children:(0,s.jsx)(d.SortHead,{label:e("permissions.members")})}),(0,s.jsx)("th",{"aria-label":e("actions")})]})}),(0,s.jsx)("tbody",{children:q.map(t=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("strong",{children:t.name})}),(0,s.jsx)("td",{children:t.description||"–"}),(0,s.jsx)("td",{children:e("teams.count",{count:t.members.length})}),(0,s.jsx)("td",{className:"wsRowEnd",children:(0,s.jsx)(d.RowMenu,{label:e("actions"),items:[...O?[{id:"members",label:e("teams.members"),onSelect:()=>G("members",t)}]:[],...F?[{id:"edit",label:e("edit"),onSelect:()=>G("edit",t)}]:[],...I?[{id:"delete",label:e("delete"),danger:!0,onSelect:()=>G("delete",t)}]:[]]})})]},t.id))})]})}):(0,s.jsx)(d.EmptyState,{title:e(W?"noResults":"teams.empty"),note:e(W?"noResultsHint":"teams.emptyHint"),action:!W&&F?(0,s.jsx)("button",{className:"rlBtn pri",onClick:()=>G("edit"),children:e("teams.create")}):void 0}),(0,s.jsx)(d.Pager,{page:V,pages:z,size:w,onPage:y,onSize:N,labels:{rows:e("rowsPerPage"),status:e("page",{page:V,total:z}),previous:e("previous"),next:e("next")}})]}),S&&(0,s.jsx)(d.Modal,{wide:"members"===S,title:e("members"===S?"teams.members":"delete"===S?"teams.deleteTitle":_?"teams.edit":"teams.create"),onClose:()=>{L||k(null)},children:(0,s.jsxs)("form",{className:"rlModalBody",onSubmit:e=>{e.preventDefault(),J()},children:["edit"===S&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("label",{className:"wsField",children:[e("name"),(0,s.jsx)("input",{className:"rlInput",required:!0,maxLength:50,autoFocus:!0,value:E,onChange:e=>U(e.target.value)}),(0,s.jsxs)("span",{className:"wsCounter",children:[E.length,"/",50]})]}),(0,s.jsxs)("label",{className:"wsField",children:[e("description"),(0,s.jsx)("textarea",{className:"rlInput wsTextarea",maxLength:200,value:M,onChange:e=>B(e.target.value)}),(0,s.jsxs)("span",{className:"wsCounter",children:[M.length,"/",200]})]})]}),"members"===S&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:_?.name}),_?.description&&(0,s.jsx)("span",{className:"rlNote",children:_.description}),(0,s.jsx)("span",{className:"rlRowN",children:e("teams.selectedCount",{count:$.length})})]}),(0,s.jsx)(d.SearchField,{value:j,onChange:v,label:e("teams.searchMembers")}),(0,s.jsx)("div",{className:"wsMemberList",children:l.filter(e=>`${e.name} ${e.email}`.toLowerCase().includes(j.toLowerCase())).map(t=>(0,s.jsxs)("label",{className:"wsCheckRow",children:[(0,s.jsx)("input",{type:"checkbox",checked:$.includes(t.id),onChange:e=>A(s=>e.target.checked?[...s,t.id]:s.filter(e=>e!==t.id))}),(0,s.jsx)(d.Mark,{size:30,color:(0,d.markColorFor)(t.email),children:(t.name||t.email).slice(0,1).toUpperCase()}),(0,s.jsxs)("span",{className:"rlRowMain",children:[(0,s.jsx)("span",{className:"rlRowT",children:t.name}),(0,s.jsx)("span",{className:"rlRowN",children:t.email})]}),(0,s.jsx)(d.RoleTag,{role:t.role,label:e(`permissions.role_${t.role}`,{defaultValue:t.role})})]},t.id))}),!l.length&&(0,s.jsx)("p",{children:e("teams.noMembers")})]}),"delete"===S&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wsPermSummary",children:[(0,s.jsx)("strong",{children:_?.name}),(0,s.jsx)("span",{className:"rlRowN",children:e("teams.count",{count:_?.members.length??0})})]}),(0,s.jsx)("p",{className:"rlNote",children:e("teams.deleteConfirm",{name:_?.name})})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{type:"button",className:"rlBtn",disabled:L,onClick:()=>k(null),children:e("cancel")}),(0,s.jsx)("button",{className:`rlBtn ${"delete"===S?"danFill":"pri"}`,disabled:L||"edit"===S&&!E.trim(),children:e(L?"saving":"delete"===S?"delete":"save")})]})]})})]})}],767900)},23701,e=>{"use strict";var s=e.i(843476),t=e.i(500932),i=e.i(271645),n=e.i(72664),a=e.i(664659),l=e.i(373375),r=e.i(463059),o=e.i(561659),c=e.i(239616),d=e.i(284765),u=e.i(649582),m=e.i(761911),p=e.i(13080),h=e.i(975157),x=e.i(572723),g=e.i(144966),b=e.i(443961),j=e.i(48396),v=e.i(426971),f=e.i(323240),y=e.i(6
154590),w=e.i(595938),N=e.i(173096),S=e.i(860643),k=e.i(284980),_=e.i(816245),C=e.i(476405),E=e.i(150646),T=e.i(196857),P=e.i(295699),U=e.i(979069),M=e.i(767900),B=e.i(154920),$=e.i(788699);e.i(785269);var A=e.i(322831),L=e.i(846696),R=e.i(543679);let F=["image/png","image/jpeg","image/webp"];function O(){let{t:e}=(0,A.useTranslation)("workspaceSettings"),{user:t,refreshUser:n,leaveOrg:a}=(0,p.useAuth)(),{org:l,loading:r,updateOrg:o,uploadLogo:c,removeLogo:d,deleteOrg:u,refetch:m}=(0,R.useOrganisation)(),[h,x]=(0,i.useState)(""),[g,b]=(0,i.useState)(""),[v,y]=(0,i.useState)(void 0),[w,N]=(0,i.useState)(!1),[S,k]=(0,i.useState)(null),[_,C]=(0,i.useState)(!1),[E,T]=(0,i.useState)(""),P=(0,i.useRef)(null),U=(0,f.usePermissions)(),M=U.has("workspace.manage"),O=U.has("workspace.delete"),I=!!l&&(h!==l.name||g!==(l.description??"")),D=I||void 0!==v,H=(0,i.useMemo)(()=>v instanceof File&&"function"==typeof URL.createObjectURL?URL.createObjectURL(v):null,[v]);(0,i.useEffect)(()=>()=>{H&&URL.revokeObjectURL(H)},[H]);let z=void 0===v?l?.logo_url??null:H,V=l?.id,q=l?.name,W=l?.description;async function G(s){if(!w){N(!0);try{await s(),await n(),L.toast.success(e("saved"))}catch(s){L.toast.error(s instanceof Error?s.message:e("saveFailed"))}finally{N(!1)}}}async function K(s,t){if(!w){N(!0);try{await ("delete"===s?u():a(t))}catch(s){L.toast.error(s instanceof Error?s.message:e("saveFailed")),N(!1)}}}if((0,i.useEffect)(()=>{null!=V&&(x(q??""),b(W??""),y(void 0))},[V,q,W]),(0,i.useEffect)(()=>{if(!D)return;let s=e=>{e.preventDefault(),e.returnValue=""};window.addEventListener("beforeunload",s);let t=s=>{window.confirm(e("unsavedDescription"))||s.preventDefault()};return window.addEventListener("palette:settings-before-navigate",t),()=>{window.removeEventListener("beforeunload",s),window.removeEventListener("palette:settings-before-navigate",t)}},[D,e]),(0,j.usePageTools)((0,s.jsxs)(s.Fragment,{children:[!M&&(0,s.jsx)("span",{className:"wsReadOnly",children:e("readOnly")}),(0,s.jsx)(j.ResetAction,{label:e("reset"),disabled:!D||w,onClick:()=>k("reset")})]}),[M,D,w]),r)return(0,s.jsx)(B.PaletteLoader,{label:e("loading")});if(!l)return(0,s.jsx)(j.Card,{title:e(t?.organization_id?"loadFailed":"noWorkspace"),children:(0,s.jsx)("div",{className:"rlEmpty",children:(0,s.jsx)("button",{className:"rlBtn",onClick:()=>void m(),children:e("retry")})})});let J=[...h.trim()||l.name][0]?.toUpperCase()??"W",Y=M&&D&&!!h.trim()&&h.length<=50&&g.length<=200&&!w;async function X(){v instanceof File?await c(v):null===v&&await d(),I&&await o({name:h.trim(),description:g.trim()||null}),y(void 0)}return(0,s.jsxs)("div",{className:"rlStack",children:[(0,s.jsxs)("form",{className:"wsProfilePage",onSubmit:e=>{e.preventDefault(),Y&&G(X)},children:[(0,s.jsxs)("div",{className:"wsProfileEditor",children:[(0,s.jsxs)("div",{className:"wsProfileLogo",children:[(0,s.jsxs)("button",{type:"button",className:"wsProfileLogoTrigger",disabled:!M||w,"aria-haspopup":"menu","aria-expanded":_,onClick:()=>C(e=>
1!e),"aria-label":e("workspace.logo"),children:[z?(0,s.jsx)("img",{src:z,alt:""}):(0,s.jsx)(j.Mark,{size:76,color:"var(--os-accent)",children:J}),(0,s.jsx)("span",{className:"wsProfileLogoEdit","aria-hidden":"true",children:(0,s.jsx)($.Pencil,{size:14})})]}),(0,s.jsx)("input",{ref:P,type:"file",hidden:!0,accept:"image/png,image/jpeg,image/webp","aria-label":e("change"),onChange:s=>{!function(s){if(s){if(!F.includes(s.type)||s.size>5242880)return L.toast.error(e("workspace.logoInvalid"));y(s)}}(s.target.files?.[0]),s.target.value=""}}),_&&(0,s.jsxs)("div",{className:"wsProfileLogoMenu",role:"menu",children:[(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>{C(!1),P.current?.click()},children:e("change")}),(0,s.jsx)("button",{type:"button",role:"menuitem",disabled:!z,onClick:()=>{C(!1),y(l.logo_url?null:void 0)},children:e("delete")}),(0,s.jsx)("p",{children:e("workspace.logoHint")})]})]}),(0,s.jsxs)("div",{className:"wsProfileCopy",children:[(0,s.jsx)("button",{type:"button",className:"wsProfileName",disabled:!M||w,onClick:()=>k("name"),children:(0,s.jsx)("strong",{children:h||l.name})}),(0,s.jsx)("span",{className:"wsProfileId",children:`ws_${l.id}`})]})]}),(0,s.jsx)("label",{className:"wsVisuallyHidden",htmlFor:"workspace-description",children:e("workspace.about")}),(0,s.jsx)("textarea",{id:"workspace-description",className:"rlInput wsProfileAbout",maxLength:200,placeholder:e("workspace.aboutPlaceholder",{defaultValue:e("workspace.about")}),value:g,disabled:!M||w,onChange:e=>b(e.target.value)}),(0,s.jsxs)("div",{className:"wsCounter",children:[g.length,"/200"]}),(0,s.jsxs)("div",{className:"wsProfileFooter",children:[(0,s.jsx)("button",{type:"button",className:"wsProfileDelete",disabled:w,onClick:()=>{T(""),k(O?"delete":"leave")},children:e(O?"workspace.delete":"workspace.leave")}),(0,s.jsx)("button",{type:"submit",className:"rlBtn pri",disabled:!Y,children:e(w?"saving":"saveChanges",{defaultValue:e("save")})})]})]}),"name"===S&&(0,s.jsx)(j.Modal,{title:e("workspace.name"),onClose:()=>{w||k(null)},children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsxs)("label",{className:"wsField",children:[e("workspace.name")," *",(0,s.jsx)("input",{className:"rlInput",maxLength:50,value:h,autoFocus:!0,onChange:e=>x(e.target.value)}),(0,s.jsxs)("span",{className:"wsCounter",children:[h.length,"/50"]})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",onClick:()=>{x(l.name),k(null)},children:e("cancel")}),(0,s.jsx)("button",{className:"rlBtn pri",disabled:!h.trim(),onClick:()=>k(null),children:e("confirm",{defaultValue:e("save")})})]})]})}),("delete"===S||"leave"===S||"reset"===S)&&(0,s.jsx)(j.Modal,{title:e("reset"===S?"reset":`workspace.${S}`),onClose:()=>{w||k(null)},children:(0,s.jsxs)("div",{className:"rlModalBody",children:[(0,s.jsx)("p",{className:"rlNote",children:e(`workspace.${S}Confirm`,{name:l.name})}),"delete"===S&&(0,s.jsxs)("label",{className:"wsField",children:[e("workspace.typeName",{name:l.name}),(0,s.jsx)("input",{className:"rlInput",value:E,onChange:e=>T(e.target.value),autoFocus:!0})]}),(0,s.jsxs)("div",{className:"rlModalActions",children:[(0,s.jsx)("button",{className:"rlBtn",disabled:w,onClick:()=>k(null),children:e("cancel")}),(0,s.jsx)("button",{className:`rlBtn ${"reset"===S?"pri":"danFill"}`,disabled:w||"delete"===S&&E!==l.name,onClick:()=>{if("reset"===S){x(l.name),b(l.description??""),y(void 0),k(null);return}K(S,l.id)},children:e("leave"===S?"workspace.leaveAction":S)})]})]})})]})}var I=e.i(711819);let D=[d.Settings2,m.Users,u.SlidersHorizontal,n.Box],H={workspace:c.Settings,billing:o.CreditCard};function z(e){return e.currentTarget.toggleAttribute("data-scrolled",e.currentTarget.scrollTop>40)}function V(e){return e.items}function q(e){return e.index>0}function W(e){return 0===e.index}function G(e){return e.items.length}function K(e){return e.items.length}e.s(["default",0,function(){let e,n,o,c,u,m,B,$,L,R,F,J,Y,X,Q,Z,ee,es,et,ei,en,ea,el,er,eo,ec,ed,eu,em,ep,eh,ex,eg,eb,ej,ev,ef,ey,ew,eN,eS,ek,e_,eC,eE,eT,eP,eU=(0,t.c)(180),{t:eM}=(0,A.useTranslation)(),{user:eB,loading:e$}=(0,p.useAuth)(),[eA,eL]=(0,i.useState)("workspace"),[eR,eF]=(0,i.useState)(null),[eO,eI]=(0,i.useState)(!1),[eD,eH]=(0,i.useState)(0),[ez,eV]=(0,i.useState)(!1),eq=(0,x.useIsPalettePhoneViewport)(),[eW,eG]=(0,i.useState)("page"),eK=(0,i.useRef)(null),eJ=(0,i.useRef)(null),eY=(0,i.useRef)(null),eX=(0,j.useCellLabels)();eU[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],eU[0]=e):e=eU[0];let[eQ,eZ]=(0,i.useState)(e),[e0,e1]=(0,i.useState)("");eU[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{let e=(0,v.resolveSection)(new URLSearchParams(window.location.search).get("section")),s=(0,v.resolveSection)(window.localStorage.getItem(v.SECTION_STORAGE_KEY));eL(e??s??"workspace"),eG(e?"page":"list"),eI(!0)},o=[],eU[1]=n,eU[2]=o):(n=eU[1],o=eU[2]),(0,i.useEffect)(n,o),eU[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{let e=()=>{let e=(0,v.resolveSection)(new URLSearchParams(window.location.search).get("section"));e?(eL(e),eG("page")):(eY.current=null,eG("list"))},s=e=>{"setting"===e.detail&&eG("list")};return window.addEventListener("palette:locationchange",e),window.addEventListener("popstate",e),window.addEventListener("palette:view-reclick",
1s),()=>{window.removeEventListener("palette:locationchange",e),window.removeEventListener("popstate",e),window.removeEventListener("palette:view-reclick",s)}},u=[],eU[3]=c,eU[4]=u):(c=eU[3],u=eU[4]),(0,i.useEffect)(c,u),eU[5]!==eA||eU[6]!==eO||eU[7]!==eW?(m=()=>{if(!eO)return;let e="profile"===eA?"account":eA;window.localStorage.setItem(v.SECTION_STORAGE_KEY,e);let s=new URL(window.location.href);"list"===eW?s.searchParams.delete("section"):s.searchParams.set("section",e),window.history.replaceState(null,"",`${s.pathname}${s.search}${s.hash}`)},B=[eA,eO,eW],eU[5]=eA,eU[6]=eO,eU[7]=eW,eU[8]=m,eU[9]=B):(m=eU[8],B=eU[9]),(0,i.useEffect)(m,B),eU[10]===Symbol.for("react.memo_cache_sentinel")?($=()=>{eJ.current&&(eJ.current.scrollTop=0)},eU[10]=$):$=eU[10],eU[11]!==eA?(L=[eA],eU[11]=eA,eU[12]=L):L=eU[12],(0,i.useEffect)($,L),eU[13]!==eA||eU[14]!==eW?(F=()=>{if("list"!==eW)return;let e=v.NAV_GROUPS.findIndex(e=>e.items.some(e=>e.id===eA));e>0&&eZ(s=>s.includes(e)?s:[...s,e])},R=[eA,eW],eU[13]=eA,eU[14]=eW,eU[15]=R,eU[16]=F):(R=eU[15],F=eU[16]),(0,i.useEffect)(F,R);let e2=(0,f.usePermissions)();eU[17]!==e2?(J=e=>{let s=v.SECTION_CAPABILITIES[e];return!s||e2.has(...s)},eU[17]=e2,eU[18]=J):J=eU[18];let e3=J;eU[19]!==eA||eU[20]!==e3||eU[21]!==e$||eU[22]!==eB?(Y=()=>{e$||!eB||e3(eA)||eL("workspace")},X=[eA,e3,e$,eB],eU[19]=eA,eU[20]=e3,eU[21]=e$,eU[22]=eB,eU[23]=Y,eU[24]=X):(Y=eU[23],X=eU[24]),(0,i.useEffect)(Y,X),eU[25]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{let e=()=>eH(Date.now());return window.addEventListener("palette:settings-relay-change",e),window.addEventListener("palette:language-change",e),()=>{window.removeEventListener("palette:settings-relay-change",e),window.removeEventListener("palette:language-change",e)}},Z=[],eU[25]=Q,eU[26]=Z):(Q=eU[25],Z=eU[26]),(0,i.useEffect)(Q,Z),eU[27]!==eD?(ee=()=>{if(!eD)return;eV(!0);let e=window.setTimeout(()=>eV(!1),1600);return()=>window.clearTimeout(e)},es=[eD],eU[27]=eD,eU[28]=ee,eU[29]=es):(ee=eU[28],es=eU[29]),(0,i.useEffect)(ee,es),eU[30]===Symbol.for("react.memo_cache_sentinel")?(et=e=>{if(!window.dispatchEvent(new Event("palette:settings-before-navigate",{cancelable:!0})))return;let s="profile"===e?e:(0,v.resolveSection)(e)??"workspace";if(eK.current?.offsetParent){let e=new URL(window.location.href);e.searchParams.set("section","profile"===s?"account":s),eY.current=`${e.pathname}${e.search}${e.hash}`,window.history.pushState(null,"",eY.current)}eL(s),eG("page")},eU[30]=et):et=eU[30];let e4=et;eU[31]===Symbol.for("react.memo_cache_sentinel")?(ei=()=>{if(eY.current!==`${window.location.pathname}${window.location.search}${window.location.hash}`)return eG("list");eY.current=null,window.history.back()},eU[31]=ei):ei=eU[31];let e5=ei;eU[32]===Symbol.for("react.memo_cache_sentinel")?(en=(e,s)=>{e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),e4(s))},eU[32]=en):en=eU[32];let e6=en,{t:e7}=(0,A.useTranslation)("workspaceSettings"),e8=v.SECTION_META[eA];if(eU[33]!==eA||eU[34]!==e3||eU[35]!==eO||eU[36]!==eX||eU[37]!==eQ||eU[38]!==eW||eU[39]!==eq||eU[40]!==e0||eU[41]!==eM||eU[42]!==eB?.email||eU[43]!==eB?.name||eU[44]!==e7){let e,t,i,n,l,o,c,u,m,p,x,f,B,$,A,L,R,F,J,Y,X,Q,Z,ee,es,et,ei,en,ep,eh,ex,eg,eb,ej,ev,ef,ey,ew,eN,eS,ek;eU[53]!==e3?(e=(e,s)=>({...e,index:s,items:e.items.filter(e=>e3(e.id))}),eU[53]=e3,eU[54]=e):e=eU[54];let e_=v.NAV_GROUPS.map(e).filter(K);eU[55]!==e7?(t=(e,s)=>e7(`nav.${e}`,{defaultValue:s}),eU[55]=e7,eU[56]=t):t=eU[56];let eC=t,eE=e0.trim().toLocaleLowerCase(),eT=e=>!eE||!!e?.toLocaleLowerCase().includes(eE),eP=e_.map(e=>{let s=e7(`groups.${e.index}`);return{...e,title:s,items:e.index>
10&&eT(s)?e.items:e.items.filter(e=>eT(eC(e.id,e.label)))}}).filter(G),e$=eP.find(W)?.items??[],eL=eP.filter(q),eR=eT(e7("account"))||eT(eB?.name)||eT(eB?.email),eF=[...e$,...eL.flatMap(V)][0]?.id;eU[57]!==eA||eU[58]!==eC?(i=(e,t)=>{let i=H[e.id]??d.Settings2;return(0,s.jsxs)("a",{href:`/settings?section=${e.id}`,"aria-current":eA===e.id?"page":void 0,className:(0,h.cn)("wsIndexRow",t&&"wsIndexChild"),onClick:s=>e6(s,e.id),children:[!t&&(0,s.jsx)(i,{"aria-hidden":"true"}),(0,s.jsx)("span",{children:eC(e.id,e.label)}),(0,s.jsx)(r.ChevronRight,{className:"wsIndexChevron","aria-hidden":"true"})]},e.id)},eU[57]=eA,eU[58]=eC,eU[59]=i):i=eU[59];let eI=i;eU[60]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(w.BillingSection,{}),l=(0,s.jsx)(O,{}),o=(0,s.jsx)(I.NotificationsSection,{}),c=(0,s.jsx)(I.SecuritySection,{}),u=(0,s.jsx)(k.DeveloperSection,{}),m=(0,s.jsx)(S.DataSection,{}),p=(0,s.jsx)(U.ProfileSection,{}),x=(0,s.jsx)(O,{}),f=(0,s.jsx)(E.MembersSection,{}),B=(0,s.jsx)(M.TeamsSection,{}),$=(0,s.jsx)(P.PermissionsSection,{}),A=(0,s.jsx)(C.LanguageSection,{}),L=(0,s.jsx)(T.ModelsSection,{}),R=(0,s.jsx)(_.GeneralSection,{}),F=(0,s.jsx)(g.McpCommandCenter,{}),J=(0,s.jsx)(k.DeveloperSection,{}),Y=(0,s.jsx)(S.DataSection,{}),X=(0,s.jsx)(N.AppsSection,{}),eU[60]=n,eU[61]=l,eU[62]=o,eU[63]=c,eU[64]=u,eU[65]=m,eU[66]=p,eU[67]=x,eU[68]=f,eU[69]=B,eU[70]=$,eU[71]=A,eU[72]=L,eU[73]=R,eU[74]=F,eU[75]=J,eU[76]=Y,eU[77]=X):(n=eU[60],l=eU[61],o=eU[62],c=eU[63],u=eU[64],m=eU[65],p=eU[66],x=eU[67],f=eU[68],B=eU[69],$=eU[70],A=eU[71],L=eU[72],R=eU[73],F=eU[74],J=eU[75],Y=eU[76],X=eU[77]),eU[78]!==eM?(Q=eM("settingsUi.settings.connectorsLive"),eU[78]=eM,eU[79]=Q):Q=eU[79],eU[80]!==eM?(Z=eM("settingsUi.settings.tasksSourcedFromDisconnectedConnector"),eU[80]=eM,eU[81]=Z):Z=eU[81],eU[82]!==Q||eU[83]!==Z?(ee=(0,s.jsx)(j.Card,{title:Q,note:Z,plainHead:!0}),eU[82]=Q,eU[83]=Z,eU[84]=ee):ee=eU[84],eU[85]===Symbol.for("react.memo_cache_sentinel")?(es=(0,s.jsx)(b.ServiceConnections,{}),eU[85]=es):es=eU[85],eU[86]!==ee?(et=(0,s.jsxs)("div",{className:"rlStack",children:[ee,es]}),eU[86]=ee,eU[87]=et):et=eU[87],eU[88]===Symbol.for("react.memo_cache_sentinel")?(ei=(0,s.jsx)(y.AboutSection,{}),eU[88]=ei):ei=eU[88],eU[89]!==et?(en={billing:n,workspace:l,notifications:o,security:c,publishing:u,storage:m,profile:p,org:x,members:f,teams:B,perm:$,lang:A,models:L,general:R,mcp:F,dev:J,data:Y,apps:X,connect:et,about:ei},eU[89]=et,eU[90]=en):en=eU[90],ea=en,ec=eX,ed="rlSet",eu=eO?eW:void 0,eU[91]===Symbol.for("react.memo_cache_sentinel")?(em={containerType:"inline-size",containerName:"rlSet"},eU[91]=em):em=eU[91],el="rlShell",eU[92]!==eM?(ep=eM("settingsUi.settings.settingsSections"),eU[92]=eM,eU[93]=ep):ep=eU[93],eU[94]===Symbol.for("react.memo_cache_sentinel")?(eh=(0,s.jsx)("span",{className:"clRelief wsNavRelief","aria-hidden":"true"}),eU[94]=eh):eh=eU[94],eU[95]!==e7?(ex=e7("settings"),eU[95]=e7,eU[96]=ex):ex=eU[96],eU[97]!==ex?(eg=(0,s.jsx)("div",{className:"wsNavTitle",children:(0,s.jsx)("strong",{children:ex})}),eU[97]=ex,eU[98]=eg):eg=eU[98],eU[99]!==eA||eU[100]!==eC||eU[101]!==e7?(eb=e=>{let t=D[e.index],i=e.items.some(e=>e.id===eA);return(0,s.jsxs)("div",{className:"wsNavGroup",children:[e.index>0&&(0,s.jsxs)("button",{type:"button",className:"wsNavHeading","aria-expanded":i,"aria-controls":`settings-group-${e.index}`,onClick:()=>e4(e.items[0].id),children:[(0,s.jsx)(t,{size:17}),(0,s.jsx)("span",{children:e7(`groups.${e.index}`)}),(0,s.jsx)(a.ChevronDown,{size:14,style:{transform:i?void 0:"rotate(-90deg)"}})]}),(0,s.jsx)("div",{id:`settings-group-${e.index}`,className:e.index>0?"wsNavChildren":void 0,hidden:e.index>0&&!i,children:e.items.map(i=>{let n=H[i.id]??t;return(0,s.jsxs)("a",{href:`/settings?section=${i.id}`,"aria-current":eA===i.id?"page":void 0,className:(0,h.cn)("rlNavRow","wsNavItem",e.index>0&&"wsNavChild",eA===i.id&&"on"),onClick:e=>e6(e,i.id),children:[0===e.index&&(0,s.jsx)(n,{size:17}),(0,s.jsx)("span",{className:"rlNavLabel",children:eC(i.id,i.label)})]},i.id)})})]},e.group)},eU[99]=eA,eU[100]=eC,eU[101]=e7,eU[102]=eb):eb=eU[102],eU[103]===Symbol.for("react.memo_cache_sentinel")?(ej=e=>e6(e,"profile"),eU[103]=ej):ej=eU[103];let eD="profile"===eA?"page":void 0;eU[104]!==eB?.email||eU[105]!==eB?.name||eU[106]!==e7?(ev=eB?.email??eB?.name??e7("account"),eU[104]=eB?.email,eU[105]=eB?.name,eU[106]=e7,eU[107]=ev):ev=eU[107],eU[108]!==ev?(ef=(0,s.jsx)("strong",{className:"rlNavAcctName",children:ev}),eU[108]=ev,eU[109]=ef):ef=eU[109],eU[110]!==e7?(ey=e7("account"),eU[110]=e7,eU[111]=ey):ey=eU[111],eU[112]!==ey?(ew=(0,s.jsx)("span",{className:"rlRowN",children:ey}),eU[112]=ey,eU[113]=ew):ew=eU[113],eU[114]!==ef||eU[115]!==ew?(eN=(0,s.jsxs)("span",{className:"wsAccountCopy",children:[ef,ew]}),eU[114]=ef,eU[115]=ew,eU[116]=eN):eN=eU[116],eU[117]===Symbol.for("react.memo_cache_sentinel")?(eS=(0,s.jsx)(r.ChevronRight,{size:13,"aria-hidden":"true"}),eU[117]=eS):eS=eU[117],eU[118]!==eD||eU[119]!==eN?(ek=(0,s.jsxs)("a",{href:"/settings?section=account",className:"rlNavAcct wsAccount",onClick:ej,"aria-current":eD,children:[eN,eS]}
1),eU[118]=eD,eU[119]=eN,eU[120]=ek):ek=eU[120],er=(0,s.jsxs)("nav",{className:"rlNav wsSettingsNav","aria-label":ep,children:[eh,eg,(0,s.jsx)("div",{className:"wsNavScroll",children:e_.map(eb)}),ek]}),eo=eq&&(0,s.jsxs)("nav",{ref:eK,className:"wsIndex","aria-label":eM("settingsUi.settings.settingsSections"),onScroll:z,children:[(0,s.jsx)("div",{className:"wsIndexBar","aria-hidden":"true",children:e7("settings")}),(0,s.jsx)("h1",{className:"wsIndexTitle",children:e7("settings")}),(0,s.jsx)("form",{className:"wsIndexSearch",role:"search",onSubmit:e=>{e.preventDefault(),eF&&e4(eF)},children:(0,s.jsx)(j.SearchField,{value:e0,onChange:e1,label:e7("search")})}),eR&&(0,s.jsxs)("a",{href:"/settings?section=account",className:"wsIndexCard wsIndexAccount","aria-current":"profile"===eA?"page":void 0,onClick:e=>e6(e,"profile"),children:[(0,s.jsx)(j.Mark,{size:40,color:"var(--os-accent)",children:(0,j.initialsOf)(eB?.name,eB?.email)}),(0,s.jsxs)("span",{className:"wsIndexCopy",children:[(0,s.jsx)("strong",{children:eB?.name||eB?.email||e7("account")}),(0,s.jsx)("span",{children:e7("account")})]}),(0,s.jsx)(r.ChevronRight,{className:"wsIndexChevron","aria-hidden":"true"})]}),e$.length>0&&(0,s.jsx)("div",{className:"wsIndexCard",children:e$.map(e=>eI(e))}),eL.length>0&&(0,s.jsx)("div",{className:"wsIndexCard",children:eL.map(e=>{let t=!!eE||eQ.includes(e.index),i=D[e.index];return(0,s.jsxs)("div",{className:"wsIndexGroup","data-open":t||void 0,children:[(0,s.jsxs)("button",{type:"button",className:"wsIndexRow","aria-expanded":t,"aria-controls":`settings-list-${e.index}`,onClick:()=>eZ(s=>s.includes(e.index)?s.filter(s=>s!==e.index):[...s,e.index]),children:[(0,s.jsx)(i,{"aria-hidden":"true"}),(0,s.jsx)("span",{children:e.title}),(0,s.jsx)(r.ChevronRight,{className:"wsIndexChevron","aria-hidden":"true"})]}),(0,s.jsx)("div",{id:`settings-list-${e.index}`,className:"wsIndexKids",role:"group","aria-label":e.title,children:(0,s.jsx)("div",{children:e.items.map(e=>eI(e,!0))})})]},e.group)})}),!eR&&!eP.length&&(0,s.jsx)("p",{className:"wsIndexEmpty",role:"status",children:e7("empty")})]}),eU[33]=eA,eU[34]=e3,eU[35]=eO,eU[36]=eX,eU[37]=eQ,eU[38]=eW,eU[39]=eq,eU[40]=e0,eU[41]=eM,eU[42]=eB?.email,eU[43]=eB?.name,eU[44]=e7,eU[45]=ea,eU[46]=el,eU[47]=er,eU[48]=eo,eU[49]=ec,eU[50]=ed,eU[51]=eu,eU[52]=em}else ea=eU[45],el=eU[46],er=eU[47],eo=eU[48],ec=eU[49],ed=eU[50],eu=eU[51],em=eU[52];eU[121]!==eq||eU[122]!==e7?(ep=eq&&(0,s.jsx)("div",{className:"wsBackBar",children:(0,s.jsxs)("button",{type:"button",className:"wsBack","aria-label":`${e7("back")}, ${e7("settings")}`,onClick:e5,children:[(0,s.jsx)(l.ChevronLeft,{size:22,"aria-hidden":"true"}),(0,s.jsx)("span",{children:e7("settings")})]})}),eU[121]=eq,eU[122]=e7,eU[123]=ep):ep=eU[123];let e9=eR&&"hasTools";eU[124]!==e9?(eh=(0,h.cn)("rlSecHead",e9),eU[124]=e9,eU[125]=eh):eh=eU[125];let se=`titles.${eA}`;eU[126]!==e8.title||eU[127]!==se||eU[128]!==e7?(ex=e7(se,{defaultValue:e8.title}),eU[126]=e8.title,eU[127]=se,eU[128]=e7,eU[129]=ex):ex=eU[129],eU[130]!==ex?(eg=(0,s.jsx)("h1",{className:"rlSecTitle",children:ex}),eU[130]=ex,eU[131]=eg):eg=eU[131];let ss=`subtitles.${eA}`;eU[132]!==e8.sub||eU[133]!==ss||eU[134]!==e7?(eb=e7(ss,{defaultValue:e8.sub}),eU[132]=e8.sub,eU[133]=ss,eU[134]=e7,eU[135]=eb):eb=eU[135],eU[136]!==eb?(ej=(0,s.jsx)("span",{className:"rlSecSub",children:eb}),eU[136]=eb,eU[137]=ej):ej=eU[137],eU[138]!==eg||eU[139]!==ej?(ev=(0,s.jsxs)("div",{className:"rlSecHeadCopy",children:[eg,ej]}),eU[138]=eg,eU[139]=ej,eU[140]=ev):ev=eU[140],eU[141]!==eR?(ef=eR&&(0,s.jsx)("div",{className:"rlPageTools",children:eR}),eU[141]=eR,eU[142]=ef):ef=eU[142];let st=+!!ez;return eU[143]!==st?(ey={opacity:st},eU[143]=st,eU[144]=ey):ey=eU[144],eU[145]===Symbol.for("react.memo_cache_sentinel")?(ew=(0,s.jsx)("i",{}),eU[145]=ew):ew=eU[145],eU[146]!==e7?(eN=e7("saved"),eU[146]=e7,eU[147]=eN):eN=eU[147],eU[148]!==ey||eU[149]!==eN?(eS=(0,s.jsxs)("span",{className:"rlSaved",style:ey,"aria-live":"polite",children:[ew,eN]}),eU[148]=ey,eU[149]=eN,eU[150]=eS):eS=eU[150],eU[151]!==eh||eU[152]!==ev||eU[153]!==ef||eU[154]!==eS?(ek=(0,s.jsxs)("div",{className:eh,
1children:[ev,ef,eS]}),eU[151]=eh,eU[152]=ev,eU[153]=ef,eU[154]=eS,eU[155]=ek):ek=eU[155],eU[156]!==eA||eU[157]!==ea||eU[158]!==eO||eU[159]!==eB?.id||eU[160]!==eB?.organization_id?(e_=eO?(0,s.jsx)(j.PageToolsProvider,{set:eF,children:(0,s.jsx)(i.Fragment,{children:ea[eA]},`${eA}:${eB?.id}:${eB?.organization_id}`)}):null,eU[156]=eA,eU[157]=ea,eU[158]=eO,eU[159]=eB?.id,eU[160]=eB?.organization_id,eU[161]=e_):e_=eU[161],eU[162]!==e_?(eC=(0,s.jsx)("div",{className:"rlPage",children:e_}),eU[162]=e_,eU[163]=eC):eC=eU[163],eU[164]!==eA||eU[165]!==ep||eU[166]!==ek||eU[167]!==eC?(eE=(0,s.jsx)("main",{className:"rlBody",ref:eJ,children:(0,s.jsxs)("div",{className:"rlWrap","data-settings-layout":eA,children:[ep,ek,eC]})}),eU[164]=eA,eU[165]=ep,eU[166]=ek,eU[167]=eC,eU[168]=eE):eE=eU[168],eU[169]!==el||eU[170]!==er||eU[171]!==eo||eU[172]!==eE?(eT=(0,s.jsxs)("div",{className:el,children:[er,eo,eE]}),eU[169]=el,eU[170]=er,eU[171]=eo,eU[172]=eE,eU[173]=eT):eT=eU[173],eU[174]!==ec||eU[175]!==ed||eU[176]!==eu||eU[177]!==em||eU[178]!==eT?(eP=(0,s.jsx)("div",{ref:ec,className:ed,"data-pane":eu,style:em,children:eT}),eU[174]=ec,eU[175]=ed,eU[176]=eu,eU[177]=em,eU[178]=eT,eU[179]=eP):eP=eU[179],eP}],23701)},543679,e=>{"use strict";var s=e.i(271645),t=e.i(402389),i=e.i(209165);e.s(["useOrganisation",0,function(){let[e,n]=(0,s.useState)(null),[a,l]=(0,s.useState)(!0),r=(0,s.useCallback)(async()=>{l(!0);try{let e=await (0,i.apiFetch)("/api/v1/org");if(!e.ok)throw Error();n(await e.json())}catch{n(null)}finally{l(!1)}},[]);return(0,s.useEffect)(()=>{r()},[r]),{org:e,loading:a,updateOrg:async function(e){let s=await (0,i.apiFetch)("/api/v1/org",{method:"PATCH",body:JSON.stringify(e)});if(!s.ok)throw Error((await s.json().catch(()=>({}))).detail??"Failed to update workspace");let t=await s.json();return n(t),t},uploadLogo:async function(e){let s=new FormData;s.append("file",e);let a=await fetch(`${i.BASE}/api/v1/org/logo`,{method:"POST",credentials:"include",body:s});if(!a.ok)throw Error((await a.json().catch(()=>({}))).detail??t.default.t("hooksUi.organisation.logoUploadFailed","Failed to upload logo"));let l=await a.json();return n(l),l},removeLogo:async function(){let e=await (0,i.apiFetch)("/api/v1/org/logo",{method:"DELETE"});if(!e.ok)throw Error((await e.json().catch(()=>({}))).detail??t.default.t("hooksUi.organisation.logoRemoveFailed","Failed to remove logo"));let s=await e.json();return n(s),s},deleteOrg:async function(){await (0,i.movingWorkspace)(()=>(0,i.apiFetch)("/api/v1/org",{method:"DELETE"})).catch(e=>{throw 409===e.status?Error(t.default.t("hooksUi.organisation.deleteSubscriptionActive","Cancel this workspace's subscription before deleting it")):e}),window.location.assign("/")},refetch:r}}])},71647,e=>{"use strict";var s=e.i(271645);e.i(785269);var t=e.i(322831),i=e.i(846696),n=e.i(209165),a=e.i(13080);e.s(["useSecureMode",0,function(){let{t:e}=(0,t.useTranslation)(),{user:l,refreshUser:r}=(0,a.useAuth)(),[o,c]=(0,s.useState)(!1),d=l?.org_secure_mode===!0,u=l?.secure_mode===!0,m=l?.org_role==="owner"||(l?.capabilities??[]).includes("security.workspace.manage");async function p(s,t,a){c(!0);try{let l=await (0,n.apiFetch)(s,{method:"PATCH",body:JSON.stringify(t)});if(!l.ok){let e=await l.json().catch(()=>({}));throw Error(e.detail)}await r(),i.toast.success(a?e("settingsUi.general.secureOnToast"):e("settingsUi.general.secureOffToast"))}catch(s){i.toast.error(s instanceof Error&&s.message?s.message:e("settingsUi.general.secureSaveFailed"))}finally{c(!1)}}async function h(e){o||d||e===u||await p("/api/v1/auth/secure-mode",{secure_mode:e},e)}async function x(e){!o&&m&&e!==d&&await p("/api/v1/org",{secure_mode:e},e)}return{secure:d||u,orgSecure:d,ownSecure:u,ownLocked:d,canManageOrg:m,busy:o,setOwnSecure:h,setOrgSecure:x,toggle:()=>h(!u)}}])},372428,e=>{"use strict";var s=e.i(271645),t=e.i(209165),i=e.i(13080);let n="palette:subscription-changed",a=null,l=new Map;async function r(e,s=!1,i=""){let n=`${i}:${e}`;if(!s&&a?.key===n)return a.data;let o=l.get(n);if(o)return o;let c=(async()=>{try{let s=await (0,t.apiFetch)("/api/v1/billing/usage");if(!s.ok)return null;let i=await s.json();if(i?.organization_id!==e||!i.usage||!i.plan||!i.subscription)return null;return i}catch{return null}})();l.set(n,c);let d=await c;return l.get(n)!==c?null:(l.delete(n),d&&(a={key:n,data:d}),d)}e.s(["formatBytes",0,function(e){if(null==e)return"—";let s=e/0x40000000;if(s>=1024)return`${(s/1024).toFixed(1)} TB`;if(s>=1)return`${Number.isInteger(s)||s>=10?Math.round(s):s.toFixed(1)} GB`;let t=e/1048576;return t>=1?`${t.toFixed(0)} MB`:`${Math.max(0,Math.round(e/1024))} KB`},"formatCredits",0,function(e,s="en"){return null==e?"—":new Intl.NumberFormat(s,{maximumFractionDigits:0}).format(Math.max(0,Math.round(e)))},"formatDate",0,function(e,s="en"){return e?new Intl.DateTimeFormat(s,{year:"numeric",month:"short",day:"numeric"}).format(new Date(e)):"—"},"formatUsd",0,function(e,s="en"){return null==e?null:new Intl.NumberFormat(s,{style:"currency",currency:"USD",maximumFractionDigits:e%100?2:0}).format(e/100)}
1,"notifySubscriptionChanged",0,function(){a=null,l.clear(),window.dispatchEvent(new Event(n))},"useSubscription",0,function(){let{user:e}=(0,i.useAuth)(),t=e?.organization_id??null,l=e?.id??"",o=`${l}:${t}`,c=(0,s.useRef)(o);c.current=o;let d=(0,s.useRef)(0),[u,m]=(0,s.useState)(()=>({key:o,data:a?.key===o?a.data:null,loading:a?.key!==o,error:!1})),p=(0,s.useCallback)(async(e=!0)=>{let s=++d.current;if(!t)return void m({key:o,data:null,loading:!1,error:!1});let i=await r(t,e,l);c.current===o&&d.current===s&&m(e=>({key:o,data:i??(e.key===o?e.data:null),loading:!1,error:null===i}))},[t,l,o]);return(0,s.useEffect)(()=>{p(a?.key!==o);let e=()=>{p(!0)},s=()=>{"visible"===document.visibilityState&&p(!0)};return window.addEventListener(n,e),document.addEventListener("visibilitychange",s),()=>{++d.current,window.removeEventListener(n,e),document.removeEventListener("visibilitychange",s)}},[o,p]),{data:u.key===o?u.data:null,loading:u.key!==o||u.loading,error:u.key===o&&u.error,reload:p}}])},798921,e=>{"use strict";var s=e.i(209165);let t="palette:byo-providers-change",i=e=>e.startsWith("device_"),n=new Map;async function a(e=!1,t="default"){let i=n.get(t);if(i||(i={rows:null,pending:null},n.set(t,i)),i.pending)return i.pending;if(i.rows&&!e)return i.rows;let l=i;return l.pending=(async()=>{try{let e=await (0,s.apiFetch)("/api/v1/llm-providers");return e.ok&&(l.rows=await e.json()),l.rows??[]}catch{return l.rows??[]}})().finally(()=>{l.pending=null}),l.pending}e.s(["BYO_CHANGE_EVENT",0,t,"byoModelGroups",0,function(e){return e.filter(e=>"inactive"!==e.status&&(!i(e.kind)||"__TAURI_INTERNALS__"in window)).filter(e=>e.models.length>0).map(e=>({provider:e.name.toUpperCase(),models:e.models.map(s=>{let t;return{id:(t=e.id,`byo:${t}:${s}`),label:s}}),kind:e.kind,status:e.status,isDefault:e.is_default}))},"fetchByoProviders",0,a,"invalidateByoProviders",0,function(){n.clear(),window.dispatchEvent(new Event(t))},"isDeviceKind",0,i])},434163,e=>{"use strict";var s=e.i(843476),t=e.i(500932);e.i(785269);var i=e.i(322831),n=e.i(372428);e.s(["MemberLimitNotice",0,function(e){let a,l,r,o,c,d,u=(0,t.c)(21),{data:m}=e,{t:p,i18n:h}=(0,i.useTranslation)("paletteOs"),x=m?.usage.member_limit;if(!x||!x.warning&&!x.blocked)return null;let g=`cdUsageBanner rlHint ${x.blocked?"danger":"warn"}`,b=x.blocked?"usage.memberBlocked":"usage.memberWarning";return u[0]!==p||u[1]!==b?(a=p(b),u[0]=p,u[1]=b,u[2]=a):a=u[2],u[3]!==a?(l=(0,s.jsx)("div",{className:"cdUsageTitle",children:a}),u[3]=a,u[4]=l):l=u[4],u[5]!==h.language||u[6]!==x.blocked||u[7]!==x.cycle_ends_at||u[8]!==x.hard_limit||u[9]!==x.used||u[10]!==x.warning_limit||u[11]!==p?(r=p("usage.memberUsage",{used:(0,n.formatCredits)(x.used,h.language),limit:(0,n.formatCredits)(x.blocked?x.hard_limit:x.warning_limit,h.language),date:(0,n.formatDate)(x.cycle_ends_at,h.language)}),u[5]=h.language,u[6]=x.blocked,u[7]=x.cycle_ends_at,u[8]=x.hard_limit,u[9]=x.used,u[10]=x.warning_limit,u[11]=p,u[12]=r):r=u[12],u[13]!==r?(o=(0,s.jsx)("div",{className:"cdUsageMeta",children:r}),u[13]=r,u[14]=o):o=u[14],u[15]!==l||u[16]!==o?(c=(0,s.jsxs)("div",{className:"cdUsageBody",children:[l,o]}),u[15]=l,u[16]=o,u[17]=c):c=u[17],u[18]!==g||u[19]!==c?(d=(0,s.jsx)("div",{className:g,role:"status","aria-live":"polite",children:c}),u[18]=g,u[19]=c,u[20]=d):d=u[20],d}])}]);

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.