@maudecode/kanvil 0.6.1 → 0.7.0
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/apps/server/dist/{auth-CFjetlB4.mjs → auth-D43XyHdK.mjs} +227 -71
- package/apps/server/dist/client.mjs +2 -2
- package/apps/server/dist/{config-BQw6mPzE.mjs → config-CQVdVhXv.mjs} +1 -1
- package/apps/server/dist/index.mjs +161 -44
- package/apps/server/dist/migrate.mjs +1 -1
- package/apps/server/dist/recover.mjs +3 -3
- package/apps/server/dist/{src-BaTNDJB7.mjs → src-D70GmZ5R.mjs} +83 -26
- package/apps/server/drizzle/0040_upload_urls.sql +20 -0
- package/apps/server/drizzle/0041_project_repositories.sql +2 -0
- package/apps/server/drizzle/meta/0040_snapshot.json +7170 -0
- package/apps/server/drizzle/meta/0041_snapshot.json +7183 -0
- package/apps/server/drizzle/meta/_journal.json +14 -0
- package/apps/web/dist/assets/{CompositeItem-Dotj8JZL.js → CompositeItem-DLTRsada.js} +1 -1
- package/apps/web/dist/assets/{Trans-CE4EAAY1.js → Trans-DqX-qhvQ.js} +1 -1
- package/apps/web/dist/assets/admin-settings-BQzdZII5.js +1 -0
- package/apps/web/dist/assets/{archive-restore-BMtgjFUu.js → archive-restore-BO1qng5Y.js} +1 -1
- package/apps/web/dist/assets/az-AZ-SXqDBPA2.js +1 -0
- package/apps/web/dist/assets/{az-B-DxMc__.js → az-CEW7-a7J.js} +1 -1
- package/apps/web/dist/assets/configuration-D0zvwrXt.js +1 -0
- package/apps/web/dist/assets/{corner-left-up-O4OsTW-L.js → corner-left-up-Be7Z9Uhf.js} +1 -1
- package/apps/web/dist/assets/{de-Btbkq-aX.js → de-B-oGVMYL.js} +1 -1
- package/apps/web/dist/assets/de-DE-CB7aQ6b-.js +1 -0
- package/apps/web/dist/assets/default-CCI1vZxa.js +56 -0
- package/apps/web/dist/assets/delivery-settings-BrwSrFIN.js +1 -0
- package/apps/web/dist/assets/{el-DBVEX16k.js → el-Cp69kezM.js} +1 -1
- package/apps/web/dist/assets/el-GR-D1ntYXIt.js +1 -0
- package/apps/web/dist/assets/{ellipsis-CvEPDi9V.js → ellipsis-B0AE8ax3.js} +1 -1
- package/apps/web/dist/assets/{es-CMJoxZBk.js → es-CwOMVSTx.js} +1 -1
- package/apps/web/dist/assets/es-ES-CllsaxcB.js +1 -0
- package/apps/web/dist/assets/{forms-DbfnnPg_.js → forms-CkVpTx29.js} +1 -1
- package/apps/web/dist/assets/{fr-OyEmYoRn.js → fr-Cy4co9ic.js} +1 -1
- package/apps/web/dist/assets/fr-FR-DxTw6LgI.js +1 -0
- package/apps/web/dist/assets/{hi-CIgXSseB.js → hi-DbO9TKwg.js} +1 -1
- package/apps/web/dist/assets/hi-IN-CaQga-0l.js +1 -0
- package/apps/web/dist/assets/{highlight-B4K3yEEh.js → highlight-zMg1BK-r.js} +1 -1
- package/apps/web/dist/assets/{id-WV2oSAPB.js → id-B6NKsmCm.js} +1 -1
- package/apps/web/dist/assets/id-ID-DBfwAAqU.js +1 -0
- package/apps/web/dist/assets/index-CZuFd4LM.js +17 -0
- package/apps/web/dist/assets/index-DPT5LAs1.css +2 -0
- package/apps/web/dist/assets/{invitations-BTB8f2Xl.js → invitations-Dp40BfHj.js} +1 -1
- package/apps/web/dist/assets/it-IT-BckuH9Nl.js +1 -0
- package/apps/web/dist/assets/{it-BWSrRqus.js → it-ilGYCq2T.js} +1 -1
- package/apps/web/dist/assets/{item-HmFuRZet.js → item-DQR89bKm.js} +1 -1
- package/apps/web/dist/assets/{ja-BtOHWvUJ.js → ja-D-hJRTgP.js} +1 -1
- package/apps/web/dist/assets/ja-JP-BAGgJKZ4.js +1 -0
- package/apps/web/dist/assets/ko-KR-srIEsTP5.js +1 -0
- package/apps/web/dist/assets/{ko-DAryK0HN.js → ko-ajkkoJ_d.js} +1 -1
- package/apps/web/dist/assets/{label-settings-ssfEX2uR.js → label-settings-ChnKkA97.js} +1 -1
- package/apps/web/dist/assets/{markdown-blocks-B1kO6iku.js → markdown-blocks-CpzrwyQG.js} +1 -1
- package/apps/web/dist/assets/{member-directory-BA4ZT1qU.js → member-directory-XK0ZEGUq.js} +1 -1
- package/apps/web/dist/assets/{mk-DBbiGUk5.js → mk-C_sMyEHX.js} +1 -1
- package/apps/web/dist/assets/mk-MK-BTa1NMAF.js +1 -0
- package/apps/web/dist/assets/{nl-D4V-8WdF.js → nl-D9-P4UPR.js} +1 -1
- package/apps/web/dist/assets/nl-NL-CQduhDqs.js +1 -0
- package/apps/web/dist/assets/{pl-C--QrxO0.js → pl-CiQM7fSB.js} +1 -1
- package/apps/web/dist/assets/pl-PL-BdZMf7Ni.js +1 -0
- package/apps/web/dist/assets/project-lifecycle-VYecJuiP.js +1 -0
- package/apps/web/dist/assets/project-settings-Bs6YEpo9.js +1 -0
- package/apps/web/dist/assets/{pt-BR-DvFVKpmO.js → pt-BR-CP7dhuqF.js} +1 -1
- package/apps/web/dist/assets/pt-BR-DZEXJNHg.js +1 -0
- package/apps/web/dist/assets/public-project-DUfWDao9.js +1 -0
- package/apps/web/dist/assets/{rotate-ccw-CB36Zu3L.js → rotate-ccw-Cxh9ec2s.js} +1 -1
- package/apps/web/dist/assets/{ru-UmbPUOka.js → ru-DxJ6vF4E.js} +1 -1
- package/apps/web/dist/assets/ru-RU-CZKEe7P8.js +1 -0
- package/apps/web/dist/assets/{search-Cvetr1OK.js → search-DfbsqO7M.js} +6 -6
- package/apps/web/dist/assets/{send-CJDct4Oj.js → send-DrJl0BKm.js} +1 -1
- package/apps/web/dist/assets/settings-BN8uIiBG.js +1 -0
- package/apps/web/dist/assets/{sliders-horizontal-dmqWngxy.js → sliders-horizontal-DM47MLe7.js} +1 -1
- package/apps/web/dist/assets/{switch-BtScTpP9.js → switch-CJTVGtE9.js} +1 -1
- package/apps/web/dist/assets/{table-byFokzo-.js → table-BLLjFPWD.js} +1 -1
- package/apps/web/dist/assets/{ticket-detail-C3YA3Hzc.js → ticket-detail-BTy_3JeU.js} +2 -2
- package/apps/web/dist/assets/ticket-editor-Bb_lyxnJ.js +2 -0
- package/apps/web/dist/assets/{ticket-list-BXUorfmj.js → ticket-list-Botp5qf5.js} +5 -5
- package/apps/web/dist/assets/ticket-list-controls-Dmkno4pm.js +1 -0
- package/apps/web/dist/assets/{tr-CNpgQ4ka.js → tr-9IkdRLIk.js} +1 -1
- package/apps/web/dist/assets/tr-TR-Y8wBLO8I.js +1 -0
- package/apps/web/dist/assets/{uk-MQoTXdpk.js → uk-Btampsdw.js} +1 -1
- package/apps/web/dist/assets/uk-UA-CVpasGUS.js +1 -0
- package/apps/web/dist/assets/{upload-D1x_ib3B.js → upload-HARy4VC_.js} +1 -1
- package/apps/web/dist/assets/{useQueries-BnlNCoy4.js → useQueries-CTeEF--U.js} +1 -1
- package/apps/web/dist/assets/{vi-CEw4gTWc.js → vi-BVZzOn_n.js} +1 -1
- package/apps/web/dist/assets/vi-VN-BMy-iJD-.js +1 -0
- package/apps/web/dist/assets/{visual-editor-CpdMRn3e.js → visual-editor-DKBPjqV-.js} +1 -1
- package/apps/web/dist/assets/{workspace-settings-BickBtZx.js → workspace-settings-DqzBNw60.js} +1 -1
- package/apps/web/dist/assets/{zh-CN-ChzoXkfr.js → zh-CN-BoUvF2do.js} +1 -1
- package/apps/web/dist/assets/zh-CN-Cds_v0R8.js +1 -0
- package/apps/web/dist/assets/{zh-TW-bWBKARrK.js → zh-TW-CEIDGTWe.js} +1 -1
- package/apps/web/dist/assets/zh-TW-DCCYakXz.js +1 -0
- package/apps/web/dist/index.html +8 -8
- package/docs/api.md +33 -3
- package/docs/cli.md +1 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/admin-settings-CO7nnD9T.js +0 -1
- package/apps/web/dist/assets/az-AZ-R8_HFWJr.js +0 -1
- package/apps/web/dist/assets/configuration-Bnt72HRu.js +0 -1
- package/apps/web/dist/assets/de-DE-BHgMj19Y.js +0 -1
- package/apps/web/dist/assets/default-DqsN66dq.js +0 -56
- package/apps/web/dist/assets/delivery-settings-Cji0N0m0.js +0 -1
- package/apps/web/dist/assets/el-GR-CQFGM5Sr.js +0 -1
- package/apps/web/dist/assets/es-ES-DZkcRVA4.js +0 -1
- package/apps/web/dist/assets/fr-FR-CRPAezXU.js +0 -1
- package/apps/web/dist/assets/hi-IN-2YFE4UQk.js +0 -1
- package/apps/web/dist/assets/id-ID-B-J0_QIW.js +0 -1
- package/apps/web/dist/assets/index-BAnwOrh1.css +0 -2
- package/apps/web/dist/assets/index-nltuyQtq.js +0 -17
- package/apps/web/dist/assets/it-IT-CJ0HYggO.js +0 -1
- package/apps/web/dist/assets/ja-JP-DDQS7D7b.js +0 -1
- package/apps/web/dist/assets/ko-KR-CkpoewEa.js +0 -1
- package/apps/web/dist/assets/mk-MK-C0RhS6XR.js +0 -1
- package/apps/web/dist/assets/nl-NL-BSKqlzcL.js +0 -1
- package/apps/web/dist/assets/pl-PL-CHz38SiU.js +0 -1
- package/apps/web/dist/assets/project-lifecycle-COZb9FqM.js +0 -1
- package/apps/web/dist/assets/project-settings-DwmTm9KA.js +0 -1
- package/apps/web/dist/assets/pt-BR-BotWHRiO.js +0 -1
- package/apps/web/dist/assets/public-project-B3hEkeCF.js +0 -1
- package/apps/web/dist/assets/ru-RU-DtOwNna6.js +0 -1
- package/apps/web/dist/assets/settings-3IXm9lJ-.js +0 -1
- package/apps/web/dist/assets/ticket-editor-CZnZQMG1.js +0 -2
- package/apps/web/dist/assets/ticket-list-controls-BxGKCZMo.js +0 -1
- package/apps/web/dist/assets/tr-TR-CdG2alU2.js +0 -1
- package/apps/web/dist/assets/uk-UA-Ceu5gorw.js +0 -1
- package/apps/web/dist/assets/vi-VN-CxshgV4W.js +0 -1
- package/apps/web/dist/assets/zh-CN-D7Yrjhd3.js +0 -1
- package/apps/web/dist/assets/zh-TW-DyF38kqx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Za as e}from"./search-
|
|
1
|
+
import{Za as e}from"./search-DfbsqO7M.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Dn as t,En as n,K as r,Mn as i,Nt as a,Pt as o,Sn as s,Ut as c,Wn as l,_ as u,_n as d,cn as f,g as p,gt as m,h,hn as ee,lt as g,mn as te,pn as ne,r as re,sn as _,ut as v}from"./default-CCI1vZxa.js";import{$a as y,$r as ie,Ba as b,Bi as ae,Br as oe,Ca as se,Ct as x,Da as S,Ea as C,Et as w,Fa as T,Gi as E,H as ce,Ir as le,J as D,Ja as O,Jt as k,Ki as A,Lt as j,Pa as M,Q as N,Qa as P,Qi as F,Rr as ue,U as I,Vi as de,Vr as fe,X as L,Xi as pe,Y as R,Yi as me,Z as z,Zi as he,_i as ge,ai as _e,ar as ve,at as B,ba as V,cn as ye,di as be,dr as H,et as U,fi as xe,ft as Se,ha as Ce,ii as we,ir as Te,ka as Ee,ko as De,kr as Oe,lr as ke,ma as Ae,mi as W,mr as je,nr as Me,oa as Ne,oi as Pe,or as Fe,ot as G,pa as Ie,pi as Le,q as Re,rr as ze,sa as Be,si as Ve,sr as He,st as K,tr as Ue,ui as We,ur as Ge,vi as Ke,vr as qe,wt as Je,xa as Ye,xt as Xe,ya as Ze,zi as Qe,zr as $e}from"./search-DfbsqO7M.js";import{g as et}from"./item-DQR89bKm.js";import{i as tt,t as nt}from"./delivery-settings-BrwSrFIN.js";import{r as rt,u as it}from"./project-lifecycle-VYecJuiP.js";import{n as at,r as ot,t as st}from"./CompositeItem-DLTRsada.js";import{t as ct}from"./ticket-list-controls-Dmkno4pm.js";import{t as lt}from"./upload-HARy4VC_.js";import{t as ut}from"./forms-CkVpTx29.js";import{Ct as dt,Et as ft,Gt as pt,Jt as mt,Kt as ht,Tt as gt,Xt as _t,Yt as vt,_t as yt,bt as q,en as bt,f as xt,ht as St,i as J,in as Ct,ln as wt,n as Y,p as Tt,qt as Et,r as Dt,t as Ot,v as kt,xt as At,y as jt}from"./index-CZuFd4LM.js";import{t as Mt}from"./switch-CJTVGtE9.js";import{a as Nt,i as X,n as Pt,o as Ft,r as Z,t as It}from"./table-BLLjFPWD.js";var Q=e(l(),1),Lt=Q.createContext(void 0);function Rt(e=!1){let t=Q.useContext(Lt);if(!t&&!e)throw Error(Ye(86));return t}Object.keys(xe);function zt(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var $=re(),Bt=[`7`,`30`,`90`,`365`,`custom`,`never`],Vt=e=>({name:d(`settings.credentials.permission.${e}.name`),description:d(`settings.credentials.permission.${e}.description`)});function Ht(e){try{return JSON.parse(e??`null`)}catch{return null}}function Ut(e){return{permissions:i({kanvil:t(n(c))}).safeParse(Ht(e.permissions)).data?.kanvil??[],projectIds:(p.safeParse(Ht(e.metadata)).data??{projectIds:[]}).projectIds}}function Wt(){let e=De(),t=pe(),[n,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l]=(0,Q.useState)(Date.now),p=y({queryKey:[`kanvil`,`credentials`],queryFn:()=>E.request(`/api/v1/credentials`,u)});function h(){i(!1),c(null)}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(G,{title:d(`settings.credentials.title`),description:d(`settings.credentials.description`),action:(0,$.jsx)(L,{label:d(`settings.credentials.create`),variant:`default`,disabled:t.isPending,onClick:()=>i(!0),children:(0,$.jsx)(et,{})})}),(0,$.jsx)(D,{error:p.error??t.error}),p.isPending?(0,$.jsx)(N,{}):p.data?.length?(0,$.jsxs)(It,{"aria-label":d(`settings.credentials.title`),mobileLayout:`rows`,children:[(0,$.jsx)(Nt,{children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(X,{children:d(`settings.credentials.name`)}),(0,$.jsx)(X,{children:d(`settings.credentials.access`)}),(0,$.jsx)(X,{children:d(`settings.credentials.projects`)}),(0,$.jsx)(X,{children:d(`settings.credentials.expires`)}),(0,$.jsx)(X,{children:(0,$.jsx)(`span`,{className:`sr-only`,children:d(`settings.credentials.actions`)})})]})}),(0,$.jsx)(Pt,{children:p.data.map(n=>{let i=Ut(n),a=!!n.expiresAt&&new Date(n.expiresAt).getTime()<=l,o=i.projectIds?.map(e=>t.data?.find(t=>t.id===e)?.name??d(`settings.credentials.unavailableProject`));return(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Z,{className:`max-w-64 whitespace-normal`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,$.jsx)(wt,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{dir:`auto`,className:`block wrap-anywhere font-medium`,children:n.name||d(`settings.credentials.untitled`)}),(0,$.jsxs)(`code`,{className:`text-xs text-muted-foreground`,children:[n.start,`…`]})]}),(a||!n.enabled)&&(0,$.jsx)(Xe,{variant:`secondary`,children:d(a?`settings.credentials.expired`:`settings.credentials.disabled`)})]})}),(0,$.jsx)(Z,{"data-label":d(`settings.credentials.access`),className:`max-w-72 whitespace-normal`,children:(0,$.jsx)(`span`,{className:`text-sm`,children:i.permissions.length===1&&i.permissions[0]===`read`?d(`settings.credentials.preset.read`):f(i.permissions.map(e=>Vt(e).name))||d(`settings.credentials.custom`)})}),(0,$.jsx)(Z,{"data-label":d(`settings.credentials.projects`),className:`max-w-64 whitespace-normal`,children:i.projectIds===null?d(`settings.credentials.global`):f(o??[])||d(`settings.credentials.noProjects`)}),(0,$.jsx)(Z,{"data-label":d(`settings.credentials.expires`),className:`whitespace-nowrap text-muted-foreground`,children:n.expiresAt?r(n.expiresAt):d(`settings.credentials.never`)}),(0,$.jsx)(Z,{children:(0,$.jsx)(I,{label:d(`settings.credentials.revoke`),icon:(0,$.jsx)(at,{}),danger:!0,description:n.name===null?d(`settings.credentials.revokeUnnamed`):d(`settings.credentials.revokeNamed`,{name:n.name}),onConfirm:async()=>{await E.request(`/api/v1/credentials/${encodeURIComponent(n.id)}`,m,{method:`DELETE`}),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]},n.id)})})]}):(0,$.jsx)(Re,{title:d(`settings.credentials.empty`),icon:wt,className:`py-16`,children:(0,$.jsx)(`p`,{className:`mb-0 max-w-sm text-center text-sm text-muted-foreground`,children:d(`settings.credentials.emptyDescription`)})}),(0,$.jsx)(U,{busy:a,title:d(s?`settings.credentials.created`:`settings.credentials.create`),open:n,onOpenChange:e=>{e||h()},children:s?(0,$.jsx)(Gt,{value:s,onDone:h}):(0,$.jsx)(qt,{pending:a,setPending:o,projects:t.data??[],loading:t.isPending,onCancel:h,onCreated:async t=>{c(t),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]})}function Gt({value:e,onDone:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{children:d(`settings.credentials.copyNow`)}),(0,$.jsx)(z,{label:d(`settings.credentials.newKey`),value:e.key,readOnly:!0,className:`font-mono text-xs`,onFocus:e=>e.target.select()}),(0,$.jsx)(D,{error:i}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(W,{onClick:()=>{Qe(e.key).then(()=>r(!0)).catch(a)},children:[n?(0,$.jsx)(O,{}):(0,$.jsx)(b,{}),d(n?`common.state.copied`:`settings.credentials.copy`)]}),(0,$.jsx)(W,{variant:`default`,onClick:t,children:d(`common.action.done`)})]})]})}function Kt({scope:e,checked:t,onChange:n}){let r=(0,Q.useId)(),i=Vt(e);return(0,$.jsxs)(ve,{orientation:`horizontal`,className:`border-b py-3 last:border-0 [&_[data-slot=field-description]]:m-0 [&_[data-slot=field-description]]:text-xs`,children:[(0,$.jsx)(Ue,{id:r,checked:t,onCheckedChange:n}),(0,$.jsxs)(Fe,{children:[(0,$.jsx)(ke,{htmlFor:r,children:i.name}),(0,$.jsx)(He,{children:i.description})]})]})}function qt({projects:e,loading:t,onCreated:n,onCancel:r,pending:i,setPending:a}){let o=Ne(),s=new Map(o.data?.map(e=>[e.id,e.name])),[{tomorrow:l,lastDay:u}]=(0,Q.useState)(()=>{let e=new Date;e.setHours(0,0,0,0),e.setDate(e.getDate()+1);let t=new Date;return t.setDate(t.getDate()+365),{tomorrow:e,lastDay:t}}),[f,p]=(0,Q.useState)(e.length===1&&e[0]?[e[0].id]:[]),[m,ee]=(0,Q.useState)(!1),[g,te]=(0,Q.useState)([`read`]),[ne,re]=(0,Q.useState)(()=>{let e=new Date;return e.setDate(e.getDate()+90),e}),[_,v]=(0,Q.useState)(`90`),[y,ie]=(0,Q.useState)(),[b,ae]=(0,Q.useState)(`read`),[oe,se]=(0,Q.useState)(``),x=e.filter(e=>`${e.name} ${e.key} ${s.get(e.workspaceId)??``}`.toLowerCase().includes(oe.toLowerCase()));async function S(e){e.preventDefault(),a(!0),ie(void 0);try{await n(await E.request(`/api/v1/credentials`,h,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:ut(new FormData(e.currentTarget),`name`),projectIds:m?null:f,scopes:g,expiresIn:_===`never`?null:_===`custom`?yt(ne):Number(_)*86400})}))}catch(e){ie(e)}finally{a(!1)}}return t?(0,$.jsx)(N,{}):(0,$.jsx)(`form`,{onSubmit:e=>{S(e)},children:(0,$.jsxs)(H,{disabled:i,children:[(0,$.jsx)(z,{label:d(`settings.credentials.keyName`),name:`name`,required:!0,maxLength:100,placeholder:d(`settings.credentials.keyNamePlaceholder`),autoFocus:!0}),(0,$.jsxs)(H,{className:`gap-2`,children:[(0,$.jsx)(Ge,{variant:`label`,children:d(`settings.credentials.projectAccess`)}),(0,$.jsx)(ce,{label:d(`settings.credentials.global`),description:d(`settings.credentials.globalDescription`),checked:m,onCheckedChange:ee}),!m&&e.length>6&&(0,$.jsx)(B,{label:d(`settings.credentials.findProject`),value:oe,onChange:se,className:`mb-2`}),!m&&(0,$.jsxs)(`div`,{className:`max-h-44 overflow-y-auto px-3 py-1`,children:[x.map(e=>(0,$.jsx)(ce,{label:e.name,description:d(`settings.credentials.projectDescription`,{key:e.key,workspace:s.get(e.workspaceId)??d(`settings.credentials.workspace`)}),checked:f.includes(e.id),onCheckedChange:t=>p(n=>t?[...n,e.id]:n.filter(t=>t!==e.id))},e.id)),x.length===0&&(0,$.jsx)(`p`,{className:`my-4 text-sm text-muted-foreground`,children:d(`settings.credentials.noMatches`)})]}),(0,$.jsx)(He,{children:d(`settings.credentials.roleLimit`)})]}),(0,$.jsxs)(K,{label:d(`settings.credentials.accessLevel`),value:b,onValueChange:e=>{let t=e??`read`;ae(t),t!==`custom`&&te(t===`read`?[`read`]:t===`write`?[`read`,`write`]:[`read`,`write`,`claim`])},children:[(0,$.jsx)(j,{value:`read`,children:d(`settings.credentials.preset.read`)}),(0,$.jsx)(j,{value:`write`,children:d(`settings.credentials.preset.write`)}),(0,$.jsx)(j,{value:`automation`,children:d(`settings.credentials.preset.automation`)}),(0,$.jsx)(j,{value:`custom`,children:d(`settings.credentials.preset.custom`)})]}),b===`custom`&&(0,$.jsx)(H,{className:`gap-0`,children:c.map(e=>(0,$.jsx)(Kt,{scope:e,checked:g.includes(e),onChange:t=>te(n=>t?e===`intake`?[`intake`]:[...n.filter(e=>e!==`intake`),e]:n.filter(t=>t!==e))},e))}),(0,$.jsx)(K,{label:d(`settings.credentials.expires`),value:_,onValueChange:e=>v(e??`90`),children:Bt.map(e=>(0,$.jsx)(j,{value:e,children:d(`settings.credentials.expiry.${e}`)},e))}),_===`custom`&&(0,$.jsx)(St,{label:d(`settings.credentials.expiresOn`),value:ne,onChange:e=>{e&&re(e)},bounds:{from:l,to:u}}),_===`never`&&(0,$.jsx)(He,{children:d(`settings.credentials.neverDescription`)}),(0,$.jsx)(R,{error:y,pending:i,submitLabel:d(`settings.credentials.create`),pendingLabel:d(`settings.credentials.creating`),submitDisabled:!m&&!f.length||!g.length,onCancel:r})]})})}function Jt(){let e=De(),t=he(),n=A.useSession(),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(!1),[o,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(),[f,p]=(0,Q.useState)(``);async function m(){await Promise.all([n.refetch(),e.invalidateQueries({queryKey:[`kanvil`]})])}async function h(e){a(!0),c(void 0),p(``);try{await E.request(`/api/v1/profile/photo`,s,e?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(await de(e))}:{method:`DELETE`}),await m(),p(d(e?`settings.profile.photoUpdated`:`settings.profile.photoRemoved`))}catch(e){c(e)}finally{a(!1)}}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(G,{title:d(`settings.profile.title`)}),(0,$.jsx)(Ot,{name:t.name,nameLabel:d(`settings.profile.displayName`),withDescription:!1,canEdit:!0,pending:i,error:l,editLabel:d(`settings.profile.edit`),media:(0,$.jsx)(tt,{label:d(`settings.profile.changePhoto`),round:!0,disabled:i,onClick:()=>r.current?.click(),children:(0,$.jsx)(Be,{name:t.name,image:t.image,className:`size-16 text-xl`})}),onSave:async({name:e})=>{u(void 0),a(!0);try{let t=await A.updateUser({name:e});if(t.error)throw Error(t.error.message);await m(),p(d(`settings.profile.saved`))}catch(e){throw u(e),e}finally{a(!1)}},children:(0,$.jsx)(`p`,{className:`mb-0 text-sm break-all text-muted-foreground`,children:t.email})}),t.image&&(0,$.jsxs)(W,{className:`mt-5`,variant:`ghost`,disabled:i,onClick:()=>{h()},children:[(0,$.jsx)(at,{}),d(`settings.profile.removePhoto`)]}),(0,$.jsx)(qe,{ref:r,type:`file`,disabled:i,accept:`image/png,image/jpeg,image/webp`,className:`hidden`,"aria-label":d(`settings.profile.photoFile`),onChange:e=>{let t=e.currentTarget.files?.[0];t&&h(t),e.currentTarget.value=``}}),(0,$.jsx)(D,{error:o}),f&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4 mb-0 text-sm text-muted-foreground`,children:f})]})}function Yt({palette:e,clip:t}){return(0,$.jsxs)(`g`,{clipPath:t,children:[(0,$.jsx)(`rect`,{width:`160`,height:`96`,fill:e.background}),(0,$.jsx)(`rect`,{width:`34`,height:`96`,fill:e.sidebar}),(0,$.jsx)(`rect`,{x:`7`,y:`10`,width:`19`,height:`4`,rx:`2`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsx)(`rect`,{x:`7`,y:27+t*12,width:t===2?12:21,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.25`},t)),(0,$.jsx)(`rect`,{x:`45`,y:`12`,width:`65`,height:`5`,rx:`2`,fill:e.foreground,opacity:`.8`}),(0,$.jsx)(`rect`,{x:`127`,y:`10`,width:`23`,height:`8`,rx:`3`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:`45`,y:34+t*18,width:`57`,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.3`}),(0,$.jsx)(`circle`,{cx:`130`,cy:35+t*18,r:`3`,fill:e.primary,opacity:t===1?1:.35}),(0,$.jsx)(`rect`,{x:`45`,y:43+t*18,width:`105`,height:`.6`,fill:e.foreground,opacity:`.12`})]},t))]})}function Xt({theme:e,mode:t=`system`,variant:n=`wireframe`,className:r}){let i=(0,Q.useId)();if(n===`orb`&&t!==`system`){let n=e[t],i=t===`light`;return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:T(`relative block size-14 shrink-0 overflow-hidden rounded-full border-2 border-background`,r),style:{boxShadow:i?`inset 0 0 0 1px rgb(0 0 0 / .1), 0 1px 2px rgb(0 0 0 / .08)`:`inset 0 0 0 1px rgb(255 255 255 / .14), 0 1px 2px rgb(0 0 0 / .18)`},children:(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`color-mix(in oklab, ${n.background} 80%, ${i?`#ffffff`:`#09090b`})`,backgroundImage:`radial-gradient(circle at ${i?`72% 22%`:`28% 78%`} in oklab, ${n.primary} 0%, color-mix(in oklab, ${n.primary} ${i?`72%`:`62%`}, transparent) 28%, transparent 58%), radial-gradient(circle at ${i?`18% 82%`:`82% 18%`} in oklab, color-mix(in oklab, ${n.primary} 45%, transparent) 0%, transparent 55%)`,filter:`blur(3px)`,transform:`scale(1.1)`}})})}return(0,$.jsxs)(`svg`,{viewBox:`0 0 160 96`,preserveAspectRatio:`none`,className:T(`w-full rounded-md`,r),"aria-hidden":`true`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`clipPath`,{id:`${i}-light`,children:(0,$.jsx)(`rect`,{width:`80`,height:`96`})}),(0,$.jsx)(`clipPath`,{id:`${i}-dark`,children:(0,$.jsx)(`rect`,{x:`80`,width:`80`,height:`96`})})]}),t===`system`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{palette:e.light,clip:`url(#${i}-light)`}),(0,$.jsx)(Yt,{palette:e.dark,clip:`url(#${i}-dark)`})]}):(0,$.jsx)(Yt,{palette:e[t]})]})}var Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},...Ae,...Le},en=Q.createContext(void 0);function tn(){return Q.useContext(en)}var nn=Q.createContext(void 0);function rn(){let e=Q.useContext(nn);if(e===void 0)throw Error(Ye(52));return e}var an=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=tn(),{disabled:h,readOnly:ee,required:g,form:te,checkedValue:ne,touched:re=!1,validation:_,name:v,setCheckedValue:y=S,setTouched:ie=S,registerInputRef:b=S}=m??{},{setTouched:ae,setFilled:x,state:w,disabled:T}=be(),E=fe(),{labelId:ce,getDescriptionProps:D}=Pe(),O=T||E.disabled||h||i,k=ee||a,A=g||o,j=te,M=m?ne===c:c===``,N=Q.useRef(null),P=oe(O,N),F=Q.useRef(null),ue=_?.registerInput,I=Q.useCallback(e=>ue?.(e,{controlRef:N,value:void 0}),[ue]),de=Ee(l,F,b,I);Ze(()=>{F.current?.checked&&x(!0)},[x]),Ze(()=>{F.current&&b(O&&M?null:F.current)},[M,O,b]);let L=Ve(),pe=we({id:d}),R=u?void 0:pe,me={role:`radio`,"aria-checked":M,"aria-labelledby":_e(s,ce,F,!u,R,p[`aria-label`]),[jt]:M?``:void 0,id:u?pe:L,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||O||k)return;e.preventDefault();let t=F.current;t&&Ke(t,e)},onFocus(e){P(!0),!(e.defaultPrevented||O||k||!re)&&(F.current?.click(),ie(!1))},onBlur(){m||P(!1)}},{getButtonProps:z,buttonRef:he}=ge({disabled:O,native:u,composite:!1}),ve={type:`radio`,ref:de,form:j,id:R,name:v,tabIndex:-1,style:v?ze:Me,"aria-hidden":!0,...c===void 0?C:{value:ye(c)},disabled:O,checked:M,required:A,readOnly:k,onChange(e){if(e.nativeEvent.defaultPrevented||O||k||c===void 0)return;let t=le(Oe,e.nativeEvent);y(c,t),!t.isCanceled&&ae(!0)},onClick(e){e.stopPropagation()},onFocus(){N.current?.focus()}},B=Q.useMemo(()=>({...w,required:A,disabled:O,readOnly:k,checked:M}),[w,O,k,M,A]),V=B,H=m!==void 0,U=[t,N,he],xe=[me,p,z,D,_?e=>_.getValidationProps(O,e):C],Se=se(`span`,e,{enabled:!H,state:B,ref:U,props:xe,stateAttributesMapping:$t});return(0,$.jsxs)(nn.Provider,{value:V,children:[H?(0,$.jsx)(st,{tag:`span`,render:n,className:r,style:f,state:B,refs:U,props:xe,stateAttributesMapping:$t}):Se,(0,$.jsx)(`input`,{...ve,suppressHydrationWarning:!0})]})}),on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=rn(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Ie(c),f={...s,transitionStatus:u},p=Q.useRef(null),m=a||l,h=se(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:$t});return Ce({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),sn=[k],cn=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:ee,setFocused:g,validationMode:te,name:ne,disabled:re,state:_,validation:v,setDirty:y,setFilled:b,validityData:ae}=be(),{labelId:oe}=Pe(),{clearErrors:se,elementRef:x}=We(),S=Rt(!0),C=re||i,w=ne??d,T=Ve(p),[E,ce]=Te({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[le,D]=Q.useState(!1),O=V((e,t)=>{s?.(e,t),!t.isCanceled&&ce(e)}),k=v.getInputControl,A=Q.useMemo(()=>({get current(){return k()}}),[k]),j=Q.useRef(null),M=Q.useRef(null),N=Ee(j,f),P=Q.useRef(N),F=V(e=>{(j.current!==e||P.current!==N)&&(P.current=N,N?.(e))});Ze(()=>{F(j.current)},[N,F]);let I=V(e=>{if(e){if(!e.disabled){M.current||=e;let t=j.current;(e.checked||t==null||t.disabled)&&F(e)}return()=>{M.current===e&&(M.current=null),j.current===e&&F(null)}}}),de=V(()=>{let e=x.current;if(!e)return E??null;for(let t of v.registeredInputs.keys())if(t.checked&&zt(t,e))return E??null;return null});$e(A,T,E??null,de,!C,d),ue(E,()=>{se(w),y(E!==ae.initialValue),b(E!=null),v.change(E);let e=M.current;E==null&&e&&!e.disabled&&F(e)});let fe=oe??S?.legendId,L={..._,disabled:C??!1,required:o??!1,readOnly:a??!1},pe=Q.useMemo(()=>({checkedValue:E,disabled:C,form:u,validation:v,name:w,readOnly:a,registerInputRef:I,required:o,setCheckedValue:O,setTouched:D,touched:le}),[E,C,u,v,w,a,I,o,O,D,le]),R={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":C||void 0,"aria-readonly":a||void 0,"aria-labelledby":fe,onBlur(e){ie(e.currentTarget,e.relatedTarget)||(D(!1),ee(!0),g(!1),te===`onBlur`&&v.commit(E))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&D(!0)}};return(0,$.jsx)(en.Provider,{value:pe,children:(0,$.jsx)(kt,{render:n,className:r,style:m,state:L,props:[R,h,e=>v.getValidationProps(C??!1,e)],refs:[t],stateAttributesMapping:Le,enableHomeAndEndKeys:!1,modifierKeys:sn})})});function ln({className:e,...t}){return(0,$.jsx)(cn,{"data-slot":`radio-group`,className:T(`grid w-full gap-2`,e),...t})}function un({className:e,...t}){return(0,$.jsx)(an,{"data-slot":`radio-group-item`,className:T(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,$.jsx)(on,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,$.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}var dn=[`system`,`light`,`dark`],fn=e=>ae(`${e.id}.kanvil-theme.json`,mt([e]));function pn({theme:e,active:t,activeModes:n,onPickMode:r,actions:i}){return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-border/70 bg-background transition-colors hover:bg-accent/10 has-[>[data-slot=radio-group-item]:focus-visible]:ring-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-ring has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-background data-[selected=true]:bg-accent/30 data-[selected=true]:shadow-[inset_0_0_0_1px_var(--ring)]`,"data-selected":t,children:[(0,$.jsx)(un,{value:e.id,id:`theme-${e.id}`,className:`peer absolute inset-0 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsx)(`div`,{className:`pointer-events-none relative flex min-h-16 items-center justify-center gap-2.5 px-3 pt-3`,children:[`light`,`dark`].map(t=>{let i=n.includes(t),a=t===`light`?bt:Ct;return(0,$.jsxs)(x,{children:[(0,$.jsxs)(w,{render:(0,$.jsx)(W,{variant:`ghost`,"aria-label":d(`settings.appearance.useMode.${t}`,{name:e.name}),"aria-pressed":i,className:`pointer-events-auto relative size-[68px] shrink-0 rounded-full p-1 transition-transform hover:scale-105 hover:bg-transparent aria-pressed:hover:scale-100`,onClick:()=>r(t)}),children:[(0,$.jsx)(Xt,{theme:e,mode:t,variant:`orb`}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 rounded-full ring-2 ring-inset ring-ring`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0.5 right-0.5 flex size-5 items-center justify-center rounded-full border border-border/70 bg-background text-foreground shadow-sm`,children:(0,$.jsx)(a,{className:`size-3`})})]})]}),(0,$.jsx)(Je,{children:d(`settings.appearance.modeOnly.${t}`)})]},t)})}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-center gap-2 px-3 pb-3 pt-2`,children:[(0,$.jsx)(je,{htmlFor:`theme-${e.id}`,title:e.name,className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(`div`,{className:`pointer-events-auto relative flex shrink-0 items-center gap-1`,children:i})]})]})}var mn=e=>e.toLocaleLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``);function hn(){let e=ht(),t=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(),l={...e.selected,light:e.lightTheme.light,dark:e.darkTheme.dark};function u(e){i({...e,id:`custom-${crypto.getRandomValues(new Uint32Array(2)).join(`-`)}`,name:d(`settings.appearance.copyName`,{name:e.name})})}let f=e.themes.filter(e=>mn(e.name).includes(mn(a)));return(0,$.jsxs)(`section`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-normal text-muted-foreground`,children:d(`settings.appearance.colorScheme`)}),(0,$.jsx)(ln,{value:e.mode,onValueChange:t=>e.setMode(n(dn).parse(t)),"aria-label":d(`settings.appearance.theme`),className:`grid grid-cols-3 gap-3`,children:dn.map(t=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(un,{id:`mode-${t}`,value:t,className:`peer absolute inset-0 z-10 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsxs)(je,{htmlFor:`mode-${t}`,className:`theme-choice flex w-full cursor-pointer flex-col gap-2 rounded-lg border border-border bg-background p-2 text-xs font-medium transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background hover:bg-muted/50 data-[selected=true]:border-primary data-[selected=true]:ring-1 data-[selected=true]:ring-primary [&_svg]:overflow-hidden [&_svg]:border [&_svg]:border-foreground/10`,"data-selected":e.mode===t,children:[(0,$.jsx)(Xt,{theme:l,mode:t,className:`h-[8.75rem]`}),(0,$.jsx)(`span`,{className:`pb-1`,children:pt[t]})]})]},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`mb-0 text-sm font-normal text-muted-foreground`,children:d(`settings.appearance.themes`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1`,children:[(0,$.jsx)(B,{label:d(`settings.appearance.search`),placeholder:d(`settings.appearance.searchPlaceholder`),value:a,onChange:o}),(0,$.jsx)(L,{label:d(`settings.appearance.create`),size:`icon-sm`,onClick:()=>u(l),children:(0,$.jsx)(et,{})}),(0,$.jsx)(L,{label:d(`settings.appearance.add`),size:`icon-sm`,onClick:()=>t.current?.click(),children:(0,$.jsx)(lt,{})})]})]}),(0,$.jsx)(qe,{ref:t,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":d(`settings.appearance.importFile`),onChange:t=>{let n=t.currentTarget.files?.[0];n&&(c(void 0),n.text().then(t=>e.importThemes(Et(t))).catch(c),t.currentTarget.value=``)}}),(0,$.jsx)(D,{error:s}),(0,$.jsx)(ln,{"aria-label":d(`settings.appearance.colorTheme`),value:e.color,onValueChange:t=>e.setColor(String(t)),className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-2`,children:f.map(t=>(0,$.jsx)(pn,{theme:t,active:t.id===e.color,activeModes:[`light`,`dark`].filter(n=>(n===`light`?e.lightTheme.id:e.darkTheme.id)===t.id),onPickMode:n=>e.setColorForMode(n,t.id),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{label:d(`settings.appearance.duplicate`,{name:t.name}),className:`size-6`,onClick:()=>u(t),children:(0,$.jsx)(b,{})}),t.id.startsWith(`custom-`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{label:d(`settings.appearance.edit`,{name:t.name}),className:`size-6`,onClick:()=>i(t),children:(0,$.jsx)(ot,{})}),(0,$.jsx)(L,{label:d(`settings.appearance.export`,{name:t.name}),className:`size-6`,onClick:()=>fn(t),children:(0,$.jsx)(it,{})}),(0,$.jsx)(I,{label:d(`settings.appearance.delete`,{name:t.name}),description:d(`settings.appearance.deleteDescription`,{name:t.name}),danger:!0,icon:(0,$.jsx)(at,{}),onConfirm:async()=>e.remove(t.id)})]})]})},t.id))}),f.length===0&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4`,children:d(`settings.appearance.noMatches`)})]}),(0,$.jsx)(U,{title:d(`settings.appearance.customTheme`),open:!!r,onOpenChange:e=>{e||i(null)},children:r&&(0,$.jsx)(gn,{initial:r,onSaved:t=>{e.save(t),o(``),i(null)}})})]})}function gn({initial:e,onSaved:t}){let[n,r]=(0,Q.useState)(e),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(void 0);try{t(_t(n))}catch(e){a(e)}},children:[(0,$.jsx)(z,{label:d(`settings.appearance.name`),value:n.name,required:!0,maxLength:60,onChange:e=>r({...n,name:e.target.value})}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-5`,children:[`light`,`dark`].map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:pt[e]}),(0,$.jsx)(Xt,{theme:n,mode:e}),(0,$.jsx)(`div`,{className:`mt-4 space-y-3`,children:vt.keyof().options.map(t=>(0,$.jsx)(z,{label:d(`settings.appearance.paletteColor`,{mode:pt[e],color:d(`settings.appearance.color.${t}`)}),type:`color`,value:n[e][t],onChange:i=>r({...n,[e]:{...n[e],[t]:i.target.value}})},t))})]},e))}),(0,$.jsx)(D,{error:i}),(0,$.jsx)(W,{type:`submit`,variant:`default`,className:`mt-4`,children:d(`settings.appearance.save`)})]})}function _n({section:e}){let[t,n]=xt(),r=he(),i=F(),a=y({queryKey:[`accounts`],refetchOnMount:`always`,queryFn:async()=>{let e=await A.listAccounts();if(e.error)throw Error(e.error.message);return e.data}}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){e.preventDefault(),n(void 0);let t=new FormData(e.currentTarget);if(t.get(`next`)!==t.get(`confirm`))n(Error(d(`settings.account.passwordMismatch`)));else{l(!0);try{let e=await A.changePassword({currentPassword:ut(t,`current`),newPassword:ut(t,`next`),revokeOtherSessions:!0});if(e.error)throw Error(e.error.message);s(!1),M.success(d(`settings.account.passwordUpdated`))}catch(e){n(e)}finally{l(!1)}}}return(0,$.jsxs)(Dt,{title:d(`settings.account.title`),section:e,children:[(0,$.jsxs)(J,{value:`account`,children:[(0,$.jsx)(Jt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(G,{title:d(`settings.account.security`)}),(0,$.jsx)(Y,{title:d(`settings.account.localPassword`),description:d(`settings.account.localPasswordDescription`),children:(0,$.jsx)(W,{onClick:()=>{n(void 0),s(!0)},children:d(`settings.account.changePassword`)})}),i.data?.providers.map(e=>{let t=a.data?.some(t=>t.providerId===e.id);return(0,$.jsx)(Y,{title:e.name,description:d(t?`settings.account.oidcLinked`:`settings.account.oidcUnlinked`),children:t?(0,$.jsx)(Xe,{variant:`secondary`,children:d(`settings.account.linked`)}):(0,$.jsx)(W,{disabled:c,onClick:()=>{l(!0),n(void 0),A.linkSocial({provider:e.id,callbackURL:`${window.location.origin}/settings?section=account`,errorCallbackURL:`${window.location.origin}/settings?section=account`}).then(e=>{if(e.error)throw Error(e.error.message)}).catch(n).finally(()=>l(!1))},children:d(`settings.account.link`,{name:e.name})})},e.id)}),(0,$.jsx)(rt,{account:r,onDeleted:()=>me(r).catch(async()=>{await r.clearPrivateData(),window.location.assign(`/login`)})}),!o&&(0,$.jsx)(D,{error:t}),(0,$.jsx)(D,{error:a.error??i.error})]}),(0,$.jsx)(U,{title:d(`settings.account.changePassword`),open:o,onOpenChange:s,busy:c,children:(0,$.jsxs)(`form`,{onSubmit:e=>{u(e)},children:[(0,$.jsx)(z,{label:d(`settings.account.currentPassword`),name:`current`,type:`password`,autoComplete:`current-password`,required:!0}),(0,$.jsx)(z,{label:d(`settings.account.newPassword`),name:`next`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(z,{label:d(`settings.account.confirmPassword`),name:`confirm`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(R,{error:t,pending:c,submitLabel:d(`settings.account.changePassword`),onCancel:()=>s(!1)})]})})]}),(0,$.jsx)(J,{value:`appearance`,children:(0,$.jsx)(hn,{})}),(0,$.jsx)(J,{value:`preferences`,children:(0,$.jsx)(vn,{})}),(0,$.jsx)(J,{value:`credentials`,children:(0,$.jsx)(Wt,{})}),(0,$.jsxs)(J,{value:`notifications`,children:[(0,$.jsx)(yn,{pushAvailable:i.data?.push??!1}),(0,$.jsx)(nt,{emailAvailable:i.data?.email??!1})]})]})}function vn(){let e=he(),[t,n]=dt(q.weekStart),[r,i]=dt(q.sidebar),{preference:a}=ft();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(G,{title:d(`settings.preferences.behavior`)}),(0,$.jsx)(Y,{title:d(`common.language.label`),description:d(`settings.preferences.languageDescription`),children:(0,$.jsxs)(K,{label:d(`common.language.label`),labelHidden:!0,className:`mb-0 w-44`,value:a,onValueChange:e=>void gt(te.parse(e)).catch(Se),children:[(0,$.jsx)(j,{value:`system`,children:d(`common.language.system`)}),ee.map(e=>(0,$.jsx)(j,{value:e,lang:e,children:ne[e].name},e))]})}),(0,$.jsx)(Y,{title:d(`settings.preferences.weekStart`),description:d(`settings.preferences.weekStartDescription`),children:(0,$.jsxs)(K,{label:d(`settings.preferences.weekStart`),labelHidden:!0,className:`mb-0 w-44`,value:t,onValueChange:e=>n(q.weekStart.schema.parse(e)),children:[(0,$.jsx)(j,{value:`language`,children:d(`settings.preferences.weekStartLanguage`)}),(0,$.jsx)(j,{value:`sunday`,children:_(new Date(2023,0,1),{weekday:`long`})}),(0,$.jsx)(j,{value:`monday`,children:_(new Date(2023,0,2),{weekday:`long`})}),(0,$.jsx)(j,{value:`saturday`,children:_(new Date(2023,0,7),{weekday:`long`})})]})}),(0,$.jsx)(Y,{title:d(`settings.preferences.sidebar`),description:d(`settings.preferences.sidebarDescription`),children:(0,$.jsxs)(K,{label:d(`settings.preferences.sidebar`),labelHidden:!0,className:`mb-0 w-44`,value:r,onValueChange:e=>i(q.sidebar.schema.parse(e)),children:[(0,$.jsx)(j,{value:`last`,children:d(`settings.preferences.sidebarLast`)}),(0,$.jsx)(j,{value:`expanded`,children:d(`settings.preferences.sidebarExpanded`)}),(0,$.jsx)(j,{value:`collapsed`,children:d(`settings.preferences.sidebarCollapsed`)})]})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(G,{title:d(`settings.preferences.ticketLists`)}),(0,$.jsx)(`div`,{className:`grid max-w-sm gap-3`,children:(0,$.jsx)(ct,{})})]}),(0,$.jsx)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:(0,$.jsx)(Y,{title:d(`settings.preferences.reset`),description:d(`settings.preferences.resetDescription`),children:(0,$.jsx)(W,{variant:`outline`,onClick:()=>{At(e.id,Object.values(q)),M.success(d(`settings.preferences.resetDone`))},children:d(`settings.preferences.reset`)})})})]})}function yn({pushAvailable:e}){let t=De(),n=E.notificationPreferences(),r=y(n),i=P({mutationFn:e=>E.setNotificationPreferences(e),networkMode:`always`,retry:!1,onSuccess:e=>t.setQueryData(n.queryKey,e)}),s=i.isPending?i.variables:r.data,c=e=>{s&&i.mutate({...s,...e})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(G,{title:d(`settings.notifications.title`)}),(0,$.jsx)(D,{error:r.error??i.error}),r.isPending?(0,$.jsx)(N,{}):s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{title:d(`settings.notifications.inbox`),description:d(`settings.notifications.inboxDescription`),children:(0,$.jsx)(Mt,{"aria-label":d(`settings.notifications.inboxSwitch`),checked:s.inApp,disabled:i.isPending,onCheckedChange:e=>c({inApp:e})})}),(0,$.jsx)(Y,{title:d(`settings.notifications.push`),description:d(e?`settings.notifications.pushDescription`:`settings.notifications.pushUnavailable`),children:(0,$.jsx)(Mt,{"aria-label":d(`settings.notifications.pushSwitch`),checked:s.push,disabled:i.isPending||!e,onCheckedChange:e=>c({push:e})})})]})]}),s&&(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(G,{title:d(`settings.notifications.categories`)}),g.map(e=>{let t=Tt[e];return(0,$.jsx)(Y,{compact:!0,title:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(t,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),v[e]]}),children:(0,$.jsx)(Mt,{"aria-label":d(`settings.notifications.categorySwitch`,{label:v[e]}),checked:s.categories[e],disabled:i.isPending,onCheckedChange:t=>c({categories:{...s.categories,[e]:t}})})},e)}),(0,$.jsx)(Y,{title:d(`settings.notifications.reminder`),description:d(`settings.notifications.reminderDescription`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(bn,{value:s.reminderLead.amount,disabled:i.isPending||!s.categories.due_soon,onCommit:e=>c({reminderLead:{...s.reminderLead,amount:e}})},s.reminderLead.amount),(0,$.jsx)(K,{label:d(`settings.notifications.reminderUnit`),labelHidden:!0,className:`mb-0 w-32`,value:s.reminderLead.unit,disabled:i.isPending||!s.categories.due_soon,onValueChange:e=>c({reminderLead:{...s.reminderLead,unit:a.parse(e)}}),children:o.map(e=>(0,$.jsx)(j,{value:e,children:d(`settings.notifications.unit.${e}`)},e))})]})})]})]})}function bn({value:e,disabled:t,onCommit:n}){let[r,i]=(0,Q.useState)(String(e)),a=()=>{let t=Number(r);Number.isInteger(t)&&t>=1&&t<=999?t!==e&&n(t):i(String(e))};return(0,$.jsx)(z,{label:d(`settings.notifications.reminderAmount`),labelHidden:!0,type:`number`,inputMode:`numeric`,min:1,max:999,className:`w-20`,value:r,disabled:t,onChange:e=>i(e.currentTarget.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()}})}export{_n as AccountSettings};
|
package/apps/web/dist/assets/{sliders-horizontal-dmqWngxy.js → sliders-horizontal-DM47MLe7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Za as e}from"./search-
|
|
1
|
+
import{Za as e}from"./search-DfbsqO7M.js";var t={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Wn as t,r as n}from"./default-CCI1vZxa.js";import{Br as ee,Ca as r,Ea as i,Fa as a,Ir as o,Rr as te,_i as ne,ai as s,di as re,ii as c,ir as l,ka as ie,kr as ae,nr as oe,oi as se,pi as u,rr as d,si as ce,ui as f,vi as p,xa as m,ya as h,zr as le}from"./search-DfbsqO7M.js";var g=e(t(),1),_=g.createContext(void 0);function v(){let e=g.useContext(_);if(e===void 0)throw Error(m(63));return e}var y=`data-checked`,b=`data-unchecked`,x={...u,checked(e){return e?{[y]:``}:{[b]:``}}},S=n(),C=g.forwardRef(function(e,t){let{checked:n,className:a,defaultChecked:u,"aria-labelledby":m,form:v,id:y,inputRef:b,name:C,nativeButton:w=!1,onCheckedChange:T,readOnly:E=!1,required:D=!1,disabled:O=!1,render:ue,uncheckedValue:k,value:A,style:de,...j}=e,{clearErrors:M}=f(),{state:N,setTouched:P,setDirty:F,validityData:I,setFilled:L,validationMode:R,disabled:z,name:B,validation:V}=re(),{labelId:H}=se(),U=z||O,W=B??C,G=g.useRef(null),fe=ie(G,b,V.inputRef),K=g.useRef(null),q=ee(U,K),J=ce(),Y=c({id:y}),X=w?void 0:Y,[Z,pe]=l({controlled:n,default:!!u,name:`Switch`,state:`checked`});le(K,J,Z,void 0,!U,C),h(()=>{L(Z)},[Z,L]),te(Z,()=>{M(W),F(Z!==I.initialValue),V.change(Z)});let{getButtonProps:Q,buttonRef:me}=ne({disabled:U,native:w}),he=s(m,H,G,!w,X,j[`aria-label`]),ge={id:w?Y:J,role:`switch`,"aria-checked":Z,"aria-readonly":E||void 0,"aria-required":D||void 0,"aria-labelledby":he,onFocus(){q(!0)},onBlur(){let e=G.current;e&&!U&&(P(!0),q(!1),R===`onBlur`&&V.commit(e.checked))},onClick(e){if(E||U)return;e.preventDefault();let t=G.current;t&&p(t,e)}},_e={...V.getValidationProps(U),checked:Z,disabled:U,form:v,id:X,name:W,required:D,style:W?d:oe,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:fe,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(E){e.preventDefault();return}let t=e.currentTarget.checked,n=o(ae,e.nativeEvent);T?.(t,n),!n.isCanceled&&pe(t)},onClick(e){e.stopPropagation()},onFocus(){K.current?.focus()},...A===void 0?i:{value:A}},$=g.useMemo(()=>({...N,checked:Z,disabled:U,readOnly:E,required:D}),[N,Z,U,E,D]),ve=r(`span`,e,{state:$,ref:[t,K,me],props:[ge,j,Q,e=>V.getValidationProps(U,e)],stateAttributesMapping:x});return(0,S.jsxs)(_.Provider,{value:$,children:[ve,!Z&&W&&k!==void 0&&(0,S.jsx)(`input`,{type:`hidden`,form:v,name:W,value:k,disabled:U}),(0,S.jsx)(`input`,{..._e,suppressHydrationWarning:!0})]})}),w=g.forwardRef(function(e,t){let{render:n,className:ee,style:i,...a}=e,o=v();return r(`span`,e,{state:o,ref:t,stateAttributesMapping:x,props:a})});function T({className:e,size:t=`default`,...n}){return(0,S.jsx)(C,{"data-slot":`switch`,"data-size":t,className:a(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,S.jsx)(w,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}export{T as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-COiEfhsA.js";import{
|
|
1
|
+
import"./rolldown-runtime-COiEfhsA.js";import{Wn as e,r as t}from"./default-CCI1vZxa.js";import{Fa as n}from"./search-DfbsqO7M.js";e();var r=t();function i({className:e,mobileLayout:t=`scroll`,...i}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,role:`table`,"data-mobile-layout":t,className:n(`w-full caption-bottom text-sm`,e),...i})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{role:`rowgroup`,"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{role:`rowgroup`,"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{role:`row`,"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{role:`columnheader`,"data-slot":`table-head`,className:n(`h-8 px-3 text-left align-middle text-xs font-normal whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0 text-[10.5px] font-medium tracking-[0.08em] uppercase`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{role:`cell`,"data-slot":`table-cell`,className:n(`px-3 py-2 align-middle text-[13px] whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ticket-editor-
|
|
2
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Dt as t,Ot as n,Vn as r,W as i,i as a,kt as o,mn as s,r as c,vt as l}from"./default-DqsN66dq.js";import{$ as u,$a as d,$n as f,Gi as p,H as m,Hi as h,J as g,Ja as _,Ka as v,Li as y,Lt as ee,Pa as b,Q as te,U as x,X as S,Y as C,Za as w,Zi as T,bt as E,ct as D,ea as O,et as k,ft as ne,ht as re,it as A,mi as j,nt as ie,ot as M,q as ae,qa as oe,ra as N,st as P,zi as se}from"./search-Cvetr1OK.js";import{t as F}from"./preload-helper-BLdHbfdN.js";import{t as I}from"./useQueries-BnlNCoy4.js";import{a as L,g as R,n as z,r as B,t as V}from"./item-HmFuRZet.js";import{t as ce}from"./archive-restore-BMtgjFUu.js";import{n as le,r as ue,t as de}from"./Trans-CE4EAAY1.js";import{n as H,r as fe}from"./CompositeItem-Dotj8JZL.js";import{t as pe}from"./corner-left-up-O4OsTW-L.js";import{t as me}from"./ellipsis-CvEPDi9V.js";import{t as U}from"./send-CJDct4Oj.js";import{r as W}from"./forms-DbfnnPg_.js";import{$ as G,A as he,B as ge,Bt as _e,I as ve,J as ye,N as be,R as K,Rt as xe,U as Se,V as Ce,Vt as we,_ as q,_n as Te,an as Ee,b as J,dt as Y,et as De,g as Oe,gn as ke,gt as Ae,h as X,j as je,m as Me,pt as Ne,q as Pe,tt as Z,x as Fe,zt as Ie}from"./index-nltuyQtq.js";import{TicketEditor as Le,a as Re,i as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./ticket-editor-CZnZQMG1.js";var Ke={name:`git-branch-plus`,size:24,node:[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]};Ke.node;var qe=w(Ke),Je={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Je.node;var Ye=w(Je),Q=e(r(),1),$=c(),Xe=(0,Q.lazy)(()=>F(()=>import(`./ticket-editor-CZnZQMG1.js`).then(e=>({default:e.TicketEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ze({ticket:e}){let t=N(e.projectId),r=d(p.query(`list_relations`,{projectId:e.projectId,ticketId:e.id})),[i,a]=(0,Q.useState)(!1),[c,u]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(),b=d({...p.query(`get_ticket`,{projectId:e.projectId,ticketId:e.parentId??e.id}),enabled:!!e.parentId}),x=d(p.query(`list_tickets`,{projectId:e.projectId,parentId:e.id,archived:`include`,limit:20,offset:h})),w=I({queries:Array.from({length:Math.ceil((r.data?.length??0)/100)},(t,n)=>p.query(`list_tickets`,{projectId:e.projectId,relatedTo:e.id,archived:`include`,sort:`number`,limit:100,offset:n*100}))}),T=new Map(w.flatMap(e=>e.data?.items??[]).map(e=>[e.id,e])),E=O(`add_relation`),D=O(`remove_relation`);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(M,{compact:!0,title:s(`detail.relations.heading`),action:t.canWrite&&(0,$.jsxs)(ge,{children:[(0,$.jsx)(Pe,{render:(0,$.jsx)(S,{label:s(`detail.relations.add`)}),children:(0,$.jsx)(R,{})}),(0,$.jsxs)(Ce,{align:`end`,className:`w-48`,children:[(0,$.jsxs)(Se,{onClick:()=>{E.reset(),y(void 0),m(null),a(!0)},children:[(0,$.jsx)(Ye,{}),s(`detail.relations.linkExisting`)]}),(0,$.jsxs)(Se,{onClick:()=>u(!0),children:[(0,$.jsx)(qe,{}),s(`detail.relations.newChild`)]})]})]})}),e.parentId&&(0,$.jsxs)(V,{size:`xs`,className:`px-0`,children:[(0,$.jsx)(pe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsxs)(B,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`detail.field.parent`)}),(0,$.jsx)(J,{projectId:e.projectId,ticketId:e.parentId,ticket:b.data?.ticket})]})]}),x.data&&(x.data.total>0||h>0)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`mt-3 mb-1 text-xs text-muted-foreground`,children:(0,$.jsx)(de,{i18nKey:`detail.relations.children`,values:{done:x.data.items.filter(e=>e.status===`done`).length,total:x.data.total},components:{count:(0,$.jsx)(`span`,{className:`tabular-nums`})}})}),(0,$.jsx)(L,{className:`gap-0`,children:x.data.items.map(n=>(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:n.id,ticket:n,canWrite:t.canWrite,children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:n.id,ticket:n})},n.id))}),(x.data.total>20||h>0)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(j,{size:`sm`,disabled:!h,onClick:()=>_(Math.max(0,h-20)),children:s(`detail.relations.previousChildren`)}),(0,$.jsx)(j,{size:`sm`,disabled:h+20>=x.data.total,onClick:()=>_(h+20),children:s(`detail.relations.nextChildren`)})]})]}),(0,$.jsx)(L,{className:`gap-0`,children:r.data?.map(n=>{let r=o(n,e.id),i=r.projectId??e.projectId;return(0,$.jsx)(Qe,{projectId:i,ticketId:r.id,ticket:T.get(r.id),canWrite:t.canWrite,label:r.label,action:(0,$.jsx)(S,{size:`icon-sm`,label:s(`detail.relations.remove.${n.type}`),onClick:()=>D.mutate({projectId:e.projectId,relationId:n.id}),children:(0,$.jsx)(Ye,{})}),children:r.restricted?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r.title}):(0,$.jsx)(J,{projectId:i,ticketId:r.id,children:r.title})},n.id)})}),!e.parentId&&!x.data?.total&&r.data?.length===0&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:s(`detail.relations.empty`)}),(0,$.jsx)(k,{title:s(`detail.relations.add`),open:i,onOpenChange:a,busy:E.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);f&&(y(void 0),E.mutateAsync({projectId:e.projectId,ticketId:e.id,targetId:f,...l(n.get(`type`))}).then(()=>a(!1)).catch(y))},children:[(0,$.jsx)(P,{label:s(`detail.relations.type`),name:`type`,children:n.map(e=>(0,$.jsx)(ee,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(We,{projectId:e.projectId,label:s(`detail.relations.ticket`),value:f,onChange:m,exclude:[e.id],allowClear:!1}),(0,$.jsx)(C,{error:v??E.error,pending:E.isPending,submitLabel:s(`detail.relations.add`),submitDisabled:!f,onCancel:()=>a(!1)})]})}),(0,$.jsx)(k,{size:`composer`,title:s(`detail.relations.newChildTitle`,{key:e.key}),open:c,onOpenChange:u,children:c&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(te,{}),children:(0,$.jsx)(Xe,{projectId:e.projectId,initial:{parentId:e.id,labels:e.labels,scopes:e.scopes},onSaved:()=>u(!1)})})}),(0,$.jsx)(g,{error:r.error??D.error??b.error??x.error??w.find(e=>e.error)?.error})]})}function Qe({projectId:e,ticketId:t,ticket:n,canWrite:r,label:i,action:a,children:o}){let{change:c,pending:l}=Ne({id:t,projectId:e,version:n?.version??0}),u=r&&n;return(0,$.jsxs)(V,{size:`xs`,className:`px-0`,children:[u?(0,$.jsx)(Z,{property:`status`,value:Y(n),onChange:e=>void c({status:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,ariaLabel:s(`detail.relations.statusOf`,{key:n.key}),className:`mx-0`}):n&&(0,$.jsx)(G,{property:`status`,value:Y(n),projectId:e,iconOnly:!0}),(0,$.jsxs)(B,{className:`min-w-0 gap-0`,children:[i&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),o]}),(u||n?.assigneeId||r&&a)&&(0,$.jsxs)(z,{className:`gap-0`,children:[u?(0,$.jsx)(Z,{property:`assignee`,value:n.assigneeId,onChange:e=>void c({assignee:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,align:`end`,ariaLabel:s(`detail.relations.assigneeOf`,{key:n.key}),className:`mx-0`}):n?.assigneeId&&(0,$.jsx)(G,{property:`assignee`,value:n.assigneeId,projectId:e,iconOnly:!0}),r&&a]})]})}function $e({ticket:e,anchor:t}){let[n,r]=(0,Q.useState)(0),[i,a]=(0,Q.useState)(``),o=d(p.query(`list_comments`,{projectId:e.projectId,ticketId:e.id,offset:n})),c=t.startsWith(`comment-`)?t.slice(8):null,[l,u]=(0,Q.useState)(c),[m,h]=(0,Q.useState)(c!==null);c!==l&&(u(c),h(c!==null)),m&&o.data&&(o.data.items.some(e=>e.id===c)?h(!1):n+50<o.data.total?r(n+50):h(!1));let _=Re(e.projectId,{ticketId:e.id}),v=O(`add_comment`),y=N(e.projectId);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(g,{error:o.error??v.error}),o.data?.total===0&&(0,$.jsx)(ae,{title:s(`detail.discussion.empty`),icon:Ee,className:`py-8`}),(0,$.jsx)(`div`,{className:`divide-y`,children:o.data?.items.map(e=>(0,$.jsx)(et,{comment:e,linked:e.id===c},e.id))}),((o.data?.total??0)>50||n>0)&&(0,$.jsxs)(He,{className:`mt-5 justify-end`,children:[(0,$.jsx)(j,{size:`sm`,disabled:!n,onClick:()=>r(Math.max(0,n-50)),children:s(`detail.discussion.previous`)}),(0,$.jsx)(j,{size:`sm`,disabled:n+50>=(o.data?.total??0),onClick:()=>r(n+50),children:s(`detail.discussion.next`)})]}),y.canWrite&&(0,$.jsx)(`form`,{onKeyDown:W,className:`mt-6`,onSubmit:t=>{t.preventDefault(),v.mutateAsync({projectId:e.projectId,ticketId:e.id,body:i}).then(()=>a(e=>e===i?``:e)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.comment`),value:i,onChange:a,rows:3,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:_,placeholder:s(`detail.discussion.placeholder`),footer:(0,$.jsxs)(j,{type:`submit`,variant:`default`,disabled:v.isPending||!i.trim(),children:[v.isPending?(0,$.jsx)(E,{}):(0,$.jsx)(U,{}),v.isPending?s(`detail.discussion.posting`):s(`detail.discussion.comment`),(0,$.jsx)(f,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})})})]})}function et({comment:e,linked:t}){let n=T(),r=N(e.projectId),i=O(`update_comment`),a=Re(e.projectId,{ticketId:e.ticketId}),o=O(`delete_comment`),[c,l]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(e.body),[p,m]=(0,Q.useState)(e.version),_=e.actorId===n.id,v=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{t&&v.current?.scrollIntoView({block:`center`})},[t]),(0,$.jsxs)(`article`,{ref:v,id:`comment-${e.id}`,"data-linked":t,className:`group/comment relative scroll-mt-16 py-4 animate-in fade-in-0 duration-200 data-[linked=true]:animate-row-in data-[linked=true]:shadow-[inset_2px_0_0_var(--primary)] data-[linked=true]:pl-3`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1 pr-20 text-xs text-muted-foreground`,children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:(0,$.jsx)(h,{projectId:e.projectId,actorId:e.actorId,avatar:!0})}),(0,$.jsx)(A,{value:e.createdAt}),e.updatedAt!==e.createdAt&&(0,$.jsx)(`span`,{children:s(`detail.discussion.edited`)})]}),c?(0,$.jsx)(`form`,{onKeyDown:W,onSubmit:t=>{t.preventDefault(),i.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:p,body:d}).then(()=>l(!1)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.edit`),value:d,onChange:f,rows:4,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:a,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{size:`sm`,disabled:i.isPending,onClick:()=>l(!1),children:s(`common.action.cancel`)}),(0,$.jsxs)(j,{type:`submit`,size:`sm`,variant:`default`,disabled:i.isPending||!d.trim(),children:[i.isPending?(0,$.jsx)(E,{}):null,s(`common.action.save`)]})]})})}):(0,$.jsx)(u,{children:e.body}),!c&&r.canWrite&&(_||n.admin)&&(0,$.jsxs)(`div`,{className:`absolute top-3 right-0 flex items-center gap-1 opacity-0 transition-opacity group-hover/comment:opacity-100 focus-within:opacity-100 max-md:opacity-100`,children:[(0,$.jsx)(S,{label:s(`detail.discussion.edit`),size:`icon-sm`,onClick:()=>{f(e.body),m(e.version),l(!0)},children:(0,$.jsx)(fe,{})}),(0,$.jsx)(x,{label:s(`detail.discussion.delete`),icon:(0,$.jsx)(H,{}),danger:!0,description:s(`detail.discussion.deleteConfirm`),onConfirm:()=>o.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:e.version})})]}),(0,$.jsx)(g,{error:i.error})]})}function tt({projectId:e,ticketId:n,preview:r}){let o=N(e),c=d(p.query(`get_ticket`,{projectId:e,ticketId:n})),l=O(`set_subscription`),[f,m]=(0,Q.useState)(!1),[ee,x]=(0,Q.useState)(!1),C=we(),[w]=(0,Q.useState)(()=>r?[]:ve(e)),T=r?.order??w,D=T.indexOf(n),M=t=>{let n=D<0?void 0:T[D+t];n&&(r?r.open(n):C({to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:e,ticketId:n}}))},P=r?`[data-slot="sheet-content"]`:void 0;y(`j`,()=>M(1),{enabled:!f,scope:P}),y(`k`,()=>M(-1),{enabled:!f,scope:P});let F=c.data?.ticket,{change:I,pending:L}=Ne(F??{id:n,projectId:e,version:1});y(`e`,()=>{o.canWrite&&m(!0)},{enabled:!!F&&!f,scope:P});let R=c.error instanceof a&&c.error.status===404,z=d({...p.query(`resolve_ticket`,{ticketId:n}),enabled:R,retry:!1}),B=xe({select:e=>r||!e.location.search.peek?e.location.hash:``});if(c.isPending||R&&z.isFetching)return(0,$.jsx)(te,{});if(R&&z.data&&z.data.project.id!==e)return r?(0,$.jsx)(nt,{preview:r,target:{projectId:z.data.project.id,ticketId:z.data.ticket.id}}):(0,$.jsx)(_e,{to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:z.data.project.id,ticketId:z.data.ticket.id},replace:!0});if(!c.data||!F||R)return R?(0,$.jsxs)(ae,{title:s(`detail.page.unavailable`),children:[(0,$.jsx)(`p`,{children:s(`detail.page.gone`)}),r?(0,$.jsx)(j,{onClick:r.close,children:s(`detail.page.closePreview`)}):(0,$.jsx)(j,{render:(0,$.jsx)(Ie,{to:`/projects/$projectId`,params:{projectId:e}}),children:s(`detail.page.backToTickets`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{error:c.error}),(0,$.jsx)(j,{onClick:()=>{c.refetch()},children:s(`common.action.retry`)})]});let{readiness:V,claim:H,canReleaseClaim:pe,subscribed:U}=c.data,W=o.canWrite&&!L;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`article`,{className:`ticket-detail grid w-full grid-cols-[minmax(0,1fr)_280px] gap-x-10 animate-in fade-in-0 duration-200 @max-[850px]:flex @max-[850px]:flex-col [&_section]:border-t [&_section]:py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ie,{title:!r&&(0,$.jsxs)(j,{variant:`ghost`,size:`sm`,className:`-ml-2 text-muted-foreground`,render:(0,$.jsx)(Ie,{to:`/projects/$projectId`,params:{projectId:e}}),children:[(0,$.jsx)(Te,{}),s(`detail.page.tickets`)]}),children:(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[D>=0&&(0,$.jsxs)(`div`,{className:`mr-1 flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,$.jsx)(S,{label:s(`detail.page.previousTicket`),title:s(`detail.page.previousTicketShortcut`),disabled:D===0,onClick:()=>M(-1),children:(0,$.jsx)(v,{})}),(0,$.jsx)(`span`,{children:s(`detail.page.position`,{position:D+1,total:T.length})}),(0,$.jsx)(S,{label:s(`detail.page.nextTicket`),title:s(`detail.page.nextTicketShortcut`),disabled:D===T.length-1,onClick:()=>M(1),children:(0,$.jsx)(oe,{})})]}),(0,$.jsx)(S,{label:s(U?`detail.page.unsubscribe`:`detail.page.subscribe`),disabled:l.isPending,onClick:()=>{l.mutateAsync({projectId:e,ticketId:F.id,enabled:!U}).then(()=>b.success(s(U?`detail.page.unsubscribed`:`detail.page.subscribed`))).catch(ne)},children:U?(0,$.jsx)(ke,{}):(0,$.jsx)(le,{})}),(0,$.jsx)(S,{label:K.label,onClick:()=>{be(K,F)},children:(0,$.jsx)(K.icon,{})}),(0,$.jsx)(S,{label:F.archived?s(`detail.page.unarchive`):s(`detail.page.archive`),disabled:!W,onClick:()=>{I({archived:!F.archived}).then(e=>{e&&b.success(F.archived?s(`detail.page.unarchivedToast`):s(`detail.page.archivedToast`))})},children:F.archived?(0,$.jsx)(ce,{}):(0,$.jsx)(ue,{})}),(0,$.jsx)(S,{label:s(`detail.page.edit`),title:s(`detail.page.editShortcut`),disabled:!o.canWrite,onClick:()=>m(!0),children:(0,$.jsx)(fe,{})}),(0,$.jsx)(je,{ticket:F,variant:`dropdown`,onEdit:()=>m(!0),children:(0,$.jsx)(j,{variant:`ghost`,size:`icon`,"aria-label":s(`detail.page.actions`),children:(0,$.jsx)(me,{})})}),r&&(0,$.jsx)(Fe,{projectId:e,ticketId:F.id,preview:r})]})}),(0,$.jsx)(je,{ticket:F,onEdit:()=>m(!0),children:(0,$.jsxs)(`header`,{className:`ticket-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(j,{variant:`ghost`,size:`xs`,className:`-ml-2 gap-1.5 font-mono text-xs text-muted-foreground`,title:s(`detail.page.copyKey`),onClick:()=>{se(F.key).then(()=>{x(!0),setTimeout(()=>x(!1),1500),b.success(s(`detail.page.keyCopied`,{key:F.key}))}).catch(ne)},children:[F.key,ee&&(0,$.jsx)(_,{className:`size-3 text-[var(--success)]`})]}),(0,$.jsx)(G,{property:`status`,value:Y(F),projectId:e}),F.archived&&(0,$.jsx)(`strong`,{children:s(`detail.page.archived`)}),L&&(0,$.jsx)(E,{className:`size-3.5 text-muted-foreground`})]}),r?(0,$.jsx)(he,{render:(0,$.jsx)(`h1`,{}),className:re,children:F.title}):(0,$.jsx)(`h1`,{className:re,children:F.title})]})}),(0,$.jsxs)(`div`,{className:`min-w-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.description`)}),(0,$.jsx)(u,{...W?{onChange:e=>I({description:e})}:{},children:F.description||s(`detail.page.noDescription`)})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.acceptanceCriteria`)}),(0,$.jsx)(u,{...W?{onChange:e=>I({acceptanceCriteria:e})}:{},children:F.acceptanceCriteria||s(`detail.page.noAcceptanceCriteria`)})]})]}),(0,$.jsxs)(Me,{defaultValue:`discussion`,className:`mt-8 min-w-0 [&_[data-slot=tabs-content]>section]:border-0 [&_[data-slot=tabs-content]>section]:pt-0`,children:[(0,$.jsxs)(Oe,{variant:`line`,className:`mb-5`,children:[(0,$.jsx)(q,{value:`discussion`,children:s(`detail.section.discussion`)}),(0,$.jsx)(q,{value:`evidence`,children:s(`detail.section.evidence`)}),(0,$.jsx)(q,{value:`activity`,children:s(`detail.section.activity`)})]}),(0,$.jsx)(X,{value:`discussion`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)($e,{ticket:F,anchor:B})}),(0,$.jsx)(X,{value:`evidence`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ue,{ticket:F})}),(0,$.jsx)(X,{value:`activity`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ge,{ticket:F})})]}),(0,$.jsx)(g,{error:c.error})]}),(0,$.jsxs)(`aside`,{className:`min-w-0 border-l pl-5 @max-[850px]:border-l-0 @max-[850px]:pl-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0 @max-[850px]:[&>section:first-child]:border-t @max-[850px]:[&>section:first-child]:pt-6 [&_h2]:text-xs [&_h2]:font-medium [&_h2]:text-muted-foreground [&_p]:text-xs [&_ul]:mb-4 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:text-xs [&_ul]:leading-relaxed [&_ul]:text-muted-foreground`,"aria-label":s(`detail.page.coordination`),children:[(0,$.jsxs)(`section`,{"aria-label":s(`detail.page.properties`),className:`ticket-properties`,children:[(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:e,value:Y(F),disabled:!W,onChange:e=>void I({status:e})}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:e,value:F.priority,disabled:!W,onChange:e=>void I({priority:e})}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:e,value:F.assigneeId,disabled:!W,onChange:e=>void I({assignee:e})}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:e,value:F.kind,disabled:!W,onChange:e=>void I({kind:e})}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:e,value:F.difficulty,disabled:!W,onChange:e=>void I({difficulty:e})}),(0,$.jsx)(Ae,{variant:`row`,value:F,disabled:!W,onChange:e=>void I(e)}),(0,$.jsx)(De,{variant:`row`,value:F.labels,disabled:!W,onChange:e=>void I({labels:e})}),(F.scopes.length>0||o.canWrite)&&(0,$.jsx)(De,{variant:`row`,kind:`scope`,value:F.scopes,disabled:!W,onChange:e=>void I({scopes:e})}),(0,$.jsx)(ye,{variant:`row`,projectId:e,values:F.customFields,disabled:!W,onChange:(e,t)=>void I({customFields:{[e]:t}})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[80px_minmax(0,1fr)] gap-x-2 gap-y-1.5 border-t pt-4 text-xs [&_dd]:m-0 [&_dd]:min-w-0 [&_dd]:wrap-anywhere [&_dt]:text-muted-foreground`,children:[(0,$.jsx)(`dt`,{children:s(`detail.page.created`)}),(0,$.jsxs)(`dd`,{children:[(0,$.jsx)(h,{projectId:e,actorId:F.createdBy}),` · `,(0,$.jsx)(A,{value:F.createdAt})]}),(0,$.jsx)(`dt`,{children:s(`detail.page.updated`)}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(A,{value:F.updatedAt})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.readiness.heading`)}),(0,$.jsx)(`p`,{className:V.ready?`text-[var(--success)]`:`text-muted-foreground`,children:V.ready?s(`detail.readiness.ready`):s(`detail.readiness.notReady`)}),(0,$.jsx)(`ul`,{children:V.reasons.map((e,n)=>(0,$.jsx)(`li`,{children:t(e,H?.workerId)},`${e.code}:${n}`))}),F.holdReason&&(0,$.jsx)(`p`,{children:s(`detail.readiness.hold`,{reason:F.holdReason})}),H&&(0,$.jsx)(`p`,{children:(0,$.jsx)(de,{i18nKey:`detail.readiness.claimedUntil`,values:{worker:H.workerId,date:i(H.expiresAt)},components:{strong:(0,$.jsx)(`strong`,{})}})}),H&&(0,$.jsx)(rt,{ticket:F,claim:H,canRelease:pe,canRecover:o.canWrite&&V.reasons.some(e=>e.code===`claim_recovery_required`)})]}),(0,$.jsx)(Ze,{ticket:F},F.id),(0,$.jsx)(ze,{ticket:F}),(0,$.jsx)(Ve,{ticket:F})]})]}),(0,$.jsx)(k,{size:`composer`,title:s(`detail.page.editTitle`,{key:F.key}),open:f,onOpenChange:m,children:f&&(0,$.jsx)(Le,{projectId:e,ticket:F,onSaved:()=>m(!1)})})]})}function nt({preview:e,target:t}){return(0,Q.useEffect)(()=>e.follow(t),[e,t]),(0,$.jsx)(te,{})}function rt({ticket:e,claim:t,canRelease:n,canRecover:r}){let i=O(`release_claim`),a=O(`recover_claim`),[o,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,$.jsx)(x,{label:s(`detail.claim.release`),description:s(`detail.claim.releaseDescription`),onConfirm:()=>i.mutateAsync({projectId:e.projectId,ticketId:e.id,claimId:t.id})}),r&&(0,$.jsx)(k,{title:s(`detail.claim.recover`),trigger:s(`detail.claim.recover`),children:(0,$.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),l&&a.mutate({projectId:e.projectId,ticketId:e.id,claimId:t.id,reason:o,confirmedStopped:!0})},children:[(0,$.jsx)(`p`,{children:s(`detail.claim.recoverHelp`)}),(0,$.jsx)(D,{label:s(`detail.claim.reason`),required:!0,minLength:10,maxLength:2e3,value:o,onChange:e=>c(e.target.value)}),(0,$.jsx)(m,{label:s(`detail.claim.confirmed`),checked:l,onCheckedChange:e=>u(e)}),(0,$.jsx)(C,{error:a.error,pending:!l,submitLabel:s(`detail.claim.submit`),submitDisabled:a.isPending})]})})]})}export{tt as TicketDetail};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ticket-editor-Bb_lyxnJ.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-CCI1vZxa.js","assets/preload-helper-BLdHbfdN.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/search-DfbsqO7M.js","assets/toDate-B3HYxwtT.js","assets/item-DQR89bKm.js","assets/CompositeItem-DLTRsada.js","assets/forms-CkVpTx29.js","assets/corner-left-up-Be7Z9Uhf.js","assets/rotate-ccw-Cxh9ec2s.js","assets/sliders-horizontal-DM47MLe7.js","assets/upload-HARy4VC_.js","assets/index-CZuFd4LM.js","assets/Trans-DqX-qhvQ.js","assets/en-US-DKYSujv3.js","assets/index-DPT5LAs1.css","assets/switch-CJTVGtE9.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{At as t,K as n,Mt as r,Wn as i,_n as a,bt as o,i as s,jt as c,r as l}from"./default-CCI1vZxa.js";import{$ as u,$a as d,$n as f,Gi as p,H as m,Hi as h,J as g,Ja as _,Ka as v,Li as y,Lt as ee,Pa as b,Q as te,U as x,X as S,Y as C,Za as w,Zi as T,bt as E,ct as D,ea as O,et as k,ft as ne,ht as re,it as A,mi as j,nt as ie,ot as M,q as ae,qa as oe,ra as N,st as P,zi as se}from"./search-DfbsqO7M.js";import{t as F}from"./preload-helper-BLdHbfdN.js";import{t as I}from"./useQueries-CTeEF--U.js";import{a as L,g as R,n as z,r as B,t as V}from"./item-DQR89bKm.js";import{t as ce}from"./archive-restore-BO1qng5Y.js";import{n as le,r as ue,t as de}from"./Trans-DqX-qhvQ.js";import{n as H,r as fe}from"./CompositeItem-DLTRsada.js";import{t as pe}from"./corner-left-up-Be7Z9Uhf.js";import{t as me}from"./ellipsis-B0AE8ax3.js";import{t as U}from"./send-DrJl0BKm.js";import{r as W}from"./forms-CkVpTx29.js";import{$ as G,A as he,B as ge,Bt as _e,I as ve,J as ye,N as be,R as K,Rt as xe,U as Se,V as Ce,Vt as we,_ as q,_n as Te,an as Ee,b as J,dt as Y,et as De,g as Oe,gn as ke,gt as Ae,h as X,j as je,m as Me,pt as Ne,q as Pe,tt as Z,x as Fe,zt as Ie}from"./index-CZuFd4LM.js";import{TicketEditor as Le,a as Re,i as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./ticket-editor-Bb_lyxnJ.js";var Ke={name:`git-branch-plus`,size:24,node:[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]};Ke.node;var qe=w(Ke),Je={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Je.node;var Ye=w(Je),Q=e(i(),1),$=l(),Xe=(0,Q.lazy)(()=>F(()=>import(`./ticket-editor-Bb_lyxnJ.js`).then(e=>({default:e.TicketEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ze({ticket:e}){let t=N(e.projectId),n=d(p.query(`list_relations`,{projectId:e.projectId,ticketId:e.id})),[i,s]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(),b=d({...p.query(`get_ticket`,{projectId:e.projectId,ticketId:e.parentId??e.id}),enabled:!!e.parentId}),x=d(p.query(`list_tickets`,{projectId:e.projectId,parentId:e.id,archived:`include`,limit:20,offset:h})),w=I({queries:Array.from({length:Math.ceil((n.data?.length??0)/100)},(t,n)=>p.query(`list_tickets`,{projectId:e.projectId,relatedTo:e.id,archived:`include`,sort:`number`,limit:100,offset:n*100}))}),T=new Map(w.flatMap(e=>e.data?.items??[]).map(e=>[e.id,e])),E=O(`add_relation`),D=O(`remove_relation`);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(M,{compact:!0,title:a(`detail.relations.heading`),action:t.canWrite&&(0,$.jsxs)(ge,{children:[(0,$.jsx)(Pe,{render:(0,$.jsx)(S,{label:a(`detail.relations.add`)}),children:(0,$.jsx)(R,{})}),(0,$.jsxs)(Ce,{align:`end`,className:`w-48`,children:[(0,$.jsxs)(Se,{onClick:()=>{E.reset(),y(void 0),m(null),s(!0)},children:[(0,$.jsx)(Ye,{}),a(`detail.relations.linkExisting`)]}),(0,$.jsxs)(Se,{onClick:()=>u(!0),children:[(0,$.jsx)(qe,{}),a(`detail.relations.newChild`)]})]})]})}),e.parentId&&(0,$.jsxs)(V,{size:`xs`,className:`px-0`,children:[(0,$.jsx)(pe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsxs)(B,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`detail.field.parent`)}),(0,$.jsx)(J,{projectId:e.projectId,ticketId:e.parentId,ticket:b.data?.ticket})]})]}),x.data&&(x.data.total>0||h>0)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`mt-3 mb-1 text-xs text-muted-foreground`,children:(0,$.jsx)(de,{i18nKey:`detail.relations.children`,values:{done:x.data.items.filter(e=>e.status===`done`).length,total:x.data.total},components:{count:(0,$.jsx)(`span`,{className:`tabular-nums`})}})}),(0,$.jsx)(L,{className:`gap-0`,children:x.data.items.map(n=>(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:n.id,ticket:n,canWrite:t.canWrite,children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:n.id,ticket:n})},n.id))}),(x.data.total>20||h>0)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(j,{size:`sm`,disabled:!h,onClick:()=>_(Math.max(0,h-20)),children:a(`detail.relations.previousChildren`)}),(0,$.jsx)(j,{size:`sm`,disabled:h+20>=x.data.total,onClick:()=>_(h+20),children:a(`detail.relations.nextChildren`)})]})]}),(0,$.jsx)(L,{className:`gap-0`,children:n.data?.map(n=>{let i=r(n,e.id),o=i.projectId??e.projectId;return(0,$.jsx)(Qe,{projectId:o,ticketId:i.id,ticket:T.get(i.id),canWrite:t.canWrite,label:i.label,action:(0,$.jsx)(S,{size:`icon-sm`,label:a(`detail.relations.remove.${n.type}`),onClick:()=>D.mutate({projectId:e.projectId,relationId:n.id}),children:(0,$.jsx)(Ye,{})}),children:i.restricted?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.title}):(0,$.jsx)(J,{projectId:o,ticketId:i.id,children:i.title})},n.id)})}),!e.parentId&&!x.data?.total&&n.data?.length===0&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:a(`detail.relations.empty`)}),(0,$.jsx)(k,{title:a(`detail.relations.add`),open:i,onOpenChange:s,busy:E.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);f&&(y(void 0),E.mutateAsync({projectId:e.projectId,ticketId:e.id,targetId:f,...o(n.get(`type`))}).then(()=>s(!1)).catch(y))},children:[(0,$.jsx)(P,{label:a(`detail.relations.type`),name:`type`,children:c.map(e=>(0,$.jsx)(ee,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(We,{projectId:e.projectId,label:a(`detail.relations.ticket`),value:f,onChange:m,exclude:[e.id],allowClear:!1}),(0,$.jsx)(C,{error:v??E.error,pending:E.isPending,submitLabel:a(`detail.relations.add`),submitDisabled:!f,onCancel:()=>s(!1)})]})}),(0,$.jsx)(k,{size:`composer`,title:a(`detail.relations.newChildTitle`,{key:e.key}),open:l,onOpenChange:u,children:l&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(te,{}),children:(0,$.jsx)(Xe,{projectId:e.projectId,initial:{parentId:e.id,labels:e.labels,scopes:e.scopes},onSaved:()=>u(!1)})})}),(0,$.jsx)(g,{error:n.error??D.error??b.error??x.error??w.find(e=>e.error)?.error})]})}function Qe({projectId:e,ticketId:t,ticket:n,canWrite:r,label:i,action:o,children:s}){let{change:c,pending:l}=Ne({id:t,projectId:e,version:n?.version??0}),u=r&&n;return(0,$.jsxs)(V,{size:`xs`,className:`px-0`,children:[u?(0,$.jsx)(Z,{property:`status`,value:Y(n),onChange:e=>void c({status:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,ariaLabel:a(`detail.relations.statusOf`,{key:n.key}),className:`mx-0`}):n&&(0,$.jsx)(G,{property:`status`,value:Y(n),projectId:e,iconOnly:!0}),(0,$.jsxs)(B,{className:`min-w-0 gap-0`,children:[i&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),s]}),(u||n?.assigneeId||r&&o)&&(0,$.jsxs)(z,{className:`gap-0`,children:[u?(0,$.jsx)(Z,{property:`assignee`,value:n.assigneeId,onChange:e=>void c({assignee:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,align:`end`,ariaLabel:a(`detail.relations.assigneeOf`,{key:n.key}),className:`mx-0`}):n?.assigneeId&&(0,$.jsx)(G,{property:`assignee`,value:n.assigneeId,projectId:e,iconOnly:!0}),r&&o]})]})}function $e({ticket:e,anchor:t}){let[n,r]=(0,Q.useState)(0),[i,o]=(0,Q.useState)(``),s=d(p.query(`list_comments`,{projectId:e.projectId,ticketId:e.id,offset:n})),c=t.startsWith(`comment-`)?t.slice(8):null,[l,u]=(0,Q.useState)(c),[m,h]=(0,Q.useState)(c!==null);c!==l&&(u(c),h(c!==null)),m&&s.data&&(s.data.items.some(e=>e.id===c)?h(!1):n+50<s.data.total?r(n+50):h(!1));let _=Re(e.projectId,{ticketId:e.id}),v=O(`add_comment`),y=N(e.projectId);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(g,{error:s.error??v.error}),s.data?.total===0&&(0,$.jsx)(ae,{title:a(`detail.discussion.empty`),icon:Ee,className:`py-8`}),(0,$.jsx)(`div`,{className:`divide-y`,children:s.data?.items.map(e=>(0,$.jsx)(et,{comment:e,linked:e.id===c},e.id))}),((s.data?.total??0)>50||n>0)&&(0,$.jsxs)(He,{className:`mt-5 justify-end`,children:[(0,$.jsx)(j,{size:`sm`,disabled:!n,onClick:()=>r(Math.max(0,n-50)),children:a(`detail.discussion.previous`)}),(0,$.jsx)(j,{size:`sm`,disabled:n+50>=(s.data?.total??0),onClick:()=>r(n+50),children:a(`detail.discussion.next`)})]}),y.canWrite&&(0,$.jsx)(`form`,{onKeyDown:W,className:`mt-6`,onSubmit:t=>{t.preventDefault(),v.mutateAsync({projectId:e.projectId,ticketId:e.id,body:i}).then(()=>o(e=>e===i?``:e)).catch(()=>{})},children:(0,$.jsx)(Be,{label:a(`detail.discussion.comment`),value:i,onChange:o,rows:3,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:_,placeholder:a(`detail.discussion.placeholder`),footer:(0,$.jsxs)(j,{type:`submit`,variant:`default`,disabled:v.isPending||!i.trim(),children:[v.isPending?(0,$.jsx)(E,{}):(0,$.jsx)(U,{}),v.isPending?a(`detail.discussion.posting`):a(`detail.discussion.comment`),(0,$.jsx)(f,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})})})]})}function et({comment:e,linked:t}){let n=T(),r=N(e.projectId),i=O(`update_comment`),o=Re(e.projectId,{ticketId:e.ticketId}),s=O(`delete_comment`),[c,l]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(e.body),[p,m]=(0,Q.useState)(e.version),_=e.actorId===n.id,v=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{t&&v.current?.scrollIntoView({block:`center`})},[t]),(0,$.jsxs)(`article`,{ref:v,id:`comment-${e.id}`,"data-linked":t,className:`group/comment relative scroll-mt-16 py-4 animate-in fade-in-0 duration-200 data-[linked=true]:animate-row-in data-[linked=true]:shadow-[inset_2px_0_0_var(--primary)] data-[linked=true]:pl-3`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1 pr-20 text-xs text-muted-foreground`,children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:(0,$.jsx)(h,{projectId:e.projectId,actorId:e.actorId,avatar:!0})}),(0,$.jsx)(A,{value:e.createdAt}),e.updatedAt!==e.createdAt&&(0,$.jsx)(`span`,{children:a(`detail.discussion.edited`)})]}),c?(0,$.jsx)(`form`,{onKeyDown:W,onSubmit:t=>{t.preventDefault(),i.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:p,body:d}).then(()=>l(!1)).catch(()=>{})},children:(0,$.jsx)(Be,{label:a(`detail.discussion.edit`),value:d,onChange:f,rows:4,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:o,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{size:`sm`,disabled:i.isPending,onClick:()=>l(!1),children:a(`common.action.cancel`)}),(0,$.jsxs)(j,{type:`submit`,size:`sm`,variant:`default`,disabled:i.isPending||!d.trim(),children:[i.isPending?(0,$.jsx)(E,{}):null,a(`common.action.save`)]})]})})}):(0,$.jsx)(u,{children:e.body}),!c&&r.canWrite&&(_||n.admin)&&(0,$.jsxs)(`div`,{className:`absolute top-3 right-0 flex items-center gap-1 opacity-0 transition-opacity group-hover/comment:opacity-100 focus-within:opacity-100 max-md:opacity-100`,children:[(0,$.jsx)(S,{label:a(`detail.discussion.edit`),size:`icon-sm`,onClick:()=>{f(e.body),m(e.version),l(!0)},children:(0,$.jsx)(fe,{})}),(0,$.jsx)(x,{label:a(`detail.discussion.delete`),icon:(0,$.jsx)(H,{}),danger:!0,description:a(`detail.discussion.deleteConfirm`),onConfirm:()=>s.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:e.version})})]}),(0,$.jsx)(g,{error:i.error})]})}function tt({projectId:e,ticketId:r,preview:i}){let o=N(e),c=d(p.query(`get_ticket`,{projectId:e,ticketId:r})),l=O(`set_subscription`),[f,m]=(0,Q.useState)(!1),[ee,x]=(0,Q.useState)(!1),C=we(),[w]=(0,Q.useState)(()=>i?[]:ve(e)),T=i?.order??w,D=T.indexOf(r),M=t=>{let n=D<0?void 0:T[D+t];n&&(i?i.open(n):C({to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:e,ticketId:n}}))},P=i?`[data-slot="sheet-content"]`:void 0;y(`j`,()=>M(1),{enabled:!f,scope:P}),y(`k`,()=>M(-1),{enabled:!f,scope:P});let F=c.data?.ticket,{change:I,pending:L}=Ne(F??{id:r,projectId:e,version:1});y(`e`,()=>{o.canWrite&&m(!0)},{enabled:!!F&&!f,scope:P});let R=c.error instanceof s&&c.error.status===404,z=d({...p.query(`resolve_ticket`,{ticketId:r}),enabled:R,retry:!1}),B=xe({select:e=>i||!e.location.search.peek?e.location.hash:``});if(c.isPending||R&&z.isFetching)return(0,$.jsx)(te,{});if(R&&z.data&&z.data.project.id!==e)return i?(0,$.jsx)(nt,{preview:i,target:{projectId:z.data.project.id,ticketId:z.data.ticket.id}}):(0,$.jsx)(_e,{to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:z.data.project.id,ticketId:z.data.ticket.id},replace:!0});if(!c.data||!F||R)return R?(0,$.jsxs)(ae,{title:a(`detail.page.unavailable`),children:[(0,$.jsx)(`p`,{children:a(`detail.page.gone`)}),i?(0,$.jsx)(j,{onClick:i.close,children:a(`detail.page.closePreview`)}):(0,$.jsx)(j,{render:(0,$.jsx)(Ie,{to:`/projects/$projectId`,params:{projectId:e}}),children:a(`detail.page.backToTickets`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{error:c.error}),(0,$.jsx)(j,{onClick:()=>{c.refetch()},children:a(`common.action.retry`)})]});let{readiness:V,claim:H,canReleaseClaim:pe,subscribed:U}=c.data,W=o.canWrite&&!L;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`article`,{className:`ticket-detail grid w-full grid-cols-[minmax(0,1fr)_280px] gap-x-10 animate-in fade-in-0 duration-200 @max-[850px]:flex @max-[850px]:flex-col [&_section]:border-t [&_section]:py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ie,{title:!i&&(0,$.jsxs)(j,{variant:`ghost`,size:`sm`,className:`-ml-2 text-muted-foreground`,render:(0,$.jsx)(Ie,{to:`/projects/$projectId`,params:{projectId:e}}),children:[(0,$.jsx)(Te,{}),a(`detail.page.tickets`)]}),children:(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[D>=0&&(0,$.jsxs)(`div`,{className:`mr-1 flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,$.jsx)(S,{label:a(`detail.page.previousTicket`),title:a(`detail.page.previousTicketShortcut`),disabled:D===0,onClick:()=>M(-1),children:(0,$.jsx)(v,{})}),(0,$.jsx)(`span`,{children:a(`detail.page.position`,{position:D+1,total:T.length})}),(0,$.jsx)(S,{label:a(`detail.page.nextTicket`),title:a(`detail.page.nextTicketShortcut`),disabled:D===T.length-1,onClick:()=>M(1),children:(0,$.jsx)(oe,{})})]}),(0,$.jsx)(S,{label:a(U?`detail.page.unsubscribe`:`detail.page.subscribe`),disabled:l.isPending,onClick:()=>{l.mutateAsync({projectId:e,ticketId:F.id,enabled:!U}).then(()=>b.success(a(U?`detail.page.unsubscribed`:`detail.page.subscribed`))).catch(ne)},children:U?(0,$.jsx)(ke,{}):(0,$.jsx)(le,{})}),(0,$.jsx)(S,{label:K.label,onClick:()=>{be(K,F)},children:(0,$.jsx)(K.icon,{})}),(0,$.jsx)(S,{label:F.archived?a(`detail.page.unarchive`):a(`detail.page.archive`),disabled:!W,onClick:()=>{I({archived:!F.archived}).then(e=>{e&&b.success(F.archived?a(`detail.page.unarchivedToast`):a(`detail.page.archivedToast`))})},children:F.archived?(0,$.jsx)(ce,{}):(0,$.jsx)(ue,{})}),(0,$.jsx)(S,{label:a(`detail.page.edit`),title:a(`detail.page.editShortcut`),disabled:!o.canWrite,onClick:()=>m(!0),children:(0,$.jsx)(fe,{})}),(0,$.jsx)(je,{ticket:F,variant:`dropdown`,onEdit:()=>m(!0),children:(0,$.jsx)(j,{variant:`ghost`,size:`icon`,"aria-label":a(`detail.page.actions`),children:(0,$.jsx)(me,{})})}),i&&(0,$.jsx)(Fe,{projectId:e,ticketId:F.id,preview:i})]})}),(0,$.jsx)(je,{ticket:F,onEdit:()=>m(!0),children:(0,$.jsxs)(`header`,{className:`ticket-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(j,{variant:`ghost`,size:`xs`,className:`-ml-2 gap-1.5 font-mono text-xs text-muted-foreground`,title:a(`detail.page.copyKey`),onClick:()=>{se(F.key).then(()=>{x(!0),setTimeout(()=>x(!1),1500),b.success(a(`detail.page.keyCopied`,{key:F.key}))}).catch(ne)},children:[F.key,ee&&(0,$.jsx)(_,{className:`size-3 text-[var(--success)]`})]}),(0,$.jsx)(G,{property:`status`,value:Y(F),projectId:e}),F.archived&&(0,$.jsx)(`strong`,{children:a(`detail.page.archived`)}),L&&(0,$.jsx)(E,{className:`size-3.5 text-muted-foreground`})]}),i?(0,$.jsx)(he,{render:(0,$.jsx)(`h1`,{}),className:re,children:F.title}):(0,$.jsx)(`h1`,{className:re,children:F.title})]})}),(0,$.jsxs)(`div`,{className:`min-w-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:a(`detail.field.description`)}),(0,$.jsx)(u,{...W?{onChange:e=>I({description:e})}:{},children:F.description||a(`detail.page.noDescription`)})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:a(`detail.field.acceptanceCriteria`)}),(0,$.jsx)(u,{...W?{onChange:e=>I({acceptanceCriteria:e})}:{},children:F.acceptanceCriteria||a(`detail.page.noAcceptanceCriteria`)})]})]}),(0,$.jsxs)(Me,{defaultValue:`discussion`,className:`mt-8 min-w-0 [&_[data-slot=tabs-content]>section]:border-0 [&_[data-slot=tabs-content]>section]:pt-0`,children:[(0,$.jsxs)(Oe,{variant:`line`,className:`mb-5`,children:[(0,$.jsx)(q,{value:`discussion`,children:a(`detail.section.discussion`)}),(0,$.jsx)(q,{value:`evidence`,children:a(`detail.section.evidence`)}),(0,$.jsx)(q,{value:`activity`,children:a(`detail.section.activity`)})]}),(0,$.jsx)(X,{value:`discussion`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)($e,{ticket:F,anchor:B})}),(0,$.jsx)(X,{value:`evidence`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ue,{ticket:F})}),(0,$.jsx)(X,{value:`activity`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ge,{ticket:F})})]}),(0,$.jsx)(g,{error:c.error})]}),(0,$.jsxs)(`aside`,{className:`min-w-0 border-l pl-5 @max-[850px]:border-l-0 @max-[850px]:pl-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0 @max-[850px]:[&>section:first-child]:border-t @max-[850px]:[&>section:first-child]:pt-6 [&_h2]:text-xs [&_h2]:font-medium [&_h2]:text-muted-foreground [&_p]:text-xs [&_ul]:mb-4 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:text-xs [&_ul]:leading-relaxed [&_ul]:text-muted-foreground`,"aria-label":a(`detail.page.coordination`),children:[(0,$.jsxs)(`section`,{"aria-label":a(`detail.page.properties`),className:`ticket-properties`,children:[(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:e,value:Y(F),disabled:!W,onChange:e=>void I({status:e})}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:e,value:F.priority,disabled:!W,onChange:e=>void I({priority:e})}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:e,value:F.assigneeId,disabled:!W,onChange:e=>void I({assignee:e})}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:e,value:F.kind,disabled:!W,onChange:e=>void I({kind:e})}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:e,value:F.difficulty,disabled:!W,onChange:e=>void I({difficulty:e})}),(0,$.jsx)(Ae,{variant:`row`,value:F,disabled:!W,onChange:e=>void I(e)}),(0,$.jsx)(De,{variant:`row`,value:F.labels,disabled:!W,onChange:e=>void I({labels:e})}),(F.scopes.length>0||o.canWrite)&&(0,$.jsx)(De,{variant:`row`,kind:`scope`,value:F.scopes,disabled:!W,onChange:e=>void I({scopes:e})}),(0,$.jsx)(ye,{variant:`row`,projectId:e,values:F.customFields,disabled:!W,onChange:(e,t)=>void I({customFields:{[e]:t}})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[80px_minmax(0,1fr)] gap-x-2 gap-y-1.5 border-t pt-4 text-xs [&_dd]:m-0 [&_dd]:min-w-0 [&_dd]:wrap-anywhere [&_dt]:text-muted-foreground`,children:[(0,$.jsx)(`dt`,{children:a(`detail.page.created`)}),(0,$.jsxs)(`dd`,{children:[(0,$.jsx)(h,{projectId:e,actorId:F.createdBy}),` · `,(0,$.jsx)(A,{value:F.createdAt})]}),(0,$.jsx)(`dt`,{children:a(`detail.page.updated`)}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(A,{value:F.updatedAt})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:a(`detail.readiness.heading`)}),(0,$.jsx)(`p`,{className:V.ready?`text-[var(--success)]`:`text-muted-foreground`,children:V.ready?a(`detail.readiness.ready`):a(`detail.readiness.notReady`)}),(0,$.jsx)(`ul`,{children:V.reasons.map((e,n)=>(0,$.jsx)(`li`,{children:t(e,H?.workerId)},`${e.code}:${n}`))}),F.holdReason&&(0,$.jsx)(`p`,{children:a(`detail.readiness.hold`,{reason:F.holdReason})}),H&&(0,$.jsx)(`p`,{children:(0,$.jsx)(de,{i18nKey:`detail.readiness.claimedUntil`,values:{worker:H.workerId,date:n(H.expiresAt)},components:{strong:(0,$.jsx)(`strong`,{})}})}),H&&(0,$.jsx)(rt,{ticket:F,claim:H,canRelease:pe,canRecover:o.canWrite&&V.reasons.some(e=>e.code===`claim_recovery_required`)})]}),(0,$.jsx)(Ze,{ticket:F},F.id),(0,$.jsx)(ze,{ticket:F}),(0,$.jsx)(Ve,{ticket:F})]})]}),(0,$.jsx)(k,{size:`composer`,title:a(`detail.page.editTitle`,{key:F.key}),open:f,onOpenChange:m,children:f&&(0,$.jsx)(Le,{projectId:e,ticket:F,onSaved:()=>m(!1)})})]})}function nt({preview:e,target:t}){return(0,Q.useEffect)(()=>e.follow(t),[e,t]),(0,$.jsx)(te,{})}function rt({ticket:e,claim:t,canRelease:n,canRecover:r}){let i=O(`release_claim`),o=O(`recover_claim`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,$.jsx)(x,{label:a(`detail.claim.release`),description:a(`detail.claim.releaseDescription`),onConfirm:()=>i.mutateAsync({projectId:e.projectId,ticketId:e.id,claimId:t.id})}),r&&(0,$.jsx)(k,{title:a(`detail.claim.recover`),trigger:a(`detail.claim.recover`),children:(0,$.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),l&&o.mutate({projectId:e.projectId,ticketId:e.id,claimId:t.id,reason:s,confirmedStopped:!0})},children:[(0,$.jsx)(`p`,{children:a(`detail.claim.recoverHelp`)}),(0,$.jsx)(D,{label:a(`detail.claim.reason`),required:!0,minLength:10,maxLength:2e3,value:s,onChange:e=>c(e.target.value)}),(0,$.jsx)(m,{label:a(`detail.claim.confirmed`),checked:l,onCheckedChange:e=>u(e)}),(0,$.jsx)(C,{error:o.error,pending:!l,submitLabel:a(`detail.claim.submit`),submitDisabled:o.isPending})]})})]})}export{tt as TicketDetail};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visual-editor-DKBPjqV-.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-CCI1vZxa.js","assets/preload-helper-BLdHbfdN.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/search-DfbsqO7M.js","assets/toDate-B3HYxwtT.js","assets/forms-CkVpTx29.js","assets/index-CZuFd4LM.js","assets/item-DQR89bKm.js","assets/Trans-DqX-qhvQ.js","assets/CompositeItem-DLTRsada.js","assets/en-US-DKYSujv3.js","assets/index-DPT5LAs1.css","assets/highlight-zMg1BK-r.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Bn as t,Bt as n,Dn as r,G as i,In as a,L as o,Mn as s,Pn as c,R as l,Wn as u,_n as d,i as f,o as p,r as m,st as h,z as g,zt as _}from"./default-CCI1vZxa.js";import{$ as v,$a as y,$n as b,A as ee,E as te,F as x,Fa as S,Fi as C,Ga as w,Gi as T,Ha as ne,Hi as E,I as D,Ia as O,Ii as re,J as k,Ja as A,Lt as j,M,Mi as ie,Ni as ae,Ot as oe,P as N,Pa as P,Pi as se,Q as ce,R as le,Ri as ue,U as de,Va as fe,Wa as F,X as I,Y as pe,Z as L,Za as R,Zi as me,_r as z,_t as he,ar as ge,bt as _e,ca as ve,ct as ye,dt as B,ea as V,et as H,ft as be,gi as xe,gr as Se,gt as Ce,hr as U,it as W,j as G,k as we,ko as Te,lr as K,mi as q,ot as J,ra as Ee,st as De,ut as Oe,vr as ke,vt as Ae,xt as Y,yt as je}from"./search-DfbsqO7M.js";import{t as Me}from"./preload-helper-BLdHbfdN.js";import{a as Ne,d as Pe,g as Fe,i as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./item-DQR89bKm.js";import{i as He,n as Ue,r as We}from"./CompositeItem-DLTRsada.js";import{t as Ge}from"./corner-left-up-Be7Z9Uhf.js";import{t as Ke}from"./rotate-ccw-Cxh9ec2s.js";import{t as qe}from"./sliders-horizontal-DM47MLe7.js";import{t as Je}from"./upload-HARy4VC_.js";import{r as Ye,t as X}from"./forms-CkVpTx29.js";import{$t as Xe,At as Ze,Ct as Qe,J as $e,Mt as et,Ot as tt,Z as nt,_ as rt,bt as it,cn as at,d as ot,dn as st,dt as ct,et as lt,fn as ut,g as dt,gt as ft,h as pt,it as mt,kt as ht,m as gt,on as _t,sn as vt,tt as Z}from"./index-CZuFd4LM.js";import{t as yt}from"./switch-CJTVGtE9.js";var bt={name:`bold`,size:24,node:[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]};bt.node;var xt=R(bt),St={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};St.node;var Ct=R(St),wt={name:`heading`,size:24,node:[[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M6 20V4`,key:`1w1bmo`}],[`path`,{d:`M18 20V4`,key:`o2hl4u`}]]};wt.node;var Tt=R(wt),Et={name:`italic`,size:24,node:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]};Et.node;var Dt=R(Et),Ot={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Ot.node;var kt=R(Ot),At={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};At.node;var jt=R(At),Mt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Mt.node;var Nt=R(Mt),Pt={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};Pt.node;var Ft=R(Pt),It={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};It.node;var Lt=R(It),Rt={name:`square-code`,size:24,node:[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`code-square`]};Rt.node;var zt=R(Rt),Q=e(u(),1),$=m(),Bt=(0,Q.lazy)(()=>Me(()=>import(`./visual-editor-DKBPjqV-.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Vt={heading:Tt,bold:xt,italic:Dt,link:kt,list:Nt,"list-ordered":jt,"list-checks":vt,"square-code":zt},Ht=e=>Vt[t[e]];function Ut(e,t){let n=/(?:^|[\s([{])@([^\s@[\]()]{0,40})$/.exec(e.slice(0,t));return n?.[1]===void 0?null:{from:t-n[1].length-1,query:n[1]}}var Wt=(e,t)=>e.filter(e=>`${e.name} ${e.email}`.toLowerCase().includes(t.toLowerCase())).slice(0,8),Gt=e=>({key:e.userId,content:(0,$.jsx)(ve,{name:e.name,email:e.email,image:e.image})}),Kt=e=>h(e.name,e.userId);function qt(e){let[t,n]=(0,Q.useState)(``),r=e.includes(t)?t:e[0];return{active:r,setHighlight:n,handleKey:(t,i,a)=>{if(!r||t.isComposing)return!1;let o={ArrowDown:1,ArrowUp:-1}[t.key];if(!o&&![`Enter`,`Tab`,`Escape`].includes(t.key))return!1;t.preventDefault();let s=e.indexOf(r);return o?n(e[(s+o+e.length)%e.length]??``):t.key===`Escape`?a():i(r),!0}}}function Jt({id:e,label:t,open:n,anchor:r,options:i,active:a,onHighlight:o,onChoose:s,onDismiss:c}){return(0,$.jsx)(x,{open:n,onOpenChange:e=>{e||c()},children:(0,$.jsx)(D,{anchor:r,align:`start`,initialFocus:!1,finalFocus:!1,className:`w-[min(20rem,calc(100vw-2rem))] p-1`,children:(0,$.jsx)(`div`,{role:`listbox`,id:e,"aria-label":t,children:i.map(t=>(0,$.jsx)(`div`,{role:`option`,id:`${e}-${t.key}`,"aria-selected":t.key===a,"data-selected":t.key===a||void 0,className:N,onMouseDown:e=>e.preventDefault(),onPointerMove:()=>o(t.key),onClick:()=>s(t.key),children:t.content},t.key))})})})}function Yt(e,t,n){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=async e=>{if(t&&e.length){i(t=>t+e.length);for(let r of e)try{n(ie(await t(r)))}catch(e){be(e)}finally{i(e=>e-1)}}},s=(0,$.jsx)(`input`,{ref:a,type:`file`,multiple:!0,hidden:!0,"aria-label":d(`detail.markdown.insertFileInto`,{label:e}),onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,o(t)}});return{uploading:r>0,send:o,pick:()=>a.current?.click(),input:s}}function Xt({label:e,flush:t,onApply:n,pressed:r,upload:i,children:a}){return(0,$.jsxs)(Se,{align:`block-start`,role:`toolbar`,"aria-label":d(`detail.markdown.formatting`,{label:e}),className:S(`gap-0.5 overflow-x-auto border-b py-1 pl-1 text-foreground [scrollbar-width:none] max-md:gap-0 max-md:px-0`,t&&`px-0`),onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r={ArrowRight:1,ArrowLeft:-1}[e.key],i=e.key===`Home`?t[0]:e.key===`End`?t.at(-1):r&&t.at((n+r)%t.length);i&&(e.preventDefault(),i.focus())},children:[C.map((e,t)=>{let i=se[e],a=Ht(e);return(0,$.jsx)(I,{label:i.label,...`shortcut`in i?{shortcut:i.shortcut}:{},...r?{"aria-pressed":r(e)}:{},size:`icon-sm`,tabIndex:t===0?0:-1,className:`text-muted-foreground hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,onClick:()=>n(e),children:(0,$.jsx)(a,{})},e)}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{label:i.uploading?d(`detail.resource.uploading`):d(`detail.markdown.insertFile`),size:`icon-sm`,tabIndex:-1,disabled:i.uploading,className:`text-muted-foreground hover:text-foreground`,onClick:i.pick,children:i.uploading?(0,$.jsx)(_e,{}):(0,$.jsx)(Lt,{})}),i.input]}),a]})}function Zt(e){return e?.files.length?[...e.files]:[]}function Qt({label:e,value:t,onChange:n,placeholder:r,rows:i=5,variant:a=`compact`,maxLength:o=1e5,required:s=!1,footer:c,mentions:l,onUpload:u}){let f=(0,Q.useId)(),p=(0,Q.useRef)(null),[m,h]=Qe(it.editor),[g,_]=(0,Q.useState)(!1),[b,ee]=(0,Q.useState)(!1),te=g?`preview`:m===`visual`&&!b?`visual`:`write`,x=y({...T.query(`list_members`,{projectId:l??``}),enabled:!!l}),[C,w]=(0,Q.useState)(0),[ne,E]=(0,Q.useState)(null),D=l?Ut(t,C):null,O=Wt(x.data??[],D?.query??``),k=qt(O.map(e=>e.userId)),A=!!D&&D.from!==ne&&O.length>0,j=`${f}-mentions`,M=e=>{let t=p.current;t&&(t.focus(),t.setSelectionRange(e.from,e.to),document.execCommand(`insertText`,!1,e.text)||(t.setRangeText(e.text),n(t.value)),t.setSelectionRange(e.start,e.end),w(e.end))},ie=e=>{let t=p.current;t&&M(ae(t.value,t.selectionStart,t.selectionEnd,e))},oe=e=>{let t=O.find(t=>t.userId===e);if(!D||!t)return;let n=`${Kt(t)} `,r=D.from+n.length;M({from:D.from,to:C,text:n,start:r,end:r})},N=Yt(e,u,e=>{let t=p.current;if(!t)return;let n=t.selectionEnd+e.length;M({from:t.selectionStart,to:t.selectionEnd,text:e,start:n,end:n})}),P=(e,t)=>{let n=u?Zt(t):[];n.length&&(e.preventDefault(),N.send(n))},se=(0,Q.useCallback)(()=>ee(!0),[]),le=a===`document`?`rounded-none border-0 bg-transparent dark:bg-transparent has-[[data-slot=input-group-control]:focus-visible]:ring-0`:void 0,ue=c&&(0,$.jsx)(Se,{align:`block-end`,className:`justify-end border-t py-2`,children:c});return(0,$.jsx)(ge,{className:S(`mb-6 [&_[data-slot=tabs-list]]:shrink-0 [&_[data-slot=tabs-trigger]]:text-xs`,a===`compact`&&`[&_textarea]:field-sizing-fixed [&_textarea]:max-h-[28rem] [&_.ProseMirror]:max-h-[28rem] [&_.ProseMirror]:overflow-y-auto`,a===`document`&&`border-t pt-5 has-[[data-slot=input-group-control]:focus]:border-t-primary has-[[data-slot=input-group-control]:focus]:[&_[data-slot=field-label]]:text-primary`),"data-variant":a,"aria-label":d(`detail.markdown.editor`,{label:e}),children:(0,$.jsxs)(gt,{value:te,onValueChange:e=>{_(e===`preview`),(e===`write`||e===`visual`)&&(h(e),ee(!1))},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(K,{htmlFor:f,children:e}),(0,$.jsxs)(dt,{"aria-label":d(`detail.markdown.editor`,{label:e}),variant:`line`,children:[(0,$.jsx)(rt,{value:`write`,children:d(`detail.markdown.write`)}),(0,$.jsx)(rt,{value:`visual`,children:d(`detail.markdown.visual`)}),(0,$.jsx)(rt,{value:`preview`,children:d(`detail.markdown.preview`)})]})]}),(0,$.jsxs)(pt,{value:`write`,children:[b&&m===`visual`&&(0,$.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:d(`detail.markdown.unsupported`)}),(0,$.jsxs)(U,{className:le,children:[(0,$.jsx)(Xt,{label:e,flush:a===`document`,onApply:ie,...u?{upload:N}:{}}),(0,$.jsx)(z,{ref:p,id:f,className:a===`document`?`field-sizing-content max-h-none resize-y px-1 py-3 text-base md:text-base leading-7 caret-primary`:void 0,style:a===`document`?{minHeight:`${i}lh`}:void 0,value:t,onChange:e=>{w(e.target.selectionStart),n(e.target.value)},onSelect:e=>w(e.currentTarget.selectionStart),onPaste:e=>P(e,e.clipboardData),onDragOver:e=>{u&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>P(e,e.dataTransfer),...l&&{"aria-autocomplete":`list`,"aria-controls":A?j:void 0,"aria-activedescendant":A&&k.active?`${j}-${k.active}`:void 0},onKeyDown:e=>{if(A&&k.handleKey(e.nativeEvent,oe,()=>E(D.from))){e.stopPropagation();return}let t=re(e);!t||t===`link`&&e.currentTarget.selectionStart===e.currentTarget.selectionEnd||(e.preventDefault(),e.stopPropagation(),ie(t))},placeholder:r,rows:i,maxLength:o,required:s}),l&&(0,$.jsx)(Jt,{id:j,label:d(`detail.markdown.mention`),open:A,anchor:p,options:O.map(Gt),active:k.active,onHighlight:k.setHighlight,onChoose:oe,onDismiss:()=>{D&&E(D.from)}}),ue]})]}),(0,$.jsx)(pt,{value:`visual`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ce,{}),children:(0,$.jsx)(Bt,{id:f,label:e,value:t,onChange:n,placeholder:r??``,rows:i,maxLength:o,flush:a===`document`,groupClassName:le,footer:ue,...l?{members:x.data??[]}:{},...u?{onUpload:u}:{},onUnsupported:se})})}),(0,$.jsxs)(pt,{value:`preview`,children:[(0,$.jsx)(`div`,{className:S(`min-h-28 rounded-lg border bg-muted/20 p-4`,a===`document`&&`rounded-none border-0 bg-transparent px-1 py-3 text-base leading-7`),children:t?(0,$.jsx)(v,{children:t}):(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:d(`detail.markdown.nothingToPreview`)})}),c&&(0,$.jsx)(`div`,{className:`mt-2 flex justify-end`,children:c})]})]})})}function $t({projectId:e,label:t,value:n,onChange:r,exclude:i=[],allowClear:o=!0,variant:s=`field`,placeholder:c=d(`ticket.picker.placeholder`)}){let l=(0,Q.useId)(),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=y({...T.query(`list_tickets`,{projectId:e,q:p,archived:`include`,limit:30}),enabled:u}),g=y({...T.query(`get_ticket`,{projectId:e,ticketId:n??``}),enabled:!!n&&a().safeParse(n).success}),_=h.data?.items.filter(e=>!i.includes(e.id))??[],v=g.data?.ticket??h.data?.items.find(e=>e.id===n),b=(0,$.jsxs)(x,{open:u,onOpenChange:e=>{f(e),e&&m(``)},children:[(0,$.jsxs)(le,{id:l,render:(0,$.jsx)(q,{variant:s===`pill`?`ghost`:`outline`,size:s===`pill`?`sm`:`default`,role:`combobox`,"aria-label":t,className:s===`pill`?`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border`:`h-auto min-h-8 w-full justify-between whitespace-normal text-left font-normal`}),children:[s===`pill`&&(0,$.jsx)(Ge,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:s===`pill`?`min-w-0 truncate`:`min-w-0 break-words`,children:v?s===`pill`?v.key:`${v.key} · ${v.title}`:n?d(`ticket.picker.loading`):c}),s!==`pill`&&(0,$.jsx)(He,{className:`ml-2 size-3.5 shrink-0 text-muted-foreground`})]}),(0,$.jsx)(D,{align:`start`,className:`w-[min(420px,var(--available-width))] p-0`,children:(0,$.jsxs)(te,{shouldFilter:!1,children:[(0,$.jsx)(ee,{"aria-label":d(`ticket.picker.searchLabel`,{label:t}),placeholder:d(`ticket.picker.searchPlaceholder`),value:p,onValueChange:m}),(0,$.jsxs)(M,{children:[o&&(0,$.jsx)(we,{children:(0,$.jsxs)(G,{value:`none`,onSelect:()=>{r(null),f(!1)},children:[d(`ticket.picker.noParent`),!n&&(0,$.jsx)(A,{className:`ml-auto`})]})}),h.isPending?(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-sm text-muted-foreground`,children:d(`ticket.picker.searching`)}):_.length?(0,$.jsx)(we,{children:_.map(e=>(0,$.jsxs)(G,{value:e.id,className:`items-start py-2`,onSelect:()=>{r(e.id),f(!1)},children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`mb-1 block font-mono text-[11px] text-muted-foreground`,children:e.key}),(0,$.jsx)(`span`,{dir:`auto`,className:`block break-words whitespace-normal`,children:e.title})]}),n===e.id&&(0,$.jsx)(A,{className:`ml-auto shrink-0`})]},e.id))}):(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-center text-sm text-muted-foreground`,children:d(`ticket.picker.empty`)}),(0,$.jsx)(k,{error:h.error})]})]})})]});return s===`pill`?(0,$.jsxs)($.Fragment,{children:[b,(0,$.jsx)(k,{error:g.error})]}):(0,$.jsxs)(ge,{className:Oe,children:[(0,$.jsx)(K,{htmlFor:l,children:t}),b,(0,$.jsx)(k,{error:g.error})]})}var en=xe(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function tn({className:e,orientation:t,...n}){return(0,$.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:S(en({orientation:t}),e),...n})}function nn({icon:e,href:t,label:n,download:r=!1,compact:i=!1,badges:a,details:o,meta:s,metaId:c,actions:l}){return(0,$.jsxs)(Ve,{role:`listitem`,size:i?`xs`:`default`,className:S(`rounded-none border-x-0 border-t-0 border-b-border px-0 animate-in fade-in-0 duration-200 last:border-b-0`,!i&&`items-start py-4`),children:[(0,$.jsx)(Re,{variant:i?`default`:`icon`,children:e}),(0,$.jsxs)(ze,{className:S(`min-w-0`,i?`gap-0`:`gap-1.5`),children:[(0,$.jsxs)(Be,{className:S(`line-clamp-none max-w-full wrap-anywhere`,i&&`text-xs font-normal`),children:[(0,$.jsxs)(`a`,{href:t,"aria-describedby":c,...r?{download:!0,className:`hover:text-primary`}:{target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`},children:[n,!r&&(0,$.jsx)(ut,{className:`size-3 shrink-0`,"aria-hidden":`true`})]}),a]}),o,s&&(0,$.jsx)(Ie,{id:c,className:S(`m-0`,i?`text-[11px]`:`text-xs`),children:s})]}),l&&(0,$.jsx)(Le,{children:l})]})}function rn(e){if(e.size>1e7)throw Error(d(`detail.attachment.tooLarge`))}var an=async e=>({name:e.name,contentType:e.type||`application/octet-stream`,data:await ue(e)});function on(e,t){let n=V(`upload_attachment`),r=V(`stage_upload`);return async i=>{rn(i);let a=await an(i),o=`ticketId`in t?await n.mutateAsync({projectId:e,ticketId:t.ticketId,...a}):await r.mutateAsync({projectId:e,...a});return`onStaged`in t&&t.onStaged(o.id),{url:p(e,o.id),name:o.name,contentType:o.contentType}}}function sn({ticket:e}){let t=y(T.query(`list_attachments`,{projectId:e.projectId,ticketId:e.id})),n=V(`upload_attachment`),r=V(`delete_attachment`),i=Ee(e.projectId),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,f]=(0,Q.useState)(!1);async function m(t){if(t.length){s(void 0),f(!0);try{t.forEach(rn);for(let r of t)await n.mutateAsync({projectId:e.projectId,ticketId:e.id,...await an(r)});P.success(d(`detail.attachment.attached`,{count:t.length}))}catch(e){s(e)}finally{f(!1)}}}return(0,$.jsxs)(`section`,{onDragOver:e=>{i.canWrite&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1),i.canWrite&&m(Array.from(e.dataTransfer.files))},className:S(`rounded-lg transition-colors`,c&&`bg-primary/5 ring-2 ring-primary/40 ring-offset-4 ring-offset-background`),children:[(0,$.jsx)(J,{compact:!0,title:d(`detail.attachment.heading`),action:i.canWrite&&(0,$.jsx)(I,{label:d(u?`detail.resource.uploading`:`detail.attachment.attach`),size:`icon-sm`,disabled:u,onClick:()=>a.current?.click(),children:u?(0,$.jsx)(_e,{}):(0,$.jsx)(Je,{})})}),!t.isPending&&!t.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:i.canWrite?d(`detail.attachment.emptyWritable`):d(`detail.attachment.empty`)}),(0,$.jsx)(Ne,{className:`gap-0`,children:t.data?.map(t=>(0,$.jsx)(nn,{compact:!0,download:!0,icon:(0,$.jsx)(st,{className:`size-4 text-muted-foreground`}),href:p(e.projectId,t.id),label:t.name,meta:B(t.size),metaId:`attachment-size-${t.id}`,actions:i.canWrite&&(0,$.jsx)(de,{label:d(`detail.attachment.remove`),icon:(0,$.jsx)(Ue,{}),description:d(`detail.resource.removeConfirm`,{name:t.name}),onConfirm:()=>r.mutateAsync({projectId:e.projectId,attachmentId:t.id})})},t.id))}),(0,$.jsx)(ke,{ref:a,type:`file`,multiple:!0,className:`hidden`,"aria-label":d(`detail.attachment.fileInput`),disabled:u,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,m(t)}}),(0,$.jsx)(k,{error:o??t.error??r.error})]})}var cn={passed:w,failed:ne,pending:fe,reported:F};function ln({ticket:e}){let t=Ee(e.projectId),n=y(T.query(`list_evidence`,{projectId:e.projectId,ticketId:e.id})),r=V(`add_evidence`),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)();return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(J,{title:d(`detail.section.evidence`),description:d(`detail.evidence.description`),action:t.canWrite&&(0,$.jsx)(I,{label:d(`detail.evidence.add`),onClick:()=>{r.reset(),c(void 0),a(!0)},children:(0,$.jsx)(Fe,{})})}),!n.isPending&&!n.data?.length&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(`detail.evidence.empty`)}),(0,$.jsx)(Ne,{className:`gap-0`,children:n.data?.map(t=>{let n=cn[t.outcome]??F;return(0,$.jsx)(nn,{icon:(0,$.jsx)(n,{className:S(t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`)}),href:t.url,label:t.title,badges:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`outline`,className:`ml-2`,children:l[t.kind]}),(0,$.jsx)(Y,{variant:`outline`,className:S(`ml-1`,t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`),"data-outcome":t.outcome,children:g[t.outcome]})]}),details:(0,$.jsxs)($.Fragment,{children:[t.commit&&(0,$.jsx)(`code`,{className:`w-fit rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] break-all`,children:t.commit}),t.note&&(0,$.jsx)(v,{children:t.note})]}),meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(W,{value:t.createdAt})]})},t.id)})}),(0,$.jsx)(H,{title:d(`detail.evidence.add`),open:i,onOpenChange:a,busy:r.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);r.mutateAsync({projectId:e.projectId,ticketId:e.id,kind:o.shape.kind.parse(n.get(`kind`)),title:X(n,`title`),url:X(n,`url`),commit:X(n,`commit`)||null,outcome:o.shape.outcome.parse(n.get(`outcome`)),note:X(n,`note`)}).then(()=>{a(!1),P.success(d(`detail.evidence.added`))}).catch(c)},children:[(0,$.jsx)(L,{label:d(`detail.field.title`),name:`title`,required:!0,maxLength:200}),(0,$.jsx)(L,{label:d(`detail.field.url`),name:`url`,type:`url`,required:!0}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-5 sm:grid-cols-2`,children:[(0,$.jsx)(De,{label:d(`detail.evidence.kindLabel`),name:`kind`,children:o.shape.kind.options.map(e=>(0,$.jsx)(j,{value:e,children:l[e]},e))}),(0,$.jsx)(De,{label:d(`detail.evidence.outcomeLabel`),name:`outcome`,children:o.shape.outcome.unwrap().options.map(e=>(0,$.jsx)(j,{value:e,children:g[e]},e))})]}),(0,$.jsx)(L,{label:d(`detail.evidence.commit`),name:`commit`,pattern:`[a-fA-F0-9]{40,64}`}),(0,$.jsx)(ye,{label:d(`detail.evidence.note`),name:`note`,maxLength:2e4}),(0,$.jsx)(pe,{error:s??r.error,pending:r.isPending,submitLabel:d(`detail.evidence.add`),onCancel:()=>a(!1)})]})}),(0,$.jsx)(k,{error:n.error})]})}function un({ticket:e}){let t=Ee(e.projectId),r=y(T.query(`list_resources`,{projectId:e.projectId,ticketId:e.id})),i=V(`add_resource`),a=V(`update_resource`),o=V(`delete_resource`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(),m=i.isPending||a.isPending,h=e=>{p(void 0),c(e),u(!0)};return(0,$.jsxs)(`section`,{"aria-label":d(`detail.link.heading`),children:[(0,$.jsx)(J,{compact:!0,title:d(`detail.link.heading`),action:t.canWrite&&(0,$.jsx)(I,{label:d(`detail.link.add`),size:`icon-sm`,onClick:()=>h(),children:(0,$.jsx)(Fe,{})})}),!r.isPending&&!r.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:d(`detail.link.empty`)}),(0,$.jsx)(Ne,{className:`gap-0`,children:r.data?.map(r=>(0,$.jsx)(nn,{compact:!0,icon:(0,$.jsx)(at,{className:`size-4 text-muted-foreground`}),href:r.url,label:r.title||r.url,meta:r.provider?(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,children:r.provider}),(0,$.jsx)(Y,{variant:`outline`,className:r.remoteState?void 0:`text-muted-foreground`,children:n(r)})]}):r.title&&_(r.url),actions:t.canWrite&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{size:`icon-sm`,label:d(`detail.link.edit`),onClick:()=>h(r),children:(0,$.jsx)(We,{})}),(0,$.jsx)(de,{label:d(`detail.link.remove`),icon:(0,$.jsx)(Ue,{}),description:d(`detail.resource.removeConfirm`,{name:r.title||r.url}),onConfirm:()=>o.mutateAsync({projectId:e.projectId,resourceId:r.id,expectedVersion:r.version})})]})},r.id))}),(0,$.jsx)(H,{title:d(s?`detail.link.edit`:`detail.link.add`),open:l,onOpenChange:u,busy:m,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget),r={url:X(n,`url`),title:X(n,`title`)};p(void 0),(s?a.mutateAsync({projectId:e.projectId,resourceId:s.id,expectedVersion:s.version,...r}):i.mutateAsync({projectId:e.projectId,ticketId:e.id,...r})).then(()=>u(!1)).catch(p)},children:[(0,$.jsx)(L,{label:d(`detail.field.url`),name:`url`,type:`url`,required:!0,autoFocus:!0,defaultValue:s?.url}),(0,$.jsx)(L,{label:d(`detail.field.title`),name:`title`,maxLength:200,defaultValue:s?.title}),(0,$.jsx)(pe,{error:f,pending:m,submitLabel:d(s?`detail.link.save`:`detail.link.add`),onCancel:()=>u(!1)})]})}),(0,$.jsx)(k,{error:r.error})]})}function dn({ticket:e}){let[t,n]=(0,Q.useState)(0),r=y(T.query(`list_activity`,{projectId:e.projectId,ticketId:e.id,offset:t}));return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:d(`detail.section.activity`)}),(0,$.jsx)(k,{error:r.error}),(0,$.jsx)(`ol`,{className:`m-0 list-none p-0`,children:r.data?.items.map(t=>(0,$.jsxs)(`li`,{className:`relative flex flex-col gap-0.5 border-l py-2.5 pl-5 text-xs before:absolute before:top-4 before:-left-[3px] before:size-[5px] before:rounded-full before:bg-muted-foreground/50`,children:[(0,$.jsx)(`span`,{children:i(t)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,$.jsx)(E,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(W,{value:t.createdAt})]})]},t.id))}),((r.data?.total??0)>50||t>0)&&(0,$.jsxs)(tn,{className:`mt-5 justify-end`,children:[(0,$.jsx)(q,{size:`sm`,disabled:!t,onClick:()=>n(Math.max(0,t-50)),children:d(`detail.activity.previous`)}),(0,$.jsx)(q,{size:`sm`,disabled:t+50>=(r.data?.total??0),onClick:()=>n(t+50),children:d(`detail.activity.next`)})]})]})}var fn=`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border aria-pressed:border-border aria-pressed:bg-muted`;function pn({projectId:e,ticket:t,initial:n,onSaved:i}){let a=Ce(),o=`kanvil:${me().id}:draft:${e}:${t?.id??`new:${n?.parentId??``}`}`,[l,u]=(0,Q.useState)(()=>{let e=ht(t);return n?{...e,fields:{...e.fields,...n}}:e}),[p,m]=(0,Q.useState)(()=>{try{let e=et.safeParse(JSON.parse(localStorage.getItem(o)??`null`));if(e.success)return e.data}catch{}return l}),h=(0,Q.useRef)(p);function g(e){h.current=e,m(e)}let _=`kanvil:composer-expanded`,[v,y]=(0,Q.useState)(()=>{try{return localStorage.getItem(_)===`1`}catch{return!1}});function ee(){y(e=>{try{localStorage.setItem(_,e?`0`:`1`)}catch{}return!e})}let[te,C]=(0,Q.useState)(()=>!!p.fields.acceptanceCriteria),[w,ne]=(0,Q.useState)(),[E,re]=(0,Q.useState)(),[A,j]=(0,Q.useState)(!1),[M,ie]=(0,Q.useState)(!1),[ae,N]=(0,Q.useState)(),se=V(`create_ticket`),ce=V(`update_ticket`),ue=V(`discard_upload`),de=Te(),fe=(0,Q.useRef)(null),F=(0,Q.useRef)(!1),I=(0,Q.useRef)(0),[pe,R]=(0,Q.useState)(!1);function z(e){g(e),N(void 0);try{localStorage.setItem(o,JSON.stringify(e)),re(void 0),j(!0)}catch{re(Error(d(`detail.editor.storageUnavailable`))),j(!1)}}function ge(){try{localStorage.removeItem(o)}catch{}ve(h.current.uploads),g(l),j(!1)}function ve(e){for(let t of e)ue.mutateAsync({projectId:W,uploadId:t}).catch(()=>{})}let B=e=>z({...h.current,fields:{...h.current.fields,...e}}),H=(e,t)=>B({[e]:t}),xe=(e,t)=>H(`customFields`,{...h.current.fields.customFields,[e]:t});async function Se(t){let n=++I.current;z({...h.current,projectId:t===e?void 0:t,fields:{...h.current.fields,parentId:null,stateId:null,customFields:{}}}),R(!0);let r=[];try{r=await de.ensureQueryData(T.query(`list_members`,{projectId:t}))}finally{if(n===I.current){let e=h.current,{assigneeId:t}=e.fields;t&&!r.some(e=>e.userId===t)&&z({...e,fields:{...e.fields,assigneeId:null}}),R(!1)}}}let U=p.fields,W=p.projectId??e,G=!!t&&p.version!==t.version,we=JSON.stringify(p.fields)!==JSON.stringify(l.fields)||p.projectId!==l.projectId,K=se.isPending||ce.isPending,J=K||G||pe,Ee=U.automationReady||U.scopes.length>0||!!U.holdReason,De=on(W,t?{ticketId:t.id}:{onStaged:e=>z({...h.current,uploads:[...h.current.uploads,e]})});async function Oe(n){if(n.preventDefault(),J||F.current)return;let r=Ze(U),s=p.uploads.filter(e=>U.description.includes(e)||U.acceptanceCriteria.includes(e));F.current=!0,a?.(!0);try{let n=t?await ce.mutateAsync({projectId:e,ticketId:t.id,expectedVersion:p.version??t.version,changes:r}):await se.mutateAsync({projectId:W,...r,uploads:s}).catch(e=>{throw ke(e),e});t||ve(p.uploads.filter(e=>!s.includes(e)));try{localStorage.removeItem(o)}catch{}if(t||!M)return P.success(d(t?`detail.editor.saved`:`detail.editor.created`,{key:n.key})),i(n);let a=h.current.fields,c=e=>a[e]===U[e]?``:a[e],l={...h.current,uploads:h.current.uploads.filter(e=>!p.uploads.includes(e)),fields:{...a,title:c(`title`),description:c(`description`),acceptanceCriteria:c(`acceptanceCriteria`)}};u({...l,fields:{...l.fields,title:``,description:``,acceptanceCriteria:``}}),l.fields.title||l.fields.description||l.fields.acceptanceCriteria?z(l):(g(l),j(!1)),C(!!l.fields.acceptanceCriteria),N(n.key),fe.current?.focus()}finally{F.current=!1,a?.(!1)}}function ke(e){let t=e instanceof f&&s({uploads:r(c())}).safeParse(e.details).data?.uploads;t&&z({...h.current,uploads:h.current.uploads.filter(e=>!t.includes(e))})}let Y=K||p.uploads.length>0,Me=(0,$.jsxs)(`div`,{className:`-mt-3 flex flex-wrap items-center gap-1`,"aria-label":d(`detail.editor.properties`),children:[!t&&(0,$.jsx)(nt,{value:W,disabled:Y,onChange:e=>void Se(e).catch(be)}),(0,$.jsx)(Z,{property:`status`,projectId:W,value:ct(U),onChange:e=>B(mt(e))}),(0,$.jsx)(Z,{property:`priority`,projectId:W,value:U.priority,onChange:e=>H(`priority`,e)}),(0,$.jsx)(Z,{property:`assignee`,projectId:W,value:U.assigneeId,onChange:e=>H(`assigneeId`,e)}),(0,$.jsx)(Z,{property:`kind`,projectId:W,value:U.kind,onChange:e=>H(`kind`,e)}),(0,$.jsx)(Z,{property:`difficulty`,projectId:W,value:U.difficulty,onChange:e=>H(`difficulty`,e)}),(0,$.jsx)(lt,{value:U.labels,onChange:e=>H(`labels`,e)}),(0,$.jsx)(ft,{variant:`pill`,value:U,onChange:B}),(0,$.jsx)($e,{variant:`pill`,projectId:W,values:U.customFields,isNew:!t,onChange:xe}),(0,$.jsx)($t,{variant:`pill`,label:d(`detail.field.parentTicket`),placeholder:d(`detail.field.parent`),projectId:W,value:U.parentId,onChange:e=>H(`parentId`,e),exclude:t?[t.id]:[]}),(0,$.jsxs)(ot,{size:`sm`,className:S(fn,`gap-1.5`),pressed:U.automationReady,onPressedChange:e=>H(`automationReady`,e),"aria-label":d(`detail.editor.readyForAgents`),title:d(`detail.editor.readyForAgentsHelp`),children:[(0,$.jsx)(Ct,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),U.automationReady?d(`detail.editor.readyForAgents`):d(`detail.editor.agents`)]}),(0,$.jsxs)(x,{children:[(0,$.jsx)(le,{render:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:S(`size-7 border border-transparent hover:border-border`,Ee&&`text-primary`),"aria-label":d(`detail.editor.moreProperties`)}),children:(0,$.jsx)(qe,{className:`size-3.5`})}),(0,$.jsxs)(D,{align:`start`,className:`w-[min(24rem,calc(100vw-2rem))] p-4`,children:[(0,$.jsx)(tt,{label:d(`detail.field.scopes`),kind:`scope`,value:U.scopes,onChange:e=>H(`scopes`,e)}),(0,$.jsx)(L,{label:d(`detail.field.holdReason`),value:U.holdReason??``,maxLength:2e3,placeholder:d(`detail.editor.holdPlaceholder`),onChange:e=>H(`holdReason`,e.target.value||null)}),(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:d(`detail.editor.claimsNote`)})]})]})]}),Ne=(0,$.jsxs)(`form`,{onSubmit:e=>{ne(void 0),Oe(e).catch(ne)},onKeyDown:Ye,className:`ticket-composer flex min-h-0 flex-1 flex-col`,"data-expanded":v,children:[(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-11 hidden sm:inline-flex`,"aria-label":d(v?`detail.editor.restoreSize`:`detail.editor.expand`),"aria-pressed":v,disabled:K,onClick:ee,children:v?(0,$.jsx)(Ft,{}):(0,$.jsx)(_t,{})}),(0,$.jsxs)(`div`,{className:S(`min-h-0 flex-1 overflow-y-auto overscroll-contain`,v&&`lg:grid lg:grid-cols-[minmax(0,1fr)_320px] lg:items-start`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-4 px-5 py-5 sm:px-8`,children:[G&&(0,$.jsxs)(he,{className:`w-auto`,children:[(0,$.jsx)(Xe,{}),(0,$.jsx)(je,{children:d(`detail.editor.staleTitle`)}),(0,$.jsxs)(Ae,{children:[d(`detail.editor.staleDescription`,{version:p.version}),(0,$.jsx)(q,{size:`sm`,className:`mt-2`,onClick:()=>z(ht(t)),children:d(`detail.editor.discardAndReload`)})]})]}),(0,$.jsx)(k,{error:w??se.error??ce.error??E}),(0,$.jsx)(`div`,{className:`[&_[data-slot=field-label]]:sr-only`,children:(0,$.jsx)(ye,{label:d(`detail.field.title`),rows:1,value:U.title,onChange:e=>H(`title`,e.target.value),required:!0,maxLength:500,autoFocus:!0,ref:fe,placeholder:d(`detail.editor.titlePlaceholder`),className:`field-sizing-content min-h-10 resize-none border-0 bg-transparent px-0 py-1 text-xl! font-semibold leading-snug shadow-none caret-primary focus-visible:ring-0 dark:bg-transparent`})}),!v&&Me,(0,$.jsx)(Qt,{label:d(`detail.field.description`),value:U.description,onChange:e=>H(`description`,e),rows:8,variant:`document`,placeholder:d(`detail.editor.descriptionPlaceholder`),onUpload:De}),te?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Qt,{label:d(`detail.field.acceptanceCriteria`),value:U.acceptanceCriteria,onChange:e=>H(`acceptanceCriteria`,e),rows:4,variant:`document`,maxLength:5e4,placeholder:d(`detail.editor.criteriaPlaceholder`),onUpload:De}),!U.acceptanceCriteria&&(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,className:`absolute top-5 right-24 text-muted-foreground`,"aria-label":d(`detail.editor.removeCriteria`),onClick:()=>C(!1),children:(0,$.jsx)(O,{})})]}):(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`w-fit text-muted-foreground`,onClick:()=>C(!0),children:[(0,$.jsx)(vt,{}),d(`detail.editor.addCriteria`)]})]}),v&&(0,$.jsxs)(`aside`,{className:`border-t bg-muted/20 p-5 lg:sticky lg:top-0 lg:min-h-full lg:border-t-0 lg:border-l`,"aria-label":d(`detail.editor.properties`),children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[!t&&(0,$.jsx)(nt,{variant:`row`,value:W,disabled:Y,onChange:e=>void Se(e).catch(be)}),(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:W,value:ct(U),onChange:e=>B(mt(e))}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:W,value:U.priority,onChange:e=>H(`priority`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:W,value:U.assigneeId,onChange:e=>H(`assigneeId`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:W,value:U.kind,onChange:e=>H(`kind`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:W,value:U.difficulty,onChange:e=>H(`difficulty`,e)}),(0,$.jsx)(ft,{variant:`row`,value:U,onChange:B}),(0,$.jsx)($e,{variant:`row`,projectId:W,values:U.customFields,isNew:!t,onChange:xe}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[80px_minmax(0,1fr)] items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`detail.editor.agents`)}),(0,$.jsxs)(ot,{size:`sm`,className:S(fn,`h-7 justify-start gap-1.5`),pressed:U.automationReady,onPressedChange:e=>H(`automationReady`,e),"aria-label":d(`detail.editor.readyForAgents`),children:[(0,$.jsx)(Ct,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),U.automationReady?d(`detail.editor.readyForAgents`):d(`detail.editor.notReady`)]})]})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t pt-5`,children:[(0,$.jsx)(tt,{label:d(`detail.field.labels`),value:U.labels,onChange:e=>H(`labels`,e)}),(0,$.jsx)($t,{label:d(`detail.field.parentTicket`),projectId:W,value:U.parentId,onChange:e=>H(`parentId`,e),exclude:t?[t.id]:[]}),(0,$.jsx)(tt,{label:d(`detail.field.scopes`),kind:`scope`,value:U.scopes,onChange:e=>H(`scopes`,e)}),(0,$.jsx)(L,{label:d(`detail.field.holdReason`),value:U.holdReason??``,maxLength:2e3,placeholder:d(`detail.editor.holdPlaceholder`),onChange:e=>H(`holdReason`,e.target.value||null)})]})]})]}),(0,$.jsxs)(`footer`,{className:`z-10 flex shrink-0 flex-wrap items-center justify-between gap-3 border-t bg-muted/40 px-5 py-3`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[ae?d(`detail.editor.created`,{key:ae}):A?d(`detail.editor.savedLocally`):E?d(`detail.editor.notSavedLocally`):``,we&&!G&&(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,disabled:K,onClick:ge,children:[(0,$.jsx)(Ke,{}),d(`detail.editor.discardDraft`)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsxs)(`label`,{className:`mr-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(yt,{size:`sm`,checked:M,disabled:K,onCheckedChange:ie}),d(`detail.editor.createMore`)]}),(0,$.jsx)(oe,{render:(0,$.jsx)(q,{disabled:K}),children:d(`common.action.cancel`)}),(0,$.jsxs)(q,{type:`submit`,variant:`default`,disabled:J,children:[K?(0,$.jsx)(_e,{}):null,d(K?`common.state.saving`:t?`detail.editor.save`:`detail.editor.create`),!K&&(0,$.jsx)(b,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})]})]})]});return(0,$.jsx)(Pe,{projectId:W,children:Ne})}export{pn as TicketEditor,Lt as _,on as a,Xt as c,Zt as d,Ht as f,qt as g,Yt as h,un as i,Qt as l,Gt as m,sn as n,tn as o,Wt as p,ln as r,$t as s,dn as t,Jt as u};
|