xaq-cli 0.0.0 → 0.1.0-nightly.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/admin-5gThRwgj.js +162 -0
- package/dist/admin-5gThRwgj.js.map +1 -0
- package/dist/admin-Btrm8mCd.js +218 -0
- package/dist/admin-Btrm8mCd.js.map +1 -0
- package/dist/admin-CWofnT_Q.js +2 -0
- package/dist/api-BFpElwqK.js +89 -0
- package/dist/api-BFpElwqK.js.map +1 -0
- package/dist/audit-BB7jK9Z5.js +2 -0
- package/dist/audit-BVYknW2i.js +79 -0
- package/dist/audit-BVYknW2i.js.map +1 -0
- package/dist/auth-CXmBdMqw.js +2 -0
- package/dist/auth-D-GmwNv-.js +550 -0
- package/dist/auth-D-GmwNv-.js.map +1 -0
- package/dist/brand--ZB8jTn1.js +32 -0
- package/dist/brand--ZB8jTn1.js.map +1 -0
- package/dist/bus-Cz0flS37.js +12 -0
- package/dist/bus-Cz0flS37.js.map +1 -0
- package/dist/bus-OKIGut72.js +2 -0
- package/dist/cli.js +234 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands-BNVLjYXA.js +167 -0
- package/dist/commands-BNVLjYXA.js.map +1 -0
- package/dist/commands-CdA6-WE7.js +112 -0
- package/dist/commands-CdA6-WE7.js.map +1 -0
- package/dist/config-C9XmYZWO.js +94 -0
- package/dist/config-C9XmYZWO.js.map +1 -0
- package/dist/config-CNVi0v5t.js +2 -0
- package/dist/connect-TtJ9n0Rw.js +362 -0
- package/dist/connect-TtJ9n0Rw.js.map +1 -0
- package/dist/content-C1lKMxFS.js +1170 -0
- package/dist/content-C1lKMxFS.js.map +1 -0
- package/dist/content-worker.js +28 -0
- package/dist/content-worker.js.map +1 -0
- package/dist/crypto-fv2fj3S8.js +75 -0
- package/dist/crypto-fv2fj3S8.js.map +1 -0
- package/dist/db-BEUEUPyP.js +561 -0
- package/dist/db-BEUEUPyP.js.map +1 -0
- package/dist/db-Q5BQuwga.js +2 -0
- package/dist/errors-FbMS3QBo.js +39 -0
- package/dist/errors-FbMS3QBo.js.map +1 -0
- package/dist/filter-Ck6OMxvu.js +158 -0
- package/dist/filter-Ck6OMxvu.js.map +1 -0
- package/dist/hermes-CKyzt1mH.js +3 -0
- package/dist/hermes-DHnDTYJp.js +1023 -0
- package/dist/hermes-DHnDTYJp.js.map +1 -0
- package/dist/import-DsN5NZT3.js +910 -0
- package/dist/import-DsN5NZT3.js.map +1 -0
- package/dist/instance-CwWbFbJ8.js +2 -0
- package/dist/instance-Dj9TpJB2.js +195 -0
- package/dist/instance-Dj9TpJB2.js.map +1 -0
- package/dist/listen-B9iO7HgQ.js +1568 -0
- package/dist/listen-B9iO7HgQ.js.map +1 -0
- package/dist/listen-CXVKG9XD.js +2 -0
- package/dist/manage-Bo6COB4p.js +477 -0
- package/dist/manage-Bo6COB4p.js.map +1 -0
- package/dist/manage-DoXqvjnU.js +2 -0
- package/dist/mcpheader-B8c5YO1B.js +2 -0
- package/dist/mcpheader-C9H4vudu.js +185 -0
- package/dist/mcpheader-C9H4vudu.js.map +1 -0
- package/dist/mcpsetup-BnHudwpq.js +2 -0
- package/dist/mcpsetup-DXXo2qjf.js +1053 -0
- package/dist/mcpsetup-DXXo2qjf.js.map +1 -0
- package/dist/node-check-CjTk6VNL.js +24 -0
- package/dist/node-check-CjTk6VNL.js.map +1 -0
- package/dist/paths-d-C2kdjo.js +2 -0
- package/dist/paths-yzOKD6ow.js +46 -0
- package/dist/paths-yzOKD6ow.js.map +1 -0
- package/dist/profile-CcMZ4hn7.js +2 -0
- package/dist/profile-NmMKAczz.js +222 -0
- package/dist/profile-NmMKAczz.js.map +1 -0
- package/dist/prompt-CKMQx_MJ.js +114 -0
- package/dist/prompt-CKMQx_MJ.js.map +1 -0
- package/dist/recipes-C7TIDlRj.js +3 -0
- package/dist/recipes-DG_-doGq.js +314 -0
- package/dist/recipes-DG_-doGq.js.map +1 -0
- package/dist/send-Dk-t8ia-.js +108 -0
- package/dist/send-Dk-t8ia-.js.map +1 -0
- package/dist/server-CDqDp1q3.js +20640 -0
- package/dist/server-CDqDp1q3.js.map +1 -0
- package/dist/service-BVn3soZZ.js +766 -0
- package/dist/service-BVn3soZZ.js.map +1 -0
- package/dist/service-BaWGPmSd.js +2 -0
- package/dist/service-C7jfo-Ex.js +457 -0
- package/dist/service-C7jfo-Ex.js.map +1 -0
- package/dist/service-DxDyKDQ-.js +2 -0
- package/dist/settings-B5qSHxRM.js +134 -0
- package/dist/settings-B5qSHxRM.js.map +1 -0
- package/dist/settings-DQvZaMN1.js +2 -0
- package/dist/setup-token-CwuSzfLK.js +48 -0
- package/dist/setup-token-CwuSzfLK.js.map +1 -0
- package/dist/skill/SKILL.md +445 -0
- package/dist/skill-1UQj3qgW.js +69 -0
- package/dist/skill-1UQj3qgW.js.map +1 -0
- package/dist/skill-pelq18JQ.js +2 -0
- package/dist/ssrf-BlVpGZ7C.js +181 -0
- package/dist/ssrf-BlVpGZ7C.js.map +1 -0
- package/dist/types-BhJDbSzE.js +135 -0
- package/dist/types-BhJDbSzE.js.map +1 -0
- package/dist/ui-B8Sd4Y7Y.js +81 -0
- package/dist/ui-B8Sd4Y7Y.js.map +1 -0
- package/dist/urls-Dp8pBGMU.js +2 -0
- package/dist/urls-U_LfYV61.js +27 -0
- package/dist/urls-U_LfYV61.js.map +1 -0
- package/dist/version-BxH7OuWD.js +20 -0
- package/dist/version-BxH7OuWD.js.map +1 -0
- package/dist/web/assets/_agentId-DonOCOlC.js +1 -0
- package/dist/web/assets/_app-B7t5lEia.js +1 -0
- package/dist/web/assets/_app-DMTGqYpM.js +65 -0
- package/dist/web/assets/_connectionId-DR5vFXOg.js +1 -0
- package/dist/web/assets/_webhookId-LfUlsULp.js +1 -0
- package/dist/web/assets/account-status-CEszs13C.js +1 -0
- package/dist/web/assets/accounts-5m7aiXuZ.js +1 -0
- package/dist/web/assets/accounts-list-YfJzThZa.js +1 -0
- package/dist/web/assets/activity-DOIe7SAg.js +1 -0
- package/dist/web/assets/add-connection-C8JR-13R.js +1 -0
- package/dist/web/assets/agent-create-form-CPxnPYH4.js +1 -0
- package/dist/web/assets/agents-B2Qj5KxT.js +1 -0
- package/dist/web/assets/approvals-BGaVaoFy.js +1 -0
- package/dist/web/assets/approve._id-BLrQnzPM.js +1 -0
- package/dist/web/assets/arrow-left-DZVAXoKj.js +1 -0
- package/dist/web/assets/arrow-right-C2zcqRr2.js +1 -0
- package/dist/web/assets/attention-gO9Nw5uW.js +1 -0
- package/dist/web/assets/audit-BPXXre8S.js +1 -0
- package/dist/web/assets/audit-bits-CGyIprzK.js +1 -0
- package/dist/web/assets/bell-ring-ig3zn1iS.js +1 -0
- package/dist/web/assets/bot-Zk76q_39.js +1 -0
- package/dist/web/assets/calendar-notice-DsCfq3VJ.js +1 -0
- package/dist/web/assets/calendar-plus-Cycfkk0y.js +1 -0
- package/dist/web/assets/calendar-setup-Pn61Wj1n.js +2 -0
- package/dist/web/assets/card-GSO5o-Ug.js +1 -0
- package/dist/web/assets/check-check-Ds1bPIGv.js +1 -0
- package/dist/web/assets/checkbox-B937U-Fd.js +1 -0
- package/dist/web/assets/chevron-right-Cqh4mDk1.js +1 -0
- package/dist/web/assets/chips-input-2xWDofmE.js +1 -0
- package/dist/web/assets/choice-cards-CgAIqBGX.js +1 -0
- package/dist/web/assets/circle-x-DcU-0zVh.js +1 -0
- package/dist/web/assets/command-khhto70y.js +1 -0
- package/dist/web/assets/common-BPZV8TFb.js +1 -0
- package/dist/web/assets/connect-agent-guide-CJdw31p2.js +1 -0
- package/dist/web/assets/connect-host-lr2c3xWh.js +6 -0
- package/dist/web/assets/connection-row-DYx_5o0c.js +1 -0
- package/dist/web/assets/connections-C4NOFb5R.js +1 -0
- package/dist/web/assets/data-table-kW1pkRB5.js +1 -0
- package/dist/web/assets/empty-DzTDioBP.js +1 -0
- package/dist/web/assets/events-C9zJnPKK.js +1 -0
- package/dist/web/assets/eye-B9gT1QSq.js +1 -0
- package/dist/web/assets/eye-off-Diktqz_g.js +1 -0
- package/dist/web/assets/field-C6ejurju.js +1 -0
- package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/assets/get-started-C38bq1gZ.js +2 -0
- package/dist/web/assets/hidden-chars-Dr9TxfvF.js +1 -0
- package/dist/web/assets/index-DGzo3kGh.js +11 -0
- package/dist/web/assets/index-zKOCQLGX.css +2 -0
- package/dist/web/assets/input-CWwJgozn.js +1 -0
- package/dist/web/assets/input-group-HG8OXcJ4.js +1 -0
- package/dist/web/assets/label-multi-select-sH8mllw8.js +1 -0
- package/dist/web/assets/labels-B5UqVwFo.js +1 -0
- package/dist/web/assets/laptop-BxJ4Nbj7.js +1 -0
- package/dist/web/assets/last-call-D-O5O94z.js +1 -0
- package/dist/web/assets/listener-handled-HNCuVrQ7.js +1 -0
- package/dist/web/assets/login-DaeKclcf.js +1 -0
- package/dist/web/assets/mail-C5fm2pTC.js +1 -0
- package/dist/web/assets/mcp-call-UoOTPFyh.js +1 -0
- package/dist/web/assets/mcp-call-card-Cr-OEDX2.js +3 -0
- package/dist/web/assets/message-square-quote-se8Bf3RP.js +1 -0
- package/dist/web/assets/mutations-CLPqJ6cj.js +1 -0
- package/dist/web/assets/network-igNw0VVx.js +1 -0
- package/dist/web/assets/pairing-XjuaVr2u.js +1 -0
- package/dist/web/assets/pairing-notifier-KPzOEZSO.js +1 -0
- package/dist/web/assets/paperclip-znS4iTrg.js +1 -0
- package/dist/web/assets/password-input-DV3aqcNf.js +1 -0
- package/dist/web/assets/pause-o-dK3khK.js +1 -0
- package/dist/web/assets/pencil-DkPFAhEq.js +1 -0
- package/dist/web/assets/play-DvCHND93.js +1 -0
- package/dist/web/assets/plug-CXAniEiR.js +1 -0
- package/dist/web/assets/plug-zap-BwR-l5wb.js +1 -0
- package/dist/web/assets/plus-B_TUslu3.js +1 -0
- package/dist/web/assets/preload-helper-Cc_aKyUb.js +1 -0
- package/dist/web/assets/public-url-rF2Xjyel.js +1 -0
- package/dist/web/assets/queries-Cv3nXx0U.js +42 -0
- package/dist/web/assets/refresh-cw-Ch5FNrby.js +1 -0
- package/dist/web/assets/revealed-keys-C_9NtJPY.js +1 -0
- package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/web/assets/rotate-ccw-B-mzPDk0.js +1 -0
- package/dist/web/assets/search-CTVKGomS.js +1 -0
- package/dist/web/assets/select-Bb806bpq.js +1 -0
- package/dist/web/assets/send-DuMVuYs1.js +1 -0
- package/dist/web/assets/settings-BWauhfFf.js +1 -0
- package/dist/web/assets/setup-B7bNKQOp.js +1 -0
- package/dist/web/assets/sheet-CYPwpUsH.js +1 -0
- package/dist/web/assets/shield-alert-CSYB-ThV.js +1 -0
- package/dist/web/assets/shield-check-BulpsYqK.js +1 -0
- package/dist/web/assets/sparkles-CUTiob4K.js +1 -0
- package/dist/web/assets/stamp-BNXUGNa3.js +1 -0
- package/dist/web/assets/step-url-51aMNak-.js +1 -0
- package/dist/web/assets/stream-Du7fY5_Y.js +1 -0
- package/dist/web/assets/tag-I5_-1jFL.js +1 -0
- package/dist/web/assets/terminal-BvxDFTJc.js +1 -0
- package/dist/web/assets/test-email-button-DYi7V_6X.js +1 -0
- package/dist/web/assets/toggle-group-Bdo1gmQ1.js +1 -0
- package/dist/web/assets/trash-Ci0aICEl.js +1 -0
- package/dist/web/assets/use-delivery-speed-BBh7W2q6.js +1 -0
- package/dist/web/assets/use-label-names-BXicesnP.js +1 -0
- package/dist/web/assets/use-sign-out-CPrY_oVO.js +1 -0
- package/dist/web/assets/useInfiniteQuery-DJLIM8yJ.js +1 -0
- package/dist/web/assets/useQuery-MrTwwNy5.js +1 -0
- package/dist/web/assets/useRouterState-D4OBK8l5.js +1 -0
- package/dist/web/assets/webhook-DjeeZiNC.js +1 -0
- package/dist/web/assets/webhook-bits-jw-y2D3u.js +1 -0
- package/dist/web/assets/webhook-sheet-B8h0skDe.js +34 -0
- package/dist/web/assets/webhooks-Cfsdpoyd.js +1 -0
- package/dist/web/assets/x-MF2TZ9aG.js +1 -0
- package/dist/web/favicon.svg +1 -0
- package/dist/web/index.html +27 -0
- package/package.json +98 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Wt as t}from"./queries-Cv3nXx0U.js";var n=e(t(),1),r=new Map,i=new Set;function a(e,t){r.set(e,t),i.forEach(e=>e())}function o(e){r.delete(e),i.forEach(e=>e())}function s(e){return(0,n.useSyncExternalStore)(e=>(i.add(e),()=>i.delete(e)),()=>r.get(e))}function c(){r.clear(),i.forEach(e=>e())}export{s as i,o as n,a as r,c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{s as n,l as r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,B as n,F as r,H as i,J as a,L as o,P as s,Q as c,R as l,U as u,Ut as d,V as f,W as p,Wt as m,X as h,Z as g,_t as _,at as v,ct as y,dt as b,et as x,ft as S,gt as C,it as w,nt as T,rt as E,tt as D,vt as O}from"./queries-Cv3nXx0U.js";import{wt as ee}from"./index-DGzo3kGh.js";var k={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};k.node;var A=_(k),j={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};j.node;var M=_(j),N=e(m(),1),te=e(O(),1),P=Object.defineProperty,F=(e,t)=>P(e,`name`,{value:t,configurable:!0});function I(e,[t,n]){return Math.min(n,Math.max(t,e))}F(I,`clamp`);var L=d(),R=Object.defineProperty,z=(e,t)=>R(e,`name`,{value:t,configurable:!0}),B={ItemAligned:`item-aligned`,Popper:`popper`},V={LTR:`ltr`,RTL:`rtl`},H=[` `,`Enter`,`ArrowUp`,`ArrowDown`],U=[` `,`Enter`],W=`Select`,[G,K,q]=T(W),[J,ne]=w(W,[q,l]),re=l(),[ie,Y]=J(W),[ae,oe]=J(W);function se(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:u,dir:d,name:f,autoComplete:p,disabled:m,required:h,form:_,internal_do_not_use_render:v}=e,y=re(t),[b,S]=N.useState(null),[C,w]=N.useState(null),[T,E]=N.useState(!1),D=g(d),[O,ee]=x({prop:r,defaultProp:i??!1,onChange:a,caller:W}),[k,A]=x({prop:o,defaultProp:l,onChange:u,caller:W}),j=N.useRef(null),M=N.useRef(!1),[te,P]=N.useState(null),F=z(e=>{P({value:e,hasConsumerStoppedPropagation:M.current}),A(e)},`handleUserSelect`),I=N.useRef(k);N.useEffect(()=>{let e=_?b?.ownerDocument.getElementById(_):b?.form;if(e instanceof HTMLFormElement){let t=z(()=>A(I.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[_,b,A]);let R=!b||!!_||!!b.closest(`form`),[B,V]=N.useState(new Set),H=c(),U=Array.from(B).map(e=>e.props.value).join(`;`),K=N.useCallback(e=>{V(t=>new Set(t).add(e))},[]),q=N.useCallback(e=>{V(t=>{let n=new Set(t);return n.delete(e),n})},[]),J={required:h,trigger:b,onTriggerChange:S,valueNode:C,onValueNodeChange:w,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:H,value:k,onValueChange:A,hasConsumerStoppedPropagationRef:M,userSelection:te,onUserSelect:F,open:O,onOpenChange:ee,dir:D,triggerPointerDownPosRef:j,disabled:m,name:f,autoComplete:p,form:_,nativeOptions:B,nativeSelectKey:U,isFormControl:R};return(0,L.jsx)(s,{...y,children:(0,L.jsx)(ie,{scope:t,...J,children:(0,L.jsx)(G.Provider,{scope:t,children:(0,L.jsx)(ae,{scope:t,onNativeOptionAdd:K,onNativeOptionRemove:q,children:Je(v)?v(J):n})})})})}z(se,`SelectProvider`);var ce=z(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,L.jsx)(se,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,L.jsxs)(L.Fragment,{children:[n,e?(0,L.jsx)(qe,{__scopeSelect:t}):null]})})},`Select`),le=`SelectTrigger`,ue=N.forwardRef(z(function(e,t){let{__scopeSelect:n,disabled:i=!1,...a}=e,o=re(n),s=Y(le,n),c=s.disabled||i,l=b(t,s.onTriggerChange),u=K(n),d=N.useRef(`touch`),[f,p,m]=Ye(e=>{let t=u().filter(e=>!e.disabled),n=Xe(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onUserSelect(n.value)}),h=z(e=>{c||(s.onOpenChange(!0),m()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,L.jsx)(r,{asChild:!0,...o,children:(0,L.jsx)(v.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...a,ref:l,onClick:D(a.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:D(a.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:D(a.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),p(e.key)),!(t&&e.key===` `)&&H.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),de=`SelectValue`,fe=N.forwardRef(z(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Y(de,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=b(t,c.onValueNodeChange);E(()=>{l(u)},[l,u]);let f=$(c.value);return(0,L.jsx)(v.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,L.jsx)(N.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),pe=N.forwardRef(z(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,L.jsx)(v.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[me,he]=J(`SelectPortal`,{forceMount:void 0}),ge=z(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,L.jsx)(me,{scope:e.__scopeSelect,forceMount:n,children:(0,L.jsx)(u,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,_e=N.forwardRef(z(function(e,n){let r=he(X,e.__scopeSelect),{forceMount:i=r.forceMount,...a}=e,o=Y(X,e.__scopeSelect),[s,c]=N.useState();return E(()=>{c(new DocumentFragment)},[]),(0,L.jsx)(t,{present:i||o.open,children:({present:e})=>e?(0,L.jsx)(xe,{...a,ref:n}):(0,L.jsx)(ve,{...a,fragment:s})})},`SelectContent`)),ve=N.forwardRef(z(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?te.createPortal((0,L.jsx)(ye,{scope:n,children:(0,L.jsx)(G.Slot,{scope:n,children:(0,L.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[ye,Q]=J(X),be=y(`SelectContent.RemoveScroll`),xe=N.forwardRef(z(function(e,t){let{__scopeSelect:r}=e,{position:o=B.ItemAligned,onCloseAutoFocus:s,onEscapeKeyDown:c,onPointerDownOutside:l,side:u,sideOffset:d,align:m,alignOffset:h,arrowPadding:g,collisionBoundary:_,collisionPadding:v,sticky:y,hideWhenDetached:x,avoidCollisions:S,...C}=e,w=Y(X,r),[T,E]=N.useState(null),[O,ee]=N.useState(null),k=b(t,E),[A,j]=N.useState(null),[M,te]=N.useState(null),P=K(r),[F,I]=N.useState(!1),R=N.useRef(!1),V=N.useRef(!1),H=N.useRef(!1);N.useEffect(()=>{if(T)return n(T)},[T]),i();let U=N.useCallback(e=>{let[t,...n]=P().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[P,O]),W=N.useCallback(()=>U([A,T]),[U,A,T]);N.useEffect(()=>{F&&W()},[F,W]);let{onOpenChange:G,triggerPointerDownPosRef:q}=w;N.useEffect(()=>{if(T){let e={x:0,y:0},t=z(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=z(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(T)||G(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[T,G,q]),N.useEffect(()=>{let e=z(()=>G(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[G]);let[J,ne]=Ye(e=>{let t=P().filter(e=>!e.disabled),n=Xe(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),re=N.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!R.current&&!n;w.value!==void 0&&w.value===t||i?(j(e),i&&(R.current=!0)):r&&j(e)},[w.value]),ie=N.useCallback(()=>T?.focus(),[T]),ae=N.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!R.current&&!n;(w.value!==void 0&&w.value===t||i||r)&&te(e)},[w.value]),oe=o===B.Popper?Ce:Se,se=oe===Ce?{side:u,sideOffset:d,align:m,alignOffset:h,arrowPadding:g,collisionBoundary:_,collisionPadding:v,sticky:y,hideWhenDetached:x,avoidCollisions:S}:{};return(0,L.jsx)(ye,{scope:r,content:T,viewport:O,onViewportChange:ee,itemRefCallback:re,selectedItem:A,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:W,selectedItemText:M,position:o,isPositioned:F,searchRef:J,children:(0,L.jsx)(f,{as:be,allowPinchZoom:!0,children:(0,L.jsx)(p,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:D(s,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,L.jsx)(a,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:(0,L.jsx)(oe,{role:`listbox`,id:w.contentId,"data-state":w.open?`open`:`closed`,dir:w.dir,onContextMenu:e=>e.preventDefault(),...C,...se,onPlaced:()=>I(!0),ref:k,style:{display:`flex`,flexDirection:`column`,outline:`none`,...C.style},onKeyDown:D(C.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=P().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>U(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Se=N.forwardRef(z(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=Y(X,n),o=Q(X,n),[s,c]=N.useState(null),[l,u]=N.useState(null),d=b(t,u),f=K(n),p=N.useRef(!1),m=N.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:y}=o,x=N.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==V.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Z,d=I(a,[Z,Math.max(Z,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Z,d=I(a,[Z,Math.max(Z,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Z*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,D=c-E,O=g.offsetHeight/2,ee=g.offsetTop+O,k=m+v+ee,A=x-k;if(k<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+A;s.style.height=t+`px`,h.scrollTop=k-E+h.offsetTop}s.style.margin=`${Z}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);E(()=>x(),[x]);let[S,C]=N.useState();E(()=>{l&&C(window.getComputedStyle(l).zIndex)},[l]);let w=N.useCallback(e=>{e&&m.current===!0&&(x(),y?.(),m.current=!1)},[x,y]);return(0,L.jsx)(we,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:w,children:(0,L.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,L.jsx)(v.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Ce=N.forwardRef(z(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,s=re(n);return(0,L.jsx)(o,{...s,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[we,Te]=J(X,{}),Ee=`SelectViewport`,De=N.forwardRef(z(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(Ee,n),o=Te(Ee,n),s=b(t,a.onViewportChange),c=N.useRef(0);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,L.jsx)(G.Slot,{scope:n,children:(0,L.jsx)(v.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:D(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Oe,ke]=J(`SelectGroup`),Ae=N.forwardRef(z(function(e,t){let{__scopeSelect:n,...r}=e,i=c();return(0,L.jsx)(Oe,{scope:n,id:i,children:(0,L.jsx)(v.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})},`SelectGroup`)),je=`SelectLabel`,Me=N.forwardRef(z(function(e,t){let{__scopeSelect:n,...r}=e,i=ke(je,n);return(0,L.jsx)(v.div,{id:i.id,...r,ref:t})},`SelectLabel`)),Ne=`SelectItem`,[Pe,Fe]=J(Ne),Ie=N.forwardRef(z(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Y(Ne,n),l=Q(Ne,n),u=s.value===r,[d,f]=N.useState(a??``),[p,m]=N.useState(!1),g=h(e=>l.itemRefCallback?.(e,r,i)),_=b(t,g),y=c(),x=N.useRef(`touch`);function S(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return z(S,`handleSelect`),(0,L.jsx)(Pe,{scope:n,value:r,disabled:i,textId:y,isSelected:u,onItemTextChange:N.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,L.jsx)(G.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,L.jsx)(v.div,{role:`option`,"aria-labelledby":y,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:_,onFocus:D(o.onFocus,()=>m(!0)),onBlur:D(o.onBlur,()=>m(!1)),onClick:D(o.onClick,e=>{i||x.current!==`mouse`&&S(e)}),onPointerUp:D(o.onPointerUp,e=>{i||x.current===`mouse`&&S(e)}),onPointerDown:D(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:D(o.onPointerMove,e=>{x.current=e.pointerType,i?l.onItemLeave?.():x.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:D(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:D(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(l.searchRef?.current===``||e.key!==` `)&&(U.includes(e.key)&&S(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Le=`SelectItemText`,Re=N.forwardRef(z(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=Y(Le,n),s=Q(Le,n),c=Fe(Le,n),l=oe(Le,n),[u,d]=N.useState(null),f=h(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=b(t,d,c.onItemTextChange,f),m=u?.textContent,g=N.useMemo(()=>(0,L.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:_,onNativeOptionRemove:y}=l;return E(()=>(_(g),()=>y(g)),[_,y,g]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(v.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?te.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),ze=`SelectItemIndicator`,Be=N.forwardRef(z(function(e,t){let{__scopeSelect:n,...r}=e;return Fe(ze,n).isSelected?(0,L.jsx)(v.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ve=`SelectScrollUpButton`,He=N.forwardRef(z(function(e,t){let n=Q(Ve,e.__scopeSelect),r=Te(Ve,e.__scopeSelect),[i,a]=N.useState(!1),o=b(t,r.onScrollButtonChange);return E(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};z(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,L.jsx)(Ge,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ue=`SelectScrollDownButton`,We=N.forwardRef(z(function(e,t){let n=Q(Ue,e.__scopeSelect),r=Te(Ue,e.__scopeSelect),[i,a]=N.useState(!1),o=b(t,r.onScrollButtonChange);return E(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};z(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,L.jsx)(Ge,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Ge=N.forwardRef(z(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Q(`SelectScrollButton`,n),o=N.useRef(null),s=K(n),c=N.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return N.useEffect(()=>()=>c(),[c]),E(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,L.jsx)(v.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:D(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:D(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:D(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),Ke=`SelectBubbleInput`,qe=N.forwardRef(z(function({__scopeSelect:e,...t},n){let r=Y(Ke,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u,userSelection:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=N.useRef(null),h=b(n,m),g=i??``,_=N.useRef(g),y=N.useRef(d),x=N.useRef(!1),S=Array.from(f).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=d!==null&&d!==y.current;y.current=d;let i=_.current!==g;_.current=g;let a=r&&i;if(r&&!i&&d.value!==g&&!d.hasConsumerStoppedPropagation&&n){x.current=!0;try{n.call(e,d.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{x.current=!1,n.call(e,g)}return}let o=a&&!d.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,g),e.dispatchEvent(t)}},[g,d]),(0,L.jsxs)(v.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>{x.current||a(e.target.value)},...t,style:{...ee,...t.style},ref:h,defaultValue:g,children:[$(i)&&!S?(0,L.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function Je(e){return typeof e==`function`}z(Je,`isFunction`);function $(e){return e===``||e===void 0}z($,`shouldShowPlaceholder`);function Ye(e){let t=h(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}z(a,`updateSearch`),a(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}z(Ye,`useTypeaheadSearch`);function Xe(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ze(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}z(Xe,`findNextItem`);function Ze(e,t){return e.map((n,r)=>e[(t+r)%e.length])}z(Ze,`wrapArray`);function Qe({...e}){return(0,L.jsx)(ce,{"data-slot":`select`,...e})}function $e({className:e,...t}){return(0,L.jsx)(Ae,{"data-slot":`select-group`,className:S(`scroll-my-1 p-1`,e),...t})}function et({...e}){return(0,L.jsx)(fe,{"data-slot":`select-value`,...e})}function tt({className:e,size:t=`default`,children:n,...r}){return(0,L.jsxs)(ue,{"data-slot":`select-trigger`,"data-size":t,className:S(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm text-foreground whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,L.jsx)(pe,{asChild:!0,children:(0,L.jsx)(A,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function nt({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,L.jsx)(ge,{children:(0,L.jsxs)(_e,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:S(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,L.jsx)(at,{}),(0,L.jsx)(De,{"data-position":n,className:S(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,L.jsx)(ot,{})]})})}function rt({className:e,...t}){return(0,L.jsx)(Me,{"data-slot":`select-label`,className:S(`px-1.5 py-1 text-xs text-muted-foreground`,e),...t})}function it({className:e,children:t,...n}){return(0,L.jsxs)(Ie,{"data-slot":`select-item`,className:S(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,L.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,L.jsx)(Be,{children:(0,L.jsx)(C,{className:`pointer-events-none`})})}),(0,L.jsx)(Re,{children:t})]})}function at({className:e,...t}){return(0,L.jsx)(He,{"data-slot":`select-scroll-up-button`,className:S(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,L.jsx)(M,{})})}function ot({className:e,...t}){return(0,L.jsx)(We,{"data-slot":`select-scroll-down-button`,className:S(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,L.jsx)(A,{})})}export{rt as a,A as c,it as i,nt as n,tt as o,$e as r,et as s,Qe as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};t.node;var n=e(t),r={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};r.node;var i=e(r);export{n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,Ct as n,D as r,Ht as i,M as a,N as o,Ut as s,Wt as c,n as l,t as u,w as d,yt as f}from"./queries-Cv3nXx0U.js";import{t as p}from"./useQuery-MrTwwNy5.js";import{i as m,n as h,o as g,s as _,t as v}from"./select-Bb806bpq.js";import{i as y,n as b,o as x,r as S,s as C,t as w}from"./card-GSO5o-Ug.js";import{i as ee,n as te,r as ne,t as re}from"./use-sign-out-CPrY_oVO.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le}from"./step-url-51aMNak-.js";import{I as ue,d as de,f as fe,i as pe,o as me,r as he,s as ge,t as _e,u as ve}from"./common-BPZV8TFb.js";import{t as ye}from"./pencil-DkPFAhEq.js";import{a as T,i as E,n as D,r as be,t as O}from"./field-C6ejurju.js";import{n as xe,t as Se}from"./chips-input-2xWDofmE.js";import{Mt as Ce,Nt as we,Ot as Te,jt as k,kt as Ee}from"./index-DGzo3kGh.js";import{t as De}from"./mutations-CLPqJ6cj.js";import{t as Oe}from"./input-CWwJgozn.js";import{n as ke}from"./calendar-setup-Pn61Wj1n.js";import{a as Ae,i as je,n as Me,t as Ne}from"./input-group-HG8OXcJ4.js";import{n as Pe,t as Fe}from"./password-input-DV3aqcNf.js";import{i as Ie,n as Le,s as Re,t as ze}from"./public-url-rF2Xjyel.js";import{t as Be}from"./command-khhto70y.js";var Ve=class{constructor(e,t){this.atom=Ce(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(we(e))}},He=class{constructor(e){this.atom=Ce(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(we(e))}};function A(e,t){return typeof e==`function`?new He(e):t?new Ve(e,t):new Ve(e)}var j=e(c(),1),M=s();function Ue(){let e=p(l.googleClient()),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(),a=e.data,s=!!a?.clientId&&a.hasSecret;return(0,M.jsxs)(w,{children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Google OAuth client`}),(0,M.jsx)(y,{children:`Your own Google Cloud OAuth client, used to connect Gmail accounts.`}),s&&!t&&(0,M.jsx)(b,{children:(0,M.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>n(!0),children:[(0,M.jsx)(ye,{}),` Edit`]})})]}),(0,M.jsxs)(S,{className:`space-y-4`,children:[e.isPending?(0,M.jsx)(ue,{className:`h-24`}):e.isError?(0,M.jsx)(ge,{error:e.error,onRetry:()=>void e.refetch()}):t||!s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(`div`,{className:`text-sm font-medium`,children:`Import the client JSON`}),(0,M.jsx)(oe,{onImported:e=>{i(e.check),n(!1)}})]}),!s&&(0,M.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Not configured yet. The`,` `,(0,M.jsx)(f,{to:`/get-started`,search:{step:`project`},className:`text-foreground underline underline-offset-4`,children:`setup guide`}),` `,`walks you through creating one.`]}),(0,M.jsx)(`div`,{className:`text-sm font-medium`,children:`Or enter the ID and secret by hand`}),(0,M.jsx)(ce,{view:a,onSaved:e=>{i(e.check),n(!1)},onCancel:s?()=>n(!1):void 0})]}):(0,M.jsxs)(`dl`,{className:`grid grid-cols-[max-content_1fr] items-center gap-x-4 gap-y-2 text-sm`,children:[(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Client ID`}),(0,M.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:a.clientId}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Secret`}),(0,M.jsxs)(`dd`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,M.jsx)(Ee,{className:`size-3.5 text-success`}),` Saved (encrypted)`,a.secretHint?`, ending in …${a.secretHint}`:``]}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Project`}),(0,M.jsx)(`dd`,{className:`font-mono text-xs`,children:a.projectId??`—`}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Audience`}),(0,M.jsx)(`dd`,{children:a.appType===`internal`?`Internal (Workspace)`:a.appType===`external`?`External`:`—`}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Callback`}),(0,M.jsx)(`dd`,{children:a.callbackMode===`direct`?(0,M.jsx)(fe,{tone:`good`,children:`Direct redirect`}):(0,M.jsx)(fe,{tone:`warn`,children:`Paste mode`})})]}),s&&!t&&(0,M.jsx)(ie,{check:r,view:a,onChecked:i}),(0,M.jsx)(ae,{}),a&&(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(`div`,{className:`text-sm font-medium`,children:`Authorized redirect URI`}),(0,M.jsx)(he,{value:a.redirectUri,label:`Copy redirect URI`}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Must be listed exactly like this on the OAuth client in Google Cloud. It follows the public URL.`})]})]})]})}function We(){let[e,t]=(0,j.useState)(``),[n,i]=(0,j.useState)(``),[a,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(!1),u=De({mutationFn:()=>r(`/api/auth/password`,{body:{current:e,next:n}}),success:`Password changed`,errorTitle:!1,onSuccess:()=>{t(``),i(``),s(``),l(!1)}}),f=n.length<10,p=a!==n;return(0,M.jsxs)(w,{children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Admin password`}),(0,M.jsx)(y,{children:`Protects this console. Agents use their own keys and aren't affected.`})]}),(0,M.jsx)(S,{children:(0,M.jsx)(`form`,{noValidate:!0,onSubmit:t=>{t.preventDefault(),l(!0),e&&!f&&!p&&u.mutate()},children:(0,M.jsxs)(E,{className:`max-w-sm`,children:[(0,M.jsxs)(O,{"data-invalid":c&&!e,children:[(0,M.jsx)(T,{htmlFor:`pw-current`,children:`Current password`}),(0,M.jsx)(Fe,{id:`pw-current`,autoComplete:`current-password`,value:e,onChange:e=>t(e.target.value)})]}),(0,M.jsxs)(O,{"data-invalid":c&&f,children:[(0,M.jsx)(T,{htmlFor:`pw-next`,children:`New password`}),(0,M.jsx)(Fe,{id:`pw-next`,autoComplete:`new-password`,value:n,onChange:e=>i(e.target.value)}),n&&(0,M.jsx)(Pe,{password:n})]}),(0,M.jsxs)(O,{"data-invalid":c&&p,children:[(0,M.jsx)(T,{htmlFor:`pw-again`,children:`Confirm new password`}),(0,M.jsx)(Fe,{id:`pw-again`,autoComplete:`new-password`,value:a,onChange:e=>s(e.target.value)}),c&&p&&(0,M.jsx)(be,{children:`Passwords don't match.`})]}),u.isError&&(0,M.jsx)(pe,{error:u.error,title:`Couldn't change the password`}),(0,M.jsx)(`div`,{children:(0,M.jsxs)(o,{type:`submit`,disabled:u.isPending||!e||!n,children:[u.isPending&&(0,M.jsx)(d,{}),` Change password`]})})]})})})]})}var Ge=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function Ke(e,t){return new Ge(e,t).maybeExecute}var qe=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{this.#c<this.#l?(this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{})):(this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop())};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e)this.debugLog(`Event bus client is disabled, not emitting event`,e,t);else if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d)this.debugLog(`Previously failed to connect, not emitting to bus`);else if(!this.#a)this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());else return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},N=new class extends qe{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function P(e,t){return typeof e==`function`?e(t):e}function F(e,t){return et(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function I(e,t,n){let r=et(t);function i(e){if(!r.length)return P(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function Je(e,t){let n=et(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var Ye=46,Xe=91,Ze=93,Qe=48,$e=57;function et(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===Xe),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===Ye||s===Xe||s===Ze){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==Qe),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==Ze&&(a!==-1||s!==Ze)&&(a!==s||s!==Ye&&s!==Xe)&&n.push(``);r=o+1,i=!0}else(s<Qe||s>$e)&&(i=!1);a=s}return n.length||n.push(``),n}function tt(e){return!(Array.isArray(e)&&e.length===0)}function L(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function R(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var z=e=>!!e&&typeof e==`object`&&`fields`in e;function B(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!B(e[i],t[i]))return!1;return!0}var nt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},rt=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function V(e,t){return e==null?t:{...e,...t}}for(var H=256,it=[],at;H--;)it[H]=(H+256).toString(16).substring(1);function ot(){let e=0,t,n=``;if(!at||H+16>256){for(at=Array(256),e=256;e--;)at[e]=256*Math.random()|0;e=0,H=0}for(;e<16;e++)t=at[H+e],n+=e===6?it[t&15|64]:e===8?it[t&63|128]:it[t],e&1&&e>1&&e<11&&(n+=`-`);return H++,n}var st=Ke(e=>N.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function U(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=U(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,U(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(U(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=U(e[n]));return t}function W(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var G=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function ct(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var lt=(e,t)=>{let n=ct(e,t);return{form:n,fields:n}},K={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:lt(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:lt(r.issues,e)}},ut=e=>!!e&&`~standard`in e,q={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function J(e){function t(t){let n=e.getFieldMeta(t)??q;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>q;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function dt(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var ft=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{st(this)}),t=N.on(`request-form-state`,e=>{e.payload.id===this._formId&&N.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=N.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=N.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),N.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return N.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!B(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!B(e.defaultState,t.defaultState)&&!this.state.isTouched;if(n||r){if(k(()=>{this.baseStore.setState(()=>dt(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=J(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}N.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=I(t,e.instance.name,e.instance.options.defaultValue))}),dt({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return k(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return k(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=L(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||G}),r=!1,i={};return k(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=pt(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=Y(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??q,r=a?.[e],{newErrorValue:s,newSource:c}=nt({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=q)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=Y(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=Y(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=R(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||G});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=Y(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=pt(r);s&&(i=i?{...i,...s}:s);let c=Y(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??q,r=i?.[e],{newErrorValue:a,newSource:o}=nt({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=q)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),k(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid)n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),N.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});else if(await this.validate(`submit`),!this.state.isValid)n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),N.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});else{k(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),k(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),N.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),N.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}}},this.getFieldValue=e=>F(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:P(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=q,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;k(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:I(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t.startsWith(`${n}.`)||t.startsWith(`${n}[`)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=Je(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),J(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],V(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),J(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),V(r,{dontValidate:!0})),J(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),V(n,{dontValidate:!0})),J(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return I(I(e,`${t}`,i),`${n}`,r)},V(r,{dontValidate:!0})),J(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},V(r,{dontValidate:!0})),J(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],V(t,{dontValidate:!0})),J(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=F(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:q},values:i===void 0?t.values:I(t.values,e,i)}})},this.setErrorMap=e=>{k(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(z(t)){let{formError:e,fieldErrors:r}=pt(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>K.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>K.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ot(),this._devtoolsSubmissionOverride=!1;let t=dt({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(n!==void 0&&z(n))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=A(t);let n;this.fieldMetaDerived=A(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=F(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!tt(u),f=!o.isDirty,p=B(l,this.getFieldInfo(a)?.instance?.options.defaultValue??F(this.options.defaultValues,a));c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s?(i[a]=c,r++):i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=A(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!W(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&W(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let ee={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(ee,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=ee}return r});let r;this.store=A(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&z(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&B(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return ut(e.validate)?K[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function pt(e){return e?z(e)?{formError:pt(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function Y(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var mt=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...q,isTouched:e.fieldMetaBase[this.name]?.isTouched??q.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??q.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??q.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(B(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,V(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,V(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,V(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,V(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,V(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,V(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,V(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,V(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=L(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||G}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=L(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||G});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;k(()=>{let e=(e,n)=>{let r=X(n.cause),a=n.validate?ht(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=rt({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=X(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=R(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||G}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=R(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||G});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));k(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=X(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=ht(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=rt({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),k(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>W(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[X(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[X(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)(!a.get(t)||t.options.asyncAlways)&&c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>K.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>K.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)W(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=A(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...q,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!B(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return ut(e.validate)?K[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function ht(e){if(e)return e}function X(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function gt(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function _t(e){return{...q,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var vt=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??gt({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(B(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...q,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??gt({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;bt(t)&&(n=t.group,r=t.fields);let i=yt(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:gt({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,V(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof mt&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&W(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=nt({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=q)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=L(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||G}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=L(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||G});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;k(()=>{let t=(t,r)=>{let i=St(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&bt(s)&&(c=s.group,l=s.fields);let u=yt(c),d=n[i],{newErrorValue:f,newSource:p}=rt({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=St(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=R(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||G}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=R(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||G});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=St(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&bt(o)&&(l=o.group,u=o.fields);let d=yt(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=rt({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return k(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>W(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[St(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>W(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),k(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid())n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});else if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid)n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});else{k(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),k(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=A(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??_t(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!B(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ut(e.validate)){let t=K[e.type](e.value,e.validate);return e.type===`validate`?xt(t):t.then(xt)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function yt(e){if(e)return e}function bt(e){return!!e&&typeof e==`object`&&`fields`in e}function xt(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function St(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Ct(e,t){if(!t)return;let n=Object.assign({},e,{state:U(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return k(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var Z=typeof window<`u`?j.useLayoutEffect:j.useEffect;function wt(e){let[t,r]=(0,j.useState)(()=>({form:e.form,name:e.name})),[i,a]=(0,j.useState)(()=>new mt({...e})),o=i;(t.form!==e.form||t.name!==e.name)&&(o=new mt({...e}),a(o),r({form:e.form,name:e.name}));let s=n(o.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),c=n(o.store,e=>e.meta.isTouched),l=n(o.store,e=>e.meta.isBlurred),u=n(o.store,e=>e.meta.isDirty),d=n(o.store,e=>e.meta.errorMap),f=n(o.store,e=>e.meta.errorSourceMap),p=n(o.store,e=>e.meta.isValidating),m=(0,j.useMemo)(()=>({...o,get state(){return{value:e.mode===`array`?o.state.value:s,get meta(){return{...o.state.meta,isTouched:c,isBlurred:l,isDirty:u,errorMap:d,errorSourceMap:f,isValidating:p}}}}}),[o,e.mode,s,c,l,u,d,f,p]);return Z(o.mount,[o]),Z(()=>{o.update(e)}),m}var Tt=(({children:e,...t})=>{let n=wt(t),r=(0,j.useMemo)(()=>P(e,n),[e,n]);return(0,M.jsx)(M.Fragment,{children:r})});function Et(){return(0,j.useState)(()=>ot())[0]}var Dt=j,Ot=`19.3.0`.split(`.`)[0]===`17`?Et:Dt.useId;function kt(e){let[t,r]=(0,j.useState)(()=>({form:e.form,name:e.name})),[i,a]=(0,j.useState)(()=>new vt({...e}));(t.form!==e.form||t.name!==e.name)&&(a(new vt({...e})),r({form:e.form,name:e.name}));let o=n(i.store,e=>e.value),s=n(i.store,e=>e.meta.isTouched),c=n(i.store,e=>e.meta.isBlurred),l=n(i.store,e=>e.meta.isDirty),u=n(i.store,e=>e.meta.errorMap),d=n(i.store,e=>e.meta.errorSourceMap),f=n(i.store,e=>e.meta.isValidating),p=n(i.store,e=>e.meta.isSubmitting),m=n(i.store,e=>e.meta.isSubmitted),h=n(i.store,e=>e.meta.submissionAttempts),g=n(i.store,e=>e.meta.isSubmitSuccessful),_=n(i.store,e=>e.meta.canSubmit),v=n(i.store,e=>e.meta.isValid),y=n(i.store,e=>e.meta.isFieldsValid),b=n(i.store,e=>e.meta.isFieldsValidating),x=n(i.store,e=>e.meta.isGroupValid),S=(0,j.useMemo)(()=>({...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get state(){return{...i.state,value:o,get meta(){return{...i.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f,isSubmitting:p,isSubmitted:m,submissionAttempts:h,isSubmitSuccessful:g,canSubmit:_,isValid:v,isFieldsValid:y,isFieldsValidating:b,isGroupValid:x}}}}}),[i,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x]);return Z(i.mount,[i]),Z(()=>{i.update(e)}),S}var At=(({children:e,...t})=>{let n=kt(t),r=(0,j.useMemo)(()=>P(e,n),[e,n]);return(0,M.jsx)(M.Fragment,{children:r})});function jt({form:e,selector:t=e=>e,children:r}){let i=n(e.store,t);return(0,M.jsx)(M.Fragment,{children:P(r,i)})}function Mt(e){let t=Ot(),[n,r]=(0,j.useState)(e?.formId),[i,a]=(0,j.useState)(()=>new ft({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new ft({...e,formId:n})),r(n)}let o=(0,j.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,M.jsx)(Tt,{...e,form:i})},e.FormGroup=function(e){return(0,M.jsx)(At,{...e,form:i})},e.Subscribe=function(e){return(0,M.jsx)(jt,{form:i,selector:e.selector,children:e.children})},e},[i]);Z(i.mount,[]),Z(()=>{i.update(e)});let s=(0,j.useRef)(!1);return Z(()=>{s.current&&e?.transform&&Ct(i,e.transform)},[i,e?.transform]),Z(()=>{s.current=!0}),o}var Nt=e=>({publicUrl:e.publicUrl,ingestMode:e.ingestMode,pollIntervalSeconds:String(e.pollIntervalSeconds),calendarPollSeconds:String(e.calendarPollSeconds),maxBodyChars:String(e.maxBodyChars),retentionDays:String(e.retentionDays),approvalTtlHours:String(e.approvalTtlHours),webhookAllowlist:e.webhookAllowlist,pairingEnabled:e.pairingEnabled,brokerUpstreams:e.brokerUpstreams}),Pt=e=>({publicUrl:e.publicUrl.trim().replace(/\/+$/,``),ingestMode:e.ingestMode,pollIntervalSeconds:Number(e.pollIntervalSeconds),calendarPollSeconds:Number(e.calendarPollSeconds),maxBodyChars:Number(e.maxBodyChars),retentionDays:Number(e.retentionDays),approvalTtlHours:Number(e.approvalTtlHours),webhookAllowlist:e.webhookAllowlist,pairingEnabled:e.pairingEnabled,brokerUpstreams:e.brokerUpstreams}),Q=(e,t,n)=>r=>{if(!/^\d+$/.test(r.trim()))return`${e} must be a whole number.`;let i=Number(r);if(i<t||i>n)return`${e} must be between ${t.toLocaleString()} and ${n.toLocaleString()}.`},Ft=e=>e.length>253?`too long`:/[/]/.test(e)&&!/^[\d.:a-f]+\/\d{1,3}$/i.test(e)?`use a hostname, IP or CIDR like 10.0.0.0/8`:null;function It({settings:e,system:n}){let s=i(),c=Mt({defaultValues:Nt(e),onSubmit:async({value:n,formApi:i})=>{let o=Pt(n),c=Object.fromEntries(Object.entries(o).filter(([t,n])=>JSON.stringify(n)!==JSON.stringify(e[t])));try{let e=await r(`/api/settings`,{method:`PATCH`,body:c});s.setQueryData(u.settings,e);for(let e of[u.system,u.googleClient,u.setupState])s.invalidateQueries({queryKey:e});i.reset(Nt(e)),a.success(`Settings saved`)}catch(e){t(e,`Couldn't save settings`)}}}),l=JSON.stringify(Nt(e)),[f,p]=(0,j.useState)(!1);return(0,M.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c.handleSubmit()},noValidate:!0,className:`space-y-6`,children:[(0,M.jsxs)(w,{children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Public URL`}),(0,M.jsx)(y,{children:`Where this instance is reachable. Used for the Google OAuth redirect and in the MCP URLs you give agents. Agents on other machines must be able to reach it.`})]}),(0,M.jsx)(S,{children:(0,M.jsx)(c.Field,{name:`publicUrl`,validators:{onChange:({value:e})=>Re(e)},children:e=>(0,M.jsxs)(O,{"data-invalid":!e.state.meta.isValid,children:[(0,M.jsx)(T,{htmlFor:e.name,children:`Public URL`}),(0,M.jsx)(Oe,{id:e.name,className:`font-mono`,inputMode:`url`,spellCheck:!1,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),"aria-invalid":!e.state.meta.isValid}),e.state.meta.isValid?(0,M.jsxs)(D,{children:[`MCP endpoint: `,e.state.value.trim().replace(/\/+$/,``),`/mcp`]}):(0,M.jsx)(be,{children:e.state.meta.errors.join(` `)}),n&&n.addresses.length>0&&(0,M.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,role:`group`,"aria-label":`Addresses this server is reachable at`,children:[...new Set([window.location.origin,...n.addresses])].map(t=>(0,M.jsxs)(o,{type:`button`,size:`sm`,variant:`outline`,className:`h-auto flex-col items-start gap-0 py-1 text-left`,onClick:()=>e.handleChange(t),children:[(0,M.jsx)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:ze(t,window.location.origin)}),(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:t})]},t))}),e.state.meta.isValid&&Le(e.state.value)&&(0,M.jsx)(se,{analysis:Le(e.state.value),browserRemote:!Ie(window.location.origin),className:`mt-1`}),(0,M.jsx)(ae,{className:`mt-2`})]})})})]}),(0,M.jsxs)(w,{children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Mail sync`}),(0,M.jsx)(y,{children:`How xaq learns about new mail.`})]}),(0,M.jsx)(S,{children:(0,M.jsxs)(E,{children:[(0,M.jsx)(c.Field,{name:`ingestMode`,children:e=>(0,M.jsxs)(O,{children:[(0,M.jsx)(T,{htmlFor:e.name,children:`Mode`}),(0,M.jsxs)(v,{value:e.state.value,onValueChange:t=>e.handleChange(t),children:[(0,M.jsx)(g,{id:e.name,className:`w-full sm:w-80`,children:(0,M.jsx)(_,{})}),(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{value:`pubsub`,children:`Real-time (Gmail push via Pub/Sub)`}),(0,M.jsx)(m,{value:`poll`,children:`Polling`})]})]}),(0,M.jsx)(D,{children:e.state.value===`pubsub`?`Needs Pub/Sub provisioned (see below). Gmail notifies within seconds.`:`Checks every account's history on an interval. No extra Google setup.`})]})}),(0,M.jsx)(c.Field,{name:`pollIntervalSeconds`,validators:{onChange:({value:e})=>Q(`Poll interval`,5,3600)(e)},children:e=>(0,M.jsx)($,{field:e,label:`Poll interval`,unit:`seconds`,description:`How often polling checks each account. Real-time mode also polls at this interval while Pub/Sub isn't set up or is failing; otherwise it re-checks every 5 minutes.`})})]})})]}),(0,M.jsxs)(w,{id:`calendar`,className:`scroll-mt-20`,children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Google Calendar`}),(0,M.jsx)(y,{children:`Lets agents read calendars, find free time, schedule events and answer invitations, per their access.`})]}),(0,M.jsx)(S,{children:(0,M.jsxs)(E,{children:[(0,M.jsx)(ke,{}),(0,M.jsx)(c.Field,{name:`calendarPollSeconds`,validators:{onChange:({value:e})=>Q(`Calendar poll interval`,15,3600)(e)},children:e=>(0,M.jsx)($,{field:e,label:`Calendar poll interval`,unit:`seconds`,description:`How often synced calendars are checked for changes and new invitations. Calendars with a verified Google push channel are re-checked every 15 minutes instead.`})})]})})]}),(0,M.jsxs)(w,{children:[(0,M.jsx)(x,{children:(0,M.jsx)(C,{children:`Agents and retention`})}),(0,M.jsx)(S,{children:(0,M.jsxs)(E,{className:`grid gap-6 sm:grid-cols-2`,children:[(0,M.jsx)(c.Field,{name:`maxBodyChars`,validators:{onChange:({value:e})=>Q(`Max body characters`,0,1e6)(e)},children:e=>(0,M.jsx)($,{field:e,label:`Max body length`,unit:`characters`,description:`Per message returned to agents; longer bodies are truncated (and flagged). 0 = no limit.`})}),(0,M.jsx)(c.Field,{name:`approvalTtlHours`,validators:{onChange:({value:e})=>Q(`Approval expiry`,1,720)(e)},children:e=>(0,M.jsx)($,{field:e,label:`Approvals expire after`,unit:`hours`,description:`Unanswered requests are rejected and their drafts deleted.`})}),(0,M.jsx)(c.Field,{name:`retentionDays`,validators:{onChange:({value:e})=>Q(`Retention`,1,3650)(e)},children:e=>(0,M.jsx)($,{field:e,label:`Keep history for`,unit:`days`,description:`Events, webhook deliveries, audit entries and decided approvals older than this are deleted.`})})]})})]}),(0,M.jsxs)(w,{id:`pairing`,className:`scroll-mt-20`,children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Agent pairing`}),(0,M.jsxs)(y,{children:[`Lets an agent ask for access from its own terminal with `,(0,M.jsx)(`code`,{className:`font-mono text-xs`,children:`npx xaq-cli connect`}),`, instead of you copying an API key.`]})]}),(0,M.jsx)(S,{children:(0,M.jsx)(c.Field,{name:`pairingEnabled`,children:e=>(0,M.jsxs)(O,{orientation:`horizontal`,className:`items-start`,children:[(0,M.jsx)(xe,{id:e.name,checked:e.state.value,onCheckedChange:t=>e.handleChange(t),className:`mt-0.5`}),(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(T,{htmlFor:e.name,children:`Accept pairing requests`}),(0,M.jsx)(D,{children:e.state.value?`Requests wait under Approvals → Agent access. Nothing gets access until you approve the matching code and choose its permissions; the key goes straight to the agent's terminal.`:`Off: connect is refused. You can still create agents under Agents and paste their key yourself.`})]})]})})})]}),(0,M.jsxs)(w,{id:`mcp-broker`,className:`scroll-mt-20`,children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Connections (MCP broker)`}),(0,M.jsx)(y,{children:`Lets your agents use other MCP servers and apps, like Notion, through xaq. xaq holds every sign-in and asks you before risky actions.`})]}),(0,M.jsx)(S,{children:(0,M.jsx)(c.Field,{name:`brokerUpstreams`,children:e=>(0,M.jsxs)(O,{orientation:`horizontal`,className:`items-start`,children:[(0,M.jsx)(xe,{id:e.name,checked:e.state.value,onCheckedChange:t=>e.handleChange(t),className:`mt-0.5`}),(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(T,{htmlFor:e.name,children:`Use connections`}),(0,M.jsx)(D,{children:e.state.value?`On: the Connections page is in the sidebar, and agents see the tools of the connections you give them.`:`Off: no connection's tools reach any agent and the Connections page is hidden. Your connections and their settings are kept.`})]})]})})})]}),(0,M.jsxs)(w,{id:`webhook-allowlist`,className:`scroll-mt-20`,children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Webhook allowlist`}),(0,M.jsx)(y,{children:`Webhooks may not target private, loopback or link-local addresses (this stops a webhook URL from probing your network), except hosts listed here.`})]}),(0,M.jsx)(S,{children:(0,M.jsx)(c.Field,{name:`webhookAllowlist`,children:e=>(0,M.jsxs)(O,{children:[(0,M.jsx)(T,{htmlFor:`allowlist`,children:`Allowed private hosts`}),(0,M.jsx)(Se,{id:`allowlist`,value:e.state.value,onChange:e.handleChange,placeholder:`e.g. 10.0.0.0/8, n8n.internal`,validate:Ft,onPendingChange:p}),(0,M.jsxs)(D,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(Te,{className:`mt-0.5 size-3.5 shrink-0`}),(0,M.jsxs)(`span`,{children:[`Hostnames, IPs or CIDR ranges, e.g. `,(0,M.jsx)(`code`,{className:`font-mono`,children:`127.0.0.0/8`}),`, `,(0,M.jsx)(`code`,{className:`font-mono`,children:`192.168.1.0/24`}),`,`,` `,(0,M.jsx)(`code`,{className:`font-mono`,children:`n8n.internal`}),`. Public hosts don't need to be listed.`]})]})]})})})]}),(0,M.jsx)(c.Subscribe,{selector:e=>[JSON.stringify(e.values)!==l,e.canSubmit,e.isSubmitting],children:([e,t,n])=>e?(0,M.jsxs)(`div`,{className:`sticky bottom-4 z-10 flex flex-wrap items-center justify-between gap-3 rounded-xl border bg-background/95 p-3 shadow-lg backdrop-blur`,children:[(0,M.jsx)(`span`,{className:`text-sm`,children:f?`Add or clear the host you're typing in the allowlist first.`:`You have unsaved changes.`}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>c.reset(),children:`Discard`}),(0,M.jsxs)(o,{type:`submit`,disabled:!t||n||f,children:[n&&(0,M.jsx)(d,{}),` Save settings`]})]})]}):null})]})}function $({field:e,label:t,unit:n,description:r}){return(0,M.jsxs)(O,{"data-invalid":!e.state.meta.isValid,children:[(0,M.jsx)(T,{htmlFor:e.name,children:t}),(0,M.jsxs)(Ne,{className:`w-full sm:w-56`,children:[(0,M.jsx)(je,{id:e.name,inputMode:`numeric`,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value.replace(/[^\d]/g,``)),"aria-invalid":!e.state.meta.isValid}),(0,M.jsx)(Me,{align:`inline-end`,children:(0,M.jsx)(Ae,{children:n})})]}),e.state.meta.isValid?(0,M.jsx)(D,{children:r}):(0,M.jsx)(be,{children:e.state.meta.errors.join(` `)})]})}function Lt(){let e=p(l.system()),t=p(l.systemLatest()),n=e.data;return(0,M.jsxs)(w,{children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`System`}),(0,M.jsx)(y,{children:`This xaq instance.`})]}),(0,M.jsxs)(S,{className:`space-y-4`,children:[e.isPending?(0,M.jsx)(ue,{className:`h-32`}):n?(0,M.jsxs)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-4 gap-y-2 text-sm`,children:[(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Version`}),(0,M.jsx)(`dd`,{className:`font-mono text-xs`,children:n.version}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Node.js`}),(0,M.jsx)(`dd`,{className:`font-mono text-xs`,children:n.nodeVersion}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Data directory`}),(0,M.jsx)(`dd`,{className:`font-mono text-xs break-all`,children:n.dataDir}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Runs as`}),(0,M.jsxs)(`dd`,{className:`min-w-0 space-y-1.5`,children:[(0,M.jsx)(`span`,{className:`block`,children:n.service?`System service (starts automatically)`:`Foreground process`}),!n.service&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Closing its terminal stops everything. To keep it running and start it at login, run this on the server:`}),(0,M.jsx)(Be,{code:n.serviceCommand,label:`service install command`}),(0,M.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Stop the one in your terminal first (Ctrl-C): the service can't start while it runs.`})]})]}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Mail sync`}),(0,M.jsxs)(`dd`,{className:`space-y-0.5`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,M.jsx)(ve,{tone:n.ingest.lastError?`bad`:n.ingest.running?`good`:`idle`}),n.ingest.mode===`pubsub`?`Real-time (Pub/Sub)`:`Polling`,` · `,n.ingest.running?`running`:`stopped`]}),(0,M.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Last check `,(0,M.jsx)(de,{date:n.ingest.lastPullAt,fallback:`never`})]}),n.ingest.lastError&&(0,M.jsx)(`span`,{className:`block text-xs break-words text-critical`,children:n.ingest.lastError})]}),(0,M.jsx)(`dt`,{className:`text-muted-foreground`,children:`Reachable at`}),(0,M.jsx)(`dd`,{className:`space-y-0.5 font-mono text-xs`,children:n.addresses.map(e=>(0,M.jsx)(`div`,{className:`break-all`,children:e},e))})]}):(0,M.jsx)(ge,{error:e.error,onRetry:()=>void e.refetch()}),t.data&&(t.data.updateAvailable&&t.data.latest?(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-chart-1/30 bg-chart-1/5 p-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,M.jsx)(ee,{className:`size-4 text-chart-1`}),` Version `,t.data.latest,` is available`]}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n?.service?`Run this on the server. It reinstalls the service with the latest version; data, accounts and agents are kept.`:`Stop xaq, then run this on the server. Your data is kept.`}),(0,M.jsx)(_e,{code:t.data.command})]}):(0,M.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,M.jsx)(Ee,{className:`size-3.5 text-success`}),` You're on the latest version.`]}))]})]})}function Rt(){let e=p(l.settings()),t=p(l.system()),n=re();return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(me,{title:`Settings`,actions:(0,M.jsx)(o,{variant:`outline`,asChild:!0,children:(0,M.jsxs)(f,{to:`/get-started`,children:[(0,M.jsx)(te,{}),` Setup guide`]})})}),e.isPending?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(ue,{className:`h-40 rounded-xl`}),(0,M.jsx)(ue,{className:`h-40 rounded-xl`})]}):e.isError?(0,M.jsx)(ge,{error:e.error,onRetry:()=>void e.refetch()}):(0,M.jsx)(It,{settings:e.data,system:t.data}),(0,M.jsx)(Ue,{}),(0,M.jsxs)(w,{id:`pubsub`,className:`scroll-mt-20`,children:[(0,M.jsxs)(x,{children:[(0,M.jsx)(C,{children:`Real-time delivery`}),(0,M.jsx)(y,{children:`Gmail push notifications through a Pub/Sub topic in your Google Cloud project.`})]}),(0,M.jsx)(S,{children:(0,M.jsx)(le,{})})]}),(0,M.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,M.jsx)(We,{}),(0,M.jsx)(Lt,{})]}),(0,M.jsx)(w,{children:(0,M.jsxs)(S,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`text-sm font-medium`,children:`Session`}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Signs out this browser. Agents keep working.`})]}),(0,M.jsxs)(o,{variant:`outline`,onClick:n,children:[(0,M.jsx)(ne,{}),` Sign out`]})]})})]})}export{Rt as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,Ht as n,N as ee,T as r,Ut as i,Wt as a,bt as o,t as s,w as c,yt as l}from"./queries-Cv3nXx0U.js";import{c as u,l as d,r as f,t as p,u as m}from"./card-GSO5o-Ug.js";import{i as te}from"./common-BPZV8TFb.js";import{t as ne}from"./terminal-BvxDFTJc.js";import{a as h,i as re,n as g,r as _,t as v}from"./field-C6ejurju.js";import{$ as y,Ot as b,at as x,kt as S}from"./index-DGzo3kGh.js";import{t as C}from"./input-CWwJgozn.js";import{n as w,t as T}from"./password-input-DV3aqcNf.js";var E=e(a());function D(e){let t=e.trim();if(!t)return``;try{let e=new URL(t).searchParams.get(`token`);if(e!==null)return e.trim()}catch{}let n=/(?:^|[?&])token=([^&#\s]*)/.exec(t);if(n)try{return decodeURIComponent(n[1]).trim()}catch{return n[1].trim()}return t}var O=e=>{let t=e??{};return{status:typeof t.status==`number`?t.status:void 0,code:typeof t.code==`string`?t.code:void 0,message:typeof t.message==`string`?t.message:String(e)}};function ie(e,t){let n=t?`link`:`token`;switch(e.status){case`checking`:return{phase:`checking`,status:`Checking the setup ${n}…`,submitLabel:`Continue`};case`ok`:return{phase:`verified`,status:`Setup ${n} verified.`,submitLabel:`Create admin password`};case`idle`:return{phase:`enter-token`,status:``,submitLabel:`Continue`};case`error`:{let n=O(e.error);return n.status===409?{phase:`claimed`,status:`This instance is already set up.`,submitLabel:`Continue`}:{phase:`enter-token`,status:``,tokenError:n.code===`invalid_token`?t?`This setup link isn't valid. It may be incomplete (copy the whole link) or from before a reset-password.`:`That setup token isn't valid. Paste the whole setup link from the terminal, or the token after ?token=.`:n.message,submitLabel:`Continue`}}}}var k=Error(`Paste the setup link or token from the terminal.`),A=i(),j=e=>t(`/api/setup/verify-token`,{body:{token:e}});function M(){let e=y.useSearch().token,i=o(),a=n(),[O,M]=(0,E.useState)(e??``),[N,P]=(0,E.useState)(e?{status:`checking`}:{status:`idle`}),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(!1),[V,H]=(0,E.useState)(),[U,W]=(0,E.useState)(!1),G=(0,E.useRef)(null),K=(0,E.useRef)(null),q=(0,E.useRef)(null),J=D(O),Y=ie(N,!!e&&J===e),ae=async e=>{P({status:`checking`});try{return await j(e),P({status:`ok`}),!0}catch(e){return P({status:`error`,error:e}),!1}};(0,E.useEffect)(()=>{if(!e)return;let t=!0;return j(e).then(()=>t&&P({status:`ok`}),e=>t&&P({status:`error`,error:e})),()=>{t=!1}},[e]),(0,E.useEffect)(()=>{Y.phase===`verified`?K.current?.focus():Y.phase===`claimed`?q.current?.focus():Y.tokenError&&G.current?.focus()},[Y.phase,Y.tokenError]);let X=F.length<10,Z=L.length>0&&L!==F,Q=!X&&L===F;async function oe(e){if(e.preventDefault(),Y.phase!==`verified`){if(N.status===`checking`)return;J?(M(J),await ae(J)):P({status:`error`,error:k})}else if(B(!0),Q){W(!0),H(void 0);try{await t(`/api/setup/claim`,{body:{token:J,password:F}}),a.setQueryData(s.setupStatus,{claimed:!0,authenticated:!0}),await i({to:`/get-started`})}catch(e){e instanceof r&&(e.code===`invalid_token`||e.code===`setup_token_expired`||e.status===409)?P({status:`error`,error:e}):H(e)}finally{W(!1)}}}let $=e=>(0,A.jsx)(`code`,{className:`font-mono text-foreground`,children:e});return(0,A.jsxs)(x,{title:`Welcome to xaq`,description:`Secure this console with an admin password. Next, we'll walk through connecting Gmail and your first agent.`,children:[(0,A.jsx)(p,{children:(0,A.jsx)(f,{children:(0,A.jsx)(`form`,{onSubmit:oe,noValidate:!0,children:(0,A.jsxs)(re,{children:[(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:Y.status&&Y.phase!==`claimed`?`flex items-center gap-2 rounded-lg border bg-muted/40 px-3 py-2 text-sm`:`sr-only`,children:[Y.phase===`checking`&&(0,A.jsx)(c,{className:`size-4`}),Y.phase===`verified`&&(0,A.jsx)(S,{className:`size-4 shrink-0 text-success`}),(0,A.jsx)(`span`,{children:Y.status})]}),Y.phase===`claimed`&&(0,A.jsxs)(u,{children:[(0,A.jsx)(b,{}),(0,A.jsx)(m,{children:`This instance is already set up`}),(0,A.jsx)(d,{children:(0,A.jsxs)(`p`,{children:[(0,A.jsx)(l,{to:`/login`,ref:q,className:`font-medium underline underline-offset-4`,children:`Sign in`}),` `,`with its admin password. Forgot it? Run `,$(`npx xaq-cli reset-password`),` on the server.`]})})]}),Y.phase===`enter-token`&&(0,A.jsxs)(v,{"data-invalid":!!Y.tokenError,children:[(0,A.jsx)(h,{htmlFor:`token`,children:`Setup link or token`}),(0,A.jsx)(C,{id:`token`,ref:G,autoFocus:!e,autoComplete:`off`,spellCheck:!1,className:`font-mono`,value:O,onChange:e=>{M(e.target.value),N.status===`error`&&P({status:`idle`})},"aria-invalid":!!Y.tokenError,"aria-describedby":Y.tokenError?`token-error token-help`:`token-help`}),Y.tokenError&&(0,A.jsx)(_,{id:`token-error`,children:Y.tokenError}),(0,A.jsxs)(g,{id:`token-help`,className:`space-y-1.5`,children:[(0,A.jsxs)(`span`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(ne,{className:`mt-0.5 size-3.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`Open the setup link that `,$(`npx xaq-cli`),` printed, or paste the link (or just its token) here.`]})]}),(0,A.jsxs)(`span`,{className:`block`,children:[`Lost the link? On the server, run `,$(`npx xaq-cli reset-password`),` (add `,$(`--data <dir>`),` if you used one): it prints the link again, and before setup it doesn't change anything. If you started it in a terminal, restarting `,$(`npx xaq-cli`),` prints it too.`]})]})]}),Y.phase===`verified`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(v,{"data-invalid":z&&X,children:[(0,A.jsx)(h,{htmlFor:`password`,children:`Admin password`}),(0,A.jsx)(T,{id:`password`,ref:K,autoComplete:`new-password`,value:F,onChange:e=>I(e.target.value),"aria-invalid":z&&X}),(0,A.jsx)(w,{password:F})]}),(0,A.jsxs)(v,{"data-invalid":Z||z&&L!==F,children:[(0,A.jsx)(h,{htmlFor:`confirm`,children:`Confirm password`}),(0,A.jsx)(T,{id:`confirm`,autoComplete:`new-password`,value:L,onChange:e=>R(e.target.value),"aria-invalid":Z||z&&L!==F}),(Z||z&&L!==F)&&(0,A.jsx)(_,{children:`Passwords don't match.`})]})]}),V!==void 0&&(0,A.jsx)(te,{error:V}),Y.phase!==`claimed`&&(0,A.jsxs)(ee,{type:`submit`,disabled:U||Y.phase===`checking`||Y.phase===`verified`&&z&&!Q,children:[(U||Y.phase===`checking`)&&(0,A.jsx)(c,{}),Y.submitLabel]})]})})})}),(0,A.jsx)(`p`,{className:`text-center text-xs text-balance text-muted-foreground`,children:`The password protects this console only. Agents get their own scoped API keys later.`})]})}export{M as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-XKyaHtl9.js";import{N as e,Ut as t,Wt as n,ft as r}from"./queries-Cv3nXx0U.js";import{t as i}from"./x-MF2TZ9aG.js";import{St as a,_t as o,bt as s,gt as c,vt as l,xt as u,yt as d}from"./index-DGzo3kGh.js";n();var f=t();function p({...e}){return(0,f.jsx)(c,{"data-slot":`sheet`,...e})}function m({...e}){return(0,f.jsx)(u,{"data-slot":`sheet-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(s,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}var g={top:`inset-x-0 top-0 h-auto border-b`,bottom:`inset-x-0 bottom-0 h-auto border-t`,left:`inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm`};function _({className:t,children:n,side:a=`right`,showCloseButton:s=!0,onInteractOutside:c,...u}){return(0,f.jsxs)(m,{children:[(0,f.jsx)(h,{}),(0,f.jsxs)(l,{"data-slot":`sheet-content`,"data-side":a,className:r(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,g[a],t),onInteractOutside:e=>{e.target?.closest?.(`[data-sonner-toaster]`)&&e.preventDefault(),c?.(e)},...u,children:[n,s&&(0,f.jsx)(o,{"data-slot":`sheet-close`,asChild:!0,children:(0,f.jsxs)(e,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,f.jsx)(i,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function v({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-0.5 p-4`,e),...t})}function y({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`sheet-footer`,className:r(`mt-auto flex flex-col gap-2 p-4`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`sheet-title`,className:r(`font-heading text-base font-medium text-foreground`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(d,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}export{v as a,y as i,_ as n,b as o,x as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};t.node;var n=e(t),r={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};r.node;var i=e(r);export{n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`stamp`,size:24,node:[[`path`,{d:`M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-6 0c0 2 1 2 1 3.5V13`,key:`i9gjdv`}],[`path`,{d:`M20 15.5a2.5 2.5 0 0 0-2.5-2.5h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1z`,key:`1vzg3v`}],[`path`,{d:`M5 22h14`,key:`ehvnwv`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,D as n,Ht as r,M as i,N as a,T as o,Ut as s,Wt as c,_t as l,ft as u,n as d,t as f,w as p}from"./queries-Cv3nXx0U.js";import{t as m}from"./useQuery-MrTwwNy5.js";import{i as h,n as g,o as _,s as ee,t as v}from"./select-Bb806bpq.js";import{c as y,d as b,l as x,u as S}from"./card-GSO5o-Ug.js";import{t as C}from"./circle-x-DcU-0zVh.js";import{I as w,a as T,d as E,f as D,i as O,m as k,p as A,r as j,t as te}from"./common-BPZV8TFb.js";import{n as M,t as ne}from"./send-DuMVuYs1.js";import{t as re}from"./laptop-BxJ4Nbj7.js";import{m as ie,n as ae,o as oe,p as se}from"./connect-host-lr2c3xWh.js";import{t as ce}from"./network-igNw0VVx.js";import{t as N}from"./refresh-cw-Ch5FNrby.js";import{a as P,i as le,n as F,r as I,t as L}from"./field-C6ejurju.js";import{t as ue}from"./choice-cards-CgAIqBGX.js";import{C as de,Et as fe,M as R,Ot as z,f as B,kt as V,l as pe,u as H,x as U,y as W}from"./index-DGzo3kGh.js";import{t as G}from"./mutations-CLPqJ6cj.js";import{n as K,t as q}from"./input-CWwJgozn.js";import{t as me}from"./password-input-DV3aqcNf.js";import{a as J,c as he,i as ge,n as Y,r as X,s as _e,t as Z}from"./public-url-rF2Xjyel.js";var ve={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};ve.node;var ye=l(ve),be={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};be.node;var xe=l(be),Se={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Se.node;var Ce=l(Se),we={name:`radio-tower`,size:24,node:[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]};we.node;var Te=l(we),Ee={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Ee.node;var De=l(Ee),Oe={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};Oe.node;var ke=l(Oe),Ae={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};Ae.node;var je=l(Ae),Me={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};Me.node;var Ne=l(Me),Q=e(c(),1),$=s(),Pe=e=>`https://console.cloud.google.com/auth/clients${e?`?project=${encodeURIComponent(e)}`:``}`,Fe=new Set([`redirect_uri_missing`,`redirect_uri_changed`]);function Ie(){let e=m(d.googleClient()),t=m(d.setupState());return e.data?.clientId?t.data?.warnings?.find(e=>Fe.has(e.code))??null:null}function Le({className:e,showStatus:t}){let i=Ie(),o=m(d.googleClient()),s=r(),c=(0,Q.useRef)(null),l=G({mutationFn:()=>n(`/api/google/client/check`,{method:`POST`}),invalidate:[f.setupState],errorTitle:`Couldn't check the OAuth client`,success:e=>e.redirectUri===`ok`?`Google confirms the redirect URI is registered`:void 0,onSuccess:()=>void s.invalidateQueries({queryKey:f.googleClient})}),h=!i&&l.data?.redirectUri===`ok`;if((0,Q.useEffect)(()=>{h&&c.current?.focus()},[h]),!o.data?.clientId)return null;if(!i)return h||t&&o.data.redirectUriConfirmed?(0,$.jsxs)(`p`,{ref:c,tabIndex:-1,role:`status`,className:u(`flex items-center gap-1.5 text-sm text-muted-foreground outline-none`,e),children:[(0,$.jsx)(V,{className:`size-4 shrink-0 text-success`}),h?`Google confirms the OAuth client has this redirect URI.`:`The OAuth client already has the new redirect URI.`]}):t?(0,$.jsxs)(`div`,{className:u(`space-y-1.5 text-sm`,e),children:[(0,$.jsx)(`p`,{children:`Make sure your OAuth client lists the new redirect URI (Google Auth Platform → Clients → your client → Authorized redirect URIs):`}),(0,$.jsx)(j,{value:o.data.redirectUri,label:`Copy redirect URI`})]}):null;let g=i.code===`redirect_uri_changed`,_=l.data?.redirectUri;return(0,$.jsxs)(y,{variant:`destructive`,className:e,children:[(0,$.jsx)(b,{}),(0,$.jsx)(S,{children:g?`Your address changed: add the new redirect URI to the OAuth client`:`The OAuth client is missing this redirect URI`}),(0,$.jsxs)(x,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-foreground/80`,children:i.message}),(0,$.jsxs)(`p`,{className:`text-foreground/80`,children:[`In Google Cloud: `,(0,$.jsx)(`strong`,{children:`Google Auth Platform → Clients`}),` → your client → `,(0,$.jsx)(`strong`,{children:`Authorized redirect URIs`}),` →`,` `,(0,$.jsx)(`strong`,{children:`Add URI`}),`, paste this, then `,(0,$.jsx)(`strong`,{children:`Save`}),`. Changes can take a few minutes to apply at Google.`]}),(0,$.jsx)(j,{value:o.data.redirectUri,label:`Copy redirect URI`,size:`lg`}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pt-1`,children:[(0,$.jsx)(T,{href:i.url??Pe(o.data.projectId),children:`Open Clients in Google Cloud`}),(0,$.jsxs)(a,{size:`sm`,variant:`outline`,onClick:()=>l.mutate(),disabled:l.isPending,children:[l.isPending?(0,$.jsx)(p,{}):(0,$.jsx)(N,{}),` I've added it, check now`]})]}),_&&!l.isPending&&(0,$.jsx)(`p`,{className:`text-xs text-foreground/70`,role:`status`,children:_===`missing`?`Google doesn't list it yet. If you just saved it, wait a minute and check again.`:_===`unknown`?`Google's answer was unclear. This clears by itself once an account connects through the new address.`:null}),!_&&(0,$.jsx)(`p`,{className:`text-xs text-foreground/70`,children:`This also clears by itself once an account connects through it.`})]})]})}var Re=e=>e?.secretHint??null,ze=/^\d+-[a-z0-9]+\.apps\.googleusercontent\.com$/;function Be(e){return e.trim()?ze.test(e.trim())?null:`Client IDs look like 1234567890-abc123.apps.googleusercontent.com`:`Paste the client ID from Google Cloud.`}function Ve(e){return e.trim()?W.test(e.trim())?null:`Project IDs are 6–30 lowercase letters, digits or hyphens, starting with a letter (e.g. xaq-123456). Use the ID, not the display name.`:`Enter the project ID.`}function He({view:e,projectId:t,appType:r,onSaved:i,submitLabel:o=`Save client`,onCancel:s}){let[c,l]=(0,Q.useState)(e?.clientId??``),[u,d]=(0,Q.useState)(``),[m,y]=(0,Q.useState)(t??e?.projectId??``),[b,x]=(0,Q.useState)(r??e?.appType??void 0),[S,C]=(0,Q.useState)(!1),w=!!e?.hasSecret,T=G({mutationFn:e=>n(`/api/google/client`,{method:`PUT`,body:e}),invalidate:[f.googleClient,f.setupState],success:`OAuth client saved`,errorTitle:!1,onSuccess:e=>{d(``),i?.(e)}}),E={clientId:Be(c),secret:!w&&!u.trim()?`Paste the client secret.`:null,projectId:t?null:Ve(m),appType:b?null:`Choose the audience you picked on the consent screen.`},D=!Object.values(E).some(Boolean);return(0,$.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),C(!0),D&&b&&T.mutate({clientId:c.trim(),...u.trim()?{clientSecret:u.trim()}:{},projectId:m.trim(),appType:b})},noValidate:!0,children:(0,$.jsxs)(le,{children:[(0,$.jsxs)(L,{"data-invalid":S&&!!E.clientId,children:[(0,$.jsx)(P,{htmlFor:`g-client-id`,children:`Client ID`}),(0,$.jsx)(q,{id:`g-client-id`,spellCheck:!1,autoComplete:`off`,className:`font-mono`,placeholder:`1234567890-abc123.apps.googleusercontent.com`,value:c,onChange:e=>l(e.target.value),"aria-invalid":S&&!!E.clientId}),S&&E.clientId&&(0,$.jsx)(I,{children:E.clientId})]}),(0,$.jsxs)(L,{"data-invalid":S&&!!E.secret,children:[(0,$.jsx)(P,{htmlFor:`g-client-secret`,children:`Client secret`}),(0,$.jsx)(me,{id:`g-client-secret`,autoComplete:`off`,spellCheck:!1,className:`font-mono`,placeholder:w?`Saved. Paste a new secret to replace it`:`GOCSPX-…`,value:u,onChange:e=>d(e.target.value),"aria-invalid":S&&!!E.secret}),S&&E.secret?(0,$.jsx)(I,{children:E.secret}):w?(0,$.jsxs)(F,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(V,{className:`size-3.5 text-success`}),` A secret is saved (encrypted)`,Re(e)?`, ending in …${Re(e)}`:``,`. Paste a new one only to replace it.`]}):(0,$.jsxs)(F,{children:[`Google shows a secret only once. Lost it? In Google Cloud open `,(0,$.jsx)(`strong`,{children:`Google Auth Platform → Clients`}),` → your client →`,` `,(0,$.jsx)(`strong`,{children:`Add secret`}),`, and paste the new one here. Stored encrypted.`]})]}),!t&&(0,$.jsxs)(L,{"data-invalid":S&&!!E.projectId,children:[(0,$.jsx)(P,{htmlFor:`g-project`,children:`Project ID`}),(0,$.jsx)(q,{id:`g-project`,spellCheck:!1,className:`font-mono`,value:m,onChange:e=>y(e.target.value.toLowerCase()),"aria-invalid":S&&!!E.projectId}),S&&E.projectId&&(0,$.jsx)(I,{children:E.projectId})]}),!r&&(0,$.jsxs)(L,{"data-invalid":S&&!!E.appType,children:[(0,$.jsx)(P,{htmlFor:`g-apptype`,children:`Audience`}),(0,$.jsxs)(v,{value:b,onValueChange:e=>x(e),children:[(0,$.jsx)(_,{id:`g-apptype`,className:`w-full`,"aria-invalid":S&&!!E.appType,children:(0,$.jsx)(ee,{placeholder:`Choose…`})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(h,{value:`internal`,children:`Internal (Google Workspace users only)`}),(0,$.jsx)(h,{value:`external`,children:`External (any Google account)`})]})]}),S&&E.appType&&(0,$.jsx)(I,{children:E.appType})]}),T.isError&&(0,$.jsx)(O,{error:T.error,title:`Couldn't save the OAuth client`}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[s&&(0,$.jsx)(a,{type:`button`,variant:`ghost`,onClick:s,children:`Cancel`}),(0,$.jsxs)(a,{type:`submit`,disabled:T.isPending,children:[T.isPending&&(0,$.jsx)(p,{}),o]})]})]})})}function Ue(e,t){let n=t?.secretHint?` (ending in …${t.secretHint})`:``;return[{label:`Client ID`,status:e.clientId===`ok`?`ok`:e.clientId===`invalid`?`bad`:`unknown`,text:e.clientId===`ok`?`Google knows this client.`:e.clientId===`invalid`?`Google doesn't know this client ID: it was deleted, mistyped, or belongs to another project. Create a new client and import it.`:`Couldn't tell. Connecting an account will show it.`},{label:`Redirect URI`,status:e.redirectUri===`ok`?`ok`:e.redirectUri===`missing`?`bad`:`unknown`,text:e.redirectUri===`ok`?`Registered on the client.`:e.redirectUri===`missing`?`Not registered yet (see above). Google applies changes within a few minutes: check again after adding it.`:`Couldn't tell. Connecting an account will show it.`},{label:`Secret`,status:e.secret===`ok`?`ok`:e.secret===`invalid`?`bad`:`unknown`,text:e.secret===`ok`?`Accepted by Google${n}.`:e.secret===`invalid`?`Google rejects the saved secret${n}. Open the client in Google Cloud, click Add secret, and enter the new one by hand below.`:`Couldn't tell. Connecting an account will show it.`}]}var We={ok:V,bad:C,unknown:ye},Ge={ok:`text-success`,bad:`text-critical`,unknown:`text-muted-foreground`};function Ke({check:e,view:t,onChecked:i}){let o=r(),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)();return(0,$.jsxs)(`div`,{className:`space-y-2`,role:`status`,"aria-live":`polite`,children:[e&&(0,$.jsx)(`dl`,{className:`divide-y rounded-lg border text-sm`,children:Ue(e,t).map(e=>{let t=We[e.status];return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[(0,$.jsx)(t,{className:u(`mt-0.5 size-4 shrink-0`,Ge[e.status]),"aria-hidden":!0}),(0,$.jsx)(`dt`,{className:`w-24 shrink-0 font-medium text-foreground`,children:e.label}),(0,$.jsx)(`dd`,{className:`min-w-0 flex-1 text-muted-foreground`,children:e.text})]},e.label)})}),l!==void 0&&(0,$.jsx)(O,{error:l,title:`Couldn't check the client`}),(0,$.jsxs)(a,{size:`sm`,variant:`outline`,onClick:async()=>{c(!0),d(void 0);try{i(await n(`/api/google/client/check`,{method:`POST`})),o.invalidateQueries({queryKey:f.setupState})}catch(e){d(e)}finally{c(!1)}},disabled:s,children:[s?(0,$.jsx)(p,{}):(0,$.jsx)(N,{}),` `,e?`Check again`:`Check the client with Google`]})]})}function qe({appType:e,expectedProjectId:t,onImported:i,onNeedsManual:s,quiet:c}){let l=r(),d=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useId)(),[g,_]=(0,Q.useState)(``),[ee,v]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(),D=async t=>{if(t.trim()){S(!0),w(void 0),E(void 0);try{let r=await n(`/api/google/client/import`,{body:{json:t,...e?{appType:e}:{}}});E(r),_(``),l.setQueryData(f.googleClient,r);for(let e of[f.googleClient,f.setupState])l.invalidateQueries({queryKey:e});i?.(r)}catch(e){w(e),_(``)}finally{S(!1),requestAnimationFrame(()=>m.current?.focus())}}},k=async e=>{e&&(e.size>64e3?w(new o(400,`client_json_invalid`,`That file is too large to be an OAuth client JSON.`,`Choose the client_secret_….json file you downloaded.`)):await D(await e.text()))},A=C instanceof o?C.code:void 0,j=T?.projectId&&t&&T.projectId!==t;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),k(e.dataTransfer.files[0])},className:u(`flex flex-col items-center gap-2 rounded-lg border-2 border-dashed p-5 text-center text-sm transition-colors`,ee?`border-primary bg-muted/60`:`border-border`),children:[(0,$.jsx)(xe,{className:`size-7 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsxs)(`p`,{className:`text-foreground`,children:[`Drop the downloaded `,(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:`client_secret_….json`}),` file here`]}),(0,$.jsxs)(a,{type:`button`,variant:`default`,size:`sm`,onClick:()=>d.current?.click(),disabled:b,children:[b?(0,$.jsx)(p,{}):(0,$.jsx)(xe,{}),` Choose the JSON file`]}),(0,$.jsx)(`input`,{ref:d,type:`file`,accept:`.json,application/json`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{k(e.target.files?.[0]),e.target.value=``}})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:h,className:`text-xs text-muted-foreground`,children:`Or paste the file's contents`}),(0,$.jsx)(K,{id:h,rows:2,spellCheck:!1,placeholder:`{"web":{"client_id":"…apps.googleusercontent.com","client_secret":"…"}}`,className:`font-mono text-xs`,value:g,onChange:e=>_(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`);t.trim().startsWith(`{`)&&(e.preventDefault(),D(t))}}),g.trim()&&(0,$.jsxs)(a,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void D(g),disabled:b,children:[b&&(0,$.jsx)(p,{}),` Import`]})]}),(0,$.jsxs)(`div`,{ref:m,tabIndex:-1,className:`space-y-2 outline-none`,role:`status`,children:[T&&!c&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm text-foreground`,children:[(0,$.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-success`}),(0,$.jsxs)(`span`,{children:[`Imported and saved: client `,(0,$.jsx)(`span`,{className:`font-mono text-xs break-all`,children:T.clientId}),T.projectId&&(0,$.jsxs)($.Fragment,{children:[` `,`in project `,(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:T.projectId})]}),`.`]})]}),j&&(0,$.jsxs)(y,{variant:`info`,children:[(0,$.jsx)(z,{}),(0,$.jsxs)(x,{children:[`This client belongs to project `,(0,$.jsx)(`span`,{className:`font-mono`,children:T.projectId}),`, not `,t,`. xaq uses`,` `,T.projectId,` from now on; if that's wrong, create the client in the right project and import that one.`]})]}),C!==void 0&&(0,$.jsx)(O,{error:C,title:A===`client_secret_missing`?`This file has no client secret`:`Couldn't import that file`,children:(A===`client_secret_missing`||A===`client_json_invalid`)&&s&&(0,$.jsx)(`div`,{className:`pt-2`,children:(0,$.jsx)(a,{size:`sm`,variant:`outline`,onClick:s,children:`Enter the client ID and secret by hand`})})})]})]})}var Je=[`Creating the Pub/Sub topic`,`Letting Gmail publish to it`,`Creating the subscription`,`Starting Gmail watches`],Ye=`serviceAccount:gmail-api-push@system.gserviceaccount.com`;function Xe({compact:e}){let s=r(),c=m(d.setupState()),l=m(d.accounts()),y=m(d.settings()),[b,x]=(0,Q.useState)(!1),[S,A]=(0,Q.useState)(),[re,ie]=(0,Q.useState)(null),[oe,se]=(0,Q.useState)(!1),[ce,P]=(0,Q.useState)(),[le,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(),ue=(0,Q.useRef)(null),R=()=>{for(let e of[f.setupState,f.settings,f.system,f.accounts])s.invalidateQueries({queryKey:e})},z=c.data?.pubsub,B=z?.mode===`pubsub`&&!!z.subscription,H=(l.data??[]).filter(e=>e.status===`active`),W=[I,z?.pendingPrincipalAccountId,z?.principalAccountId].find(e=>!!e&&H.some(t=>t.id===e))??H[0]?.id,G=B&&!!z?.principalAccountId&&W!==z.principalAccountId,K=l.data?.find(e=>e.id===W),q=c.data?.gcpProjectId??``,me=K?de(q,K.email):null,J=async(e=W)=>{x(!0),A(void 0),P(void 0);try{await n(`/api/google/pubsub/provision`,{method:`POST`,body:e?{accountId:e}:{}}),pe({pubsubSkipped:!1}),ie(null),i.success(`New mail now arrives within seconds`,{description:`Send a test to confirm.`}),R()}catch(e){A(e),R()}finally{x(!1)}};(0,Q.useEffect)(()=>{S!==void 0&&requestAnimationFrame(()=>ue.current?.focus())},[S]);let he=async()=>{se(!0);try{P(await n(`/api/google/pubsub/test`,{method:`POST`})),R()}catch(e){t(e,`Test failed`)}finally{se(!1)}},ge=async()=>{F(!0);try{await n(`/api/settings`,{method:`PATCH`,body:{ingestMode:`poll`}}),pe({pubsubSkipped:!0}),A(void 0),R()}catch(e){t(e,`Couldn't switch to polling`)}finally{F(!1)}},Y=()=>{let e=K;ae({scopes:[`pubsub`],reauthAccountId:e?.id,email:e?.email,onDone:t=>{t&&ie(e?.email??``),J(e?.id)}})};if(c.isPending)return(0,$.jsx)(w,{className:`h-32 rounded-xl`});let X=S instanceof o?S.code:void 0,_e=y.data?.ingestMode!==`pubsub`,Z=H.length>1&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Set up with`}),(0,$.jsxs)(v,{value:W,onValueChange:e=>L(e),children:[(0,$.jsx)(_,{size:`sm`,className:`min-w-56`,"aria-label":`Account that sets up Pub/Sub`,children:(0,$.jsx)(ee,{})}),(0,$.jsx)(g,{children:H.map(e=>(0,$.jsx)(h,{value:e.id,children:e.email},e.id))})]})]});return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg border p-3`,children:[(0,$.jsx)(`span`,{className:u(`flex size-9 items-center justify-center rounded-lg`,B?`bg-success/15 text-success`:`bg-muted text-muted-foreground`),children:B?(0,$.jsx)(Ne,{className:`size-4`}):(0,$.jsx)(je,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-medium`,children:[B?`Real-time (Pub/Sub)`:`Polling`,B?(0,$.jsx)(D,{tone:`good`,children:`Active`}):(0,$.jsxs)(D,{tone:`idle`,children:[`Every `,y.data?.pollIntervalSeconds??`…`,`s`]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B?(0,$.jsxs)($.Fragment,{children:[`Set up with `,z?.principalEmail??`a connected account`,`. Last message `,(0,$.jsx)(E,{date:z?.lastMessageAt,fallback:`none yet`})]}):`New mail shows up within ${y.data?.pollIntervalSeconds??30} seconds.`})]})]}),z&&(z.topic||z.subscription)&&!e&&(0,$.jsxs)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Topic`}),(0,$.jsx)(`dd`,{className:`font-mono break-all`,children:z.topic??`—`}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Subscription`}),(0,$.jsx)(`dd`,{className:`font-mono break-all`,children:z.subscription??`—`})]}),z?.lastError&&S===void 0&&!_e&&(0,$.jsx)(O,{error:Error(z.lastError),title:`Pub/Sub reported a problem`}),B&&z?.pendingPrincipalEmail&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,role:`status`,children:[`Switching to `,z.pendingPrincipalEmail,`… Real-time delivery keeps working with `,z.principalEmail??`the current account`,` until the switch succeeds.`]}),b&&(0,$.jsx)(et,{}),(0,$.jsxs)(`div`,{ref:ue,tabIndex:-1,className:`space-y-3 outline-none`,role:S===void 0?void 0:`alert`,children:[X===`pubsub_scope_required`&&(0,$.jsxs)($e,{icon:(0,$.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-warning`}),title:re===null?`One more permission: Pub/Sub`:`The Pub/Sub box wasn't ticked`,children:[(0,$.jsx)(`p`,{children:re===null?(0,$.jsxs)($.Fragment,{children:[`Connecting Gmail only asked for mail access. To create its notification channel, xaq also needs Pub/Sub access from`,` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:K?.email??`the account it sets up with`}),`. You'll see a Google window once.`]}):`Google didn't give xaq Pub/Sub access. Click Grant again and tick the Pub/Sub box on Google's screen.`}),Z,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(a,{size:`sm`,onClick:Y,children:[(0,$.jsx)(M,{}),` Grant Pub/Sub access`]}),(0,$.jsxs)(a,{size:`sm`,variant:`outline`,onClick:()=>void J(),disabled:b,children:[(0,$.jsx)(N,{}),` Try again`]})]})]}),X===`pubsub_permission_denied`&&(0,$.jsxs)($e,{icon:(0,$.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-warning`}),title:`${K?.email??`This account`} can't manage Pub/Sub in ${q||`the project`}`,children:[(0,$.jsxs)(`p`,{children:[`It needs the Owner or Pub/Sub Admin role on the project (whoever created the project is Owner already). Either set up with an account that has it, or give this one the role: in IAM, click `,(0,$.jsx)(`strong`,{className:`text-foreground`,children:`Grant access`}),`, paste the account, choose the role, and Save.`]}),Z,K&&(0,$.jsx)(j,{value:K.email,label:`Copy account email`}),(0,$.jsx)(j,{value:`roles/pubsub.admin`,label:`Copy role`}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:q&&(0,$.jsx)(T,{href:U.iam(q),children:`Open IAM in Google Cloud`})}),me&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Or run this in Cloud Shell as the project owner:`}),(0,$.jsx)(te,{code:me,wrap:!0,copyLabel:`Copy gcloud command`})]}),(0,$.jsxs)(a,{size:`sm`,onClick:()=>void J(),disabled:b,children:[(0,$.jsx)(N,{}),` Try again`]})]}),X===`pubsub_org_policy`&&(0,$.jsxs)($e,{icon:(0,$.jsx)(fe,{className:`mt-0.5 size-4 shrink-0 text-warning`}),title:`Your organization's policy blocks Gmail notifications`,children:[(0,$.jsxs)(`p`,{children:[`A Google Workspace rule (Domain Restricted Sharing, `,(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:`iam.allowedPolicyMemberDomains`}),`) stops Gmail's notification service from publishing into your project. Polling works without it.`]}),(0,$.jsx)(`p`,{children:`To use real-time anyway, someone with the Organization Policy Administrator role opens the policy for this project, temporarily allows all values (Manage policy → Override parent's policy → Allow all), you click Try again here, and then they restore the policy. The permission xaq granted stays in place.`}),(0,$.jsx)(j,{value:`roles/orgpolicy.policyAdmin`,label:`Copy Organization Policy Administrator role`}),(0,$.jsxs)(`p`,{className:`text-xs`,children:[`This policy lists customer IDs, not accounts, so it can't allow just Gmail's service account. Organizations using the newer`,` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`iam.managed.allowedPolicyMembers`}),` policy can allow that one principal instead:`]}),(0,$.jsx)(j,{value:Ye,label:`Copy Gmail push principal`}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[q&&(0,$.jsx)(T,{href:U.orgPolicies(q),children:`Open Organization policies`}),(0,$.jsxs)(a,{size:`sm`,onClick:()=>void J(),disabled:b,children:[(0,$.jsx)(N,{}),` Try again`]})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:`Creating the project outside your organization also avoids it, but then the app can't be Internal.`})]}),X===`pubsub_api_disabled`&&(0,$.jsxs)($e,{icon:(0,$.jsx)(Ce,{className:`mt-0.5 size-4 shrink-0 text-warning`}),title:`Turn on the Pub/Sub API in ${q||`your project`}`,children:[(0,$.jsxs)(`p`,{children:[`Real-time delivery uses Google Cloud Pub/Sub, which is off in new projects. Open the link, confirm the project, click`,` `,(0,$.jsx)(`strong`,{className:`text-foreground`,children:`Next`}),` and `,(0,$.jsx)(`strong`,{className:`text-foreground`,children:`Enable`}),`, wait a minute, then try again.`]}),(0,$.jsx)(Qe,{interval:y.data?.pollIntervalSeconds??30}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[q&&(0,$.jsx)(T,{href:U.enablePubsub(q),children:`Enable the Pub/Sub API`}),(0,$.jsxs)(a,{size:`sm`,onClick:()=>void J(),disabled:b,children:[(0,$.jsx)(N,{}),` Try again`]})]})]}),S!==void 0&&!Ze.has(X??``)&&(0,$.jsxs)(O,{error:S,title:G?`Couldn't switch to ${K?.email??`that account`}; real-time keeps working as before`:`Couldn't turn on real-time delivery`,children:[X===`pubsub_billing`&&q&&(0,$.jsx)(`p`,{className:`pt-1`,children:(0,$.jsx)(T,{href:U.billing(q),children:`Link a billing account`})}),X===`pubsub_billing`&&(0,$.jsx)(`p`,{className:`pt-1`,children:`Pub/Sub's free tier covers Gmail notifications, but Google wants a billing account on file for it.`}),(X===`needs_reauth`||X===`account_paused`)&&K&&(0,$.jsx)(`div`,{className:`pt-2`,children:(0,$.jsxs)(a,{size:`sm`,variant:`outline`,onClick:()=>ae({reauthAccountId:K.id,email:K.email}),children:[`Reconnect `,K.email]})}),Z&&(0,$.jsx)(`div`,{className:`pt-2`,children:Z}),(0,$.jsx)(`p`,{className:`pt-1 text-foreground/80`,children:`Polling works fine too; it's just slower to notice new mail.`})]})]}),ce&&(0,$.jsxs)(`div`,{className:u(`flex items-start gap-2 rounded-lg border p-3 text-sm`,ce.ok?`border-success/30 bg-success/5`:`border-critical/30 bg-critical/5`),role:`status`,children:[ce.ok?(0,$.jsx)(V,{className:`mt-0.5 size-4 text-success`}):(0,$.jsx)(C,{className:`mt-0.5 size-4 text-critical`}),(0,$.jsx)(`span`,{children:k(ce.message)})]}),!B&&S===void 0&&q&&(0,$.jsxs)(`div`,{className:`space-y-1 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`p`,{children:[`First, turn on the Pub/Sub API in `,(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:q}),`:`,` `,(0,$.jsx)(T,{href:U.enablePubsub(q),children:`Enable the Pub/Sub API`}),`, confirm the project, then click Next and Enable. Then set it up here.`]}),(0,$.jsx)(Qe,{interval:y.data?.pollIntervalSeconds??30})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 empty:hidden`,children:[S===void 0&&(0,$.jsxs)(a,{onClick:()=>void J(),disabled:b||H.length===0,variant:B?`outline`:`default`,children:[b?(0,$.jsx)(p,{}):(0,$.jsx)(Te,{}),` `,B?G?`Switch to ${K?.email??`this account`}`:`Set up again`:`Set up real-time automatically`]}),S!==void 0&&!Ze.has(X??``)&&(0,$.jsxs)(a,{variant:`outline`,onClick:()=>void J(),disabled:b,children:[(0,$.jsx)(N,{}),` Try again`]}),B&&(0,$.jsxs)(a,{variant:`outline`,onClick:he,disabled:oe,children:[oe?(0,$.jsx)(p,{}):(0,$.jsx)(ne,{}),` Send test`]}),!e&&(y.data?.ingestMode===`pubsub`?(0,$.jsx)(a,{variant:`ghost`,onClick:ge,disabled:le,children:`Switch to polling`}):S!==void 0&&(0,$.jsx)(a,{variant:`ghost`,onClick:ge,disabled:le,children:`Use polling instead`})),S===void 0&&H.length>1&&Z]}),H.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Connect a Gmail account first: setting this up uses its Google access.`})]})}var Ze=new Set([`pubsub_scope_required`,`pubsub_permission_denied`,`pubsub_org_policy`,`pubsub_api_disabled`]);function Qe({interval:e}){return(0,$.jsxs)(`p`,{children:[`Google may ask for a billing account before it turns on Pub/Sub. If it does, you can skip this: polling every `,e,` seconds works fine without one.`]})}function $e({icon:e,title:t,children:n}){return(0,$.jsx)(`div`,{className:`space-y-3 rounded-lg border border-warning/40 bg-warning/[0.06] p-3 text-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[e,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`font-medium text-foreground`,children:t}),n]})]})})}function et(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(()=>t(e=>Math.min(e+1,Je.length-1)),1200);return()=>clearInterval(e)},[]),(0,$.jsx)(`ol`,{className:`space-y-1.5 rounded-lg border bg-muted/30 p-3 text-sm`,"aria-live":`polite`,children:Je.map((t,n)=>(0,$.jsxs)(`li`,{className:u(`flex items-center gap-2`,n>e&&`text-muted-foreground/60`,n<e&&`text-muted-foreground`),children:[n<e?(0,$.jsx)(`span`,{className:`mx-[3px] size-2 rounded-full bg-muted-foreground/60`}):n===e?(0,$.jsx)(p,{className:`size-3.5`}):(0,$.jsx)(`span`,{className:`mx-[3px] size-2 rounded-full border`}),t]},t))})}var tt=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),nt=e=>e===`localhost`||e===`::1`||e.startsWith(`127.`);function rt({port:e,addresses:t,browserHost:n}){let r=`localhost`;if(t.length===1)try{let e=tt(new URL(t[0]).hostname);nt(e)||(r=e)}catch{}let i=`${e}:${r.includes(`:`)?`[${r}]`:r}:${e}`,a=tt(n),o=a&&!nt(a)?a:`your-server`;return`ssh -N -L ${R(i)} ${R(`you@${o}`)}`}var it={good:V,warn:fe,bad:C,info:z},at={good:`text-success`,warn:`text-warning`,bad:`text-critical`,info:`text-chart-1`};function ot({analysis:e,browserRemote:t,className:n}){let r=he(e,t),i=[[`Google sign-in`,r.google],[`Agents`,r.agents]];return(0,$.jsx)(`dl`,{className:u(`divide-y rounded-lg border text-sm`,n),children:i.map(([e,[t,n]])=>{let r=it[t];return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[(0,$.jsx)(r,{className:u(`mt-0.5 size-4 shrink-0`,at[t]),"aria-hidden":!0}),(0,$.jsx)(`dt`,{className:`w-28 shrink-0 font-medium`,children:e}),(0,$.jsx)(`dd`,{className:`min-w-0 flex-1 text-muted-foreground`,children:n})]},e)})})}function st(e){let t=m(d.settings()),n=m(d.system());return t.isPending?(0,$.jsx)(w,{className:`h-96 rounded-xl`}):t.isError?(0,$.jsx)(O,{error:t.error,title:`Couldn't load settings`}):(0,$.jsx)(ct,{...e,settings:t.data,addresses:n.data?.addresses??[]})}function ct({index:e,onNext:t,returnTo:i,settings:o,addresses:s}){let c=r(),{statuses:l}=H(),p=window.location.origin,m=!ge(p),h=l.url!==`done`,[g,_]=(0,Q.useState)(h&&Y(p)?p:o.publicUrl),[ee,v]=(0,Q.useState)(!1),b=_e(g),C=g.trim().replace(/\/+$/,``),w=b?null:Y(C),T=X(s,o.publicUrl),E=[...new Set([p,...s])],D=Ie(),[k,j]=(0,Q.useState)(m?Y(p)?.transport===`tailscale`?`tailscale`:Y(p)?.transport===`https`?`public`:`remote`:void 0),M=G({mutationFn:e=>n(`/api/settings`,{method:`PATCH`,body:{publicUrl:e}}),errorTitle:!1,onSuccess:async e=>{c.setQueryData(f.settings,e),c.invalidateQueries({queryKey:f.system}),pe({urlConfirmed:!0});let n=c.getQueryData(f.googleClient),r=await c.fetchQuery({...d.googleClient(),staleTime:0});await c.fetchQuery({...d.setupState(),staleTime:0}),n?.clientId&&n.redirectUri!==r.redirectUri?v(!0):t()}}),ne=()=>{b||(C===o.publicUrl?(pe({urlConfirmed:!0}),t()):M.mutate(C))},ae=rt({port:T,addresses:s,browserHost:window.location.hostname}),{url:N,fromBrowser:le}=J(p,T);return(0,$.jsx)(se,{index:e,title:B.url.title,description:`Google sends you back to this address after you sign in, and your agents use it to reach xaq.`,footer:ee?(0,$.jsx)(ie,{onNext:t,nextLabel:D?`I'll add it, continue`:`Continue`}):(0,$.jsx)(ie,{onNext:ne,nextDisabled:!!b,pending:M.isPending,nextLabel:i?`Looks right, back to ${B[i].short}`:`Looks right`}),children:ee?(0,$.jsxs)(`div`,{className:`space-y-3`,role:`status`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[`Saved: xaq is now at `,(0,$.jsx)(`code`,{className:`font-mono`,children:o.publicUrl}),`.`]}),(0,$.jsx)(Le,{showStatus:!0})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{"data-invalid":!!b,children:[(0,$.jsx)(P,{htmlFor:`setup-url`,children:`Address of xaq`}),(0,$.jsx)(q,{id:`setup-url`,className:`font-mono`,inputMode:`url`,spellCheck:!1,autoComplete:`off`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>e.key===`Enter`&&ne(),"aria-invalid":!!b,"aria-describedby":`setup-url-hint`}),(0,$.jsx)(`div`,{id:`setup-url-hint`,children:b?(0,$.jsx)(I,{children:b}):(0,$.jsxs)(F,{children:[h&&C===p&&o.publicUrl!==p?`Filled in from your browser's address bar. `:``,`Agents will connect to`,` `,(0,$.jsx)(`span`,{className:`font-mono`,children:(0,$.jsx)(A,{text:`${C}/mcp`})})]})}),E.length>1&&(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,role:`group`,"aria-label":`Addresses this server is reachable at`,children:E.map(e=>(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,className:u(`h-auto flex-col items-start gap-0 py-1 text-left`,e===C&&`border-primary`),"aria-pressed":e===C,onClick:()=>_(e),children:[(0,$.jsx)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:Z(e,p)}),(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:e})]},e))})]}),M.isError&&(0,$.jsx)(O,{error:M.error,title:`Couldn't save the address`}),w&&(0,$.jsx)(ot,{analysis:w,browserRemote:m}),w?.host===`loopback`&&m&&(0,$.jsxs)(y,{variant:`warning`,children:[(0,$.jsx)(fe,{}),(0,$.jsx)(S,{children:`You're browsing from another computer`}),(0,$.jsx)(x,{children:(0,$.jsxs)(`p`,{children:[`This console is open at `,(0,$.jsx)(`span`,{className:`font-mono`,children:p}),`, so localhost here means your own computer, not the server. Use an SSH tunnel (below) to make localhost work, or pick another option.`]})})]}),(0,$.jsxs)(oe,{summary:`Not sure which address to use? Pick your situation`,defaultOpen:m,children:[(0,$.jsx)(ue,{"aria-label":`Where xaq runs`,value:k,onChange:j,columns:2,choices:[{value:`local`,icon:re,title:`All on this computer`,description:`Your browser, xaq and your agents run on one machine.`},{value:`remote`,icon:De,title:`On a server or VM`,description:`xaq runs on another machine you reach over SSH (a server, VM, Raspberry Pi).`},{value:`tailscale`,icon:ce,title:`I use Tailscale`,description:`The machines are on the same tailnet.`},{value:`public`,icon:ke,title:`Public, with a domain`,description:`A server reachable from the internet, e.g. mail.example.com.`}]}),k&&(0,$.jsxs)(`div`,{className:`space-y-2.5 pt-1 text-foreground`,role:`region`,"aria-label":`What to do`,children:[k===`local`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[le?(0,$.jsxs)($.Fragment,{children:[`Use `,(0,$.jsx)(`span`,{className:`font-mono`,children:N}),`, the address this console is open at.`]}):`Use localhost.`,` `,`Google sign-in works directly, and agents on this computer connect without extra flags.`]}),(0,$.jsx)(a,{size:`sm`,variant:`outline`,onClick:()=>_(N),disabled:C===N,children:C===N?`Using ${N}`:`Use ${N}`})]}),k===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Easiest: an SSH tunnel. Run this on the computer with your browser (replace `,(0,$.jsx)(`code`,{className:`font-mono`,children:`you`}),` with your SSH user) and keep it open:`]}),(0,$.jsx)(te,{code:ae,wrap:!0,copyLabel:`Copy SSH tunnel command`}),(0,$.jsxs)(`p`,{children:[`Then open `,(0,$.jsx)(`span`,{className:`font-mono`,children:N}),` in your browser, sign in to this console again, and use`,` `,(0,$.jsx)(`span`,{className:`font-mono`,children:N}),` as the address. Agents on the server connect directly; agents on your computer connect through the tunnel while it's open.`]}),(0,$.jsxs)(a,{size:`sm`,variant:`outline`,onClick:()=>_(N),children:[`Use `,N]}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Agents on several machines? Use Tailscale or https instead (see the other options).`})]}),k===`tailscale`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`On the machine running xaq, give it an https address on your tailnet:`}),(0,$.jsx)(te,{code:`tailscale serve --bg ${T}`,wrap:!0,copyLabel:`Copy Tailscale command`}),(0,$.jsxs)(`p`,{children:[`It prints an address like `,(0,$.jsx)(`span`,{className:`font-mono`,children:`https://your-machine.your-tailnet.ts.net`}),`. Open that in your browser and use it here: Google sign-in works directly and every device on your tailnet can connect. (If Tailscale asks you to enable HTTPS certificates, follow its link.)`]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`The plain `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[`http://100.x.y.z:`,T]}),` address also works for agents, but sign-in then needs the paste step.`]})]}),k===`public`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Put an https reverse proxy in front of xaq and keep xaq itself private. For example with Caddy (it gets the certificate for you):`}),(0,$.jsx)(te,{code:`caddy reverse-proxy --from mail.example.com --to localhost:${T}`,wrap:!0,copyLabel:`Copy Caddy command`}),(0,$.jsx)(`p`,{children:`Start xaq so only the proxy can reach it, and trust the proxy's headers:`}),(0,$.jsx)(te,{code:`TRUST_PROXY=1 npx xaq-cli --host 127.0.0.1 --port ${T}`,wrap:!0,copyLabel:`Copy start command`}),(0,$.jsxs)(`p`,{children:[`Then use `,(0,$.jsx)(`span`,{className:`font-mono`,children:`https://mail.example.com`}),` (your domain) here.`]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`You can change this later in Settings; xaq then shows the new redirect URI to add in Google Cloud.`})]})})}export{Ke as a,Le as c,qe as i,Ne as l,ot as n,He as o,Xe as r,Re as s,st as t,je as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ht as t,Ut as n,Wt as r,t as i}from"./queries-Cv3nXx0U.js";var a=e(r(),1),o=n(),s=(0,a.createContext)({state:`connecting`,subscribe:()=>()=>{}}),c={event:[i.events,i.overview],delivery:[i.deliveries,i.webhooks,i.overview],approval:[i.approvals,i.overview],audit:[i.audit,i.agents,i.overview],account:[i.accounts,i.setupState,i.overview,i.calendarSetup],pairing:[i.pairings,i.agents],agent:[]},l=[...new Set([...Object.values(c).flat(),i.eventHistory,i.auditLog])];function u(e,t){let n=!1;e.setQueryData(i.agents,e=>e?.map(e=>e.id===t.id?(n=!0,t):e)),e.getQueryData(i.agent(t.id))&&e.setQueryData(i.agent(t.id),t);for(let n of[i.agents,i.agent(t.id)])e.isFetching({queryKey:n,exact:!0})&&e.invalidateQueries({queryKey:n,exact:!0});!n&&e.getQueryData(i.agents)&&e.invalidateQueries({queryKey:i.agents,exact:!0});let r=e.getQueryData(i.setupState);r&&!r.verified&&(t.lastMcpAt||t.listeners.some(e=>e.ackedSeq>(e.startSeq??0)))&&e.invalidateQueries({queryKey:i.setupState})}function d(e){return!!e&&typeof e==`object`&&typeof e.kind==`string`&&`data`in e}function f({children:e}){let n=t(),[r,i]=(0,a.useState)(`connecting`),f=(0,a.useRef)(new Set);(0,a.useEffect)(()=>{let e=null,t,r,a=0,o=!1,s=!1,p=new Map,m=e=>{for(let t of e)p.set(t.join(`/`),t);r??=setTimeout(()=>{r=void 0;for(let e of p.values())n.invalidateQueries({queryKey:e});p.clear()},300)},h=()=>{s||(e?.close(),e=new EventSource(`/api/events/stream`,{withCredentials:!0}),e.onopen=()=>{o&&m(l),o=!0,a=0,i(`open`)},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(d(t)){t.kind===`agent`&&u(n,t.data),m(c[t.kind]??[]);for(let e of f.current)e(t)}},e.onerror=()=>{if(!e||e.readyState!==EventSource.CLOSED){i(`reconnecting`);return}e.close(),i(o?`reconnecting`:`offline`);let n=Math.min(3e4,1e3*2**a++);clearTimeout(t),t=setTimeout(h,n)})},g=()=>{document.visibilityState===`visible`&&(!e||e.readyState===EventSource.CLOSED)&&(clearTimeout(t),a=0,h())};return h(),document.addEventListener(`visibilitychange`,g),()=>{s=!0,document.removeEventListener(`visibilitychange`,g),clearTimeout(t),clearTimeout(r),e?.close()}},[n]);let[p]=(0,a.useState)(()=>e=>(f.current.add(e),()=>void f.current.delete(e)));return(0,o.jsx)(s,{value:{state:r,subscribe:p},children:e})}var p=()=>(0,a.useContext)(s).state;function m(e){let{subscribe:t}=(0,a.useContext)(s),n=(0,a.useRef)(e);(0,a.useEffect)(()=>{n.current=e}),(0,a.useEffect)(()=>t(e=>n.current(e)),[t])}export{m as n,p as r,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ht as t,Wt as n,_t as r}from"./queries-Cv3nXx0U.js";import{A as i,E as a,O as o,a as s,b as c,c as l,d as u,i as d,l as f,o as p,r as m,s as h,u as g,v as _}from"./useQuery-MrTwwNy5.js";function v(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var y=class extends c{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,_.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),a=e.length!==n.length,o=n.some((t,n)=>t!==e[n]),s=a||o,c=s?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!i(e,n)});(s||c)&&(s&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(s&&(v(e,n).forEach(e=>{e.destroy()}),v(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=o(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new u(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&_.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},b=e(n(),1);function x({queries:e,...n},r){let i=t(r),o=g(),c=f(),v=n.subscribed!==!1,x=b.useMemo(()=>e.map(e=>{let t=i.defaultQueryOptions(e);return t._optimisticResults=o?`isRestoring`:v?`optimistic`:void 0,t}),[e,i,o,v]);x.forEach(e=>{m(e);let t=i.getQueryCache().get(e.queryHash);p(e,c,t)}),l(c);let[S]=b.useState(()=>new y(i,x,n)),[C,w,T]=S.getOptimisticResult(x,n.combine),E=!o&&v;b.useSyncExternalStore(b.useCallback(e=>E?S.subscribe(_.batchCalls(e)):a,[S,E]),()=>S.getCurrentResult(),()=>S.getCurrentResult()),b.useEffect(()=>{S.setQueries(x,n)},[x,n,S]);let D=C.some((e,t)=>s(x[t],e))?C.flatMap((e,t)=>{let n=x[t];if(n&&s(n,e)){let e=new u(i,n);return d(n,e,c)}return[]}):[];if(D.length>0)throw Promise.all(D);let O=C.find((e,t)=>{let n=x[t];return n&&h({result:e,errorResetBoundary:c,throwOnError:n.throwOnError,query:i.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(O)throw O.error;return w(T())}var S={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};S.node;var C=r(S);export{x as n,C as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,N as n,Ut as r,Wt as i,_t as a,ft as o,k as s,n as c,w as l}from"./queries-Cv3nXx0U.js";import{t as u}from"./useQuery-MrTwwNy5.js";import{t as d}from"./tag-I5_-1jFL.js";import{t as f}from"./bell-ring-ig3zn1iS.js";import{t as p}from"./calendar-plus-Cycfkk0y.js";import{n as m,t as h}from"./listener-handled-HNCuVrQ7.js";import{i as g,n as _,o as v,s as y,t as b}from"./select-Bb806bpq.js";import{t as ee}from"./chevron-right-Cqh4mDk1.js";import{C as x,L as S,S as C,_ as w,a as T,d as E,f as D,g as O,t as k,v as A}from"./common-BPZV8TFb.js";import{n as j,t as M}from"./send-DuMVuYs1.js";import{t as N}from"./mail-C5fm2pTC.js";import{t as te}from"./paperclip-znS4iTrg.js";import{Et as P,J as F}from"./index-DGzo3kGh.js";import{a as I,r as L,u as R}from"./labels-B5UqVwFo.js";import{n as z}from"./hidden-chars-Dr9TxfvF.js";import{t as B}from"./use-label-names-BXicesnP.js";var V={name:`calendar-x`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m14 13-4 4`,key:`1gib57`}],[`path`,{d:`m10 13 4 4`,key:`153uiq`}]]};V.node;var H=a(V),U={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};U.node;var W=a(U),G=e(i(),1),K=[`account.auth_failed`,`sync.gap`];function q(e,t){if(e.accountId!==t.accountId)return!1;if(K.includes(t.type))return e.capabilities.includes(`read`)||e.capabilities.includes(`calendar.read`);if(F(t.type)){let n=t.calendarEvent?.calendarId;return e.capabilities.includes(`calendar.read`)&&!!n&&(e.calendarScope===null||e.calendarScope.includes(n))}return e.capabilities.includes(`read`)?e.labelScope===null||(t.threadLabelIds??t.message?.labelIds??[]).some(t=>e.labelScope.includes(t)):!1}function J(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}var Y=e=>e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`;function X(e){let t=e?.changes;if(!Array.isArray(t))return`Changed (xaq hadn't seen the earlier version)`;let n=t.map(e=>L[e]??e);return n.length?`Changed: ${Y(n)}`:`Changed`}function Z(e,t){let n=e.organizer?.email.toLowerCase();return e.organizerSelf||n===t.toLowerCase()||n===e.calendarId.toLowerCase()}function ne(e,t={}){let n=e.calendarEvent;if(!n||!F(e.type))return null;let r=Z(n,e.accountEmail)?`you organize`:n.organizer?`organized by ${A(n.organizer)}`:null,i=n.location;return e.type===`calendar.event_updated`?i=X(e.detail):e.type===`calendar.event_cancelled`?i=e.detail?.wasOrganizer?`Cancelled (the account organized it)`:`Cancelled`:e.type===`calendar.invitation_received`&&n.selfResponse&&n.selfResponse!==`needsAction`&&(i=`Answered: ${I[n.selfResponse]}`),{title:n.summary||`(no title)`,when:C(n,t),organizer:r,note:i,needsAnswer:e.type===`calendar.invitation_received`&&n.selfResponse===`needsAction`}}var Q=r(),re={"message.received":N,"message.sent":M,"thread.reply_received":W,"label.added":d,"label.removed":d,"account.auth_failed":j,"sync.gap":P,"calendar.event_created":p,"calendar.event_updated":m,"calendar.event_cancelled":H,"calendar.invitation_received":p,"connection.auth_failed":j,"connection.tool_changed":P,"connection.expiring":j,"approval.requested":M},$=[`account.auth_failed`,`sync.gap`];function ie({type:e,className:t}){let n=re[e]??N;return(0,Q.jsx)(`span`,{className:o(`flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted`,$.includes(e)&&`bg-warning/15 text-warning`,t),"aria-hidden":!0,children:(0,Q.jsx)(n,{className:`size-4`})})}function ae(e){return e.message?e.message.subject||`(no subject)`:e.type===`account.auth_failed`?`Google rejected the account's token. Reconnect it on the Accounts page.`:e.type===`sync.gap`?`Events may be missing: history was too old, so a bounded resync ran.`:R[e.type]?.description??e.type}function oe(e){let t=u(c.agents()),n=[];for(let r of t.data??[])if(r.grants.some(t=>q(t,e)))for(let t of r.listeners)h(t,e)&&n.push({name:r.name,host:t.client.hostname??null});return n}function se({event:e,fresh:t}){let[n,r]=(0,G.useState)(!1),i=oe(e),a=e.message,s=ne(e),l=R[e.type],d=e.type===`label.added`||e.type===`label.removed`,p=u({...c.labels(e.accountId),enabled:d&&!!e.labelIds?.length}),m=d?(e.labelIds??[]).map(e=>{let t=p.data?.find(t=>t.id===e);return t&&t.type===`user`?t.name:B(e)}):[];return(0,Q.jsxs)(`li`,{className:o(t&&`animate-in duration-500 fade-in slide-in-from-top-1`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),"aria-expanded":n,className:`flex w-full items-start gap-3 px-4 py-3 text-left outline-none hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,children:[(0,Q.jsx)(ie,{type:e.type}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(S,{variant:`outline`,className:`font-normal`,children:[l?.label??e.type,m.length>0&&(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:m.join(`, `)})]}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.accountEmail}),a?.from&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`from `,A(a.from)]})]}),a?.hasAttachments&&(0,Q.jsx)(te,{className:`size-3.5`,"aria-label":`Has attachments`}),s?.organizer&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Q.jsx)(`span`,{className:`truncate`,children:s.organizer})]}),s?.needsAnswer&&(0,Q.jsx)(D,{tone:`warn`,children:`Needs your answer`}),i.length>0&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success`,children:[(0,Q.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),i.length===1?(0,Q.jsxs)(Q.Fragment,{children:[`Delivered to `,(0,Q.jsx)(z,{text:i[0].name})]}):`Delivered to ${i.length} listeners`]})]}),(0,Q.jsx)(`div`,{className:o(`truncate text-sm`,a||s?`font-medium`:`text-muted-foreground`,e.type===`calendar.event_cancelled`&&`line-through decoration-muted-foreground/60`),children:s?s.title:ae(e)}),a?.snippet&&(0,Q.jsx)(`div`,{className:`line-clamp-1 text-xs text-muted-foreground`,children:a.snippet}),s&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:s.when}),s.note&&(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`· `}),(0,Q.jsx)(z,{text:s.note})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pt-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(E,{date:e.createdAt}),(0,Q.jsx)(ee,{className:o(`size-4 transition-transform`,n&&`rotate-90`)})]})]}),n&&(0,Q.jsx)(ce,{event:e,delivered:i})]})}function ce({event:e,delivered:t}){let n=e.message,r=[[`Event`,(0,Q.jsxs)(`code`,{className:`font-mono`,children:[e.id,` · #`,e.seq]},`id`)],[`When`,x(e.createdAt)],[`Account`,e.accountEmail]];return n&&r.push([`From`,w(n.from)],[`To`,n.to.map(w).join(`, `)||`—`],...n.cc.length?[[`Cc`,n.cc.map(w).join(`, `)]]:[],[`Date`,x(n.date)],[`Labels`,n.labelIds.join(`, `)||`—`],[`Message`,(0,Q.jsx)(`code`,{className:`font-mono break-all`,children:n.id},`msg`)],[`Thread`,(0,Q.jsx)(`code`,{className:`font-mono break-all`,children:n.threadId},`thread`)]),e.calendarEvent&&r.push(...le(e.calendarEvent,e.accountEmail)),e.labelIds?.length&&r.push([e.type===`label.removed`?`Removed`:`Added`,e.labelIds.join(`, `)]),t.length&&r.push([`Listeners`,(0,Q.jsx)(z,{text:`Delivered to ${t.map(e=>O(e.name,e.host)).join(`, `)}`},`listeners`)]),(0,Q.jsxs)(`div`,{className:`space-y-3 border-t bg-muted/20 px-4 py-3 sm:pl-15`,children:[(0,Q.jsx)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-xs`,children:r.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]},e))}),n?.snippet&&(0,Q.jsx)(`p`,{className:`rounded-md border bg-background p-2 text-xs whitespace-pre-wrap text-muted-foreground`,children:n.snippet}),e.detail&&Object.keys(e.detail).length>0&&(0,Q.jsx)(k,{code:JSON.stringify(e.detail,null,2)})]})}function le(e,t){let n=J(e.htmlLink),r=J(e.conferenceUrl),i=e.attendees.map(e=>`${w(e)}${e.organizer?` (organizer)`:``}: ${I[e.responseStatus]}`);e.attendeeCount>e.attendees.length&&i.push(`and ${e.attendeeCount-e.attendees.length} more`);let a=[[`Title`,(0,Q.jsx)(z,{text:e.summary||`(no title)`},`title`)],[`Scheduled`,`${C(e)}${e.timeZone?` (${e.timeZone})`:``}${e.recurring||e.recurringEventId?`, repeats`:``}`]];return e.location&&a.push([`Where`,(0,Q.jsx)(z,{text:e.location},`where`)]),a.push([`Organizer`,Z(e,t)?`This account`:(0,Q.jsx)(z,{text:w(e.organizer)},`org`)]),i.length&&a.push([`Guests`,(0,Q.jsx)(z,{text:i.join(`, `)},`guests`)]),e.selfResponse&&a.push([`Your answer`,I[e.selfResponse]]),e.conferenceUrl&&a.push([`Video call`,r?(0,Q.jsx)(T,{href:r,className:`break-all`,children:r},`call`):(0,Q.jsx)(`code`,{className:`font-mono break-all`,children:e.conferenceUrl},`call`)]),a.push([`Calendar`,(0,Q.jsx)(`code`,{className:`font-mono break-all`,children:e.calendarId},`cal`)],[`Event id`,n?(0,Q.jsx)(T,{href:n,className:`font-mono break-all`,children:e.id},`ev`):(0,Q.jsx)(`code`,{className:`font-mono break-all`,children:e.id},`ev`)]),a}function ue({accounts:e,className:r}){let i=e.filter(e=>e.status===`active`),[a,c]=(0,G.useState)(),u=a??i[0]?.id,[d,f]=(0,G.useState)({kind:`idle`}),p=(0,G.useId)();if(!i.length)return null;let m=async()=>{if(u){f({kind:`sending`});try{await t(`/api/accounts/${encodeURIComponent(u)}/test-email`,{method:`POST`}),f({kind:`sent`})}catch(e){let{message:t,hint:n}=s(e);f({kind:`error`,text:n?`${t} ${n}`:t})}}};return(0,Q.jsxs)(`div`,{className:o(`flex flex-col items-center gap-2`,r),children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[i.length>1&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`label`,{htmlFor:p,className:`sr-only`,children:`Account to send from`}),(0,Q.jsxs)(b,{value:u,onValueChange:c,children:[(0,Q.jsx)(v,{id:p,className:`w-auto min-w-48`,children:(0,Q.jsx)(y,{})}),(0,Q.jsx)(_,{children:i.map(e=>(0,Q.jsx)(g,{value:e.id,children:e.email},e.id))})]})]}),(0,Q.jsxs)(n,{variant:`outline`,onClick:()=>void m(),disabled:d.kind===`sending`,children:[d.kind===`sending`?(0,Q.jsx)(l,{}):(0,Q.jsx)(M,{}),` Send a test email`]})]}),(0,Q.jsx)(`p`,{role:`status`,className:o(`text-xs`,d.kind===`error`?`text-destructive`:`text-muted-foreground`),children:d.kind===`sent`?`Sent. It shows up here within moments.`:d.kind===`error`?d.text:`From ${i.length===1?i[0].email:`the account`} to itself; nobody else gets it.`})]})}export{se as n,ue as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ut as t,Wt as n,Z as r,at as i,et as a,ft as o,it as s,pt as c,tt as l}from"./queries-Cv3nXx0U.js";import{ht as u,mt as d,pt as f}from"./index-DGzo3kGh.js";var p=e(n(),1),m=t(),h=Object.defineProperty,g=(e,t)=>h(e,`name`,{value:t,configurable:!0}),_=`Toggle`,v=p.forwardRef(g(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[c,u]=a({prop:n,onChange:o,defaultProp:r??!1,caller:_});return(0,m.jsx)(i.button,{type:`button`,"aria-pressed":c,"data-state":c?`on`:`off`,"data-disabled":e.disabled?``:void 0,...s,ref:t,onClick:l(e.onClick,()=>{e.disabled||u(!c)})})},`Toggle`)),y=Object.defineProperty,b=(e,t)=>y(e,`name`,{value:t,configurable:!0}),x=`ToggleGroup`,S={Single:`single`,Multiple:`multiple`},[C,w]=s(x,[u]),T=u(),E=p.forwardRef(b(function(e,t){let{type:n,...r}=e;if(n===S.Single)return(0,m.jsx)(k,{role:`radiogroup`,...r,ref:t});if(n===S.Multiple)return(0,m.jsx)(A,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${x}\``)},`ToggleGroup`)),[D,O]=C(x),k=p.forwardRef(b(function(e,t){let{value:n,defaultValue:r,onValueChange:i=b(()=>{},`onValueChange`),...o}=e,[s,c]=a({prop:n,defaultProp:r??``,onChange:i,caller:x});return(0,m.jsx)(D,{scope:e.__scopeToggleGroup,type:S.Single,value:p.useMemo(()=>s?[s]:[],[s]),onItemActivate:c,onItemDeactivate:p.useCallback(()=>c(``),[c]),children:(0,m.jsx)(N,{...o,ref:t})})},`ToggleGroupImplSingle`)),A=p.forwardRef(b(function(e,t){let{value:n,defaultValue:r,onValueChange:i=b(()=>{},`onValueChange`),...o}=e,[s,c]=a({prop:n,defaultProp:r??[],onChange:i,caller:x}),l=p.useCallback(e=>c((t=[])=>[...t,e]),[c]),u=p.useCallback(e=>c((t=[])=>t.filter(t=>t!==e)),[c]);return(0,m.jsx)(D,{scope:e.__scopeToggleGroup,type:S.Multiple,value:s,onItemActivate:l,onItemDeactivate:u,children:(0,m.jsx)(N,{...o,ref:t})})},`ToggleGroupImplMultiple`)),[j,M]=C(x),N=p.forwardRef(b(function(e,t){let{__scopeToggleGroup:n,disabled:a=!1,rovingFocus:o=!0,orientation:s,dir:c,loop:l=!0,...u}=e,d=T(n),p=r(c),h={dir:p,...u};return(0,m.jsx)(j,{scope:n,rovingFocus:o,disabled:a,children:o?(0,m.jsx)(f,{asChild:!0,...d,orientation:s,dir:p,loop:l,children:(0,m.jsx)(i.div,{...h,ref:t})}):(0,m.jsx)(i.div,{...h,ref:t})})},`ToggleGroupImpl`)),P=`ToggleGroupItem`,F=p.forwardRef(b(function(e,t){let n=O(P,e.__scopeToggleGroup),r=M(P,e.__scopeToggleGroup),i=T(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=p.useRef(null);return r.rovingFocus?(0,m.jsx)(d,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,m.jsx)(I,{...s,ref:t})}):(0,m.jsx)(I,{...s,ref:t})},`ToggleGroupItem`)),I=p.forwardRef(b(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=O(P,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===S.Single?o:void 0;return(0,m.jsx)(v,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`)),L=c(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),R=p.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function z({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...s}){return(0,m.jsx)(E,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:o(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,e),...s,children:(0,m.jsx)(R.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function B({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=p.useContext(R);return(0,m.jsx)(F,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:o(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,L({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}export{B as n,z as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};t.node;var n=e(t),r={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};r.node;var i=e(r);export{n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ut as e,n as t,yt as n}from"./queries-Cv3nXx0U.js";import{t as r}from"./useQuery-MrTwwNy5.js";import"./index-DGzo3kGh.js";function i(e){return e<120?`${e} seconds`:e===3600?`an hour`:`${Math.round(e/60)} minutes`}var a=(e,t)=>!!e.lastError?.startsWith(`Gmail watch failed`)||!e.watchExpiresAt||Date.parse(e.watchExpiresAt)<=t;function o(e,t,n,r=Date.now()){return n!==void 0&&(!n||n.status!==`active`)?`inactive`:e.mode===`pubsub`?e.subscription?t.lastError||n&&a(n,r)?`broken`:`realtime`:`unfinished`:`poll`}var s=e();function c(e){let n=r(t.setupState()),i=r(t.settings()),a=r(t.system()),s=r({...t.accounts(),enabled:!!e});if(!n.data||!i.data||!a.data||e&&!s.data)return{ready:!1};let c=e?s.data?.find(t=>t.id===e)??null:void 0;return{ready:!0,mode:o(n.data.pubsub,a.data.ingest,c),interval:i.data.pollIntervalSeconds}}var l=e=>(0,s.jsx)(n,{to:`/settings`,hash:`pubsub`,className:`font-medium text-foreground underline underline-offset-4`,children:e});function u({of:e,neutral:t,it:n=`it`,accountId:r}){let a=c(r);if(!a.ready||a.mode===`inactive`)return(0,s.jsx)(s.Fragment,{children:t});let o=e?` of ${e}`:``;return a.mode===`realtime`?(0,s.jsxs)(s.Fragment,{children:[`within seconds`,o]}):(0,s.jsxs)(s.Fragment,{children:[`within about `,i(a.interval),o,` (`,a.mode===`poll`?(0,s.jsxs)(s.Fragment,{children:[`turn on `,l(`real-time delivery in Settings`),` to get `,n,` within seconds`]}):a.mode===`unfinished`?(0,s.jsxs)(s.Fragment,{children:[`finish setting up `,l(`real-time delivery in Settings`),` to get `,n,` within seconds`]}):(0,s.jsxs)(s.Fragment,{children:[`real-time delivery isn't working right now, see `,l(`Settings`)]}),`)`]})}export{c as n,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./queries-Cv3nXx0U.js";import{n as t}from"./tag-I5_-1jFL.js";function n(e){if(!/^[A-Z_]+$/.test(e))return e;let t=e.replace(/^CATEGORY_/,``).toLowerCase().replace(/_/g,` `);return t[0].toUpperCase()+t.slice(1)}function r(r){let i=t({queries:r.map(t=>({...e.labels(t.id),enabled:t.status===`active`}))}),a=new Map;for(let e of i)for(let t of e.data??[])t.type===`user`&&a.set(t.id,t.name);return e=>a.get(e)??n(e)}export{r as n,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,D as t,Ht as n,_t as r,bt as i,t as a}from"./queries-Cv3nXx0U.js";import{t as o}from"./revealed-keys-C_9NtJPY.js";var s={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};s.node;var c=r(s),l={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};l.node;var u=r(l),d={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};d.node;var f=r(d);function p(){let r=n(),s=i();return async()=>{try{await t(`/api/auth/logout`,{method:`POST`})}catch(t){e(t,`Couldn't sign out`);return}o(),r.clear(),r.setQueryData(a.setupStatus,{claimed:!0,authenticated:!1}),await s({to:`/login`})}}export{c as i,f as n,u as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e,m as t,n,p as r}from"./useQuery-MrTwwNy5.js";var i=class extends e{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,n){let{state:i}=e,a=super.createResult(e,n),{isFetching:o,isRefetching:s,isError:c,isRefetchError:l}=a,u=i.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=o&&u===`forward`,p=c&&u===`backward`,m=o&&u===`backward`;return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:r(n,i.data),hasPreviousPage:t(n,i.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function a(e,t){return n(e,i,t)}export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ht as t,Ut as n,Wt as r}from"./queries-Cv3nXx0U.js";var i={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},a=new class{#e=i;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function o(e){setTimeout(e,0)}var s=typeof window>`u`||`Deno`in globalThis;function c(){}function l(e,t){return typeof e==`function`?e(t):e}function u(e){return typeof e==`number`&&e>=0&&e!==1/0}function d(e,t){return Math.max(e+(t||0)-Date.now(),0)}function f(e,t){return typeof e==`function`?e(t):e}function p(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==h(o,t.options))return!1}else if(!_(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function m(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(g(t.options.mutationKey)!==g(a))return!1}else if(!_(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function h(e,t){return(t?.queryKeyHashFn||g)(e)}function g(e){return JSON.stringify(e,(e,t)=>S(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function _(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!_(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!_(e[r],t[r]))return!1;return!0}return!1}var v=Object.prototype.hasOwnProperty;function y(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=x(e)&&x(t);if(!r&&!(S(e)&&S(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:v.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=y(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function b(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function x(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function S(e){if(!C(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!C(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function ee(e){return new Promise(t=>{a.setTimeout(t,e)})}function w(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:y(e,t)}function te(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var T=Symbol();function E(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===T?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function D(e,t){return typeof e==`function`?e(...t):!!e}function re(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var ie=()=>s,O=()=>ie(),k=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},A=new class extends k{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},ae=o;function oe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ae,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var j=oe(),M=new class extends k{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function se(e){return Math.min(1e3*2**e,3e4)}function N(e){return(e??`online`)!==`online`||M.isOnline()}var P=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function F(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(c);let l=()=>i!==`pending`,u=t=>{if(!l()){let n=new P(t);g(n),e.onCancel?.(n)}},d=()=>{t=!0},f=()=>{t=!1},p=()=>A.isFocused()&&(e.networkMode===`always`||M.isOnline())&&e.canRun(),m=()=>N(e.networkMode)&&e.canRun(),h=e=>{l()||(r?.(),i=`resolved`,a(e))},g=e=>{l()||(r?.(),i=`rejected`,o(e))},_=t=>new Promise(n=>{r=e=>{(l()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,l()||e.onContinue?.()}),v=()=>{if(l())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(h).catch(r=>{if(l())return;let i=e.retry??(O()?0:3),a=e.retryDelay??se,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?g(r):(n++,e.onFail?.(n,r),ee(o).then(()=>p()?void 0:_(p)).then(()=>{t?g(r):v()}))})};return{promise:s,status:()=>i,cancel:u,continue:()=>(r?.(),s),cancelRetry:d,continueRetry:f,canStart:m,start:()=>(m()?v():_(m).then(v),s)}}var I=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),u(this.gcTime)&&(this.#e=a.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(O()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(a.clearTimeout(this.#e),this.#e=void 0)}};function ce(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{re(e,()=>t.signal,()=>n=!0)},u=E(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?ne:te;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?R:L,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:L(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function L(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function R(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function le(e,t){return t?L(e,t)!=null:!1}function ue(e,t){return!t||!e.getPreviousPageParam?!1:R(e,t)!=null}var de=class extends I{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=fe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=fe(this.options);e.data!==void 0&&(this.setState(B(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=w(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(c).catch(c):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>f(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===T||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>f(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!d(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=E(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ce(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=F({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof P&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof P){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...z(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...B(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),j.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function z(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:N(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function B(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function fe(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var V=class extends k{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),H(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return U(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return U(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof f(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!b(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&W(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||f(this.options.enabled,this.#t)!==f(t.enabled,this.#t)||f(this.options.staleTime,this.#t)!==f(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||f(this.options.enabled,this.#t)!==f(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return b(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(c)),t}#h(e){return!O()&&f(this.options.enabled,this.#t)!==!1&&u(e)}#g(){this.#b();let e=f(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=d(this.#r.dataUpdatedAt,e)+1;this.#u=a.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return f(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=a.setInterval(()=>{(this.options.refetchIntervalInBackground||A.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(a.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(a.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&H(e,t),o=i&&W(e,n,t,r);(a||o)&&(l={...l,...z(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(h=`success`,d=w(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=w(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(p=this.#o,d=this.#c,m=Date.now(),h=`error`,u=!1);let _=l.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=d!==void 0;return{status:h,fetchStatus:l.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:G(e,t),refetch:this.refetch,isEnabled:f(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),b(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();j.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function pe(e,t){return f(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||f(t.retryOnMount,e)!==!1)}function H(e,t){return pe(e,t)||e.state.data!==void 0&&U(e,t,t.refetchOnMount)}function U(e,t,n){if(f(t.enabled,e)!==!1&&f(t.staleTime,e)!==`static`){let r=f(n,e);return r===`always`||r!==!1&&G(e,t)}return!1}function W(e,t,n,r){return(e!==t||f(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&G(e,n)}function G(e,t){return f(t.enabled,e)!==!1&&e.isStaleByTime(f(t.staleTime,e))}var K=e(r(),1),q=K.createContext(!1),J=()=>K.useContext(q);q.Provider,n();function me(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var he=K.createContext(me()),Y=()=>K.useContext(he),X=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?D(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Z=e=>{K.useEffect(()=>{e.clearReset()},[e])},Q=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||D(n,[e.error,r])),$=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},ge=(e,t)=>e?.suspense&&t.isPending,_e=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ve(e,n,r){let i=J(),a=Y(),o=t(r),s=o.defaultQueryOptions(e),l=o.getQueryCache().get(s.queryHash),u=e.subscribed!==!1;s._optimisticResults=i?`isRestoring`:u?`optimistic`:void 0,$(s),X(s,a,l),Z(a);let[d]=K.useState(()=>new n(o,s)),f=d.getOptimisticResult(s),p=!i&&u;if(K.useSyncExternalStore(K.useCallback(e=>{let t=p?d.subscribe(j.batchCalls(e)):c;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),K.useEffect(()=>{d.setOptions(s)},[s,d]),ge(s,f))throw _e(s,d,a);if(Q({result:f,errorResetBoundary:a,throwOnError:s.throwOnError,query:l,suspense:s.suspense}))throw f.error;return s.notifyOnChangeProps?f:d.trackResult(f)}function ye(e,t){return ve(e,V,t)}export{b as A,h as C,_ as D,c as E,T as M,y as O,g as S,p as T,M as _,ge as a,k as b,Z as c,V as d,de as f,F as g,I as h,_e as i,D as j,f as k,Y as l,ue as m,ve as n,X as o,le as p,$ as r,Q as s,ye as t,J as u,j as v,m as w,l as x,A as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ct as e,Et as t,St as n}from"./queries-Cv3nXx0U.js";function r(r){let i=t({warn:r?.router===void 0}),a=r?.router||i;return e(a.stores.__store,n(r,a))}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_t as e}from"./queries-Cv3nXx0U.js";var t={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ut as e,ft as t}from"./queries-Cv3nXx0U.js";import{d as n,f as r}from"./common-BPZV8TFb.js";import{c as i}from"./labels-B5UqVwFo.js";var a=e();function o({status:e}){let t=i[e];return(0,a.jsx)(r,{tone:t.tone,pulse:e===`pending`,children:t.label})}function s({enabled:e}){return e?(0,a.jsx)(r,{tone:`good`,children:`Enabled`}):(0,a.jsx)(r,{tone:`idle`,children:`Paused`})}function c({webhook:e,className:r}){return(0,a.jsxs)(`span`,{className:t(`flex flex-wrap gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground`,r),children:[(0,a.jsx)(`span`,{children:`Last 24h:`}),(0,a.jsxs)(`span`,{className:`tabular`,children:[(0,a.jsx)(`span`,{className:`text-foreground`,children:e.stats.succeeded24h}),` delivered`]}),(0,a.jsxs)(`span`,{className:t(`tabular`,e.stats.failed24h>0&&`text-critical`),children:[`· `,(0,a.jsx)(`span`,{className:e.stats.failed24h>0?`font-medium`:`text-foreground`,children:e.stats.failed24h}),` failed`]}),(0,a.jsx)(`span`,{children:`·`}),(0,a.jsxs)(`span`,{children:[`Last delivery `,(0,a.jsx)(n,{date:e.stats.lastDeliveryAt,fallback:`never`})]})]})}function l(e){return e==null?`text-muted-foreground`:e>=200&&e<300?`text-success`:e>=400?`text-critical`:`text-warning`}export{l as i,s as n,c as r,o as t};
|