@kienmatu/inkos-studio 0.1.2 → 0.1.3

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.
Files changed (61) hide show
  1. package/dist/assets/{FilmWizard-CuCB-1xV.js → FilmWizard-BAeDX_rI.js} +1 -1
  2. package/dist/assets/{FlowView-rMLtzFZK.js → FlowView-C6n6r8pJ.js} +1 -1
  3. package/dist/assets/{_baseUniq-xbTfIKo7.js → _baseUniq-CHNUfn5h.js} +1 -1
  4. package/dist/assets/{arc-BJ0Jn4qy.js → arc-CdPV8k-0.js} +1 -1
  5. package/dist/assets/{architectureDiagram-Q4EWVU46-B54hBS8X.js → architectureDiagram-Q4EWVU46-oodkcVSQ.js} +1 -1
  6. package/dist/assets/{blockDiagram-DXYQGD6D-BrQpuNBu.js → blockDiagram-DXYQGD6D-CIbxhPHs.js} +1 -1
  7. package/dist/assets/{c4Diagram-AHTNJAMY-nN4kJiPC.js → c4Diagram-AHTNJAMY-CxIpgCiP.js} +1 -1
  8. package/dist/assets/channel-BudrdgJ_.js +1 -0
  9. package/dist/assets/{chunk-4BX2VUAB-DnzQoX6p.js → chunk-4BX2VUAB-Cf70tfVa.js} +1 -1
  10. package/dist/assets/{chunk-4TB4RGXK-PeEeEWP2.js → chunk-4TB4RGXK-uFQAF256.js} +1 -1
  11. package/dist/assets/{chunk-55IACEB6-BZHFzH6I.js → chunk-55IACEB6-4u7WcTds.js} +1 -1
  12. package/dist/assets/{chunk-EDXVE4YY-B06PJNq-.js → chunk-EDXVE4YY-DKvxdCCA.js} +1 -1
  13. package/dist/assets/{chunk-FMBD7UC4-Cny1qCNu.js → chunk-FMBD7UC4-DA6v8xvJ.js} +1 -1
  14. package/dist/assets/{chunk-OYMX7WX6-MqHFCczv.js → chunk-OYMX7WX6-DwLlaWl9.js} +1 -1
  15. package/dist/assets/{chunk-QZHKN3VN-Bu8oSEuV.js → chunk-QZHKN3VN-CFgB8UWK.js} +1 -1
  16. package/dist/assets/{chunk-YZCP3GAM-DW9WLjg7.js → chunk-YZCP3GAM-JgBXvZgf.js} +1 -1
  17. package/dist/assets/classDiagram-6PBFFD2Q-CNYOE6Pk.js +1 -0
  18. package/dist/assets/classDiagram-v2-HSJHXN6E-CNYOE6Pk.js +1 -0
  19. package/dist/assets/clone-CbLIuAlV.js +1 -0
  20. package/dist/assets/{cose-bilkent-S5V4N54A-BFF3VF0W.js → cose-bilkent-S5V4N54A-DKMKqdAL.js} +1 -1
  21. package/dist/assets/{dagre-KV5264BT-7wO_SFt1.js → dagre-KV5264BT-DuZ4zm4B.js} +1 -1
  22. package/dist/assets/{diagram-5BDNPKRD-DpdLNbTp.js → diagram-5BDNPKRD-CoA3HYsp.js} +1 -1
  23. package/dist/assets/{diagram-G4DWMVQ6-B2Xd9yJj.js → diagram-G4DWMVQ6-DVnnKNaz.js} +1 -1
  24. package/dist/assets/{diagram-MMDJMWI5-BcJABwZb.js → diagram-MMDJMWI5-iB_Pzv_O.js} +1 -1
  25. package/dist/assets/{diagram-TYMM5635-ByagqgDJ.js → diagram-TYMM5635-CJ1VtRnc.js} +1 -1
  26. package/dist/assets/{erDiagram-SMLLAGMA-zfdClUWU.js → erDiagram-SMLLAGMA-SWAf-S26.js} +1 -1
  27. package/dist/assets/{flowDiagram-DWJPFMVM-Cign1ovE.js → flowDiagram-DWJPFMVM-bjSm1F6q.js} +1 -1
  28. package/dist/assets/{ganttDiagram-T4ZO3ILL-zHFblbgr.js → ganttDiagram-T4ZO3ILL-B3eioyUQ.js} +1 -1
  29. package/dist/assets/{gitGraphDiagram-UUTBAWPF-DgUNvxqj.js → gitGraphDiagram-UUTBAWPF-DGaIKwEh.js} +1 -1
  30. package/dist/assets/{graph-CT_N4MvP.js → graph-zC0IkLW4.js} +1 -1
  31. package/dist/assets/{highlighted-body-OFNGDK62-CbTQmRda.js → highlighted-body-OFNGDK62-CkE4PgdB.js} +1 -1
  32. package/dist/assets/{index-C5AvWGUU.js → index-9mF0_S-1.js} +12 -7
  33. package/dist/assets/{index-DaFEDFsq.css → index-B9yC-RFq.css} +1 -1
  34. package/dist/assets/{infoDiagram-42DDH7IO-B1j6wnrX.js → infoDiagram-42DDH7IO-z7BfWhD6.js} +1 -1
  35. package/dist/assets/{ishikawaDiagram-UXIWVN3A-CmTERA2Q.js → ishikawaDiagram-UXIWVN3A-DgkoM8pX.js} +1 -1
  36. package/dist/assets/{journeyDiagram-VCZTEJTY-lXMvtopT.js → journeyDiagram-VCZTEJTY-7szsjnaK.js} +1 -1
  37. package/dist/assets/{kanban-definition-6JOO6SKY-D2nd3IRf.js → kanban-definition-6JOO6SKY-CN_iYP62.js} +1 -1
  38. package/dist/assets/{layout-Dwdg17w2.js → layout-B1_IEbhE.js} +1 -1
  39. package/dist/assets/{linear-BGLXP-7J.js → linear-DgZKeCD_.js} +1 -1
  40. package/dist/assets/{min-CWmMAm2D.js → min-BGmTIgk7.js} +1 -1
  41. package/dist/assets/{mindmap-definition-QFDTVHPH-Bc_KwUJk.js → mindmap-definition-QFDTVHPH-CaZaCUVQ.js} +1 -1
  42. package/dist/assets/{pieDiagram-DEJITSTG-Dk4TEXCU.js → pieDiagram-DEJITSTG-Bai_9_pu.js} +1 -1
  43. package/dist/assets/{quadrantDiagram-34T5L4WZ-DjpGwBeJ.js → quadrantDiagram-34T5L4WZ-CgKE3-Ag.js} +1 -1
  44. package/dist/assets/{requirementDiagram-MS252O5E-D-KTxT1S.js → requirementDiagram-MS252O5E-CiP3d8R4.js} +1 -1
  45. package/dist/assets/{sankeyDiagram-XADWPNL6-CAAThfhf.js → sankeyDiagram-XADWPNL6-RIeASvdJ.js} +1 -1
  46. package/dist/assets/{sequenceDiagram-FGHM5R23-EhYXipit.js → sequenceDiagram-FGHM5R23-Buf7D5PQ.js} +1 -1
  47. package/dist/assets/{stateDiagram-FHFEXIEX-DlwRa19l.js → stateDiagram-FHFEXIEX-5uYn-_xo.js} +1 -1
  48. package/dist/assets/stateDiagram-v2-QKLJ7IA2-CiNPYrtS.js +1 -0
  49. package/dist/assets/{timeline-definition-GMOUNBTQ-CnNt36mp.js → timeline-definition-GMOUNBTQ-fcTegT1X.js} +1 -1
  50. package/dist/assets/{value-BUuNnoEe.js → value-CCp47p1v.js} +1 -1
  51. package/dist/assets/{vennDiagram-DHZGUBPP-CONWdidS.js → vennDiagram-DHZGUBPP-BUY_I73j.js} +1 -1
  52. package/dist/assets/{wardley-RL74JXVD-Dx3T9_uF.js → wardley-RL74JXVD-CfGeUcvr.js} +1 -1
  53. package/dist/assets/{wardleyDiagram-NUSXRM2D-Brxifhti.js → wardleyDiagram-NUSXRM2D-0A6kvF9i.js} +1 -1
  54. package/dist/assets/{xychartDiagram-5P7HB3ND-DkX9QW6S.js → xychartDiagram-5P7HB3ND-C2L50m3n.js} +1 -1
  55. package/dist/index.html +2 -2
  56. package/package.json +2 -2
  57. package/dist/assets/channel-BMnRcRpv.js +0 -1
  58. package/dist/assets/classDiagram-6PBFFD2Q-BpMdbRYm.js +0 -1
  59. package/dist/assets/classDiagram-v2-HSJHXN6E-BpMdbRYm.js +0 -1
  60. package/dist/assets/clone-Bfx4_ecn.js +0 -1
  61. package/dist/assets/stateDiagram-v2-QKLJ7IA2-DWOlnZT2.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/dagre-KV5264BT-7wO_SFt1.js","assets/graph-CT_N4MvP.js","assets/_baseUniq-xbTfIKo7.js","assets/layout-Dwdg17w2.js","assets/min-CWmMAm2D.js","assets/clone-Bfx4_ecn.js","assets/cose-bilkent-S5V4N54A-BFF3VF0W.js","assets/cytoscape.esm-DxGcaOPV.js","assets/c4Diagram-AHTNJAMY-nN4kJiPC.js","assets/chunk-YZCP3GAM-DW9WLjg7.js","assets/flowDiagram-DWJPFMVM-Cign1ovE.js","assets/chunk-FMBD7UC4-Cny1qCNu.js","assets/chunk-55IACEB6-BZHFzH6I.js","assets/chunk-EDXVE4YY-B06PJNq-.js","assets/channel-BMnRcRpv.js","assets/erDiagram-SMLLAGMA-zfdClUWU.js","assets/gitGraphDiagram-UUTBAWPF-DgUNvxqj.js","assets/chunk-4BX2VUAB-DnzQoX6p.js","assets/chunk-QZHKN3VN-Bu8oSEuV.js","assets/wardley-RL74JXVD-Dx3T9_uF.js","assets/ganttDiagram-T4ZO3ILL-zHFblbgr.js","assets/linear-BGLXP-7J.js","assets/value-BUuNnoEe.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-DX6XiGOO.js","assets/infoDiagram-42DDH7IO-B1j6wnrX.js","assets/pieDiagram-DEJITSTG-Dk4TEXCU.js","assets/arc-BJ0Jn4qy.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-34T5L4WZ-DjpGwBeJ.js","assets/xychartDiagram-5P7HB3ND-DkX9QW6S.js","assets/requirementDiagram-MS252O5E-D-KTxT1S.js","assets/sequenceDiagram-FGHM5R23-EhYXipit.js","assets/classDiagram-6PBFFD2Q-BpMdbRYm.js","assets/chunk-4TB4RGXK-PeEeEWP2.js","assets/classDiagram-v2-HSJHXN6E-BpMdbRYm.js","assets/stateDiagram-FHFEXIEX-DlwRa19l.js","assets/chunk-OYMX7WX6-MqHFCczv.js","assets/stateDiagram-v2-QKLJ7IA2-DWOlnZT2.js","assets/journeyDiagram-VCZTEJTY-lXMvtopT.js","assets/timeline-definition-GMOUNBTQ-CnNt36mp.js","assets/mindmap-definition-QFDTVHPH-Bc_KwUJk.js","assets/kanban-definition-6JOO6SKY-D2nd3IRf.js","assets/sankeyDiagram-XADWPNL6-CAAThfhf.js","assets/diagram-TYMM5635-ByagqgDJ.js","assets/diagram-MMDJMWI5-BcJABwZb.js","assets/blockDiagram-DXYQGD6D-BrQpuNBu.js","assets/diagram-5BDNPKRD-DpdLNbTp.js","assets/architectureDiagram-Q4EWVU46-B54hBS8X.js","assets/diagram-G4DWMVQ6-B2Xd9yJj.js","assets/wardleyDiagram-NUSXRM2D-Brxifhti.js","assets/FlowView-rMLtzFZK.js","assets/FlowView-C5ap-Sga.css","assets/FilmWizard-CuCB-1xV.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/dagre-KV5264BT-DuZ4zm4B.js","assets/graph-zC0IkLW4.js","assets/_baseUniq-CHNUfn5h.js","assets/layout-B1_IEbhE.js","assets/min-BGmTIgk7.js","assets/clone-CbLIuAlV.js","assets/cose-bilkent-S5V4N54A-DKMKqdAL.js","assets/cytoscape.esm-DxGcaOPV.js","assets/c4Diagram-AHTNJAMY-CxIpgCiP.js","assets/chunk-YZCP3GAM-JgBXvZgf.js","assets/flowDiagram-DWJPFMVM-bjSm1F6q.js","assets/chunk-FMBD7UC4-DA6v8xvJ.js","assets/chunk-55IACEB6-4u7WcTds.js","assets/chunk-EDXVE4YY-DKvxdCCA.js","assets/channel-BudrdgJ_.js","assets/erDiagram-SMLLAGMA-SWAf-S26.js","assets/gitGraphDiagram-UUTBAWPF-DGaIKwEh.js","assets/chunk-4BX2VUAB-Cf70tfVa.js","assets/chunk-QZHKN3VN-CFgB8UWK.js","assets/wardley-RL74JXVD-CfGeUcvr.js","assets/ganttDiagram-T4ZO3ILL-B3eioyUQ.js","assets/linear-DgZKeCD_.js","assets/value-CCp47p1v.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-DX6XiGOO.js","assets/infoDiagram-42DDH7IO-z7BfWhD6.js","assets/pieDiagram-DEJITSTG-Bai_9_pu.js","assets/arc-CdPV8k-0.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-34T5L4WZ-CgKE3-Ag.js","assets/xychartDiagram-5P7HB3ND-C2L50m3n.js","assets/requirementDiagram-MS252O5E-CiP3d8R4.js","assets/sequenceDiagram-FGHM5R23-Buf7D5PQ.js","assets/classDiagram-6PBFFD2Q-CNYOE6Pk.js","assets/chunk-4TB4RGXK-uFQAF256.js","assets/classDiagram-v2-HSJHXN6E-CNYOE6Pk.js","assets/stateDiagram-FHFEXIEX-5uYn-_xo.js","assets/chunk-OYMX7WX6-DwLlaWl9.js","assets/stateDiagram-v2-QKLJ7IA2-CiNPYrtS.js","assets/journeyDiagram-VCZTEJTY-7szsjnaK.js","assets/timeline-definition-GMOUNBTQ-fcTegT1X.js","assets/mindmap-definition-QFDTVHPH-CaZaCUVQ.js","assets/kanban-definition-6JOO6SKY-CN_iYP62.js","assets/sankeyDiagram-XADWPNL6-RIeASvdJ.js","assets/diagram-TYMM5635-CJ1VtRnc.js","assets/diagram-MMDJMWI5-iB_Pzv_O.js","assets/blockDiagram-DXYQGD6D-CIbxhPHs.js","assets/diagram-5BDNPKRD-CoA3HYsp.js","assets/architectureDiagram-Q4EWVU46-oodkcVSQ.js","assets/diagram-G4DWMVQ6-DVnnKNaz.js","assets/wardleyDiagram-NUSXRM2D-0A6kvF9i.js","assets/FlowView-C6n6r8pJ.js","assets/FlowView-C5ap-Sga.css","assets/FilmWizard-BAeDX_rI.js"])))=>i.map(i=>d[i]);
2
2
  var Lie=Object.defineProperty;var Rie=Object.getPrototypeOf;var Mie=Reflect.get;var OL=e=>{throw TypeError(e)};var Iie=(e,t,r)=>t in e?Lie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ve=(e,t,r)=>Iie(e,typeof t!="symbol"?t+"":t,r),Ok=(e,t,r)=>t.has(e)||OL("Cannot "+r);var es=(e,t,r)=>(Ok(e,t,"read from private field"),r?r.call(e):t.get(e)),ch=(e,t,r)=>t.has(e)?OL("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Xa=(e,t,r,n)=>(Ok(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),Bk=(e,t,r)=>(Ok(e,t,"access private method"),r);var BL=(e,t,r)=>Mie(Rie(e),r,t);function Oie(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(n,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=r(i);fetch(i.href,s)}})();function d1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function RKe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var Dk={exports:{}},em={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -52,7 +52,10 @@ Error generating stack: `+b.message+`
52
52
 
53
53
  ---
54
54
 
55
- `),r+=s.content,s.streaming&&(n=!0);continue}if(s.type==="text"){t+=s.content;continue}i.push(s.execution)}return{content:t,...r?{thinking:r}:{},...n?{thinkingStreaming:!0}:{},...i.length>0?{toolExecutions:i}:{}}}function Fse(e,t){if(t.length===0)return e;const r=new Set((e.toolExecutions??[]).map(l=>l.id)),n=t.filter(l=>!r.has(l.id));if(n.length===0)return e;const i=e.parts??(e.content?[{type:"text",content:e.content}]:[]),s=i.filter(l=>l.type!=="text"),a=i.filter(l=>l.type==="text"),o=[...s,...n.map(l=>({type:"tool",execution:l})),...a];return{...e,...ru(o),parts:o}}function xb(e){return{sessionId:e.sessionId,bookId:e.bookId,sessionKind:e.sessionKind,playMode:e.playMode,title:e.title,messages:e.messages??[],stream:null,isStreaming:!1,isChatStreaming:!1,lastError:null,isDraft:e.isDraft??!1}}function KL(e){return e.filter(t=>t.role==="user"||t.role==="assistant").map(t=>{const r=$se(t),n=[];if(t.thinking&&n.push({type:"thinking",content:t.thinking,streaming:!1}),r)for(const i of r)n.push({type:"tool",execution:i});return t.content&&n.push({type:"text",content:t.content}),{role:t.role,content:t.content,thinking:t.thinking,toolExecutions:r,timestamp:t.timestamp,parts:n.length>0?n:void 0}})}function DF(e,t){let r=!1;const n=e.map(i=>{var c,h,f,g;const s=((c=i.toolExecutions)==null?void 0:c.some(m=>m.id===t.id))??!1,a=((h=i.parts)==null?void 0:h.some(m=>m.type==="tool"&&m.execution.id===t.id))??!1;if(!s&&!a)return i;r=!0;const o=s?(f=i.toolExecutions)==null?void 0:f.map(m=>m.id===t.id?t:m):[...i.toolExecutions??[],t],l=a?(g=i.parts)==null?void 0:g.map(m=>m.type==="tool"&&m.execution.id===t.id?{type:"tool",execution:t}:m):[...i.parts??[],{type:"tool",execution:t}];return{...i,toolExecutions:o,parts:l}});return r?n:[...n,{role:"assistant",content:"",timestamp:t.startedAt,toolExecutions:[t],parts:[{type:"tool",execution:t}]}]}function tw(e,t){const r=t.background?t:{...t,background:!0};return DF(e,r)}function zse(e,t){const r=n=>n.id===t&&(n.status==="running"||n.status==="processing");return e.some(n=>{var i,s;return(((i=n.toolExecutions)==null?void 0:i.some(r))??!1)||(((s=n.parts)==null?void 0:s.some(a=>a.type==="tool"&&r(a.execution)))??!1)})}function rw(e){const t=r=>r.status==="running"||r.status==="processing";return e.some(r=>{var n,i;return(((n=r.toolExecutions)==null?void 0:n.some(t))??!1)||(((i=r.parts)==null?void 0:i.some(s=>s.type==="tool"&&t(s.execution)))??!1)})}function ox(e,t,r){let n=!1;const i=e.map(s=>{var l;if(!(((l=s.parts)==null?void 0:l.some(c=>c.type==="tool"&&c.execution.id===t))??!1))return s;n=!0;const o=(s.parts??[]).map(c=>c.type==="tool"&&c.execution.id===t?{type:"tool",execution:r(c.execution)}:c);return{...s,...ru(o),parts:o}});return n?i:null}function ZL(e,t,r=Date.now(),n=()=>!0){const i=s=>(s.status==="running"||s.status==="processing")&&n(s)?{...s,status:"error",error:t,completedAt:r}:s;return e.map(s=>({...s,...s.toolExecutions?{toolExecutions:s.toolExecutions.map(i)}:{},...s.parts?{parts:s.parts.map(a=>a.type==="tool"?{...a,execution:i(a.execution)}:a)}:{}}))}function $se(e){var n;const t=e.toolExecutions;if(Array.isArray(t))return t;const r=(n=e.legacyDisplay)==null?void 0:n.toolExecutions;return Array.isArray(r)?r:void 0}function Hse(e){if(e.tool!=="propose_action"||e.status!=="completed"||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="proposed_action"?null:typeof t.action=="string"&&t.action.trim()?t.action:null}function Use(e,t){return e.status!=="completed"?!1:t==="create_book"?e.tool==="sub_agent"&&e.agent==="architect":t==="short_run"?e.tool==="short_fiction_run":t==="play_start"?e.tool==="play_start":t==="generate_cover"?e.tool==="generate_cover":t==="script_create"?e.tool==="script_create":t==="storyboard_create"?e.tool==="storyboard_create":t==="interactive_film_create"?e.tool==="interactive_film_create":!1}function QL(e){const t=new Map,r={};for(const n of e)for(const i of n.toolExecutions??[]){const s=Hse(i);if(s){t.set(i.id,s);continue}const a=Array.from(t.entries());for(let o=a.length-1;o>=0;o-=1){const[l,c]=a[o];if(Use(i,c)){r[l]="confirmed",t.delete(l);break}}}return r}function Dr(e,t,r){const n=e[t];return n?{...e,[t]:{...n,...r(n)}}:e}function qse(e,t){const r=e[t.sessionId];return{...e,[t.sessionId]:r?{...r,bookId:t.bookId,sessionKind:t.sessionKind??r.sessionKind,playMode:t.playMode??r.playMode,title:t.title}:xb(t)}}function Im(e,t){if(!(e!=null&&e.length))return[...t];const r=new Set(e),n=t.filter(i=>!r.has(i));return n.length===0?e:[...e,...n]}function Ka(e,t){return!t||typeof t!="object"?!1:t.sessionId===e}const Vse=48,Wse=750;function Hk(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Uk(e){const t=e==null?void 0:e.executionId;return typeof t=="string"&&t?t:void 0}function Gse(e,t){const r=[...e];for(const n of t){if(!n.text)continue;if(n.kind==="thinking"){const s=r[r.length-1];(s==null?void 0:s.type)==="thinking"&&(r[r.length-1]={...s,content:s.content+n.text});continue}const i=r[r.length-1];(i==null?void 0:i.type)==="text"?r[r.length-1]={...i,content:i.content+n.text}:r.push({type:"text",content:n.text})}return r}function Yse(e,t){return[...e??[],...t].slice(-80)}function Xse(e){for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.type==="tool"&&r.execution.status==="running"&&!r.execution.background)return r}}function JL(e,t){for(let r=e.length-1;r>=0;r-=1){const n=e[r],i=Xse(n.parts??[]);if(!i)continue;const s=t(i.execution);if(!s)return null;const a=(n.parts??[]).map(o=>o.type==="tool"&&o.execution.id===i.execution.id?{type:"tool",execution:s}:o);return[...e.slice(0,r),{...n,...ru(a),parts:a},...e.slice(r+1)]}return null}function Kse(e,t=Vse){let r=[],n=null;const i=()=>{n!==null&&(clearTimeout(n),n=null)},s=()=>{if(i(),r.length===0)return;const o=r;r=[],e(o)},a=()=>{n===null&&(n=setTimeout(s,t))};return{enqueue(o){r.push(o),a()},flush:s}}function Zse(e,t=Wse){let r,n=!1,i=null,s=null;const a=()=>{s!==null&&(clearTimeout(s),s=null)},o=h=>{i=Date.now(),e(h)},l=()=>{if(a(),!n)return;const h=r;r=void 0,n=!1,o(h)},c=()=>{if(s!==null)return;const h=i===null?t:Date.now()-i,f=Math.max(0,t-h);s=setTimeout(l,f)};return{enqueue(h){if(i===null){o(h);return}r=h,n=!0,Date.now()-i>=t?l():c()},flush:l}}function eR({sessionId:e,streamTs:t,sourceRequestId:r,streamEs:n,set:i,get:s}){const a=Kse(m=>{i(x=>({sessions:Dr(x.sessions,e,v=>{const[C,k]=rm(v.messages,t),T=Gse(k.parts??[],m),w=ru(T);return{messages:nm(C,{...k,...w,parts:T})}})}))}),o=()=>a.flush(),l=(m,x)=>{var v;return{...m,stages:(v=m.stages)==null?void 0:v.map(C=>C.status==="active"?{...C,progress:{status:x.status,elapsedMs:x.elapsedMs,totalChars:x.totalChars,chineseChars:x.chineseChars}}:C)}},c=new Map,h=m=>{const x=m??"",v=c.get(x);if(v)return v;const C=Zse(k=>{i(T=>({sessions:Dr(T.sessions,e,w=>{const L=m?ox(w.messages,m,N=>N.stages?l(N,k):N):JL(w.messages,N=>N.stages?l(N,k):null);return L?{messages:L}:{}})}))});return c.set(x,C),C},f=()=>{for(const m of c.values())m.flush()};n.addEventListener("draft:complete",o),n.addEventListener("draft:error",o);const g=m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),f();const v=s().sessions[e];if(!v||v.isChatStreaming||rw(v.messages))return;n.close(),i(C=>({sessions:Dr(C.sessions,e,()=>({isStreaming:!1,stream:null}))}))}catch{}};n.addEventListener("agent:complete",g),n.addEventListener("agent:error",g),n.addEventListener("task:snapshot",m=>{var x,v;try{const C=m.data?JSON.parse(m.data):null;if(!Ka(e,C)||!(C!=null&&C.execution))return;const k=C.execution,T=k.status==="running"||k.status==="processing",w=T&&typeof r=="string"&&C.sourceRequestId===r;if(!T&&!zse(((x=s().sessions[e])==null?void 0:x.messages)??[],k.id))return;const L=!!((v=s().sessions[e])!=null&&v.isChatStreaming),N=T||L;i(A=>({sessions:Dr(A.sessions,e,R=>({messages:tw(R.messages,k),isStreaming:N,...w&&R.isChatStreaming?{isChatStreaming:!1}:{},stream:N?R.stream:null}))})),N||n.close()}catch{}}),n.addEventListener("agent:aborted",g),n.addEventListener("thinking:start",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),i(v=>({sessions:Dr(v.sessions,e,C=>{const[k,T]=rm(C.messages,t),w=[...T.parts??[],{type:"thinking",content:"",streaming:!0}],L=ru(w);return{messages:nm(k,{...T,...L,parts:w})}})}))}catch{}}),n.addEventListener("thinking:delta",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.text))return;a.enqueue({kind:"thinking",text:x.text})}catch{}}),n.addEventListener("thinking:end",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),i(v=>({sessions:Dr(v.sessions,e,C=>{const[k,T]=rm(C.messages,t),w=[...T.parts??[]],L=w[w.length-1];(L==null?void 0:L.type)==="thinking"&&(w[w.length-1]={...L,streaming:!1});const N=ru(w);return{messages:nm(k,{...T,...N,parts:w})}})}))}catch{}}),n.addEventListener("draft:delta",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.text))return;a.enqueue({kind:"text",text:x.text})}catch{}}),n.addEventListener("tool:start",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.tool))return;const v=x.background===!0,C=typeof r=="string"&&x.sourceRequestId===r;o(),i(k=>({sessions:Dr(k.sessions,e,T=>{var U;const w=x.id;if(T.messages.some(W=>{var J,G;return((J=W.toolExecutions)==null?void 0:J.some(O=>O.id===w))||((G=W.parts)==null?void 0:G.some(O=>O.type==="tool"&&O.execution.id===w))}))return v&&C&&T.isChatStreaming?{isChatStreaming:!1}:{};const[N,A]=rm(T.messages,t),R=[...A.parts??[]];if(x.tool==="sub_agent"){const W=R[R.length-1];if((W==null?void 0:W.type)==="text"&&W.content){R.pop();const J=R[R.length-1];(J==null?void 0:J.type)==="thinking"?R[R.length-1]={...J,content:J.content+(J.content?`
55
+ `),r+=s.content,s.streaming&&(n=!0);continue}if(s.type==="text"){t&&!t.endsWith(`
56
+ `)&&(t+=`
57
+
58
+ `),t+=s.content;continue}i.push(s.execution)}return{content:t,...r?{thinking:r}:{},...n?{thinkingStreaming:!0}:{},...i.length>0?{toolExecutions:i}:{}}}function Fse(e,t){if(t.length===0)return e;const r=new Set((e.toolExecutions??[]).map(l=>l.id)),n=t.filter(l=>!r.has(l.id));if(n.length===0)return e;const i=e.parts??(e.content?[{type:"text",content:e.content}]:[]),s=i.filter(l=>l.type!=="text"),a=i.filter(l=>l.type==="text"),o=[...s,...n.map(l=>({type:"tool",execution:l})),...a];return{...e,...ru(o),parts:o}}function xb(e){return{sessionId:e.sessionId,bookId:e.bookId,sessionKind:e.sessionKind,playMode:e.playMode,title:e.title,messages:e.messages??[],stream:null,isStreaming:!1,isChatStreaming:!1,lastError:null,isDraft:e.isDraft??!1}}function KL(e){return e.filter(t=>t.role==="user"||t.role==="assistant").map(t=>{const r=$se(t),n=[];if(t.thinking&&n.push({type:"thinking",content:t.thinking,streaming:!1}),r)for(const i of r)n.push({type:"tool",execution:i});return t.content&&n.push({type:"text",content:t.content}),{role:t.role,content:t.content,thinking:t.thinking,toolExecutions:r,timestamp:t.timestamp,parts:n.length>0?n:void 0}})}function DF(e,t){let r=!1;const n=e.map(i=>{var c,h,f,g;const s=((c=i.toolExecutions)==null?void 0:c.some(m=>m.id===t.id))??!1,a=((h=i.parts)==null?void 0:h.some(m=>m.type==="tool"&&m.execution.id===t.id))??!1;if(!s&&!a)return i;r=!0;const o=s?(f=i.toolExecutions)==null?void 0:f.map(m=>m.id===t.id?t:m):[...i.toolExecutions??[],t],l=a?(g=i.parts)==null?void 0:g.map(m=>m.type==="tool"&&m.execution.id===t.id?{type:"tool",execution:t}:m):[...i.parts??[],{type:"tool",execution:t}];return{...i,toolExecutions:o,parts:l}});return r?n:[...n,{role:"assistant",content:"",timestamp:t.startedAt,toolExecutions:[t],parts:[{type:"tool",execution:t}]}]}function tw(e,t){const r=t.background?t:{...t,background:!0};return DF(e,r)}function zse(e,t){const r=n=>n.id===t&&(n.status==="running"||n.status==="processing");return e.some(n=>{var i,s;return(((i=n.toolExecutions)==null?void 0:i.some(r))??!1)||(((s=n.parts)==null?void 0:s.some(a=>a.type==="tool"&&r(a.execution)))??!1)})}function rw(e){const t=r=>r.status==="running"||r.status==="processing";return e.some(r=>{var n,i;return(((n=r.toolExecutions)==null?void 0:n.some(t))??!1)||(((i=r.parts)==null?void 0:i.some(s=>s.type==="tool"&&t(s.execution)))??!1)})}function ox(e,t,r){let n=!1;const i=e.map(s=>{var l;if(!(((l=s.parts)==null?void 0:l.some(c=>c.type==="tool"&&c.execution.id===t))??!1))return s;n=!0;const o=(s.parts??[]).map(c=>c.type==="tool"&&c.execution.id===t?{type:"tool",execution:r(c.execution)}:c);return{...s,...ru(o),parts:o}});return n?i:null}function ZL(e,t,r=Date.now(),n=()=>!0){const i=s=>(s.status==="running"||s.status==="processing")&&n(s)?{...s,status:"error",error:t,completedAt:r}:s;return e.map(s=>({...s,...s.toolExecutions?{toolExecutions:s.toolExecutions.map(i)}:{},...s.parts?{parts:s.parts.map(a=>a.type==="tool"?{...a,execution:i(a.execution)}:a)}:{}}))}function $se(e){var n;const t=e.toolExecutions;if(Array.isArray(t))return t;const r=(n=e.legacyDisplay)==null?void 0:n.toolExecutions;return Array.isArray(r)?r:void 0}function Hse(e){if(e.tool!=="propose_action"||e.status!=="completed"||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="proposed_action"?null:typeof t.action=="string"&&t.action.trim()?t.action:null}function Use(e,t){return e.status!=="completed"?!1:t==="create_book"?e.tool==="sub_agent"&&e.agent==="architect":t==="short_run"?e.tool==="short_fiction_run":t==="play_start"?e.tool==="play_start":t==="generate_cover"?e.tool==="generate_cover":t==="script_create"?e.tool==="script_create":t==="storyboard_create"?e.tool==="storyboard_create":t==="interactive_film_create"?e.tool==="interactive_film_create":!1}function QL(e){const t=new Map,r={};for(const n of e)for(const i of n.toolExecutions??[]){const s=Hse(i);if(s){t.set(i.id,s);continue}const a=Array.from(t.entries());for(let o=a.length-1;o>=0;o-=1){const[l,c]=a[o];if(Use(i,c)){r[l]="confirmed",t.delete(l);break}}}return r}function Dr(e,t,r){const n=e[t];return n?{...e,[t]:{...n,...r(n)}}:e}function qse(e,t){const r=e[t.sessionId];return{...e,[t.sessionId]:r?{...r,bookId:t.bookId,sessionKind:t.sessionKind??r.sessionKind,playMode:t.playMode??r.playMode,title:t.title}:xb(t)}}function Im(e,t){if(!(e!=null&&e.length))return[...t];const r=new Set(e),n=t.filter(i=>!r.has(i));return n.length===0?e:[...e,...n]}function Ka(e,t){return!t||typeof t!="object"?!1:t.sessionId===e}const Vse=48,Wse=750;function Hk(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Uk(e){const t=e==null?void 0:e.executionId;return typeof t=="string"&&t?t:void 0}function Gse(e,t){const r=[...e];for(const n of t){if(!n.text)continue;if(n.kind==="thinking"){const s=r[r.length-1];(s==null?void 0:s.type)==="thinking"&&(r[r.length-1]={...s,content:s.content+n.text});continue}const i=r[r.length-1];(i==null?void 0:i.type)==="text"?r[r.length-1]={...i,content:i.content+n.text}:r.push({type:"text",content:n.text})}return r}function Yse(e,t){return[...e??[],...t].slice(-80)}function Xse(e){for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.type==="tool"&&r.execution.status==="running"&&!r.execution.background)return r}}function JL(e,t){for(let r=e.length-1;r>=0;r-=1){const n=e[r],i=Xse(n.parts??[]);if(!i)continue;const s=t(i.execution);if(!s)return null;const a=(n.parts??[]).map(o=>o.type==="tool"&&o.execution.id===i.execution.id?{type:"tool",execution:s}:o);return[...e.slice(0,r),{...n,...ru(a),parts:a},...e.slice(r+1)]}return null}function Kse(e,t=Vse){let r=[],n=null;const i=()=>{n!==null&&(clearTimeout(n),n=null)},s=()=>{if(i(),r.length===0)return;const o=r;r=[],e(o)},a=()=>{n===null&&(n=setTimeout(s,t))};return{enqueue(o){r.push(o),a()},flush:s}}function Zse(e,t=Wse){let r,n=!1,i=null,s=null;const a=()=>{s!==null&&(clearTimeout(s),s=null)},o=h=>{i=Date.now(),e(h)},l=()=>{if(a(),!n)return;const h=r;r=void 0,n=!1,o(h)},c=()=>{if(s!==null)return;const h=i===null?t:Date.now()-i,f=Math.max(0,t-h);s=setTimeout(l,f)};return{enqueue(h){if(i===null){o(h);return}r=h,n=!0,Date.now()-i>=t?l():c()},flush:l}}function eR({sessionId:e,streamTs:t,sourceRequestId:r,streamEs:n,set:i,get:s}){const a=Kse(m=>{i(x=>({sessions:Dr(x.sessions,e,v=>{const[C,k]=rm(v.messages,t),T=Gse(k.parts??[],m),w=ru(T);return{messages:nm(C,{...k,...w,parts:T})}})}))}),o=()=>a.flush(),l=(m,x)=>{var v;return{...m,stages:(v=m.stages)==null?void 0:v.map(C=>C.status==="active"?{...C,progress:{status:x.status,elapsedMs:x.elapsedMs,totalChars:x.totalChars,chineseChars:x.chineseChars}}:C)}},c=new Map,h=m=>{const x=m??"",v=c.get(x);if(v)return v;const C=Zse(k=>{i(T=>({sessions:Dr(T.sessions,e,w=>{const L=m?ox(w.messages,m,N=>N.stages?l(N,k):N):JL(w.messages,N=>N.stages?l(N,k):null);return L?{messages:L}:{}})}))});return c.set(x,C),C},f=()=>{for(const m of c.values())m.flush()};n.addEventListener("draft:complete",o),n.addEventListener("draft:error",o);const g=m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),f();const v=s().sessions[e];if(!v||v.isChatStreaming||rw(v.messages))return;n.close(),i(C=>({sessions:Dr(C.sessions,e,()=>({isStreaming:!1,stream:null}))}))}catch{}};n.addEventListener("agent:complete",g),n.addEventListener("agent:error",g),n.addEventListener("task:snapshot",m=>{var x,v;try{const C=m.data?JSON.parse(m.data):null;if(!Ka(e,C)||!(C!=null&&C.execution))return;const k=C.execution,T=k.status==="running"||k.status==="processing",w=T&&typeof r=="string"&&C.sourceRequestId===r;if(!T&&!zse(((x=s().sessions[e])==null?void 0:x.messages)??[],k.id))return;const L=!!((v=s().sessions[e])!=null&&v.isChatStreaming),N=T||L;i(A=>({sessions:Dr(A.sessions,e,R=>({messages:tw(R.messages,k),isStreaming:N,...w&&R.isChatStreaming?{isChatStreaming:!1}:{},stream:N?R.stream:null}))})),N||n.close()}catch{}}),n.addEventListener("agent:aborted",g),n.addEventListener("thinking:start",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),i(v=>({sessions:Dr(v.sessions,e,C=>{const[k,T]=rm(C.messages,t),w=[...T.parts??[],{type:"thinking",content:"",streaming:!0}],L=ru(w);return{messages:nm(k,{...T,...L,parts:w})}})}))}catch{}}),n.addEventListener("thinking:delta",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.text))return;a.enqueue({kind:"thinking",text:x.text})}catch{}}),n.addEventListener("thinking:end",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),i(v=>({sessions:Dr(v.sessions,e,C=>{const[k,T]=rm(C.messages,t),w=[...T.parts??[]],L=w[w.length-1];(L==null?void 0:L.type)==="thinking"&&(w[w.length-1]={...L,streaming:!1});const N=ru(w);return{messages:nm(k,{...T,...N,parts:w})}})}))}catch{}}),n.addEventListener("draft:delta",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.text))return;a.enqueue({kind:"text",text:x.text})}catch{}}),n.addEventListener("tool:start",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.tool))return;const v=x.background===!0,C=typeof r=="string"&&x.sourceRequestId===r;o(),i(k=>({sessions:Dr(k.sessions,e,T=>{var U;const w=x.id;if(T.messages.some(W=>{var J,G;return((J=W.toolExecutions)==null?void 0:J.some(O=>O.id===w))||((G=W.parts)==null?void 0:G.some(O=>O.type==="tool"&&O.execution.id===w))}))return v&&C&&T.isChatStreaming?{isChatStreaming:!1}:{};const[N,A]=rm(T.messages,t),R=[...A.parts??[]];if(x.tool==="sub_agent"){const W=R[R.length-1];if((W==null?void 0:W.type)==="text"&&W.content){R.pop();const J=R[R.length-1];(J==null?void 0:J.type)==="thinking"?R[R.length-1]={...J,content:J.content+(J.content?`
56
59
 
57
60
  `:"")+W.content}:R.push({type:"thinking",content:W.content,streaming:!1})}}const P=x.tool==="sub_agent"?(U=x.args)==null?void 0:U.agent:void 0,q=Array.isArray(x.stages)&&x.stages.length>0?x.stages.map(W=>({label:W,status:"pending"})):void 0;R.push({type:"tool",execution:{id:w,tool:x.tool,agent:P,label:Ose(x.tool,P),status:"running",args:x.args,stages:q,startedAt:Date.now(),...v?{background:!0}:{}}});const j=ru(R);return{messages:nm(N,{...A,...j,parts:R}),...v&&C&&T.isChatStreaming?{isChatStreaming:!1}:{}}})}))}catch{}}),n.addEventListener("tool:end",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.tool))return;o(),f(),i(v=>({sessions:Dr(v.sessions,e,C=>{const k=ox(C.messages,x.id,T=>{var N;const w={...T};w.status=x.isError?"error":"completed",w.completedAt=Date.now(),w.stages=(N=w.stages)==null?void 0:N.map(A=>A.status!=="completed"?{...A,status:"completed",progress:void 0}:A),x.isError?w.error=Pse(x.result):w.result=Bse(x.result);const L=x.details??Dse(x.result);return L!==void 0&&(w.details=L),w});return k?{messages:k}:{}})})),Ase(x.tool)&&s().bumpBookDataVersion()}catch{}}),n.addEventListener("log",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;const v=x==null?void 0:x.message;if(!v)return;const C=Uk(x);o(),i(k=>({sessions:Dr(k.sessions,e,T=>{const w=N=>({...N,logs:Yse(N.logs,[v])}),L=C?ox(T.messages,C,w):JL(T.messages,w);return L?{messages:L}:{}})}))}catch{}}),n.addEventListener("llm:progress",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x))return;o(),h(Uk(x)).enqueue({status:typeof x.status=="string"?x.status:void 0,elapsedMs:Hk(x.elapsedMs),totalChars:Hk(x.totalChars),chineseChars:Hk(x.chineseChars)})}catch{}}),n.addEventListener("context:compression",m=>{try{const x=m.data?JSON.parse(m.data):null;if(!Ka(e,x)||!(x!=null&&x.category)||!x.phase)return;const v=x.category,C=x.phase,k=Uk(x);i(T=>({sessions:Dr(T.sessions,e,w=>{if(k){const P=ox(w.messages,k,q=>tae(q,v,C,x));return P?{messages:P}:{}}const[L,N]=rm(w.messages,t),A=[...N.parts??[]];rae(A,v,C,x);const R=ru(A);return{messages:nm(L,{...N,...R,parts:A})}})}))}catch{}})}function _f(e){return e==="session_context"?V("整理会话记忆","Organize session memory","Sắp xếp bộ nhớ phiên"):V("压缩故事上下文","Compress story context","Nén ngữ cảnh câu chuyện")}function Qse(e){if(!e||e.length===0)return"";const t=e.slice(0,3).join(", "),r=e.length>3?` +${e.length-3}`:"";return`${V("来源","sources","nguồn")} ${e.length}: ${t}${r}`}function Jse(e){if(e.phase!=="start")return;const t=[e.protectedTokens!==void 0?`${V("保护","protected","bảo vệ")} ${e.protectedTokens}`:"",e.compressibleTokens!==void 0?`${V("可压缩","compressible","có thể nén")} ${e.compressibleTokens}`:"",e.budgetTokens!==void 0?`${V("预算","budget","ngân sách")} ${e.budgetTokens}`:"",Qse(e.sources)].filter(Boolean);return{status:t.length>0?t.join(" · "):"compressing",elapsedMs:0,totalChars:0,chineseChars:0}}function nw(e,t,r,n){const i=_f(t),a=(e==null?void 0:e.some(l=>l.label===i))??!1?[...e??[]]:[...e??[],{label:i,status:"pending"}],o=r==="start"?"active":"completed";return a.map(l=>l.label===i?{...l,status:o,progress:r==="start"?Jse(n):void 0}:l)}function eae(e){const t=jse(e);return t==null?void 0:t.execution}function tae(e,t,r,n){const i=nw(e.stages,t,r,n);return r==="error"?{...e,stages:i,status:"error",error:n.message??`${_f(t)}${V("失败"," failed"," thất bại")}`}:{...e,stages:i}}function rae(e,t,r,n){const i=t==="session_context"?void 0:eae(e);if(i){i.stages=nw(i.stages,t,r,n),r==="error"&&(i.status="error",i.error=n.message??`${_f(t)}${V("失败"," failed"," thất bại")}`);return}const s=`context-${t}`,a=e.find(c=>c.type==="tool"&&c.execution.id===s),o=r==="start"?"running":r==="error"?"error":"completed",l=(a==null?void 0:a.execution)??{id:s,tool:"context_compression",label:_f(t),status:o,stages:[],startedAt:Date.now()};l.status=o,l.label=_f(t),l.stages=nw(l.stages,t,r,n),r!=="start"&&(l.completedAt=Date.now()),r==="error"&&(l.error=n.message??`${_f(t)}${V("失败"," failed"," thất bại")}`),a||e.push({type:"tool",execution:l})}const nae=/(^|\s)@([a-z][a-z0-9-]*)(?=\s|$)/gi;function iae(e){const t=[],r=new Set;return{instruction:e.replace(nae,(i,s,a)=>{const o=a.toLowerCase();return r.has(o)||(r.add(o),t.push(o)),s}).replace(/\s+/g," ").trim()||e.trim(),requestedSkills:t}}function tR(e,t){const r=[],n=new Set;for(const i of[...e,...t??[]]){const s=i.trim().toLowerCase();!s||n.has(s)||(n.add(s),r.push(s))}return r}function sae(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.ceil(e/1024)} KB`:`${e} B`}function rR(e,t){if(t.length===0)return e;const r=V("附件:","Attachments:","Tệp đính kèm:"),n=e?[e,"",r]:[r];for(const i of t)n.push(`- ${i.filename} (${i.mediaType||"application/octet-stream"}, ${sae(i.size)})`);return n.join(`
58
61
  `)}const aae=(e,t)=>{const r=n=>{var s;const i=t().activeSessionId;!i||i===n||(s=t().sessions[i])!=null&&s.isChatStreaming&&t().abortSession(i,"chat")};return{activateSession:n=>{r(n),e({activeSessionId:n})},setSessionPlayMode:(n,i)=>{const s=t().sessions[n];e(a=>({sessions:Dr(a.sessions,n,()=>({playMode:i}))})),!(s!=null&&s.isDraft)&&ct(`/sessions/${n}/play-mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({playMode:i})}).catch(()=>{})},setInput:n=>e({input:n}),addUserMessage:(n,i)=>e(s=>({sessions:Dr(s.sessions,n,a=>({messages:[...a.messages,{role:"user",content:i,timestamp:Date.now()}],lastError:null}))})),appendStreamChunk:(n,i,s)=>e(a=>({sessions:Dr(a.sessions,n,o=>{const l=o.messages[o.messages.length-1];return(l==null?void 0:l.timestamp)===s&&l.role==="assistant"?{messages:[...o.messages.slice(0,-1),{...l,content:l.content+i}]}:{messages:[...o.messages,{role:"assistant",content:i,timestamp:s}]}})})),finalizeStream:(n,i,s,a)=>e(o=>({sessions:Dr(o.sessions,n,l=>({messages:l.messages.map(c=>{if(c.timestamp!==i||c.role!=="assistant")return c;const h=[...c.parts??[]],f=h[h.length-1];return(f==null?void 0:f.type)==="text"?h[h.length-1]={...f,content:s}:s&&h.push({type:"text",content:s}),{...c,content:s,toolCall:a,parts:h}})}))})),replaceStreamWithError:(n,i,s)=>e(a=>({sessions:Dr(a.sessions,n,o=>{const l=o.messages.find(g=>g.timestamp===i&&g.role==="assistant");return{messages:[...(l==null?void 0:l.toolExecutions)??[],...((l==null?void 0:l.parts)??[]).flatMap(g=>g.type==="tool"?[g.execution]:[])].some(g=>g.status==="running"||g.status==="processing"||g.status==="error")?o.messages.map(g=>g.timestamp===i&&g.role==="assistant"?ZL([g],s)[0]:g):[...o.messages.filter(g=>!(g.timestamp===i&&g.role==="assistant")),{role:"assistant",content:`✗ ${s}`,timestamp:Date.now()}],lastError:s}})})),addErrorMessage:(n,i)=>e(s=>({sessions:Dr(s.sessions,n,a=>({messages:[...a.messages,{role:"assistant",content:`✗ ${i}`,timestamp:Date.now()}],lastError:i}))})),loadSessionMessages:(n,i)=>e(s=>{const a=s.sessions[n];if(!a||a.messages.length>0)return{};const o=KL(i);return{sessions:Dr(s.sessions,n,()=>({messages:o})),resolvedProposals:{...s.resolvedProposals,...QL(o)}}}),setSelectedModel:(n,i)=>e({selectedModel:n,selectedService:i}),loadSessionList:async n=>{const i=n===null?"null":encodeURIComponent(n);try{const s=await ct(`/sessions?bookId=${i}`);return e(a=>{let o=a.sessions;for(const l of s.sessions)o=qse(o,l);return{sessions:o,sessionIdsByBook:{...a.sessionIdsByBook,[Aa(n)]:s.sessions.map(l=>l.sessionId)}}}),s.sessions}catch{return[]}},createSession:async(n,i,s)=>{var l;r(null);const a=await ct("/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookId:n,sessionKind:i,playMode:s})}),o=(l=a.session)==null?void 0:l.sessionId;if(!o)throw new Error("Failed to create session");return e(c=>{var f,g,m,x;const h=xb({sessionId:o,bookId:((f=a.session)==null?void 0:f.bookId)??n??null,sessionKind:((g=a.session)==null?void 0:g.sessionKind)??i,playMode:(m=a.session)==null?void 0:m.playMode,title:((x=a.session)==null?void 0:x.title)??null});return{sessions:{...c.sessions,[o]:h},sessionIdsByBook:{...c.sessionIdsByBook,[Aa(h.bookId)]:Im(c.sessionIdsByBook[Aa(h.bookId)],[o])},activeSessionId:o}}),o},createDraftSession:(n,i,s)=>{r(null);const a=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e(o=>{const l=xb({sessionId:a,bookId:n,sessionKind:i,playMode:s,title:null,isDraft:!0});return{sessions:{...o.sessions,[a]:l},activeSessionId:a}}),a},renameSession:async(n,i)=>{var a;const s=((a=t().sessions[n])==null?void 0:a.title)??null;e(o=>({sessions:Dr(o.sessions,n,()=>({title:i}))}));try{await ct(`/sessions/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:i})})}catch{e(o=>({sessions:Dr(o.sessions,n,()=>({title:s}))}))}},deleteSession:async n=>{var s;const i=t().sessions[n];if((s=i==null?void 0:i.stream)==null||s.close(),i&&!i.isDraft)try{await ct(`/sessions/${n}`,{method:"DELETE"})}catch{}e(a=>{var f;const{[n]:o,...l}=a.sessions,c=Object.fromEntries(Object.entries(a.sessionIdsByBook).map(([g,m])=>[g,m.filter(x=>x!==n)]));let h=a.activeSessionId;if(h===n){const g=Aa((i==null?void 0:i.bookId)??null);h=((f=c[g])==null?void 0:f[0])??null}return{sessions:l,sessionIdsByBook:c,activeSessionId:h}})},abortSession:async(n,i="all")=>{var f;const s=t().sessions[n],a=Date.now(),o=V("已由用户停止","Stopped by user","Đã dừng bởi người dùng"),l=i==="chat",c=ZL((s==null?void 0:s.messages)??[],o,a,g=>!l||g.background!==!0),h=l&&rw(c);h||(f=s==null?void 0:s.stream)==null||f.close(),e(g=>({sessions:Dr(g.sessions,n,m=>({isStreaming:h,isChatStreaming:!1,stream:h?m.stream:null,lastError:null,messages:c}))}));try{await ct(`/sessions/${n}/abort${l?"?scope=chat":""}`,{method:"POST"})}catch(g){t().addErrorMessage(n,g instanceof Error?g.message:String(g))}},loadSessionDetail:async n=>{var s;const i=t().sessions[n];if(!(i!=null&&i.isDraft)&&!(i!=null&&i.isStreaming&&i.stream))try{const a=await ct(`/sessions/${n}`),o=a.session;if(!(o!=null&&o.sessionId))return;const l=o.sessionId,c=o.messages?KL(o.messages):[],h=a.task,f=(h==null?void 0:h.execution.status)==="running"||(h==null?void 0:h.execution.status)==="processing";let g=c;h&&(g=tw(g,h.execution));const m=g,x=QL(m);if(e(v=>{const C=v.sessions[l],k=o.bookId??(C==null?void 0:C.bookId)??null,T=C!=null&&C.messages.length?C.messages:m,w=h?tw(T,h.execution):T;return{sessions:{...v.sessions,[l]:{...C??xb({sessionId:l,bookId:k,sessionKind:o.sessionKind,playMode:o.playMode,title:o.title??null}),bookId:k,sessionKind:o.sessionKind??(C==null?void 0:C.sessionKind),playMode:o.playMode??(C==null?void 0:C.playMode),title:o.title??(C==null?void 0:C.title)??null,messages:w,isStreaming:f}},sessionIdsByBook:{...v.sessionIdsByBook,[Aa(k)]:Im(v.sessionIdsByBook[Aa(k)],[l])},resolvedProposals:{...v.resolvedProposals,...x}}}),f&&h){const v=t().sessions[l];(s=v==null?void 0:v.stream)==null||s.close();const C=new EventSource(`/api/v1/events?sessionId=${encodeURIComponent(l)}`);e(k=>({sessions:Dr(k.sessions,l,()=>({stream:C,isStreaming:!0}))})),eR({sessionId:l,streamTs:h.execution.startedAt,streamEs:C,set:e,get:t})}}catch{}},sendMessage:async(n,i,s)=>{var R,P,q,j,U,W,J,G,O,D,H,Y,ae,z,K;const a=i.trim(),o=(s==null?void 0:s.attachments)??[],l=t().sessions[n];if(!a&&o.length===0||!l||l.isChatStreaming)return;const c=a||V("请阅读我上传的文件。","Please read the files I uploaded."),h=(s==null?void 0:s.activeBookId)??l.bookId??void 0,f=(s==null?void 0:s.sessionKind)??l.sessionKind??(h?"book":"chat"),g=(s==null?void 0:s.actionSource)??"free-text",m=(s==null?void 0:s.playMode)??l.playMode,x=Nse(g,s==null?void 0:s.requestedIntent),v=()=>{x||e(se=>({sessions:Dr(se.sessions,n,()=>({lastFailedSend:s?{text:i,options:s}:{text:i}}))}))};if(!t().selectedModel){t().addUserMessage(n,rR(c,o)),t().addErrorMessage(n,V("请先选择一个模型","Select a model first","Vui lòng chọn model trước")),v();return}if(l.isDraft)try{await ct("/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n,bookId:l.bookId,sessionKind:f,playMode:m})}),e(se=>({sessions:Dr(se.sessions,n,()=>({isDraft:!1,sessionKind:f,playMode:m})),sessionIdsByBook:{...se.sessionIdsByBook,[Aa(l.bookId)]:Im(se.sessionIdsByBook[Aa(l.bookId)],[n])}}))}catch(se){t().addErrorMessage(n,se instanceof Error?se.message:String(se)),v();return}const C=iae(c),k=C.instruction,T=tR(C.requestedSkills,s==null?void 0:s.requestedSkills),w=tR([],s==null?void 0:s.disabledSkills),L=Date.now()+1,N=wse();e(se=>({input:"",activeSessionId:n,sessions:Dr(se.sessions,n,()=>({isStreaming:!0,isChatStreaming:!x,lastError:null,lastFailedSend:void 0}))})),t().addUserMessage(n,rR(c,o)),(R=l.stream)==null||R.close();const A=new EventSource(`/api/v1/events?sessionId=${encodeURIComponent(n)}`);e(se=>({sessions:Dr(se.sessions,n,()=>({stream:A}))})),eR({sessionId:n,streamTs:L,sourceRequestId:N,streamEs:A,set:e,get:t});try{const se=await ct("/agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({instruction:k,activeBookId:h,sessionKind:f,playMode:m,actionSource:g,requestedIntent:s==null?void 0:s.requestedIntent,actionPayload:s==null?void 0:s.actionPayload,requestedSkills:T,disabledSkills:w,attachments:o,sessionId:n,clientRequestId:N,model:t().selectedModel??void 0,service:t().selectedService??void 0})}),X=((P=se.details)==null?void 0:P.draftRaw)||se.response||"",ke=((q=se.details)==null?void 0:q.toolCall)??void 0,ye=((j=se.details)==null?void 0:j.toolExecutions)??[],we=((U=se.session)==null?void 0:U.activeBookId)??((W=se.session)==null?void 0:W.bookId),Fe=(J=se.session)==null?void 0:J.sessionKind;(we||Fe||(G=se.session)!=null&&G.title||(O=se.session)!=null&&O.playMode)&&e(Te=>{const Ue=Te.sessions[n];if(!Ue)return{};const Qe=we??Ue.bookId;return{sessions:Dr(Te.sessions,n,()=>{var We,de;return{bookId:Qe,sessionKind:Fe??Ue.sessionKind,playMode:((We=se.session)==null?void 0:We.playMode)??Ue.playMode,title:((de=se.session)==null?void 0:de.title)??Ue.title}}),sessionIdsByBook:{...Te.sessionIdsByBook,[Aa(Qe)]:Im(Te.sessionIdsByBook[Aa(Qe)],[n])}}});const ue=!!((D=t().sessions[n])!=null&&D.messages.some(Te=>Te.timestamp===L)),Ne=()=>{ye.length!==0&&e(Te=>({sessions:Dr(Te.sessions,n,Ue=>({messages:ye.reduce((Qe,We)=>DF(Qe,We),Ue.messages)}))}))};if(se.error){const Te=Ise(se.error);ue?t().replaceStreamWithError(n,L,Te):t().addErrorMessage(n,Te),(H=t().sessions[n])!=null&&H.isChatStreaming&&v()}else if(X)if(ue)t().finalizeStream(n,L,X,ke),Ne();else{const Te=Fse({role:"assistant",content:X,timestamp:Date.now(),toolCall:ke},ye);e(Ue=>({sessions:Dr(Ue.sessions,n,Qe=>({messages:[...Qe.messages,Te]}))}))}else if(ye.length>0)ue&&t().finalizeStream(n,L,"",ke),Ne();else if(ue)t().finalizeStream(n,L,"",ke);else{const Te=V("模型未返回文本内容。请检查协议类型(chat/responses)、流式开关或上游服务兼容性。","The model returned no text. Check the protocol type (chat/responses), the streaming toggle, or upstream service compatibility.","Model không trả về nội dung văn bản. Hãy kiểm tra loại giao thức (chat/responses), công tắc streaming, hoặc khả năng tương thích của dịch vụ upstream.");t().addErrorMessage(n,Te),(Y=t().sessions[n])!=null&&Y.isChatStreaming&&v()}}catch(se){const X=se instanceof Error?se.message:String(se);if((ae=t().sessions[n])!=null&&ae.isChatStreaming&&v(),((z=t().sessions[n])==null?void 0:z.messages.some(we=>[...we.toolExecutions??[],...(we.parts??[]).flatMap(ue=>ue.type==="tool"?[ue.execution]:[])].some(ue=>ue.status==="error"&&(ue.completedAt??0)>=L)))??!1)return;!!((K=t().sessions[n])!=null&&K.messages.some(we=>we.timestamp===L))?t().replaceStreamWithError(n,L,X):t().addErrorMessage(n,X)}finally{const se=t().sessions[n];if(se&&(se.stream===A||se.stream===null)){const X=rw(se.messages);X||A.close(),e(ke=>({sessions:Dr(ke.sessions,n,()=>({isChatStreaming:!1,isStreaming:X,stream:X?A:null}))}))}}},retryLastSend:async n=>{const i=t().sessions[n],s=i==null?void 0:i.lastFailedSend;!i||!s||i.isChatStreaming||(e(a=>({sessions:Dr(a.sessions,n,()=>({lastFailedSend:void 0}))})),await t().sendMessage(n,s.text,s.options))}}},oae=e=>({bumpBookDataVersion:()=>e(t=>({bookDataVersion:t.bookDataVersion+1})),openArtifact:t=>e({sidebarView:"artifact",artifactFile:t,artifactChapter:null}),openChapterArtifact:t=>e({sidebarView:"artifact",artifactFile:null,artifactChapter:t}),closeArtifact:()=>e({sidebarView:"panel",artifactFile:null,artifactChapter:null}),openProjectArtifact:t=>e({projectArtifactPath:t}),closeProjectArtifact:()=>e({projectArtifactPath:null}),setBookSummary:t=>e({bookSummary:t}),markProposalResolved:(t,r)=>e(n=>({resolvedProposals:{...n.resolvedProposals,[t]:r}}))}),Ht=f_()((...e)=>({...kse,...aae(...e),...oae(...e)})),lae=[],yf={activeSession:e=>e.activeSessionId?e.sessions[e.activeSessionId]??null:null,activeMessages:e=>{var t;return(e.activeSessionId?(t=e.sessions[e.activeSessionId])==null?void 0:t.messages:void 0)??lae},isActiveSessionStreaming:e=>{var t;return!!(e.activeSessionId&&((t=e.sessions[e.activeSessionId])!=null&&t.isStreaming))},isActiveSessionChatStreaming:e=>{var t;return!!(e.activeSessionId&&((t=e.sessions[e.activeSessionId])!=null&&t.isChatStreaming))},activeSessionLastFailedSend:e=>{var t;return(e.activeSessionId?(t=e.sessions[e.activeSessionId])==null?void 0:t.lastFailedSend:void 0)??null}};var Zo=LF();/**
@@ -1261,8 +1264,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
1261
1264
  L0,20`)},"requirement_arrow"),ZEe=B((e,t,r)=>{const n=En(),{themeVariables:i}=n,{strokeWidth:s}=i;e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").attr("stroke-width",`${s}`).attr("viewBox","0 0 25 20").append("path").attr("d",`M0,0
1262
1265
  L20,10
1263
1266
  M20,10
1264
- L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),QEe=B((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),JEe=B((e,t,r)=>{const n=En(),{themeVariables:i}=n,{strokeWidth:s}=i,a=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");a.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),a.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),a.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),a.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),e8e={extension:MEe,composition:IEe,aggregation:OEe,dependency:BEe,lollipop:DEe,point:PEe,circle:jEe,cross:FEe,barb:zEe,barbNeo:$Ee,only_one:HEe,zero_or_one:UEe,one_or_more:qEe,zero_or_more:VEe,only_one_neo:WEe,zero_or_one_neo:GEe,one_or_more_neo:YEe,zero_or_more_neo:XEe,requirement_arrow:KEe,requirement_contains:QEe,requirement_arrow_neo:ZEe,requirement_contains_neo:JEe},t8e=REe,r8e={common:A1,getConfig:En,insertCluster:J_e,insertEdge:LEe,insertEdgeLabel:wEe,insertMarkers:t8e,insertNode:nK,interpolateToCurve:u8,labelHelper:Kt,log:Ze,positionEdgeLabel:SEe},e1={},oK=B(e=>{for(const t of e)e1[t.name]=t},"registerLayoutLoaders"),n8e=B(()=>{oK([{name:"dagre",loader:B(async()=>await re(()=>import("./dagre-KV5264BT-7wO_SFt1.js"),__vite__mapDeps([101,102,103,104,105,106])),"loader")},{name:"cose-bilkent",loader:B(async()=>await re(()=>import("./cose-bilkent-S5V4N54A-BFF3VF0W.js"),__vite__mapDeps([107,108])),"loader")}])},"registerDefaultLayoutLoaders");n8e();var gZe=B(async(e,t)=>{if(!(e.layoutAlgorithm in e1))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(const h of e.nodes){const f=h.domId||h.id;h.domId=`${e.diagramId}-${f}`}const r=e1[e.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=e.config,{useGradient:a,gradientStart:o,gradientStop:l}=s,c=t.attr("id");if(t.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),t.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),a){const h=t.append("linearGradient").attr("id",t.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");h.append("svg:stop").attr("offset","0%").attr("stop-color",o).attr("stop-opacity",1),h.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(e,t,r8e,{algorithm:r.algorithm})},"render"),yZe=B((e="",{fallback:t="dagre"}={})=>{if(e in e1)return e;if(t in e1)return Ze.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),lK="comm",cK="rule",uK="decl",i8e="@import",s8e="@namespace",a8e="@keyframes",o8e="@layer",hK=Math.abs,R8=String.fromCharCode;function dK(e){return e.trim()}function Hb(e,t,r){return e.replace(t,r)}function l8e(e,t,r){return e.indexOf(t,r)}function qf(e,t){return e.charCodeAt(t)|0}function T0(e,t,r){return e.slice(t,r)}function Do(e){return e.length}function c8e(e){return e.length}function Kx(e,t){return t.push(e),e}var c3=1,w0=1,fK=0,Ha=0,Jn=0,rp="";function M8(e,t,r,n,i,s,a,o){return{value:e,root:t,parent:r,type:n,props:i,children:s,line:c3,column:w0,length:a,return:"",siblings:o}}function u8e(){return Jn}function h8e(){return Jn=Ha>0?qf(rp,--Ha):0,w0--,Jn===10&&(w0=1,c3--),Jn}function lo(){return Jn=Ha<fK?qf(rp,Ha++):0,w0++,Jn===10&&(w0=1,c3++),Jn}function cu(){return qf(rp,Ha)}function Ub(){return Ha}function u3(e,t){return T0(rp,e,t)}function t1(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function d8e(e){return c3=w0=1,fK=Do(rp=e),Ha=0,[]}function f8e(e){return rp="",e}function cT(e){return dK(u3(Ha-1,n6(e===91?e+2:e===40?e+1:e)))}function p8e(e){for(;(Jn=cu())&&Jn<33;)lo();return t1(e)>2||t1(Jn)>3?"":" "}function m8e(e,t){for(;--t&&lo()&&!(Jn<48||Jn>102||Jn>57&&Jn<65||Jn>70&&Jn<97););return u3(e,Ub()+(t<6&&cu()==32&&lo()==32))}function n6(e){for(;lo();)switch(Jn){case e:return Ha;case 34:case 39:e!==34&&e!==39&&n6(Jn);break;case 40:e===41&&n6(e);break;case 92:lo();break}return Ha}function g8e(e,t){for(;lo()&&e+Jn!==57;)if(e+Jn===84&&cu()===47)break;return"/*"+u3(t,Ha-1)+"*"+R8(e===47?e:lo())}function y8e(e){for(;!t1(cu());)lo();return u3(e,Ha)}function x8e(e){return f8e(qb("",null,null,null,[""],e=d8e(e),0,[0],e))}function qb(e,t,r,n,i,s,a,o,l){for(var c=0,h=0,f=a,g=0,m=0,x=0,v=1,C=1,k=1,T=0,w="",L=i,N=s,A=n,R=w;C;)switch(x=T,T=lo()){case 40:if(x!=108&&qf(R,f-1)==58){l8e(R+=Hb(cT(T),"&","&\f"),"&\f",hK(c?o[c-1]:0))!=-1&&(k=-1);break}case 34:case 39:case 91:R+=cT(T);break;case 9:case 10:case 13:case 32:R+=p8e(x);break;case 92:R+=m8e(Ub()-1,7);continue;case 47:switch(cu()){case 42:case 47:Kx(b8e(g8e(lo(),Ub()),t,r,l),l),(t1(x||1)==5||t1(cu()||1)==5)&&Do(R)&&T0(R,-1,void 0)!==" "&&(R+=" ");break;default:R+="/"}break;case 123*v:o[c++]=Do(R)*k;case 125*v:case 59:case 0:switch(T){case 0:case 125:C=0;case 59+h:k==-1&&(R=Hb(R,/\f/g,"")),m>0&&(Do(R)-f||v===0&&x===47)&&Kx(m>32?SB(R+";",n,r,f-1,l):SB(Hb(R," ","")+";",n,r,f-2,l),l);break;case 59:R+=";";default:if(Kx(A=wB(R,t,r,c,h,i,o,w,L=[],N=[],f,s),s),T===123)if(h===0)qb(R,t,A,A,L,s,f,o,N);else{switch(g){case 99:if(qf(R,3)===110)break;case 108:if(qf(R,2)===97)break;default:h=0;case 100:case 109:case 115:}h?qb(e,A,A,n&&Kx(wB(e,A,A,0,0,i,o,w,i,L=[],f,N),N),i,N,f,o,n?L:N):qb(R,A,A,A,[""],N,0,o,N)}}c=h=m=0,v=k=1,w=R="",f=a;break;case 58:f=1+Do(R),m=x;default:if(v<1){if(T==123)--v;else if(T==125&&v++==0&&h8e()==125)continue}switch(R+=R8(T),T*v){case 38:k=h>0?1:(R+="\f",-1);break;case 44:o[c++]=(Do(R)-1)*k,k=1;break;case 64:cu()===45&&(R+=cT(lo())),g=cu(),h=f=Do(w=R+=y8e(Ub())),T++;break;case 45:x===45&&Do(R)==2&&(v=0)}}return s}function wB(e,t,r,n,i,s,a,o,l,c,h,f){for(var g=i-1,m=i===0?s:[""],x=c8e(m),v=0,C=0,k=0;v<n;++v)for(var T=0,w=T0(e,g+1,g=hK(C=a[v])),L=e;T<x;++T)(L=dK(C>0?m[T]+" "+w:Hb(w,/&\f/g,m[T])))&&(l[k++]=L);return M8(e,t,r,i===0?cK:o,l,c,h,f)}function b8e(e,t,r,n){return M8(e,t,r,lK,R8(u8e()),T0(e,2,-2),0,n)}function SB(e,t,r,n,i){return M8(e,t,r,uK,T0(e,0,n),T0(e,n+1,-1),n,i)}function i6(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function v8e(e,t,r,n){switch(e.type){case o8e:if(e.children.length)break;case i8e:case s8e:case uK:return e.return=e.return||e.value;case lK:return"";case a8e:return e.return=e.value+"{"+i6(e.children,n)+"}";case cK:if(!Do(e.value=e.props.join(",")))return""}return Do(r=i6(e.children,n))?e.return=e.value+"{"+r+"}":""}var C8e=DG(Object.keys,Object),k8e=Object.prototype,T8e=k8e.hasOwnProperty;function w8e(e){if(!e3(e))return C8e(e);var t=[];for(var r in Object(e))T8e.call(e,r)&&r!="constructor"&&t.push(r);return t}var s6=Cd(dl,"DataView"),a6=Cd(dl,"Promise"),o6=Cd(dl,"Set"),l6=Cd(dl,"WeakMap"),_B="[object Map]",S8e="[object Object]",EB="[object Promise]",AB="[object Set]",NB="[object WeakMap]",LB="[object DataView]",_8e=vd(s6),E8e=vd(Qg),A8e=vd(a6),N8e=vd(o6),L8e=vd(l6),Th=Q0;(s6&&Th(new s6(new ArrayBuffer(1)))!=LB||Qg&&Th(new Qg)!=_B||a6&&Th(a6.resolve())!=EB||o6&&Th(new o6)!=AB||l6&&Th(new l6)!=NB)&&(Th=function(e){var t=Q0(e),r=t==S8e?e.constructor:void 0,n=r?vd(r):"";if(n)switch(n){case _8e:return LB;case E8e:return _B;case A8e:return EB;case N8e:return AB;case L8e:return NB}return t});var R8e="[object Map]",M8e="[object Set]",I8e=Object.prototype,O8e=I8e.hasOwnProperty;function RB(e){if(e==null)return!0;if(t3(e)&&(dv(e)||typeof e=="string"||typeof e.splice=="function"||l8(e)||c8(e)||hv(e)))return!e.length;var t=Th(e);if(t==R8e||t==M8e)return!e.size;if(e3(e))return!w8e(e).length;for(var r in e)if(O8e.call(e,r))return!1;return!0}var pK="c4",B8e=B(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),D8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./c4Diagram-AHTNJAMY-nN4kJiPC.js");return{diagram:t}},__vite__mapDeps([109,110]));return{id:pK,diagram:e}},"loader"),P8e={id:pK,detector:B8e,loader:D8e},j8e=P8e,mK="flowchart",F8e=B((e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),z8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-Cign1ovE.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:mK,diagram:e}},"loader"),$8e={id:mK,detector:F8e,loader:z8e},H8e=$8e,gK="flowchart-v2",U8e=B((e,t)=>{var r,n,i;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((i=t==null?void 0:t.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),q8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-Cign1ovE.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:gK,diagram:e}},"loader"),V8e={id:gK,detector:U8e,loader:q8e},W8e=V8e,yK="er",G8e=B(e=>/^\s*erDiagram/.test(e),"detector"),Y8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./erDiagram-SMLLAGMA-zfdClUWU.js");return{diagram:t}},__vite__mapDeps([116,113,114,115]));return{id:yK,diagram:e}},"loader"),X8e={id:yK,detector:G8e,loader:Y8e},K8e=X8e,xK="gitGraph",Z8e=B(e=>/^\s*gitGraph/.test(e),"detector"),Q8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./gitGraphDiagram-UUTBAWPF-DgUNvxqj.js");return{diagram:t}},__vite__mapDeps([117,118,119,120,105,103]));return{id:xK,diagram:e}},"loader"),J8e={id:xK,detector:Z8e,loader:Q8e},e7e=J8e,bK="gantt",t7e=B(e=>/^\s*gantt/.test(e),"detector"),r7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./ganttDiagram-T4ZO3ILL-zHFblbgr.js");return{diagram:t}},__vite__mapDeps([121,122,123,124,125]));return{id:bK,diagram:e}},"loader"),n7e={id:bK,detector:t7e,loader:r7e},i7e=n7e,vK="info",s7e=B(e=>/^\s*info/.test(e),"detector"),a7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./infoDiagram-42DDH7IO-B1j6wnrX.js");return{diagram:t}},__vite__mapDeps([126,120,105,103]));return{id:vK,diagram:e}},"loader"),o7e={id:vK,detector:s7e,loader:a7e},CK="pie",l7e=B(e=>/^\s*pie/.test(e),"detector"),c7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./pieDiagram-DEJITSTG-Dk4TEXCU.js");return{diagram:t}},__vite__mapDeps([127,118,120,105,103,128,129,124]));return{id:CK,diagram:e}},"loader"),u7e={id:CK,detector:l7e,loader:c7e},kK="quadrantChart",h7e=B(e=>/^\s*quadrantChart/.test(e),"detector"),d7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./quadrantDiagram-34T5L4WZ-DjpGwBeJ.js");return{diagram:t}},__vite__mapDeps([130,122,123,124,125]));return{id:kK,diagram:e}},"loader"),f7e={id:kK,detector:h7e,loader:d7e},p7e=f7e,TK="xychart",m7e=B(e=>/^\s*xychart(-beta)?/.test(e),"detector"),g7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./xychartDiagram-5P7HB3ND-DkX9QW6S.js");return{diagram:t}},__vite__mapDeps([131,124,129,122,123,125]));return{id:TK,diagram:e}},"loader"),y7e={id:TK,detector:m7e,loader:g7e},x7e=y7e,wK="requirement",b7e=B(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),v7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./requirementDiagram-MS252O5E-D-KTxT1S.js");return{diagram:t}},__vite__mapDeps([132,113,114]));return{id:wK,diagram:e}},"loader"),C7e={id:wK,detector:b7e,loader:v7e},k7e=C7e,SK="sequence",T7e=B(e=>/^\s*sequenceDiagram/.test(e),"detector"),w7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./sequenceDiagram-FGHM5R23-EhYXipit.js");return{diagram:t}},__vite__mapDeps([133,110,119]));return{id:SK,diagram:e}},"loader"),S7e={id:SK,detector:T7e,loader:w7e},_7e=S7e,_K="class",E7e=B((e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),A7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./classDiagram-6PBFFD2Q-BpMdbRYm.js");return{diagram:t}},__vite__mapDeps([134,135,112,110,113,114]));return{id:_K,diagram:e}},"loader"),N7e={id:_K,detector:E7e,loader:A7e},L7e=N7e,EK="classDiagram",R7e=B((e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),M7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./classDiagram-v2-HSJHXN6E-BpMdbRYm.js");return{diagram:t}},__vite__mapDeps([136,135,112,110,113,114]));return{id:EK,diagram:e}},"loader"),I7e={id:EK,detector:R7e,loader:M7e},O7e=I7e,AK="state",B7e=B((e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),D7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./stateDiagram-FHFEXIEX-DlwRa19l.js");return{diagram:t}},__vite__mapDeps([137,138,113,114,102,103,104,105]));return{id:AK,diagram:e}},"loader"),P7e={id:AK,detector:B7e,loader:D7e},j7e=P7e,NK="stateDiagram",F7e=B((e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),z7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./stateDiagram-v2-QKLJ7IA2-DWOlnZT2.js");return{diagram:t}},__vite__mapDeps([139,138,113,114]));return{id:NK,diagram:e}},"loader"),$7e={id:NK,detector:F7e,loader:z7e},H7e=$7e,LK="journey",U7e=B(e=>/^\s*journey/.test(e),"detector"),q7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./journeyDiagram-VCZTEJTY-lXMvtopT.js");return{diagram:t}},__vite__mapDeps([140,112,110,128]));return{id:LK,diagram:e}},"loader"),V7e={id:LK,detector:U7e,loader:q7e},W7e=V7e,G7e=B((e,t,r)=>{Ze.debug(`rendering svg for syntax error
1265
- `);const n=g5e(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),tV(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),RK={draw:G7e},Y7e=RK,X7e={db:{},renderer:RK,parser:{parse:B(()=>{},"parse")}},K7e=X7e,MK="flowchart-elk",Z7e=B((e,t={})=>{var r;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),Q7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-Cign1ovE.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:MK,diagram:e}},"loader"),J7e={id:MK,detector:Z7e,loader:Q7e},eAe=J7e,IK="timeline",tAe=B(e=>/^\s*timeline/.test(e),"detector"),rAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./timeline-definition-GMOUNBTQ-CnNt36mp.js");return{diagram:t}},__vite__mapDeps([141,128]));return{id:IK,diagram:e}},"loader"),nAe={id:IK,detector:tAe,loader:rAe},iAe=nAe,OK="mindmap",sAe=B(e=>/^\s*mindmap/.test(e),"detector"),aAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./mindmap-definition-QFDTVHPH-Bc_KwUJk.js");return{diagram:t}},__vite__mapDeps([142,113,114]));return{id:OK,diagram:e}},"loader"),oAe={id:OK,detector:sAe,loader:aAe},lAe=oAe,BK="kanban",cAe=B(e=>/^\s*kanban/.test(e),"detector"),uAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./kanban-definition-6JOO6SKY-D2nd3IRf.js");return{diagram:t}},__vite__mapDeps([143,112]));return{id:BK,diagram:e}},"loader"),hAe={id:BK,detector:cAe,loader:uAe},dAe=hAe,DK="sankey",fAe=B(e=>/^\s*sankey(-beta)?/.test(e),"detector"),pAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./sankeyDiagram-XADWPNL6-CAAThfhf.js");return{diagram:t}},__vite__mapDeps([144,129,124]));return{id:DK,diagram:e}},"loader"),mAe={id:DK,detector:fAe,loader:pAe},gAe=mAe,PK="packet",yAe=B(e=>/^\s*packet(-beta)?/.test(e),"detector"),xAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-TYMM5635-ByagqgDJ.js");return{diagram:t}},__vite__mapDeps([145,118,120,105,103]));return{id:PK,diagram:e}},"loader"),bAe={id:PK,detector:yAe,loader:xAe},jK="radar",vAe=B(e=>/^\s*radar-beta/.test(e),"detector"),CAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-MMDJMWI5-BcJABwZb.js");return{diagram:t}},__vite__mapDeps([146,118,120,105,103]));return{id:jK,diagram:e}},"loader"),kAe={id:jK,detector:vAe,loader:CAe},FK="block",TAe=B(e=>/^\s*block(-beta)?/.test(e),"detector"),wAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./blockDiagram-DXYQGD6D-BrQpuNBu.js");return{diagram:t}},__vite__mapDeps([147,112,106,102,103,115]));return{id:FK,diagram:e}},"loader"),SAe={id:FK,detector:TAe,loader:wAe},_Ae=SAe,zK="treeView",EAe=B(e=>/^\s*treeView-beta/.test(e),"detector"),AAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-5BDNPKRD-DpdLNbTp.js");return{diagram:t}},__vite__mapDeps([148,118,119,120,105,103]));return{id:zK,diagram:e}},"loader"),NAe={id:zK,detector:EAe,loader:AAe},LAe=NAe,$K="architecture",RAe=B(e=>/^\s*architecture/.test(e),"detector"),MAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./architectureDiagram-Q4EWVU46-B54hBS8X.js");return{diagram:t}},__vite__mapDeps([149,118,120,105,103,108]));return{id:$K,diagram:e}},"loader"),IAe={id:$K,detector:RAe,loader:MAe},OAe=IAe,HK="ishikawa",BAe=B(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),DAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./ishikawaDiagram-UXIWVN3A-CmTERA2Q.js");return{diagram:t}},[]);return{id:HK,diagram:e}},"loader"),PAe={id:HK,detector:BAe,loader:DAe},UK="venn",jAe=B(e=>/^\s*venn-beta/.test(e),"detector"),FAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./vennDiagram-DHZGUBPP-CONWdidS.js");return{diagram:t}},[]);return{id:UK,diagram:e}},"loader"),zAe={id:UK,detector:jAe,loader:FAe},$Ae=zAe,qK="treemap",HAe=B(e=>/^\s*treemap/.test(e),"detector"),UAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-G4DWMVQ6-B2Xd9yJj.js");return{diagram:t}},__vite__mapDeps([150,114,118,120,105,103,125,129,124]));return{id:qK,diagram:e}},"loader"),qAe={id:qK,detector:HAe,loader:UAe},VK="wardley-beta",VAe=B(e=>/^\s*wardley-beta/i.test(e),"detector"),WAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./wardleyDiagram-NUSXRM2D-Brxifhti.js");return{diagram:t}},__vite__mapDeps([151,118,120,105,103]));return{id:VK,diagram:e}},"loader"),GAe={id:VK,detector:VAe,loader:WAe},YAe=GAe,MB=!1,h3=B(()=>{MB||(MB=!0,G2("error",K7e,e=>e.toLowerCase().trim()==="error"),G2("---",{db:{clear:B(()=>{},"clear")},styles:{},renderer:{draw:B(()=>{},"draw")},parser:{parse:B(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:B(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),dS(eAe,lAe,OAe),dS(j8e,dAe,O7e,L7e,K8e,i7e,o7e,u7e,k7e,_7e,W8e,H8e,iAe,e7e,H7e,j7e,W7e,p7e,gAe,bAe,x7e,_Ae,LAe,kAe,PAe,qAe,$Ae,YAe))},"addDiagrams"),XAe=B(async()=>{Ze.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(rd).map(async([r,{detector:n,loader:i}])=>{if(i)try{gS(r)}catch{try{const{diagram:s,id:a}=await i();G2(a,s,n)}catch(s){throw Ze.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete rd[r],s}}}))).filter(r=>r.status==="rejected");if(t.length>0){Ze.error(`Failed to load ${t.length} external diagrams`);for(const r of t)Ze.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),KAe="graphics-document document";function WK(e,t){e.attr("role",KAe),t!==""&&e.attr("aria-roledescription",t)}B(WK,"setA11yDiagramInfo");function GK(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}B(GK,"addSVGa11yTitleDescription");var Xh,c6=(Xh=class{constructor(t,r,n,i,s){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(t,r={}){var c,h;const n=En(),i=OE(t,n);t=b6e(t)+`
1267
+ L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),QEe=B((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),JEe=B((e,t,r)=>{const n=En(),{themeVariables:i}=n,{strokeWidth:s}=i,a=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");a.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),a.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),a.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),a.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),e8e={extension:MEe,composition:IEe,aggregation:OEe,dependency:BEe,lollipop:DEe,point:PEe,circle:jEe,cross:FEe,barb:zEe,barbNeo:$Ee,only_one:HEe,zero_or_one:UEe,one_or_more:qEe,zero_or_more:VEe,only_one_neo:WEe,zero_or_one_neo:GEe,one_or_more_neo:YEe,zero_or_more_neo:XEe,requirement_arrow:KEe,requirement_contains:QEe,requirement_arrow_neo:ZEe,requirement_contains_neo:JEe},t8e=REe,r8e={common:A1,getConfig:En,insertCluster:J_e,insertEdge:LEe,insertEdgeLabel:wEe,insertMarkers:t8e,insertNode:nK,interpolateToCurve:u8,labelHelper:Kt,log:Ze,positionEdgeLabel:SEe},e1={},oK=B(e=>{for(const t of e)e1[t.name]=t},"registerLayoutLoaders"),n8e=B(()=>{oK([{name:"dagre",loader:B(async()=>await re(()=>import("./dagre-KV5264BT-DuZ4zm4B.js"),__vite__mapDeps([101,102,103,104,105,106])),"loader")},{name:"cose-bilkent",loader:B(async()=>await re(()=>import("./cose-bilkent-S5V4N54A-DKMKqdAL.js"),__vite__mapDeps([107,108])),"loader")}])},"registerDefaultLayoutLoaders");n8e();var gZe=B(async(e,t)=>{if(!(e.layoutAlgorithm in e1))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(const h of e.nodes){const f=h.domId||h.id;h.domId=`${e.diagramId}-${f}`}const r=e1[e.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=e.config,{useGradient:a,gradientStart:o,gradientStop:l}=s,c=t.attr("id");if(t.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),t.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),a){const h=t.append("linearGradient").attr("id",t.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");h.append("svg:stop").attr("offset","0%").attr("stop-color",o).attr("stop-opacity",1),h.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(e,t,r8e,{algorithm:r.algorithm})},"render"),yZe=B((e="",{fallback:t="dagre"}={})=>{if(e in e1)return e;if(t in e1)return Ze.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),lK="comm",cK="rule",uK="decl",i8e="@import",s8e="@namespace",a8e="@keyframes",o8e="@layer",hK=Math.abs,R8=String.fromCharCode;function dK(e){return e.trim()}function Hb(e,t,r){return e.replace(t,r)}function l8e(e,t,r){return e.indexOf(t,r)}function qf(e,t){return e.charCodeAt(t)|0}function T0(e,t,r){return e.slice(t,r)}function Do(e){return e.length}function c8e(e){return e.length}function Kx(e,t){return t.push(e),e}var c3=1,w0=1,fK=0,Ha=0,Jn=0,rp="";function M8(e,t,r,n,i,s,a,o){return{value:e,root:t,parent:r,type:n,props:i,children:s,line:c3,column:w0,length:a,return:"",siblings:o}}function u8e(){return Jn}function h8e(){return Jn=Ha>0?qf(rp,--Ha):0,w0--,Jn===10&&(w0=1,c3--),Jn}function lo(){return Jn=Ha<fK?qf(rp,Ha++):0,w0++,Jn===10&&(w0=1,c3++),Jn}function cu(){return qf(rp,Ha)}function Ub(){return Ha}function u3(e,t){return T0(rp,e,t)}function t1(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function d8e(e){return c3=w0=1,fK=Do(rp=e),Ha=0,[]}function f8e(e){return rp="",e}function cT(e){return dK(u3(Ha-1,n6(e===91?e+2:e===40?e+1:e)))}function p8e(e){for(;(Jn=cu())&&Jn<33;)lo();return t1(e)>2||t1(Jn)>3?"":" "}function m8e(e,t){for(;--t&&lo()&&!(Jn<48||Jn>102||Jn>57&&Jn<65||Jn>70&&Jn<97););return u3(e,Ub()+(t<6&&cu()==32&&lo()==32))}function n6(e){for(;lo();)switch(Jn){case e:return Ha;case 34:case 39:e!==34&&e!==39&&n6(Jn);break;case 40:e===41&&n6(e);break;case 92:lo();break}return Ha}function g8e(e,t){for(;lo()&&e+Jn!==57;)if(e+Jn===84&&cu()===47)break;return"/*"+u3(t,Ha-1)+"*"+R8(e===47?e:lo())}function y8e(e){for(;!t1(cu());)lo();return u3(e,Ha)}function x8e(e){return f8e(qb("",null,null,null,[""],e=d8e(e),0,[0],e))}function qb(e,t,r,n,i,s,a,o,l){for(var c=0,h=0,f=a,g=0,m=0,x=0,v=1,C=1,k=1,T=0,w="",L=i,N=s,A=n,R=w;C;)switch(x=T,T=lo()){case 40:if(x!=108&&qf(R,f-1)==58){l8e(R+=Hb(cT(T),"&","&\f"),"&\f",hK(c?o[c-1]:0))!=-1&&(k=-1);break}case 34:case 39:case 91:R+=cT(T);break;case 9:case 10:case 13:case 32:R+=p8e(x);break;case 92:R+=m8e(Ub()-1,7);continue;case 47:switch(cu()){case 42:case 47:Kx(b8e(g8e(lo(),Ub()),t,r,l),l),(t1(x||1)==5||t1(cu()||1)==5)&&Do(R)&&T0(R,-1,void 0)!==" "&&(R+=" ");break;default:R+="/"}break;case 123*v:o[c++]=Do(R)*k;case 125*v:case 59:case 0:switch(T){case 0:case 125:C=0;case 59+h:k==-1&&(R=Hb(R,/\f/g,"")),m>0&&(Do(R)-f||v===0&&x===47)&&Kx(m>32?SB(R+";",n,r,f-1,l):SB(Hb(R," ","")+";",n,r,f-2,l),l);break;case 59:R+=";";default:if(Kx(A=wB(R,t,r,c,h,i,o,w,L=[],N=[],f,s),s),T===123)if(h===0)qb(R,t,A,A,L,s,f,o,N);else{switch(g){case 99:if(qf(R,3)===110)break;case 108:if(qf(R,2)===97)break;default:h=0;case 100:case 109:case 115:}h?qb(e,A,A,n&&Kx(wB(e,A,A,0,0,i,o,w,i,L=[],f,N),N),i,N,f,o,n?L:N):qb(R,A,A,A,[""],N,0,o,N)}}c=h=m=0,v=k=1,w=R="",f=a;break;case 58:f=1+Do(R),m=x;default:if(v<1){if(T==123)--v;else if(T==125&&v++==0&&h8e()==125)continue}switch(R+=R8(T),T*v){case 38:k=h>0?1:(R+="\f",-1);break;case 44:o[c++]=(Do(R)-1)*k,k=1;break;case 64:cu()===45&&(R+=cT(lo())),g=cu(),h=f=Do(w=R+=y8e(Ub())),T++;break;case 45:x===45&&Do(R)==2&&(v=0)}}return s}function wB(e,t,r,n,i,s,a,o,l,c,h,f){for(var g=i-1,m=i===0?s:[""],x=c8e(m),v=0,C=0,k=0;v<n;++v)for(var T=0,w=T0(e,g+1,g=hK(C=a[v])),L=e;T<x;++T)(L=dK(C>0?m[T]+" "+w:Hb(w,/&\f/g,m[T])))&&(l[k++]=L);return M8(e,t,r,i===0?cK:o,l,c,h,f)}function b8e(e,t,r,n){return M8(e,t,r,lK,R8(u8e()),T0(e,2,-2),0,n)}function SB(e,t,r,n,i){return M8(e,t,r,uK,T0(e,0,n),T0(e,n+1,-1),n,i)}function i6(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function v8e(e,t,r,n){switch(e.type){case o8e:if(e.children.length)break;case i8e:case s8e:case uK:return e.return=e.return||e.value;case lK:return"";case a8e:return e.return=e.value+"{"+i6(e.children,n)+"}";case cK:if(!Do(e.value=e.props.join(",")))return""}return Do(r=i6(e.children,n))?e.return=e.value+"{"+r+"}":""}var C8e=DG(Object.keys,Object),k8e=Object.prototype,T8e=k8e.hasOwnProperty;function w8e(e){if(!e3(e))return C8e(e);var t=[];for(var r in Object(e))T8e.call(e,r)&&r!="constructor"&&t.push(r);return t}var s6=Cd(dl,"DataView"),a6=Cd(dl,"Promise"),o6=Cd(dl,"Set"),l6=Cd(dl,"WeakMap"),_B="[object Map]",S8e="[object Object]",EB="[object Promise]",AB="[object Set]",NB="[object WeakMap]",LB="[object DataView]",_8e=vd(s6),E8e=vd(Qg),A8e=vd(a6),N8e=vd(o6),L8e=vd(l6),Th=Q0;(s6&&Th(new s6(new ArrayBuffer(1)))!=LB||Qg&&Th(new Qg)!=_B||a6&&Th(a6.resolve())!=EB||o6&&Th(new o6)!=AB||l6&&Th(new l6)!=NB)&&(Th=function(e){var t=Q0(e),r=t==S8e?e.constructor:void 0,n=r?vd(r):"";if(n)switch(n){case _8e:return LB;case E8e:return _B;case A8e:return EB;case N8e:return AB;case L8e:return NB}return t});var R8e="[object Map]",M8e="[object Set]",I8e=Object.prototype,O8e=I8e.hasOwnProperty;function RB(e){if(e==null)return!0;if(t3(e)&&(dv(e)||typeof e=="string"||typeof e.splice=="function"||l8(e)||c8(e)||hv(e)))return!e.length;var t=Th(e);if(t==R8e||t==M8e)return!e.size;if(e3(e))return!w8e(e).length;for(var r in e)if(O8e.call(e,r))return!1;return!0}var pK="c4",B8e=B(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),D8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./c4Diagram-AHTNJAMY-CxIpgCiP.js");return{diagram:t}},__vite__mapDeps([109,110]));return{id:pK,diagram:e}},"loader"),P8e={id:pK,detector:B8e,loader:D8e},j8e=P8e,mK="flowchart",F8e=B((e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),z8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-bjSm1F6q.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:mK,diagram:e}},"loader"),$8e={id:mK,detector:F8e,loader:z8e},H8e=$8e,gK="flowchart-v2",U8e=B((e,t)=>{var r,n,i;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((i=t==null?void 0:t.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),q8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-bjSm1F6q.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:gK,diagram:e}},"loader"),V8e={id:gK,detector:U8e,loader:q8e},W8e=V8e,yK="er",G8e=B(e=>/^\s*erDiagram/.test(e),"detector"),Y8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./erDiagram-SMLLAGMA-SWAf-S26.js");return{diagram:t}},__vite__mapDeps([116,113,114,115]));return{id:yK,diagram:e}},"loader"),X8e={id:yK,detector:G8e,loader:Y8e},K8e=X8e,xK="gitGraph",Z8e=B(e=>/^\s*gitGraph/.test(e),"detector"),Q8e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./gitGraphDiagram-UUTBAWPF-DGaIKwEh.js");return{diagram:t}},__vite__mapDeps([117,118,119,120,105,103]));return{id:xK,diagram:e}},"loader"),J8e={id:xK,detector:Z8e,loader:Q8e},e7e=J8e,bK="gantt",t7e=B(e=>/^\s*gantt/.test(e),"detector"),r7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./ganttDiagram-T4ZO3ILL-B3eioyUQ.js");return{diagram:t}},__vite__mapDeps([121,122,123,124,125]));return{id:bK,diagram:e}},"loader"),n7e={id:bK,detector:t7e,loader:r7e},i7e=n7e,vK="info",s7e=B(e=>/^\s*info/.test(e),"detector"),a7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./infoDiagram-42DDH7IO-z7BfWhD6.js");return{diagram:t}},__vite__mapDeps([126,120,105,103]));return{id:vK,diagram:e}},"loader"),o7e={id:vK,detector:s7e,loader:a7e},CK="pie",l7e=B(e=>/^\s*pie/.test(e),"detector"),c7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./pieDiagram-DEJITSTG-Bai_9_pu.js");return{diagram:t}},__vite__mapDeps([127,118,120,105,103,128,129,124]));return{id:CK,diagram:e}},"loader"),u7e={id:CK,detector:l7e,loader:c7e},kK="quadrantChart",h7e=B(e=>/^\s*quadrantChart/.test(e),"detector"),d7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./quadrantDiagram-34T5L4WZ-CgKE3-Ag.js");return{diagram:t}},__vite__mapDeps([130,122,123,124,125]));return{id:kK,diagram:e}},"loader"),f7e={id:kK,detector:h7e,loader:d7e},p7e=f7e,TK="xychart",m7e=B(e=>/^\s*xychart(-beta)?/.test(e),"detector"),g7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./xychartDiagram-5P7HB3ND-C2L50m3n.js");return{diagram:t}},__vite__mapDeps([131,124,129,122,123,125]));return{id:TK,diagram:e}},"loader"),y7e={id:TK,detector:m7e,loader:g7e},x7e=y7e,wK="requirement",b7e=B(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),v7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./requirementDiagram-MS252O5E-CiP3d8R4.js");return{diagram:t}},__vite__mapDeps([132,113,114]));return{id:wK,diagram:e}},"loader"),C7e={id:wK,detector:b7e,loader:v7e},k7e=C7e,SK="sequence",T7e=B(e=>/^\s*sequenceDiagram/.test(e),"detector"),w7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./sequenceDiagram-FGHM5R23-Buf7D5PQ.js");return{diagram:t}},__vite__mapDeps([133,110,119]));return{id:SK,diagram:e}},"loader"),S7e={id:SK,detector:T7e,loader:w7e},_7e=S7e,_K="class",E7e=B((e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),A7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./classDiagram-6PBFFD2Q-CNYOE6Pk.js");return{diagram:t}},__vite__mapDeps([134,135,112,110,113,114]));return{id:_K,diagram:e}},"loader"),N7e={id:_K,detector:E7e,loader:A7e},L7e=N7e,EK="classDiagram",R7e=B((e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),M7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./classDiagram-v2-HSJHXN6E-CNYOE6Pk.js");return{diagram:t}},__vite__mapDeps([136,135,112,110,113,114]));return{id:EK,diagram:e}},"loader"),I7e={id:EK,detector:R7e,loader:M7e},O7e=I7e,AK="state",B7e=B((e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),D7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./stateDiagram-FHFEXIEX-5uYn-_xo.js");return{diagram:t}},__vite__mapDeps([137,138,113,114,102,103,104,105]));return{id:AK,diagram:e}},"loader"),P7e={id:AK,detector:B7e,loader:D7e},j7e=P7e,NK="stateDiagram",F7e=B((e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),z7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./stateDiagram-v2-QKLJ7IA2-CiNPYrtS.js");return{diagram:t}},__vite__mapDeps([139,138,113,114]));return{id:NK,diagram:e}},"loader"),$7e={id:NK,detector:F7e,loader:z7e},H7e=$7e,LK="journey",U7e=B(e=>/^\s*journey/.test(e),"detector"),q7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./journeyDiagram-VCZTEJTY-7szsjnaK.js");return{diagram:t}},__vite__mapDeps([140,112,110,128]));return{id:LK,diagram:e}},"loader"),V7e={id:LK,detector:U7e,loader:q7e},W7e=V7e,G7e=B((e,t,r)=>{Ze.debug(`rendering svg for syntax error
1268
+ `);const n=g5e(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),tV(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),RK={draw:G7e},Y7e=RK,X7e={db:{},renderer:RK,parser:{parse:B(()=>{},"parse")}},K7e=X7e,MK="flowchart-elk",Z7e=B((e,t={})=>{var r;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),Q7e=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./flowDiagram-DWJPFMVM-bjSm1F6q.js");return{diagram:t}},__vite__mapDeps([111,112,110,113,114,115]));return{id:MK,diagram:e}},"loader"),J7e={id:MK,detector:Z7e,loader:Q7e},eAe=J7e,IK="timeline",tAe=B(e=>/^\s*timeline/.test(e),"detector"),rAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./timeline-definition-GMOUNBTQ-fcTegT1X.js");return{diagram:t}},__vite__mapDeps([141,128]));return{id:IK,diagram:e}},"loader"),nAe={id:IK,detector:tAe,loader:rAe},iAe=nAe,OK="mindmap",sAe=B(e=>/^\s*mindmap/.test(e),"detector"),aAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./mindmap-definition-QFDTVHPH-CaZaCUVQ.js");return{diagram:t}},__vite__mapDeps([142,113,114]));return{id:OK,diagram:e}},"loader"),oAe={id:OK,detector:sAe,loader:aAe},lAe=oAe,BK="kanban",cAe=B(e=>/^\s*kanban/.test(e),"detector"),uAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./kanban-definition-6JOO6SKY-CN_iYP62.js");return{diagram:t}},__vite__mapDeps([143,112]));return{id:BK,diagram:e}},"loader"),hAe={id:BK,detector:cAe,loader:uAe},dAe=hAe,DK="sankey",fAe=B(e=>/^\s*sankey(-beta)?/.test(e),"detector"),pAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./sankeyDiagram-XADWPNL6-RIeASvdJ.js");return{diagram:t}},__vite__mapDeps([144,129,124]));return{id:DK,diagram:e}},"loader"),mAe={id:DK,detector:fAe,loader:pAe},gAe=mAe,PK="packet",yAe=B(e=>/^\s*packet(-beta)?/.test(e),"detector"),xAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-TYMM5635-CJ1VtRnc.js");return{diagram:t}},__vite__mapDeps([145,118,120,105,103]));return{id:PK,diagram:e}},"loader"),bAe={id:PK,detector:yAe,loader:xAe},jK="radar",vAe=B(e=>/^\s*radar-beta/.test(e),"detector"),CAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-MMDJMWI5-iB_Pzv_O.js");return{diagram:t}},__vite__mapDeps([146,118,120,105,103]));return{id:jK,diagram:e}},"loader"),kAe={id:jK,detector:vAe,loader:CAe},FK="block",TAe=B(e=>/^\s*block(-beta)?/.test(e),"detector"),wAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./blockDiagram-DXYQGD6D-CIbxhPHs.js");return{diagram:t}},__vite__mapDeps([147,112,106,102,103,115]));return{id:FK,diagram:e}},"loader"),SAe={id:FK,detector:TAe,loader:wAe},_Ae=SAe,zK="treeView",EAe=B(e=>/^\s*treeView-beta/.test(e),"detector"),AAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-5BDNPKRD-CoA3HYsp.js");return{diagram:t}},__vite__mapDeps([148,118,119,120,105,103]));return{id:zK,diagram:e}},"loader"),NAe={id:zK,detector:EAe,loader:AAe},LAe=NAe,$K="architecture",RAe=B(e=>/^\s*architecture/.test(e),"detector"),MAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./architectureDiagram-Q4EWVU46-oodkcVSQ.js");return{diagram:t}},__vite__mapDeps([149,118,120,105,103,108]));return{id:$K,diagram:e}},"loader"),IAe={id:$K,detector:RAe,loader:MAe},OAe=IAe,HK="ishikawa",BAe=B(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),DAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./ishikawaDiagram-UXIWVN3A-DgkoM8pX.js");return{diagram:t}},[]);return{id:HK,diagram:e}},"loader"),PAe={id:HK,detector:BAe,loader:DAe},UK="venn",jAe=B(e=>/^\s*venn-beta/.test(e),"detector"),FAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./vennDiagram-DHZGUBPP-BUY_I73j.js");return{diagram:t}},[]);return{id:UK,diagram:e}},"loader"),zAe={id:UK,detector:jAe,loader:FAe},$Ae=zAe,qK="treemap",HAe=B(e=>/^\s*treemap/.test(e),"detector"),UAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./diagram-G4DWMVQ6-DVnnKNaz.js");return{diagram:t}},__vite__mapDeps([150,114,118,120,105,103,125,129,124]));return{id:qK,diagram:e}},"loader"),qAe={id:qK,detector:HAe,loader:UAe},VK="wardley-beta",VAe=B(e=>/^\s*wardley-beta/i.test(e),"detector"),WAe=B(async()=>{const{diagram:e}=await re(async()=>{const{diagram:t}=await import("./wardleyDiagram-NUSXRM2D-0A6kvF9i.js");return{diagram:t}},__vite__mapDeps([151,118,120,105,103]));return{id:VK,diagram:e}},"loader"),GAe={id:VK,detector:VAe,loader:WAe},YAe=GAe,MB=!1,h3=B(()=>{MB||(MB=!0,G2("error",K7e,e=>e.toLowerCase().trim()==="error"),G2("---",{db:{clear:B(()=>{},"clear")},styles:{},renderer:{draw:B(()=>{},"draw")},parser:{parse:B(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:B(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),dS(eAe,lAe,OAe),dS(j8e,dAe,O7e,L7e,K8e,i7e,o7e,u7e,k7e,_7e,W8e,H8e,iAe,e7e,H7e,j7e,W7e,p7e,gAe,bAe,x7e,_Ae,LAe,kAe,PAe,qAe,$Ae,YAe))},"addDiagrams"),XAe=B(async()=>{Ze.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(rd).map(async([r,{detector:n,loader:i}])=>{if(i)try{gS(r)}catch{try{const{diagram:s,id:a}=await i();G2(a,s,n)}catch(s){throw Ze.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete rd[r],s}}}))).filter(r=>r.status==="rejected");if(t.length>0){Ze.error(`Failed to load ${t.length} external diagrams`);for(const r of t)Ze.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),KAe="graphics-document document";function WK(e,t){e.attr("role",KAe),t!==""&&e.attr("aria-roledescription",t)}B(WK,"setA11yDiagramInfo");function GK(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}B(GK,"addSVGa11yTitleDescription");var Xh,c6=(Xh=class{constructor(t,r,n,i,s){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(t,r={}){var c,h;const n=En(),i=OE(t,n);t=b6e(t)+`
1266
1269
  `;try{gS(i)}catch{const f=Ive(i);if(!f)throw new $q(`Diagram ${i} not found.`);const{id:g,diagram:m}=await f();G2(g,m)}const{db:s,parser:a,renderer:o,init:l}=gS(i);return a.parser&&(a.parser.yy=s),(c=s.clear)==null||c.call(s),l==null||l(n),r.title&&((h=s.setDiagramTitle)==null||h.call(s,r.title)),await a.parse(t),new Xh(i,t,s,a,o)}async render(t,r){await this.renderer.draw(this.text,t,r,this)}getParser(){return this.parser}getType(){return this.type}},B(Xh,"Diagram"),Xh),IB=[],ZAe=B(()=>{IB.forEach(e=>{e()}),IB=[]},"attachFunctions"),QAe=B(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function YK(e){const t=e.match(zq);if(!t)return{text:e,metadata:{}};let r=TTe(t[1],{schema:kTe})??{};r=typeof r=="object"&&!Array.isArray(r)?r:{};const n={};return r.displayMode&&(n.displayMode=r.displayMode.toString()),r.title&&(n.title=r.title.toString()),r.config&&(n.config=r.config),{text:e.slice(t[0].length),metadata:n}}B(YK,"extractFrontMatter");var JAe=B(e=>e.replace(/\r\n?/g,`
1267
1270
  `).replace(/<(\w+)([^>]*)>/g,(t,r,n)=>"<"+r+n.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),e9e=B(e=>{const{text:t,metadata:r}=YK(e),{displayMode:n,title:i,config:s={}}=r;return n&&(s.gantt||(s.gantt={}),s.gantt.displayMode=n),{title:i,config:s,text:t}},"processFrontmatter"),t9e=B(e=>{const t=so.detectInit(e)??{},r=so.detectDirective(e,"wrap");return Array.isArray(r)?t.wrap=r.some(({type:n})=>n==="wrap"):(r==null?void 0:r.type)==="wrap"&&(t.wrap=!0),{text:a6e(e),directive:t}},"processDirectives");function I8(e){const t=JAe(e),r=e9e(t),n=t9e(r.text),i=m8(r.config,n.directive);return e=QAe(n.text),{code:e,title:r.title,config:i}}B(I8,"preprocessDiagram");function XK(e){const t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCodePoint(n)).join("");return btoa(r)}B(XK,"toBase64");var r9e=5e4,n9e="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",i9e="sandbox",s9e="loose",a9e="http://www.w3.org/2000/svg",o9e="http://www.w3.org/1999/xlink",l9e="http://www.w3.org/1999/xhtml",c9e="100%",u9e="100%",h9e="border:0;margin:0;",d9e="margin:0",f9e="allow-top-navigation-by-user-activation allow-popups",p9e='The "iframe" tag is not supported by your browser.',m9e=["foreignobject"],g9e=["dominant-baseline"];function O8(e){const t=I8(e);return V2(),oCe(t.config??{}),t}B(O8,"processAndSetConfigs");async function KK(e,t){h3();try{const{code:r,config:n}=O8(e);return{diagramType:(await QK(r)).type,config:n}}catch(r){if(t!=null&&t.suppressErrors)return!1;throw r}}B(KK,"parse");var OB=B((e,t,r=[])=>`
1268
1271
  .${e} ${t} { ${r.join(" !important; ")} !important; }`,"cssImportantStyles"),y9e=B((e,t=new Map)=>{let r="";if(e.themeCSS!==void 0&&(r+=`
@@ -1382,7 +1385,7 @@ ${t}</tr>
1382
1385
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Mo(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:r,tokens:n}){let i=this.parser.parseInline(n),s=GD(t);if(s===null)return i;t=s;let a='<a href="'+t+'"';return r&&(a+=' title="'+Mo(r)+'"'),a+=">"+i+"</a>",a}image({href:t,title:r,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=GD(t);if(s===null)return Mo(n);t=s;let a=`<img src="${t}" alt="${Mo(n)}"`;return r&&(a+=` title="${Mo(r)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Mo(t.text)}},d7=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ro=class w6{constructor(t){ve(this,"options");ve(this,"renderer");ve(this,"textRenderer");this.options=t||Sd,this.options.renderer=this.options.renderer||new Rv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new d7}static parse(t,r){return new w6(r).parse(t)}static parseInline(t,r){return new w6(r).parseInline(t)}parse(t){var n,i;this.renderer.parser=this;let r="";for(let s=0;s<t.length;s++){let a=t[s];if((i=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&i[a.type]){let l=a,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){r+=c||"";continue}}let o=a;switch(o.type){case"space":{r+=this.renderer.space(o);break}case"hr":{r+=this.renderer.hr(o);break}case"heading":{r+=this.renderer.heading(o);break}case"code":{r+=this.renderer.code(o);break}case"table":{r+=this.renderer.table(o);break}case"blockquote":{r+=this.renderer.blockquote(o);break}case"list":{r+=this.renderer.list(o);break}case"checkbox":{r+=this.renderer.checkbox(o);break}case"html":{r+=this.renderer.html(o);break}case"def":{r+=this.renderer.def(o);break}case"paragraph":{r+=this.renderer.paragraph(o);break}case"text":{r+=this.renderer.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(t,r=this.renderer){var i,s;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let o=t[a];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[o.type]){let c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){n+=c||"";continue}}let l=o;switch(l.type){case"escape":{n+=r.text(l);break}case"html":{n+=r.html(l);break}case"link":{n+=r.link(l);break}case"image":{n+=r.image(l);break}case"checkbox":{n+=r.checkbox(l);break}case"strong":{n+=r.strong(l);break}case"em":{n+=r.em(l);break}case"codespan":{n+=r.codespan(l);break}case"br":{n+=r.br(l);break}case"del":{n+=r.del(l);break}case"text":{n+=r.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}},yb,Wm=(yb=class{constructor(e){ve(this,"options");ve(this,"block");this.options=e||Sd}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ra.lex:Ra.lexInline}provideParser(e=this.block){return e?ro.parse:ro.parseInline}},ve(yb,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ve(yb,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),yb),DFe=class{constructor(...t){ve(this,"defaults",i7());ve(this,"options",this.setOptions);ve(this,"parse",this.parseMarkdown(!0));ve(this,"parseInline",this.parseMarkdown(!1));ve(this,"Parser",ro);ve(this,"Renderer",Rv);ve(this,"TextRenderer",d7);ve(this,"Lexer",Ra);ve(this,"Tokenizer",Lv);ve(this,"Hooks",Wm);this.use(...t)}walkTokens(t,r){var i,s;let n=[];for(let a of t)switch(n=n.concat(r.call(this,a)),a.type){case"table":{let o=a;for(let l of o.header)n=n.concat(this.walkTokens(l.tokens,r));for(let l of o.rows)for(let c of l)n=n.concat(this.walkTokens(c.tokens,r));break}case"list":{let o=a;n=n.concat(this.walkTokens(o.items,r));break}default:{let o=a;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{let c=o[l].flat(1/0);n=n.concat(this.walkTokens(c,r))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,r)))}}return n}use(...t){let r=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let a=r.renderers[s.name];a?r.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}:r.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=r[s.level];a?a.unshift(s.tokenizer):r[s.level]=[s.tokenizer],s.start&&(s.level==="block"?r.startBlock?r.startBlock.push(s.start):r.startBlock=[s.start]:s.level==="inline"&&(r.startInline?r.startInline.push(s.start):r.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(r.childTokens[s.name]=s.childTokens)}),i.extensions=r),n.renderer){let s=this.defaults.renderer||new Rv(this.defaults);for(let a in n.renderer){if(!(a in s))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,l=n.renderer[o],c=s[o];s[o]=(...h)=>{let f=l.apply(s,h);return f===!1&&(f=c.apply(s,h)),f||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Lv(this.defaults);for(let a in n.tokenizer){if(!(a in s))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,l=n.tokenizer[o],c=s[o];s[o]=(...h)=>{let f=l.apply(s,h);return f===!1&&(f=c.apply(s,h)),f}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Wm;for(let a in n.hooks){if(!(a in s))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,l=n.hooks[o],c=s[o];Wm.passThroughHooks.has(a)?s[o]=h=>{if(this.defaults.async&&Wm.passThroughHooksRespectAsync.has(a))return(async()=>{let g=await l.call(s,h);return c.call(s,g)})();let f=l.call(s,h);return c.call(s,f)}:s[o]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await l.apply(s,h);return g===!1&&(g=await c.apply(s,h)),g})();let f=l.apply(s,h);return f===!1&&(f=c.apply(s,h)),f}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,a=n.walkTokens;i.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,r){return Ra.lex(t,r??this.defaults)}parser(t,r){return ro.parse(t,r??this.defaults)}parseMarkdown(t){return(r,n)=>{let i={...n},s={...this.defaults,...i},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(r):r,l=await(s.hooks?await s.hooks.provideLexer(t):t?Ra.lex:Ra.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser(t):t?ro.parse:ro.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(a);try{s.hooks&&(r=s.hooks.preprocess(r));let o=(s.hooks?s.hooks.provideLexer(t):t?Ra.lex:Ra.lexInline)(r,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let l=(s.hooks?s.hooks.provideParser(t):t?ro.parse:ro.parseInline)(o,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(o){return a(o)}}}onError(t,r){return n=>{if(n.message+=`
1383
1386
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Mo(n.message+"",!0)+"</pre>";return r?Promise.resolve(i):i}if(r)return Promise.reject(n);throw n}}},hd=new DFe;function nn(e,t){return hd.parse(e,t)}nn.options=nn.setOptions=function(e){return hd.setOptions(e),nn.defaults=hd.defaults,GQ(nn.defaults),nn};nn.getDefaults=i7;nn.defaults=Sd;nn.use=function(...e){return hd.use(...e),nn.defaults=hd.defaults,GQ(nn.defaults),nn};nn.walkTokens=function(e,t){return hd.walkTokens(e,t)};nn.parseInline=hd.parseInline;nn.Parser=ro;nn.parser=ro.parse;nn.Renderer=Rv;nn.TextRenderer=d7;nn.Lexer=Ra;nn.lexer=Ra.lex;nn.Tokenizer=Lv;nn.Hooks=Wm;nn.parse=nn;nn.options;nn.setOptions;nn.use;nn.walkTokens;nn.parseInline;ro.parse;Ra.lex;var PFe=300,jFe="300px",FFe=500;function zFe(e={}){let{immediate:t=!1,debounceDelay:r=PFe,rootMargin:n=jFe,idleTimeout:i=FFe}=e,[s,a]=_.useState(!1),o=_.useRef(null),l=_.useRef(null),c=_.useRef(null),h=_.useMemo(()=>m=>{let x=Date.now();return window.setTimeout(()=>{m({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-x))})},1)},[]),f=_.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(m,x)=>window.requestIdleCallback(m,x):h,[h]),g=_.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m)},[]);return _.useEffect(()=>{if(t){a(!0);return}let m=o.current;if(!m)return;l.current&&(clearTimeout(l.current),l.current=null),c.current&&(g(c.current),c.current=null);let x=()=>{l.current&&(clearTimeout(l.current),l.current=null),c.current&&(g(c.current),c.current=null)},v=w=>{c.current=f(L=>{L.timeRemaining()>0||L.didTimeout?(a(!0),w.disconnect()):c.current=f(()=>{a(!0),w.disconnect()},{timeout:i/2})},{timeout:i})},C=w=>{x(),l.current=window.setTimeout(()=>{var L,N;let A=w.takeRecords();(A.length===0||(N=(L=A.at(-1))==null?void 0:L.isIntersecting)!=null&&N)&&v(w)},r)},k=(w,L)=>{w.isIntersecting?C(L):x()},T=new IntersectionObserver(w=>{for(let L of w)k(L,T)},{rootMargin:n,threshold:0});return T.observe(m),()=>{l.current&&clearTimeout(l.current),c.current&&g(c.current),T.disconnect()}},[t,r,n,i,g,f]),{shouldRender:s,containerRef:o}}var nJ=/\s/,$Fe=/^\s+$/,HFe=new Set(["code","pre","svg","math","annotation"]),UFe=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",qFe=e=>e.some(t=>UFe(t)&&HFe.has(t.tagName)),VFe=e=>{let t=[],r="",n=!1;for(let i of e){let s=nJ.test(i);s!==n&&r&&(t.push(r),r=""),r+=i,n=s}return r&&t.push(r),t},WFe=e=>{let t=[],r="";for(let n of e)nJ.test(n)?r+=n:(r&&(t.push(r),r=""),t.push(n));return r&&t.push(r),t},GFe=(e,t,r,n,i,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${i?0:r}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:a},children:[{type:"text",value:e}]}},YFe=(e,t,r,n,i)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(qFe(t))return Mh;let a=s,o=a.children.indexOf(e);if(o===-1)return;let l=e.value;if(!l.trim()){i.count+=l.length;return}let c=r.sep==="char"?WFe(l):VFe(l),h=n.prevContentLength,f=c.map(g=>{let m=i.count;if(i.count+=g.length,$Fe.test(g))return{type:"text",value:g};let x=h>0&&m<h,v=x?0:i.newIndex++*r.stagger;return GFe(g,r.animation,r.duration,r.easing,x,v)});return a.children.splice(o,1,...f),o+f.length},XFe=0;function S6(e){var t,r,n,i,s;let a={animation:(t=e==null?void 0:e.animation)!=null?t:"fadeIn",duration:(r=e==null?void 0:e.duration)!=null?r:150,easing:(n=e==null?void 0:e.easing)!=null?n:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(s=e==null?void 0:e.stagger)!=null?s:40},o={prevContentLength:0,lastRenderCharCount:0},l=XFe++,c=()=>h=>{let f={count:0,newIndex:0};bC(h,"text",(g,m)=>YFe(g,m,a,o,f)),o.lastRenderCharCount=f.count,o.prevContentLength=0};return Object.defineProperty(c,"name",{value:`rehypeAnimate$${l}`}),{name:"animate",type:"animate",rehypePlugin:c,setPrevContentLength(h){o.prevContentLength=h},getLastRenderCharCount(){let h=o.lastRenderCharCount;return o.lastRenderCharCount=0,h}}}S6();var iJ=_.createContext(!1),KFe=()=>_.useContext(iJ),f7=(...e)=>z_(pC(e)),ZFe=(e,t)=>{if(!e||!t)return t;let r=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(r)?n:`${e}:${n}`).join(" ")},QFe=e=>e?(...t)=>ZFe(e,z_(pC(t))):f7,Vf=(e,t,r)=>{let n=typeof t=="string"&&r.startsWith("text/csv")?"\uFEFF":"",i=typeof t=="string"?new Blob([n+t],{type:r}):t,s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)},_6=_.createContext(f7),kr=()=>_.useContext(_6),JFe=f7("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),eze=e=>{let t={};for(let r of e.split(";")){let n=r.indexOf(":");if(n>0){let i=r.slice(0,n).trim(),s=r.slice(n+1).trim();i&&s&&(t[i]=s)}}return t},tze=_.memo(({children:e,result:t,language:r,className:n,startLine:i,lineNumbers:s=!0,...a})=>{let o=kr(),l=_.useMemo(()=>o(JFe),[o]),c=_.useMemo(()=>{let h={};return t.bg&&(h["--sdm-bg"]=t.bg),t.fg&&(h["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(h,eze(t.rootStyle)),h},[t.bg,t.fg,t.rootStyle]);return p.jsx("div",{className:o(n,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":r,"data-streamdown":"code-block-body",...a,children:p.jsx("pre",{className:o(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:c,children:p.jsx("code",{className:s?o("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((h,f)=>p.jsx("span",{className:s?l:void 0,children:h.length===0||h.length===1&&h[0].content===""?`
1384
1387
  `:h.map((g,m)=>{let x={},v=!!g.bgColor;if(g.color&&(x["--sdm-c"]=g.color),g.bgColor&&(x["--sdm-tbg"]=g.bgColor),g.htmlStyle)for(let[C,k]of Object.entries(g.htmlStyle))C==="color"?x["--sdm-c"]=k:C==="background-color"?(x["--sdm-tbg"]=k,v=!0):x[C]=k;return p.jsx("span",{className:o("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",v&&"bg-[var(--sdm-tbg)]",v&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:x,...g.htmlAttrs,children:g.content},m)})},f))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),rze=({className:e,language:t,style:r,isIncomplete:n,...i})=>{let s=kr();return p.jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...r},...i})},sJ=_.createContext({code:""}),aJ=()=>_.useContext(sJ),nze=({language:e})=>{let t=kr();return p.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:p.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},ize=e=>{let t=e.length;for(;t>0&&e[t-1]===`
1385
- `;)t--;return e.slice(0,t)},sze=_.lazy(()=>re(()=>import("./highlighted-body-OFNGDK62-CbTQmRda.js"),[]).then(e=>({default:e.HighlightedCodeBlockBody}))),aze=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:s,lineNumbers:a,...o})=>{let l=kr(),c=_.useMemo(()=>ize(e),[e]),h=_.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
1388
+ `;)t--;return e.slice(0,t)},sze=_.lazy(()=>re(()=>import("./highlighted-body-OFNGDK62-CkE4PgdB.js"),[]).then(e=>({default:e.HighlightedCodeBlockBody}))),aze=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:s,lineNumbers:a,...o})=>{let l=kr(),c=_.useMemo(()=>ize(e),[e]),h=_.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
1386
1389
  `).map(f=>[{content:f,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return p.jsx(sJ.Provider,{value:{code:e},children:p.jsxs(rze,{isIncomplete:i,language:t,children:[p.jsx(nze,{language:t}),n?p.jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:p.jsx("div",{className:l("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,p.jsx(_.Suspense,{fallback:p.jsx(tze,{className:r,language:t,lineNumbers:a,result:h,startLine:s,...o}),children:p.jsx(sze,{className:r,code:c,language:t,lineNumbers:a,raw:h,startLine:s,...o})})]})})},oze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),lze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),cze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),uze=e=>p.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[p.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),p.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),hze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),dze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),fze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),pze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),mze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),gze=e=>p.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:p.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Gm={CheckIcon:oze,CopyIcon:lze,DownloadIcon:cze,ExternalLinkIcon:pze,Loader2Icon:uze,Maximize2Icon:hze,RotateCcwIcon:dze,XIcon:fze,ZoomInIcon:mze,ZoomOutIcon:gze},oJ=_.createContext(Gm),yze=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(i=>e[i]===t[i])},KD=({icons:e,children:t})=>{let r=_.useRef(e),n=_.useRef(e?{...Gm,...e}:Gm);yze(r.current,e)||(r.current=e,n.current=e?{...Gm,...e}:Gm);let i=n.current;return p.jsx(oJ.Provider,{value:i,children:t})},bo=()=>_.useContext(oJ),lJ={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},E6=_.createContext(lJ),gc=()=>_.useContext(E6),ZD=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:i,code:s,...a})=>{let o=kr(),[l,c]=_.useState(!1),h=_.useRef(0),{code:f}=aJ(),{isAnimating:g}=_.useContext(ua),m=gc(),x=s??f,v=async()=>{var T;if(typeof window>"u"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(x),c(!0),e==null||e(),h.current=window.setTimeout(()=>c(!1),r))}catch(w){t==null||t(w)}};_.useEffect(()=>()=>{window.clearTimeout(h.current)},[]);let C=bo(),k=l?C.CheckIcon:C.CopyIcon;return p.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:g,onClick:v,title:m.copyCode,type:"button",...a,children:n??p.jsx(k,{size:14})})},QD={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},xze=({onDownload:e,onError:t,language:r,children:n,className:i,code:s,...a})=>{let o=kr(),{code:l}=aJ(),{isAnimating:c}=_.useContext(ua),h=gc(),f=bo(),g=s??l,m=`file.${r&&r in QD?QD[r]:"txt"}`,x="text/plain",v=()=>{try{Vf(m,g,x),e==null||e()}catch(C){t==null||t(C)}};return p.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:c,onClick:v,title:h.downloadFile,type:"button",...a,children:n??p.jsx(f.DownloadIcon,{size:14})})},JD=()=>{let{Loader2Icon:e}=bo(),t=kr();return p.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[p.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),p.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:p.jsx(e,{className:t("size-4 animate-spin")})})]})},bze=/\.[^/.]+$/,vze=({node:e,className:t,src:r,alt:n,onLoad:i,onError:s,...a})=>{let{DownloadIcon:o}=bo(),l=kr(),c=_.useRef(null),[h,f]=_.useState(!1),[g,m]=_.useState(!1),x=gc(),v=a.width!=null||a.height!=null,C=(h||v)&&!g,k=g&&!v;_.useEffect(()=>{let N=c.current;if(N!=null&&N.complete){let A=N.naturalWidth>0;f(A),m(!A)}},[]);let T=_.useCallback(N=>{f(!0),m(!1),i==null||i(N)},[i]),w=_.useCallback(N=>{f(!1),m(!0),s==null||s(N)},[s]),L=async()=>{if(r)try{let N=await(await fetch(r)).blob(),A=new URL(r,window.location.origin).pathname.split("/").pop()||"",R=A.split(".").pop(),P=A.includes(".")&&R!==void 0&&R.length<=4,q="";if(P)q=A;else{let j=N.type,U="png";j.includes("jpeg")||j.includes("jpg")?U="jpg":j.includes("png")?U="png":j.includes("svg")?U="svg":j.includes("gif")?U="gif":j.includes("webp")&&(U="webp"),q=`${(n||A||"image").replace(bze,"")}.${U}`}Vf(q,N,N.type)}catch{window.open(r,"_blank")}};return r?p.jsxs("div",{className:l("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[p.jsx("img",{alt:n,className:l("max-w-full rounded-lg",k&&"hidden",t),"data-streamdown":"image",onError:w,onLoad:T,ref:c,src:r,...a}),k&&p.jsx("span",{className:l("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),p.jsx("div",{className:l("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),C&&p.jsx("button",{className:l("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:L,title:x.downloadImage,type:"button",children:p.jsx(o,{size:14})})]}):null},vg=0,p7=()=>{vg+=1,vg===1&&(document.body.style.overflow="hidden")},m7=()=>{vg=Math.max(0,vg-1),vg===0&&(document.body.style.overflow="")},Cze=({url:e,isOpen:t,onClose:r,onConfirm:n})=>{let{CheckIcon:i,CopyIcon:s,ExternalLinkIcon:a,XIcon:o}=bo(),l=kr(),[c,h]=_.useState(!1),f=gc(),g=_.useCallback(async()=>{try{await navigator.clipboard.writeText(e),h(!0),setTimeout(()=>h(!1),2e3)}catch{}},[e]),m=_.useCallback(()=>{n(),r()},[n,r]);return _.useEffect(()=>{if(t){p7();let x=v=>{v.key==="Escape"&&r()};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x),m7()}}},[t,r]),t?p.jsx("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:r,onKeyDown:x=>{x.key==="Escape"&&r()},role:"button",tabIndex:0,children:p.jsxs("div",{className:l("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:x=>x.stopPropagation(),onKeyDown:x=>x.stopPropagation(),role:"presentation",children:[p.jsx("button",{className:l("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:r,title:f.close,type:"button",children:p.jsx(o,{size:16})}),p.jsxs("div",{className:l("flex flex-col gap-2"),children:[p.jsxs("div",{className:l("flex items-center gap-2 font-semibold text-lg"),children:[p.jsx(a,{size:20}),p.jsx("span",{children:f.openExternalLink})]}),p.jsx("p",{className:l("text-muted-foreground text-sm"),children:f.externalLinkWarning})]}),p.jsx("div",{className:l("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),p.jsxs("div",{className:l("flex gap-2"),children:[p.jsx("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:g,type:"button",children:c?p.jsxs(p.Fragment,{children:[p.jsx(i,{size:14}),p.jsx("span",{children:f.copied})]}):p.jsxs(p.Fragment,{children:[p.jsx(s,{size:14}),p.jsx("span",{children:f.copyLink})]})}),p.jsxs("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:m,type:"button",children:[p.jsx(a,{size:14}),p.jsx("span",{children:f.openLink})]})]})]})}):null},A6=_.createContext(null),g7=()=>_.useContext(A6),vZe=()=>{var e;let t=g7();return(e=t==null?void 0:t.code)!=null?e:null},y7=()=>{var e;let t=g7();return(e=t==null?void 0:t.mermaid)!=null?e:null},kze=e=>{var t;let r=g7();return r!=null&&r.renderers&&e&&(t=r.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?t:null},Tze=(e,t)=>{var r;let n=(r=void 0)!=null?r:5;return new Promise((i,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),o=new Image;o.crossOrigin="anonymous",o.onload=()=>{let l=document.createElement("canvas"),c=o.width*n,h=o.height*n;l.width=c,l.height=h;let f=l.getContext("2d");if(!f){s(new Error("Failed to create 2D canvas context for PNG export"));return}f.drawImage(o,0,0,c,h),l.toBlob(g=>{if(!g){s(new Error("Failed to create PNG blob"));return}i(g)},"image/png")},o.onerror=()=>s(new Error("Failed to load SVG image")),o.src=a})},wze=({chart:e,children:t,className:r,onDownload:n,config:i,onError:s})=>{let a=kr(),[o,l]=_.useState(!1),c=_.useRef(null),{isAnimating:h}=_.useContext(ua),f=bo(),g=y7(),m=gc(),x=async v=>{try{if(v==="mmd"){Vf("diagram.mmd",e,"text/plain"),l(!1),n==null||n(v);return}if(!g){s==null||s(new Error("Mermaid plugin not available"));return}let C=g.getMermaid(i),k=e.split("").reduce((L,N)=>(L<<5)-L+N.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(k)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:w}=await C.render(T,e);if(!w){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(v==="svg"){Vf("diagram.svg",w,"image/svg+xml"),l(!1),n==null||n(v);return}if(v==="png"){let L=await Tze(w);Vf("diagram.png",L,"image/png"),n==null||n(v),l(!1);return}}catch(C){s==null||s(C)}};return _.useEffect(()=>{let v=C=>{let k=C.composedPath();c.current&&!k.includes(c.current)&&l(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),p.jsxs("div",{className:a("relative"),ref:c,children:[p.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:h,onClick:()=>l(!o),title:m.downloadDiagram,type:"button",children:t??p.jsx(f.DownloadIcon,{size:14})}),o?p.jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[p.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),p.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),p.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})},Sze=({chart:e,config:t,onFullscreen:r,onExit:n,className:i,...s})=>{let{Maximize2Icon:a,XIcon:o}=bo(),l=kr(),[c,h]=_.useState(!1),{isAnimating:f,controls:g}=_.useContext(ua),m=gc(),x=(()=>{if(typeof g=="boolean")return g;let C=g.mermaid;return C===!1?!1:C===!0||C===void 0?!0:C.panZoom!==!1})(),v=()=>{h(!c)};return _.useEffect(()=>{if(c){p7();let C=k=>{k.key==="Escape"&&h(!1)};return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C),m7()}}},[c]),_.useEffect(()=>{c?r==null||r():n&&n()},[c,r,n]),p.jsxs(p.Fragment,{children:[p.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:f,onClick:v,title:m.viewFullscreen,type:"button",...s,children:p.jsx(a,{size:14})}),c?Zo.createPortal(p.jsxs("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:v,onKeyDown:C=>{C.key==="Escape"&&v()},role:"button",tabIndex:0,children:[p.jsx("button",{className:l("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:v,title:m.exitFullscreen,type:"button",children:p.jsx(o,{size:20})}),p.jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:C=>C.stopPropagation(),onKeyDown:C=>C.stopPropagation(),role:"presentation",children:p.jsx(HJ,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:x})})]}),document.body):null]})},cJ=e=>{var t,r;let n=[],i=[],s=e.querySelectorAll("thead th");for(let o of s)n.push(((t=o.textContent)==null?void 0:t.trim())||"");let a=e.querySelectorAll("tbody tr");for(let o of a){let l=[],c=o.querySelectorAll("td");for(let h of c)l.push(((r=h.textContent)==null?void 0:r.trim())||"");i.push(l)}return{headers:n,rows:i}},uJ=e=>{let{headers:t,rows:r}=e,n=o=>{let l=!1,c=!1;for(let h of o){if(h==='"'){l=!0,c=!0;break}(h===","||h===`
1387
1390
  `)&&(l=!0)}return l?c?`"${o.replace(/"/g,'""')}"`:`"${o}"`:o},i=t.length>0?r.length+1:r.length,s=new Array(i),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let o of r)s[a]=o.map(n).join(","),a+=1;return s.join(`
1388
1391
  `)},_ze=e=>{let{headers:t,rows:r}=e,n=o=>{let l=!1;for(let h of o)if(h===" "||h===`
@@ -1401,7 +1404,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
1401
1404
  `)?"":`
1402
1405
  `);return`${a}${h}${l}
1403
1406
 
1404
- `})}return r},a$e=/([\\`*_~[\]|])/g,o$e=e=>e.replace(a$e,"\\$1"),l$e=(e,t)=>{if(!t.length)return e;let r=e;for(let n of t){let i=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");r=r.replace(i,(s,a,o,l)=>{let c=o$e(o).replace(/\n\n/g,"&#10;&#10;");return a+c+l})}return r},jJ=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(jJ).join(""):"",c$e=e=>t=>{if(!e||e.length===0)return;let r=new Set(e.map(n=>n.toLowerCase()));fo(t,"element",n=>{if(r.has(n.tagName.toLowerCase())){let i=jJ(n);n.children=i?[{type:"text",value:i}]:[]}})},u$e=()=>e=>{fo(e,"code",t=>{var r,n;t.meta&&(t.data=(r=t.data)!=null?r:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta})})},h$e=/^[ \t]*<[\w!/?-]/,d$e=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,f$e=e=>typeof e!="string"||e.length===0||!h$e.test(e)?e:e.replace(d$e,"$1"),uP,hP,dP,fP,Yb={...Eh,protocols:{...Eh.protocols,href:[...(hP=(uP=Eh.protocols)==null?void 0:uP.href)!=null?hP:[],"tel"]},attributes:{...Eh.attributes,code:[...(fP=(dP=Eh.attributes)==null?void 0:dP.code)!=null?fP:[],"metastring"]}},R6={raw:m6,sanitize:[YZ,Yb],harden:[R9e,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},p$e={gfm:[ABe,{}],codeMeta:u$e},pP=Object.values(R6),m$e=Object.values(p$e),g$e={block:" ▋",circle:" ●"},FJ=["github-light","github-dark"],zJ={enabled:!0},y$e={shikiTheme:FJ,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:zJ},ua=_.createContext(y$e),$J=_.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:r,index:n,isIncomplete:i,dir:s,animatePlugin:a,...o})=>{if(a){let h=a.getLastRenderCharCount();a.setPrevContentLength(h)}let l=typeof e=="string"&&r?f$e(e):e,c=p.jsx(PJ,{...o,children:l});return p.jsx(iJ.Provider,{value:i,children:s?p.jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let r=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(r.length!==n.length||r.some(i=>{var s,a;return((s=e.components)==null?void 0:s[i])!==((a=t.components)==null?void 0:a[i])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});$J.displayName="Block";var Ho=_.memo(({children:e,mode:t="streaming",dir:r,parseIncompleteMarkdown:n=!0,normalizeHtmlIndentation:i=!1,components:s,rehypePlugins:a=pP,remarkPlugins:o=m$e,className:l,shikiTheme:c=FJ,mermaid:h,controls:f=!0,isAnimating:g=!1,animated:m,BlockComponent:x=$J,parseMarkdownIntoBlocksFn:v=i$e,caret:C,plugins:k,remend:T,linkSafety:w=zJ,lineNumbers:L=!0,allowedTags:N,literalTagContent:A,translations:R,icons:P,prefix:q,onAnimationStart:j,onAnimationEnd:U,...W})=>{let J=_.useId(),[G,O]=_.useTransition(),D=_.useMemo(()=>QFe(q),[q]),H=_.useRef(null),Y=_.useRef(j),ae=_.useRef(U);Y.current=j,ae.current=U,_.useEffect(()=>{var Be,Ee,je;if(t==="static")return;let ge=H.current;if(H.current=g,ge===null){g&&((Be=Y.current)==null||Be.call(Y));return}g&&!ge?(Ee=Y.current)==null||Ee.call(Y):!g&&ge&&((je=ae.current)==null||je.call(ae))},[g,t]);let z=_.useMemo(()=>N?Object.keys(N):[],[N]),K=_.useMemo(()=>{if(typeof e!="string")return"";let Be=t==="streaming"&&n?FDe(e,T):e;return A&&A.length>0&&(Be=l$e(Be,A)),z.length>0&&(Be=s$e(Be,z)),Be},[e,t,n,T,z,A]),se=_.useMemo(()=>v(K),[K,v]),[X,ke]=_.useState(se);_.useEffect(()=>{t==="streaming"&&!Ne?O(()=>{ke(se)}):ke(se)},[se,t]);let ye=t==="streaming"?X:se,we=_.useMemo(()=>r==="auto"?ye.map(tP):void 0,[ye,r]),Fe=_.useMemo(()=>ye.map((Be,Ee)=>`${J}-${Ee}`),[ye.length,J]),ue=_.useMemo(()=>m===!0?"true":m?JSON.stringify(m):"",[m]),Ne=_.useMemo(()=>ue?ue==="true"?S6():S6(m):null,[ue]),Te=_.useMemo(()=>{var Be,Ee;return{shikiTheme:(Ee=(Be=k==null?void 0:k.code)==null?void 0:Be.getThemes())!=null?Ee:c,controls:f,isAnimating:g,lineNumbers:L,mode:t,mermaid:h,linkSafety:w}},[c,f,g,L,t,h,w,k==null?void 0:k.code]),Ue=_.useMemo(()=>R?JSON.stringify(R):"",[R]),Qe=_.useMemo(()=>({...lJ,...R}),[Ue]),We=_.useMemo(()=>{let{inlineCode:Be,...Ee}=s??{},je={...Bze,...Ee};if(Be){let ge=je.code;je.code=De=>"data-block"in De?ge?_.createElement(ge,De):null:_.createElement(Be,De)}return je},[s]),de=_.useMemo(()=>{let Be=[];return k!=null&&k.cjk&&(Be=[...Be,...k.cjk.remarkPluginsBefore]),Be=[...Be,...o],k!=null&&k.cjk&&(Be=[...Be,...k.cjk.remarkPluginsAfter]),k!=null&&k.math&&(Be=[...Be,k.math.remarkPlugin]),Be},[o,k==null?void 0:k.math,k==null?void 0:k.cjk]),te=_.useMemo(()=>{var Be;let Ee=a;if(N&&Object.keys(N).length>0&&a===pP){let je={...Yb,tagNames:[...(Be=Yb.tagNames)!=null?Be:[],...Object.keys(N)],attributes:{...Yb.attributes,...N}};Ee=[R6.raw,[YZ,je],R6.harden]}return A&&A.length>0&&(Ee=[...Ee,[c$e,A]]),k!=null&&k.math&&(Ee=[...Ee,k.math.rehypePlugin]),Ne&&g&&(Ee=[...Ee,Ne.rehypePlugin]),Ee},[a,k==null?void 0:k.math,Ne,g,N,A]),$e=_.useMemo(()=>{if(!g||ye.length===0)return!1;let Be=ye.at(-1);return rP(Be)||zze(Be)},[g,ye]),Ie=_.useMemo(()=>C&&g&&!$e?{"--streamdown-caret":`"${g$e[C]}"`}:void 0,[C,g,$e]);return t==="static"?p.jsx(E6.Provider,{value:Qe,children:p.jsx(A6.Provider,{value:k??null,children:p.jsx(ua.Provider,{value:Te,children:p.jsx(KD,{icons:P,children:p.jsx(_6.Provider,{value:D,children:p.jsx("div",{className:D("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:r==="auto"?tP(K):r,children:p.jsx(PJ,{components:We,rehypePlugins:te,remarkPlugins:de,...W,children:K})})})})})})}):p.jsx(E6.Provider,{value:Qe,children:p.jsx(A6.Provider,{value:k??null,children:p.jsx(ua.Provider,{value:Te,children:p.jsx(KD,{icons:P,children:p.jsx(_6.Provider,{value:D,children:p.jsxs("div",{className:D("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",C&&!$e?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),style:Ie,children:[ye.length===0&&C&&g&&p.jsx("span",{}),ye.map((Be,Ee)=>{var je;let ge=Ee===ye.length-1,De=g&&ge&&rP(Be);return p.jsx(x,{animatePlugin:Ne,components:We,content:Be,dir:(je=we==null?void 0:we[Ee])!=null?je:r!=="auto"?r:void 0,index:Ee,isIncomplete:De,rehypePlugins:te,remarkPlugins:de,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:n,...W},Fe[Ee])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Ho.displayName="Streamdown";var x$e=({children:e,className:t,minZoom:r=.5,maxZoom:n=3,zoomStep:i=.1,showControls:s=!0,initialZoom:a=1,fullscreen:o=!1})=>{let{RotateCcwIcon:l,ZoomInIcon:c,ZoomOutIcon:h}=bo(),f=kr(),g=_.useRef(null),m=_.useRef(null),[x,v]=_.useState(a),[C,k]=_.useState({x:0,y:0}),[T,w]=_.useState(!1),[L,N]=_.useState({x:0,y:0}),[A,R]=_.useState({x:0,y:0}),P=_.useCallback(D=>{v(H=>Math.max(r,Math.min(n,H+D)))},[r,n]),q=_.useCallback(()=>{P(i)},[P,i]),j=_.useCallback(()=>{P(-i)},[P,i]),U=_.useCallback(()=>{v(a),k({x:0,y:0})},[a]),W=_.useCallback(D=>{D.preventDefault();let H=D.deltaY>0?-i:i;P(H)},[P,i]),J=_.useCallback(D=>{if(D.button!==0||D.isPrimary===!1)return;w(!0),N({x:D.clientX,y:D.clientY}),R(C);let H=D.currentTarget;H instanceof HTMLElement&&H.setPointerCapture(D.pointerId)},[C]),G=_.useCallback(D=>{if(!T)return;D.preventDefault();let H=D.clientX-L.x,Y=D.clientY-L.y;k({x:A.x+H,y:A.y+Y})},[T,L,A]),O=_.useCallback(D=>{w(!1);let H=D.currentTarget;H instanceof HTMLElement&&H.releasePointerCapture(D.pointerId)},[]);return _.useEffect(()=>{let D=g.current;if(D)return D.addEventListener("wheel",W,{passive:!1}),()=>{D.removeEventListener("wheel",W)}},[W]),_.useEffect(()=>{let D=m.current;if(D&&T)return document.body.style.userSelect="none",D.addEventListener("pointermove",G,{passive:!1}),D.addEventListener("pointerup",O),D.addEventListener("pointercancel",O),()=>{document.body.style.userSelect="",D.removeEventListener("pointermove",G),D.removeEventListener("pointerup",O),D.removeEventListener("pointercancel",O)}},[T,G,O]),p.jsxs("div",{className:f("relative flex flex-col",o?"h-full w-full":"min-h-28 w-full",t),ref:g,style:{cursor:T?"grabbing":"grab"},children:[s?p.jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",o?"bottom-4 left-4":"bottom-2 left-2"),children:[p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:x>=n,onClick:q,title:"Zoom in",type:"button",children:p.jsx(c,{size:16})}),p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:x<=r,onClick:j,title:"Zoom out",type:"button",children:p.jsx(h,{size:16})}),p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:U,title:"Reset zoom and pan",type:"button",children:p.jsx(l,{size:16})})]}):null,p.jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",o?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:J,ref:m,role:"application",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${x})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},HJ=({chart:e,className:t,config:r,fullscreen:n=!1,showControls:i=!0})=>{let s=kr(),[a,o]=_.useState(null),[l,c]=_.useState(!1),[h,f]=_.useState(""),[g,m]=_.useState(""),[x,v]=_.useState(0),{mermaid:C}=_.useContext(ua),k=y7(),T=C==null?void 0:C.errorComponent,{shouldRender:w,containerRef:L}=zFe({immediate:n});if(_.useEffect(()=>{if(w){if(!k){o("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{o(null),c(!0);let A=k.getMermaid(r),R=e.split("").reduce((j,U)=>(j<<5)-j+U.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(R)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:q}=await A.render(P,e);f(q),m(q)}catch(A){if(!(g||h)){let R=A instanceof Error?A.message:"Failed to render Mermaid chart";o(R)}}finally{c(!1)}})()}},[e,r,x,w,k]),!(w||h||g))return p.jsx("div",{className:s("my-4 min-h-[200px]",t),ref:L});if(l&&!h&&!g)return p.jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:L,children:p.jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[p.jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),p.jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!h&&!g){let A=()=>v(R=>R+1);return T?p.jsx("div",{ref:L,children:p.jsx(T,{chart:e,error:a,retry:A})}):p.jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:L,children:[p.jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),p.jsxs("details",{className:s("mt-2"),children:[p.jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),p.jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let N=h||g;return p.jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:L,children:p.jsx(x$e,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:p.jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:N},role:"img"})})})};const UJ=_.createContext({});function b$e(e){const t=_.useRef(null);return t.current===null&&(t.current=e()),t.current}const v$e=typeof window<"u",C$e=v$e?_.useLayoutEffect:_.useEffect,b7=_.createContext(null);function v7(e,t){e.indexOf(t)===-1&&e.push(t)}function Mv(e,t){const r=e.indexOf(t);r>-1&&e.splice(r,1)}const nl=(e,t,r)=>r>t?t:r<e?e:r;let C7=()=>{};const Ru={},qJ=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function VJ(e){return typeof e=="object"&&e!==null}const WJ=e=>/^0[^.\s]+$/u.test(e);function GJ(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fa=e=>e,k$e=(e,t)=>r=>t(e(r)),q1=(...e)=>e.reduce(k$e),s1=(e,t,r)=>{const n=t-e;return n===0?1:(r-e)/n};class k7{constructor(){this.subscriptions=[]}add(t){return v7(this.subscriptions,t),()=>Mv(this.subscriptions,t)}notify(t,r,n){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,r,n);else for(let s=0;s<i;s++){const a=this.subscriptions[s];a&&a(t,r,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const sa=e=>e*1e3,Pa=e=>e/1e3;function YJ(e,t){return t?e*(1e3/t):0}const XJ=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,T$e=1e-7,w$e=12;function S$e(e,t,r,n,i){let s,a,o=0;do a=t+(r-t)/2,s=XJ(a,n,i)-e,s>0?r=a:t=a;while(Math.abs(s)>T$e&&++o<w$e);return a}function V1(e,t,r,n){if(e===t&&r===n)return Fa;const i=s=>S$e(s,0,1,e,r);return s=>s===0||s===1?s:XJ(i(s),t,n)}const KJ=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ZJ=e=>t=>1-e(1-t),QJ=V1(.33,1.53,.69,.99),T7=ZJ(QJ),JJ=KJ(T7),eee=e=>e>=1?1:(e*=2)<1?.5*T7(e):.5*(2-Math.pow(2,-10*(e-1))),w7=e=>1-Math.sin(Math.acos(e)),tee=ZJ(w7),ree=KJ(w7),_$e=V1(.42,0,1,1),E$e=V1(0,0,.58,1),nee=V1(.42,0,.58,1),A$e=e=>Array.isArray(e)&&typeof e[0]!="number",iee=e=>Array.isArray(e)&&typeof e[0]=="number",N$e={linear:Fa,easeIn:_$e,easeInOut:nee,easeOut:E$e,circIn:w7,circInOut:ree,circOut:tee,backIn:T7,backInOut:JJ,backOut:QJ,anticipate:eee},L$e=e=>typeof e=="string",mP=e=>{if(iee(e)){C7(e.length===4);const[t,r,n,i]=e;return V1(t,r,n,i)}else if(L$e(e))return N$e[e];return e},sb=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function R$e(e,t){let r=new Set,n=new Set,i=!1,s=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){a.has(h)&&(c.schedule(h),e()),h(o)}const c={schedule:(h,f=!1,g=!1)=>{const x=g&&i?r:n;return f&&a.add(h),x.add(h),h},cancel:h=>{n.delete(h),a.delete(h)},process:h=>{if(o=h,i){s=!0;return}i=!0;const f=r;r=n,n=f,r.forEach(l),r.clear(),i=!1,s&&(s=!1,c.process(h))}};return c}const M$e=40;function see(e,t){let r=!1,n=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>r=!0,a=sb.reduce((w,L)=>(w[L]=R$e(s),w),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:h,update:f,preRender:g,render:m,postRender:x}=a,v=()=>{const w=Ru.useManualTiming,L=w?i.timestamp:performance.now();r=!1,w||(i.delta=n?1e3/60:Math.max(Math.min(L-i.timestamp,M$e),1)),i.timestamp=L,i.isProcessing=!0,o.process(i),l.process(i),c.process(i),h.process(i),f.process(i),g.process(i),m.process(i),x.process(i),i.isProcessing=!1,r&&t&&(n=!1,e(v))},C=()=>{r=!0,n=!0,i.isProcessing||e(v)};return{schedule:sb.reduce((w,L)=>{const N=a[L];return w[L]=(A,R=!1,P=!1)=>(r||C(),N.schedule(A,R,P)),w},{}),cancel:w=>{for(let L=0;L<sb.length;L++)a[sb[L]].cancel(w)},state:i,steps:a}}const{schedule:on,cancel:Mu,state:Bi,steps:OT}=see(typeof requestAnimationFrame<"u"?requestAnimationFrame:Fa,!0);let Xb;function I$e(){Xb=void 0}const ds={now:()=>(Xb===void 0&&ds.set(Bi.isProcessing||Ru.useManualTiming?Bi.timestamp:performance.now()),Xb),set:e=>{Xb=e,queueMicrotask(I$e)}},aee=e=>t=>typeof t=="string"&&t.startsWith(e),oee=aee("--"),O$e=aee("var(--"),S7=e=>O$e(e)?B$e.test(e.split("/*")[0].trim()):!1,B$e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function gP(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const lp={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},a1={...lp,transform:e=>nl(0,1,e)},ab={...lp,default:1},Cg=e=>Math.round(e*1e5)/1e5,_7=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function D$e(e){return e==null}const P$e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,E7=(e,t)=>r=>!!(typeof r=="string"&&P$e.test(r)&&r.startsWith(e)||t&&!D$e(r)&&Object.prototype.hasOwnProperty.call(r,t)),lee=(e,t,r)=>n=>{if(typeof n!="string")return n;const[i,s,a,o]=n.match(_7);return{[e]:parseFloat(i),[t]:parseFloat(s),[r]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},j$e=e=>nl(0,255,e),BT={...lp,transform:e=>Math.round(j$e(e))},Fh={test:E7("rgb","red"),parse:lee("red","green","blue"),transform:({red:e,green:t,blue:r,alpha:n=1})=>"rgba("+BT.transform(e)+", "+BT.transform(t)+", "+BT.transform(r)+", "+Cg(a1.transform(n))+")"};function F$e(e){let t="",r="",n="",i="";return e.length>5?(t=e.substring(1,3),r=e.substring(3,5),n=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),r=e.substring(2,3),n=e.substring(3,4),i=e.substring(4,5),t+=t,r+=r,n+=n,i+=i),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const M6={test:E7("#"),parse:F$e,transform:Fh.transform},W1=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Kc=W1("deg"),Yo=W1("%"),_t=W1("px"),z$e=W1("vh"),$$e=W1("vw"),yP={...Yo,parse:e=>Yo.parse(e)/100,transform:e=>Yo.transform(e*100)},Mf={test:E7("hsl","hue"),parse:lee("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:r,alpha:n=1})=>"hsla("+Math.round(e)+", "+Yo.transform(Cg(t))+", "+Yo.transform(Cg(r))+", "+Cg(a1.transform(n))+")"},Kn={test:e=>Fh.test(e)||M6.test(e)||Mf.test(e),parse:e=>Fh.test(e)?Fh.parse(e):Mf.test(e)?Mf.parse(e):M6.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Fh.transform(e):Mf.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},H$e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function U$e(e){var t,r;return isNaN(e)&&typeof e=="string"&&(((t=e.match(_7))==null?void 0:t.length)||0)+(((r=e.match(H$e))==null?void 0:r.length)||0)>0}const cee="number",uee="color",q$e="var",V$e="var(",xP="${}",W$e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function A0(e){const t=e.toString(),r=[],n={color:[],number:[],var:[]},i=[];let s=0;const o=t.replace(W$e,l=>(Kn.test(l)?(n.color.push(s),i.push(uee),r.push(Kn.parse(l))):l.startsWith(V$e)?(n.var.push(s),i.push(q$e),r.push(l)):(n.number.push(s),i.push(cee),r.push(parseFloat(l))),++s,xP)).split(xP);return{values:r,split:o,indexes:n,types:i}}function G$e(e){return A0(e).values}function hee({split:e,types:t}){const r=e.length;return n=>{let i="";for(let s=0;s<r;s++)if(i+=e[s],n[s]!==void 0){const a=t[s];a===cee?i+=Cg(n[s]):a===uee?i+=Kn.transform(n[s]):i+=n[s]}return i}}function Y$e(e){return hee(A0(e))}const X$e=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,K$e=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:X$e(e);function Z$e(e){const t=A0(e);return hee(t)(t.values.map((n,i)=>K$e(n,t.split[i])))}const uo={test:U$e,parse:G$e,createTransformer:Y$e,getAnimatableNone:Z$e};function DT(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function Q$e({hue:e,saturation:t,lightness:r,alpha:n}){e/=360,t/=100,r/=100;let i=0,s=0,a=0;if(!t)i=s=a=r;else{const o=r<.5?r*(1+t):r+t-r*t,l=2*r-o;i=DT(l,o,e+1/3),s=DT(l,o,e),a=DT(l,o,e-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:n}}function Iv(e,t){return r=>r>0?t:e}const gn=(e,t,r)=>e+(t-e)*r,PT=(e,t,r)=>{const n=e*e,i=r*(t*t-n)+n;return i<0?0:Math.sqrt(i)},J$e=[M6,Fh,Mf],eHe=e=>J$e.find(t=>t.test(e));function bP(e){const t=eHe(e);if(!t)return!1;let r=t.parse(e);return t===Mf&&(r=Q$e(r)),r}const vP=(e,t)=>{const r=bP(e),n=bP(t);if(!r||!n)return Iv(e,t);const i={...r};return s=>(i.red=PT(r.red,n.red,s),i.green=PT(r.green,n.green,s),i.blue=PT(r.blue,n.blue,s),i.alpha=gn(r.alpha,n.alpha,s),Fh.transform(i))},I6=new Set(["none","hidden"]);function tHe(e,t){return I6.has(e)?r=>r<=0?e:t:r=>r>=1?t:e}function rHe(e,t){return r=>gn(e,t,r)}function A7(e){return typeof e=="number"?rHe:typeof e=="string"?S7(e)?Iv:Kn.test(e)?vP:sHe:Array.isArray(e)?dee:typeof e=="object"?Kn.test(e)?vP:nHe:Iv}function dee(e,t){const r=[...e],n=r.length,i=e.map((s,a)=>A7(s)(s,t[a]));return s=>{for(let a=0;a<n;a++)r[a]=i[a](s);return r}}function nHe(e,t){const r={...e,...t},n={};for(const i in r)e[i]!==void 0&&t[i]!==void 0&&(n[i]=A7(e[i])(e[i],t[i]));return i=>{for(const s in n)r[s]=n[s](i);return r}}function iHe(e,t){const r=[],n={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const s=t.types[i],a=e.indexes[s][n[s]],o=e.values[a]??0;r[i]=o,n[s]++}return r}const sHe=(e,t)=>{const r=uo.createTransformer(t),n=A0(e),i=A0(t);return n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length?I6.has(e)&&!i.values.length||I6.has(t)&&!n.values.length?tHe(e,t):q1(dee(iHe(n,i),i.values),r):Iv(e,t)};function fee(e,t,r){return typeof e=="number"&&typeof t=="number"&&typeof r=="number"?gn(e,t,r):A7(e)(e,t)}const aHe=e=>{const t=({timestamp:r})=>e(r);return{start:(r=!0)=>on.update(t,r),stop:()=>Mu(t),now:()=>Bi.isProcessing?Bi.timestamp:ds.now()}},pee=(e,t,r=10)=>{let n="";const i=Math.max(Math.round(t/r),2);for(let s=0;s<i;s++)n+=Math.round(e(s/(i-1))*1e4)/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},Ov=2e4;function N7(e){let t=0;const r=50;let n=e.next(t);for(;!n.done&&t<Ov;)t+=r,n=e.next(t);return t>=Ov?1/0:t}function oHe(e,t=100,r){const n=r({...e,keyframes:[0,t]}),i=Math.min(N7(n),Ov);return{type:"keyframes",ease:s=>n.next(i*s).value/t,duration:Pa(i)}}const In={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function O6(e,t){return e*Math.sqrt(1-t*t)}const lHe=12;function cHe(e,t,r){let n=r;for(let i=1;i<lHe;i++)n=n-e(n)/t(n);return n}const jT=.001;function uHe({duration:e=In.duration,bounce:t=In.bounce,velocity:r=In.velocity,mass:n=In.mass}){let i,s,a=1-t;a=nl(In.minDamping,In.maxDamping,a),e=nl(In.minDuration,In.maxDuration,Pa(e)),a<1?(i=c=>{const h=c*a,f=h*e,g=h-r,m=O6(c,a),x=Math.exp(-f);return jT-g/m*x},s=c=>{const f=c*a*e,g=f*r+r,m=Math.pow(a,2)*Math.pow(c,2)*e,x=Math.exp(-f),v=O6(Math.pow(c,2),a);return(-i(c)+jT>0?-1:1)*((g-m)*x)/v}):(i=c=>{const h=Math.exp(-c*e),f=(c-r)*e+1;return-jT+h*f},s=c=>{const h=Math.exp(-c*e),f=(r-c)*(e*e);return h*f});const o=5/e,l=cHe(i,s,o);if(e=sa(e),isNaN(l))return{stiffness:In.stiffness,damping:In.damping,duration:e};{const c=Math.pow(l,2)*n;return{stiffness:c,damping:a*2*Math.sqrt(n*c),duration:e}}}const hHe=["duration","bounce"],dHe=["stiffness","damping","mass"];function CP(e,t){return t.some(r=>e[r]!==void 0)}function fHe(e){let t={velocity:In.velocity,stiffness:In.stiffness,damping:In.damping,mass:In.mass,isResolvedFromDuration:!1,...e};if(!CP(e,dHe)&&CP(e,hHe))if(t.velocity=0,e.visualDuration){const r=e.visualDuration,n=2*Math.PI/(r*1.2),i=n*n,s=2*nl(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:In.mass,stiffness:i,damping:s}}else{const r=uHe({...e,velocity:0});t={...t,...r,mass:In.mass},t.isResolvedFromDuration=!0}return t}function Bv(e=In.visualDuration,t=In.bounce){const r=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:n,restDelta:i}=r;const s=r.keyframes[0],a=r.keyframes[r.keyframes.length-1],o={done:!1,value:s},{stiffness:l,damping:c,mass:h,duration:f,velocity:g,isResolvedFromDuration:m}=fHe({...r,velocity:-Pa(r.velocity||0)}),x=g||0,v=c/(2*Math.sqrt(l*h)),C=a-s,k=Pa(Math.sqrt(l/h)),T=Math.abs(C)<5;n||(n=T?In.restSpeed.granular:In.restSpeed.default),i||(i=T?In.restDelta.granular:In.restDelta.default);let w,L,N,A,R,P;if(v<1)N=O6(k,v),A=(x+v*k*C)/N,w=j=>{const U=Math.exp(-v*k*j);return a-U*(A*Math.sin(N*j)+C*Math.cos(N*j))},R=v*k*A+C*N,P=v*k*C-A*N,L=j=>Math.exp(-v*k*j)*(R*Math.sin(N*j)+P*Math.cos(N*j));else if(v===1){w=U=>a-Math.exp(-k*U)*(C+(x+k*C)*U);const j=x+k*C;L=U=>Math.exp(-k*U)*(k*j*U-x)}else{const j=k*Math.sqrt(v*v-1);w=G=>{const O=Math.exp(-v*k*G),D=Math.min(j*G,300);return a-O*((x+v*k*C)*Math.sinh(D)+j*C*Math.cosh(D))/j};const U=(x+v*k*C)/j,W=v*k*U-C*j,J=v*k*C-U*j;L=G=>{const O=Math.exp(-v*k*G),D=Math.min(j*G,300);return O*(W*Math.sinh(D)+J*Math.cosh(D))}}const q={calculatedDuration:m&&f||null,velocity:j=>sa(L(j)),next:j=>{if(!m&&v<1){const W=Math.exp(-v*k*j),J=Math.sin(N*j),G=Math.cos(N*j),O=a-W*(A*J+C*G),D=sa(W*(R*J+P*G));return o.done=Math.abs(D)<=n&&Math.abs(a-O)<=i,o.value=o.done?a:O,o}const U=w(j);if(m)o.done=j>=f;else{const W=sa(L(j));o.done=Math.abs(W)<=n&&Math.abs(a-U)<=i}return o.value=o.done?a:U,o},toString:()=>{const j=Math.min(N7(q),Ov),U=pee(W=>q.next(j*W).value,j,30);return j+"ms "+U},toTransition:()=>{}};return q}Bv.applyToOptions=e=>{const t=oHe(e,100,Bv);return e.ease=t.ease,e.duration=sa(t.duration),e.type="keyframes",e};const pHe=5;function mee(e,t,r){const n=Math.max(t-pHe,0);return YJ(r-e(n),t-n)}function B6({keyframes:e,velocity:t=0,power:r=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:h}){const f=e[0],g={done:!1,value:f},m=P=>o!==void 0&&P<o||l!==void 0&&P>l,x=P=>o===void 0?l:l===void 0||Math.abs(o-P)<Math.abs(l-P)?o:l;let v=r*t;const C=f+v,k=a===void 0?C:a(C);k!==C&&(v=k-f);const T=P=>-v*Math.exp(-P/n),w=P=>k+T(P),L=P=>{const q=T(P),j=w(P);g.done=Math.abs(q)<=c,g.value=g.done?k:j};let N,A;const R=P=>{m(g.value)&&(N=P,A=Bv({keyframes:[g.value,x(g.value)],velocity:mee(w,P,g.value),damping:i,stiffness:s,restDelta:c,restSpeed:h}))};return R(0),{calculatedDuration:null,next:P=>{let q=!1;return!A&&N===void 0&&(q=!0,L(P),R(P)),N!==void 0&&P>=N?A.next(P-N):(!q&&L(P),g)}}}function mHe(e,t,r){const n=[],i=r||Ru.mix||fee,s=e.length-1;for(let a=0;a<s;a++){let o=i(e[a],e[a+1]);if(t){const l=Array.isArray(t)?t[a]||Fa:t;o=q1(l,o)}n.push(o)}return n}function gHe(e,t,{clamp:r=!0,ease:n,mixer:i}={}){const s=e.length;if(C7(s===t.length),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=mHe(t,n,i),l=o.length,c=h=>{if(a&&h<e[0])return t[0];let f=0;if(l>1)for(;f<e.length-2&&!(h<e[f+1]);f++);const g=s1(e[f],e[f+1],h);return o[f](g)};return r?h=>c(nl(e[0],e[s-1],h)):c}function yHe(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const i=s1(0,t,n);e.push(gn(r,1,i))}}function xHe(e){const t=[0];return yHe(t,e.length-1),t}function bHe(e,t){return e.map(r=>r*t)}function vHe(e,t){return e.map(()=>t||nee).splice(0,e.length-1)}function kg({duration:e=300,keyframes:t,times:r,ease:n="easeInOut"}){const i=A$e(n)?n.map(mP):mP(n),s={done:!1,value:t[0]},a=bHe(r&&r.length===t.length?r:xHe(t),e),o=gHe(a,t,{ease:Array.isArray(i)?i:vHe(t,i)});return{calculatedDuration:e,next:l=>(s.value=o(l),s.done=l>=e,s)}}const CHe=e=>e!==null;function k3(e,{repeat:t,repeatType:r="loop"},n,i=1){const s=e.filter(CHe),o=i<0||t&&r!=="loop"&&t%2===1?0:s.length-1;return!o||n===void 0?s[o]:n}const kHe={decay:B6,inertia:B6,tween:kg,keyframes:kg,spring:Bv};function gee(e){typeof e.type=="string"&&(e.type=kHe[e.type])}class L7{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,r){return this.finished.then(t,r)}}const THe=e=>e/100;class Dv extends L7{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,i;const{motionValue:r}=this.options;r&&r.updatedAt!==ds.now()&&this.tick(ds.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(n=this.options).onStop)==null||i.call(n))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;gee(t);const{type:r=kg,repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:a=0}=t;let{keyframes:o}=t;const l=r||kg;l!==kg&&typeof o[0]!="number"&&(this.mixKeyframes=q1(THe,fee(o[0],o[1])),o=[0,100]);const c=l({...t,keyframes:o});s==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=N7(c));const{calculatedDuration:h}=c;this.calculatedDuration=h,this.resolvedDuration=h+i,this.totalDuration=this.resolvedDuration*(n+1)-i,this.generator=c}updateTime(t){const r=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(t,r=!1){const{generator:n,totalDuration:i,mixKeyframes:s,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:l}=this;if(this.startTime===null)return n.next(0);const{delay:c=0,keyframes:h,repeat:f,repeatType:g,repeatDelay:m,type:x,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),r?this.currentTime=t:this.updateTime(t);const k=this.currentTime-c*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?k<0:k>i;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let w=this.currentTime,L=n;if(f){const P=Math.min(this.currentTime,i)/o;let q=Math.floor(P),j=P%1;!j&&P>=1&&(j=1),j===1&&q--,q=Math.min(q,f+1),!!(q%2)&&(g==="reverse"?(j=1-j,m&&(j-=m/o)):g==="mirror"&&(L=a)),w=nl(0,1,j)*o}let N;T?(this.delayState.value=h[0],N=this.delayState):N=L.next(w),s&&!T&&(N.value=s(N.value));let{done:A}=N;!T&&l!==null&&(A=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&A);return R&&x!==B6&&(N.value=k3(h,this.options,C,this.speed)),v&&v(N.value),R&&this.finish(),N}then(t,r){return this.finished.then(t,r)}get duration(){return Pa(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pa(t)}get time(){return Pa(this.currentTime)}set time(t){t=sa(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const r=this.generator.next(t).value;return mee(n=>this.generator.next(n).value,t,r)}get speed(){return this.playbackSpeed}set speed(t){const r=this.playbackSpeed!==t;r&&this.driver&&this.updateTime(ds.now()),this.playbackSpeed=t,r&&this.driver&&(this.time=Pa(this.currentTime))}play(){var i,s;if(this.isStopped)return;const{driver:t=aHe,startTime:r}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),(s=(i=this.options).onPlay)==null||s.call(i);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(ds.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(t=this.options).onComplete)==null||r.call(t)}cancel(){var t,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(t=this.options).onCancel)==null||r.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),t.observe(this)}}function wHe(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const zh=e=>e*180/Math.PI,D6=e=>{const t=zh(Math.atan2(e[1],e[0]));return P6(t)},SHe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:D6,rotateZ:D6,skewX:e=>zh(Math.atan(e[1])),skewY:e=>zh(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},P6=e=>(e=e%360,e<0&&(e+=360),e),kP=D6,TP=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),wP=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),_He={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:TP,scaleY:wP,scale:e=>(TP(e)+wP(e))/2,rotateX:e=>P6(zh(Math.atan2(e[6],e[5]))),rotateY:e=>P6(zh(Math.atan2(-e[2],e[0]))),rotateZ:kP,rotate:kP,skewX:e=>zh(Math.atan(e[4])),skewY:e=>zh(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function j6(e){return e.includes("scale")?1:0}function F6(e,t){if(!e||e==="none")return j6(t);const r=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,i;if(r)n=_He,i=r;else{const o=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=SHe,i=o}if(!i)return j6(t);const s=n[t],a=i[1].split(",").map(AHe);return typeof s=="function"?s(a):a[s]}const EHe=(e,t)=>{const{transform:r="none"}=getComputedStyle(e);return F6(r,t)};function AHe(e){return parseFloat(e.trim())}const cp=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],up=new Set(cp),SP=e=>e===lp||e===_t,NHe=new Set(["x","y","z"]),LHe=cp.filter(e=>!NHe.has(e));function RHe(e){const t=[];return LHe.forEach(r=>{const n=e.getValue(r);n!==void 0&&(t.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),t}const hu={width:({x:e},{paddingLeft:t="0",paddingRight:r="0",boxSizing:n})=>{const i=e.max-e.min;return n==="border-box"?i:i-parseFloat(t)-parseFloat(r)},height:({y:e},{paddingTop:t="0",paddingBottom:r="0",boxSizing:n})=>{const i=e.max-e.min;return n==="border-box"?i:i-parseFloat(t)-parseFloat(r)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>F6(t,"x"),y:(e,{transform:t})=>F6(t,"y")};hu.translateX=hu.x;hu.translateY=hu.y;const Gh=new Set;let z6=!1,$6=!1,H6=!1;function yee(){if($6){const e=Array.from(Gh).filter(n=>n.needsMeasurement),t=new Set(e.map(n=>n.element)),r=new Map;t.forEach(n=>{const i=RHe(n);i.length&&(r.set(n,i),n.render())}),e.forEach(n=>n.measureInitialState()),t.forEach(n=>{n.render();const i=r.get(n);i&&i.forEach(([s,a])=>{var o;(o=n.getValue(s))==null||o.set(a)})}),e.forEach(n=>n.measureEndState()),e.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}$6=!1,z6=!1,Gh.forEach(e=>e.complete(H6)),Gh.clear()}function xee(){Gh.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&($6=!0)})}function MHe(){H6=!0,xee(),yee(),H6=!1}class R7{constructor(t,r,n,i,s,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=r,this.name=n,this.motionValue=i,this.element=s,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Gh.add(this),z6||(z6=!0,on.read(xee),on.resolveKeyframes(yee))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:r,element:n,motionValue:i}=this;if(t[0]===null){const s=i==null?void 0:i.get(),a=t[t.length-1];if(s!==void 0)t[0]=s;else if(n&&r){const o=n.readValue(r,a);o!=null&&(t[0]=o)}t[0]===void 0&&(t[0]=a),i&&s===void 0&&i.set(t[0])}wHe(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Gh.delete(this)}cancel(){this.state==="scheduled"&&(Gh.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const IHe=e=>e.startsWith("--");function bee(e,t,r){IHe(t)?e.style.setProperty(t,r):e.style[t]=r}const OHe={};function vee(e,t){const r=GJ(e);return()=>OHe[t]??r()}const BHe=vee(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Cee=vee(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ym=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`,_P={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ym([0,.65,.55,1]),circOut:Ym([.55,0,1,.45]),backIn:Ym([.31,.01,.66,-.59]),backOut:Ym([.33,1.53,.69,.99])};function kee(e,t){if(e)return typeof e=="function"?Cee()?pee(e,t):"ease-out":iee(e)?Ym(e):Array.isArray(e)?e.map(r=>kee(r,t)||_P.easeOut):_P[e]}function DHe(e,t,r,{delay:n=0,duration:i=300,repeat:s=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c=void 0){const h={[t]:r};l&&(h.offset=l);const f=kee(o,i);Array.isArray(f)&&(h.easing=f);const g={delay:n,duration:i,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"};return c&&(g.pseudoElement=c),e.animate(h,g)}function Tee(e){return typeof e=="function"&&"applyToOptions"in e}function PHe({type:e,...t}){return Tee(e)&&Cee()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class wee extends L7{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:r,name:n,keyframes:i,pseudoElement:s,allowFlatten:a=!1,finalKeyframe:o,onComplete:l}=t;this.isPseudoElement=!!s,this.allowFlatten=a,this.options=t,C7(typeof t.type!="string");const c=PHe(t);this.animation=DHe(r,n,i,c,s),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const h=k3(i,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(h),bee(r,n,h),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,r;(r=(t=this.animation).finish)==null||r.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,i;const t=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((i=(n=this.animation).commitStyles)==null||i.call(n))}get duration(){var r,n;const t=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return Pa(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pa(t)}get time(){return Pa(Number(this.animation.currentTime)||0)}set time(t){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=sa(t),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:r,rangeEnd:n,observe:i}){var s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&BHe()?(this.animation.timeline=t,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Fa):i(this)}}const See={anticipate:eee,backInOut:JJ,circInOut:ree};function jHe(e){return e in See}function FHe(e){typeof e.ease=="string"&&jHe(e.ease)&&(e.ease=See[e.ease])}const FT=10;class zHe extends wee{constructor(t){FHe(t),gee(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:r,onUpdate:n,onComplete:i,element:s,...a}=this.options;if(!r)return;if(t!==void 0){r.set(t);return}const o=new Dv({...a,autoplay:!1}),l=Math.max(FT,ds.now()-this.startTime),c=nl(0,FT,l-FT),h=o.sample(l).value,{name:f}=this.options;s&&f&&bee(s,f,h),r.setWithVelocity(o.sample(Math.max(0,l-c)).value,h,c),o.stop()}}const EP=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(uo.test(e)||e==="0")&&!e.startsWith("url("));function $He(e){const t=e[0];if(e.length===1)return!0;for(let r=0;r<e.length;r++)if(e[r]!==t)return!0}function HHe(e,t,r,n){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const s=e[e.length-1],a=EP(i,t),o=EP(s,t);return!a||!o?!1:$He(e)||(r==="spring"||Tee(r))&&n}function U6(e){e.duration=0,e.type="keyframes"}const _ee=new Set(["opacity","clipPath","filter","transform"]),UHe=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function qHe(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&UHe.test(e[t]))return!0;return!1}const VHe=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),WHe=GJ(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function GHe(e){var f;const{motionValue:t,name:r,repeatDelay:n,repeatType:i,damping:s,type:a,keyframes:o}=e;if(!(((f=t==null?void 0:t.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=t.owner.getProps();return WHe()&&r&&(_ee.has(r)||VHe.has(r)&&qHe(o))&&(r!=="transform"||!h)&&!c&&!n&&i!=="mirror"&&s!==0&&a!=="inertia"}const YHe=40;class XHe extends L7{constructor({autoplay:t=!0,delay:r=0,type:n="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:a="loop",keyframes:o,name:l,motionValue:c,element:h,...f}){var x;super(),this.stop=()=>{var v,C;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(C=this.keyframeResolver)==null||C.cancel()},this.createdAt=ds.now();const g={autoplay:t,delay:r,type:n,repeat:i,repeatDelay:s,repeatType:a,name:l,motionValue:c,element:h,...f},m=(h==null?void 0:h.KeyframeResolver)||R7;this.keyframeResolver=new m(o,(v,C,k)=>this.onKeyframesResolved(v,C,g,!k),l,c,h),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,r,n,i){var k,T;this.keyframeResolver=void 0;const{name:s,type:a,velocity:o,delay:l,isHandoff:c,onUpdate:h}=n;this.resolvedAt=ds.now();let f=!0;HHe(t,s,a,o)||(f=!1,(Ru.instantAnimations||!l)&&(h==null||h(k3(t,n,r))),t[0]=t[t.length-1],U6(n),n.repeat=0);const m={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>YHe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:t},x=f&&!c&&GHe(m),v=(T=(k=m.motionValue)==null?void 0:k.owner)==null?void 0:T.current;let C;if(x)try{C=new zHe({...m,element:v})}catch{C=new Dv(m)}else C=new Dv(m);C.finished.then(()=>{this.notifyFinished()}).catch(Fa),this.pendingTimeline&&(this.stopTimeline=C.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=C}get finished(){return this._animation?this.animation.finished:this._finished}then(t,r){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),MHe()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function Eee(e,t,r,n=0,i=1){const s=Array.from(e).sort((c,h)=>c.sortNodePosition(h)).indexOf(t),a=e.size,o=(a-1)*n;return typeof r=="function"?r(s,a):i===1?s*n:o-s*n}const KHe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ZHe(e){const t=KHe.exec(e);if(!t)return[,];const[,r,n,i]=t;return[`--${r??n}`,i]}function Aee(e,t,r=1){const[n,i]=ZHe(e);if(!n)return;const s=window.getComputedStyle(t).getPropertyValue(n);if(s){const a=s.trim();return qJ(a)?parseFloat(a):a}return S7(i)?Aee(i,t,r+1):i}const QHe={type:"spring",stiffness:500,damping:25,restSpeed:10},JHe=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),eUe={type:"keyframes",duration:.8},tUe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rUe=(e,{keyframes:t})=>t.length>2?eUe:up.has(e)?e.startsWith("scale")?JHe(t[1]):QHe:tUe;function Nee(e,t){if(e!=null&&e.inherit&&t){const{inherit:r,...n}=e;return{...t,...n}}return e}function M7(e,t){const r=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return r!==e?Nee(r,e):r}const nUe=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function iUe(e){for(const t in e)if(!nUe.has(t))return!0;return!1}const I7=(e,t,r,n={},i,s)=>a=>{const o=M7(n,e)||{},l=o.delay||n.delay||0;let{elapsed:c=0}=n;c=c-sa(l);const h={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:g=>{t.set(g),o.onUpdate&&o.onUpdate(g)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:s?void 0:i};iUe(o)||Object.assign(h,rUe(e,h)),h.duration&&(h.duration=sa(h.duration)),h.repeatDelay&&(h.repeatDelay=sa(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let f=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(U6(h),h.delay===0&&(f=!0)),(Ru.instantAnimations||Ru.skipAnimations||i!=null&&i.shouldSkipAnimations)&&(f=!0,U6(h),h.delay=0),h.allowFlatten=!o.type&&!o.ease,f&&!s&&t.get()!==void 0){const g=k3(h.keyframes,o);if(g!==void 0){on.update(()=>{h.onUpdate(g),h.onComplete()});return}}return o.isSync?new Dv(h):new XHe(h)};function AP(e){const t=[{},{}];return e==null||e.values.forEach((r,n)=>{t[0][n]=r.get(),t[1][n]=r.getVelocity()}),t}function O7(e,t,r,n){if(typeof t=="function"){const[i,s]=AP(n);t=t(r!==void 0?r:e.custom,i,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,s]=AP(n);t=t(r!==void 0?r:e.custom,i,s)}return t}function Yh(e,t,r){const n=e.getProps();return O7(n,t,r!==void 0?r:n.custom,e)}const Lee=new Set(["width","height","top","left","right","bottom",...cp]),NP=30,sUe=e=>!isNaN(parseFloat(e));class aUe{constructor(t,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var s;const i=ds.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((s=this.events.change)==null||s.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=r.owner}setCurrent(t){this.current=t,this.updatedAt=ds.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=sUe(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,r){this.events[t]||(this.events[t]=new k7);const n=this.events[t].add(r);return t==="change"?()=>{n(),on.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,r){this.passiveEffect=t,this.stopPassiveEffect=r}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,r=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=ds.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>NP)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,NP);return YJ(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(t){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=t(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,r;(t=this.dependents)==null||t.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function N0(e,t){return new aUe(e,t)}const q6=e=>Array.isArray(e);function oUe(e,t,r){e.hasValue(t)?e.getValue(t).set(r):e.addValue(t,N0(r))}function lUe(e){return q6(e)?e[e.length-1]||0:e}function cUe(e,t){const r=Yh(e,t);let{transitionEnd:n={},transition:i={},...s}=r||{};s={...s,...n};for(const a in s){const o=lUe(s[a]);oUe(e,a,o)}}const Pi=e=>!!(e&&e.getVelocity);function uUe(e){return!!(Pi(e)&&e.add)}function V6(e,t){const r=e.getValue("willChange");if(uUe(r))return r.add(t);if(!r&&Ru.WillChange){const n=new Ru.WillChange("auto");e.addValue("willChange",n),n.add(t)}}function B7(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const hUe="framerAppearId",Ree="data-"+B7(hUe);function Mee(e){return e.props[Ree]}function dUe({protectedKeys:e,needsAnimating:t},r){const n=e.hasOwnProperty(r)&&t[r]!==!0;return t[r]=!1,n}function Iee(e,t,{delay:r=0,transitionOverride:n,type:i}={}){let{transition:s,transitionEnd:a,...o}=t;const l=e.getDefaultTransition();s=s?Nee(s,l):l;const c=s==null?void 0:s.reduceMotion;n&&(s=n);const h=[],f=i&&e.animationState&&e.animationState.getState()[i];for(const g in o){const m=e.getValue(g,e.latestValues[g]??null),x=o[g];if(x===void 0||f&&dUe(f,g))continue;const v={delay:r,...M7(s||{},g)},C=m.get();if(C!==void 0&&!m.isAnimating()&&!Array.isArray(x)&&x===C&&!v.velocity){on.update(()=>m.set(x));continue}let k=!1;if(window.MotionHandoffAnimation){const L=Mee(e);if(L){const N=window.MotionHandoffAnimation(L,g,on);N!==null&&(v.startTime=N,k=!0)}}V6(e,g);const T=c??e.shouldReduceMotion;m.start(I7(g,m,x,T&&Lee.has(g)?{type:!1}:v,e,k));const w=m.animation;w&&h.push(w)}if(a){const g=()=>on.update(()=>{a&&cUe(e,a)});h.length?Promise.all(h).then(g):g()}return h}function W6(e,t,r={}){var l;const n=Yh(e,t,r.type==="exit"?(l=e.presenceContext)==null?void 0:l.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(i=r.transitionOverride);const s=n?()=>Promise.all(Iee(e,n,r)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:f,staggerDirection:g}=i;return fUe(e,t,c,h,f,g,r)}:()=>Promise.resolve(),{when:o}=i;if(o){const[c,h]=o==="beforeChildren"?[s,a]:[a,s];return c().then(()=>h())}else return Promise.all([s(),a(r.delay)])}function fUe(e,t,r=0,n=0,i=0,s=1,a){const o=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),o.push(W6(l,t,{...a,delay:r+(typeof n=="function"?0:n)+Eee(e.variantChildren,l,n,i,s)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}function pUe(e,t,r={}){e.notify("AnimationStart",t);let n;if(Array.isArray(t)){const i=t.map(s=>W6(e,s,r));n=Promise.all(i)}else if(typeof t=="string")n=W6(e,t,r);else{const i=typeof t=="function"?Yh(e,t,r.custom):t;n=Promise.all(Iee(e,i,r))}return n.then(()=>{e.notify("AnimationComplete",t)})}const mUe={test:e=>e==="auto",parse:e=>e},Oee=e=>t=>t.test(e),Bee=[lp,_t,Yo,Kc,$$e,z$e,mUe],LP=e=>Bee.find(Oee(e));function gUe(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||WJ(e):!0}const yUe=new Set(["brightness","contrast","saturate","opacity"]);function xUe(e){const[t,r]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[n]=r.match(_7)||[];if(!n)return e;const i=r.replace(n,"");let s=yUe.has(t)?1:0;return n!==r&&(s*=100),t+"("+s+i+")"}const bUe=/\b([a-z-]*)\(.*?\)/gu,G6={...uo,getAnimatableNone:e=>{const t=e.match(bUe);return t?t.map(xUe).join(" "):e}},Y6={...uo,getAnimatableNone:e=>{const t=uo.parse(e);return uo.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},RP={...lp,transform:Math.round},vUe={rotate:Kc,rotateX:Kc,rotateY:Kc,rotateZ:Kc,scale:ab,scaleX:ab,scaleY:ab,scaleZ:ab,skew:Kc,skewX:Kc,skewY:Kc,distance:_t,translateX:_t,translateY:_t,translateZ:_t,x:_t,y:_t,z:_t,perspective:_t,transformPerspective:_t,opacity:a1,originX:yP,originY:yP,originZ:_t},D7={borderWidth:_t,borderTopWidth:_t,borderRightWidth:_t,borderBottomWidth:_t,borderLeftWidth:_t,borderRadius:_t,borderTopLeftRadius:_t,borderTopRightRadius:_t,borderBottomRightRadius:_t,borderBottomLeftRadius:_t,width:_t,maxWidth:_t,height:_t,maxHeight:_t,top:_t,right:_t,bottom:_t,left:_t,inset:_t,insetBlock:_t,insetBlockStart:_t,insetBlockEnd:_t,insetInline:_t,insetInlineStart:_t,insetInlineEnd:_t,padding:_t,paddingTop:_t,paddingRight:_t,paddingBottom:_t,paddingLeft:_t,paddingBlock:_t,paddingBlockStart:_t,paddingBlockEnd:_t,paddingInline:_t,paddingInlineStart:_t,paddingInlineEnd:_t,margin:_t,marginTop:_t,marginRight:_t,marginBottom:_t,marginLeft:_t,marginBlock:_t,marginBlockStart:_t,marginBlockEnd:_t,marginInline:_t,marginInlineStart:_t,marginInlineEnd:_t,fontSize:_t,backgroundPositionX:_t,backgroundPositionY:_t,...vUe,zIndex:RP,fillOpacity:a1,strokeOpacity:a1,numOctaves:RP},CUe={...D7,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:G6,WebkitFilter:G6,mask:Y6,WebkitMask:Y6},Dee=e=>CUe[e],kUe=new Set([G6,Y6]);function Pee(e,t){let r=Dee(e);return kUe.has(r)||(r=uo),r.getAnimatableNone?r.getAnimatableNone(t):void 0}const TUe=new Set(["auto","none","0"]);function wUe(e,t,r){let n=0,i;for(;n<e.length&&!i;){const s=e[n];typeof s=="string"&&!TUe.has(s)&&A0(s).values.length&&(i=e[n]),n++}if(i&&r)for(const s of t)e[s]=Pee(r,i)}class SUe extends R7{constructor(t,r,n,i,s){super(t,r,n,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:r,name:n}=this;if(!r||!r.current)return;super.readKeyframes();for(let h=0;h<t.length;h++){let f=t[h];if(typeof f=="string"&&(f=f.trim(),S7(f))){const g=Aee(f,r.current);g!==void 0&&(t[h]=g),h===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!Lee.has(n)||t.length!==2)return;const[i,s]=t,a=LP(i),o=LP(s),l=gP(i),c=gP(s);if(l!==c&&hu[n]){this.needsMeasurement=!0;return}if(a!==o)if(SP(a)&&SP(o))for(let h=0;h<t.length;h++){const f=t[h];typeof f=="string"&&(t[h]=parseFloat(f))}else hu[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:r}=this,n=[];for(let i=0;i<t.length;i++)(t[i]===null||gUe(t[i]))&&n.push(i);n.length&&wUe(t,n,r)}measureInitialState(){const{element:t,unresolvedKeyframes:r,name:n}=this;if(!t||!t.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=hu[n](t.measureViewportBox(),window.getComputedStyle(t.current)),r[0]=this.measuredOrigin;const i=r[r.length-1];i!==void 0&&t.getValue(n,i).jump(i,!1)}measureEndState(){var o;const{element:t,name:r,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const i=t.getValue(r);i&&i.jump(this.measuredOrigin,!1);const s=n.length-1,a=n[s];n[s]=hu[r](t.measureViewportBox(),window.getComputedStyle(t.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(o=this.removedTransforms)!=null&&o.length&&this.removedTransforms.forEach(([l,c])=>{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function jee(e,t,r){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let n=document;const i=(r==null?void 0:r[e])??n.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(n=>n!=null)}const Fee=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function _Ue(e){return VJ(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:P7}=see(queueMicrotask,!1),Ja={x:!1,y:!1};function zee(){return Ja.x||Ja.y}function EUe(e){return e==="x"||e==="y"?Ja[e]?null:(Ja[e]=!0,()=>{Ja[e]=!1}):Ja.x||Ja.y?null:(Ja.x=Ja.y=!0,()=>{Ja.x=Ja.y=!1})}function $ee(e,t){const r=jee(e),n=new AbortController,i={passive:!0,...t,signal:n.signal};return[r,i,()=>n.abort()]}function AUe(e){return!(e.pointerType==="touch"||zee())}function NUe(e,t,r={}){const[n,i,s]=$ee(e,r);return n.forEach(a=>{let o=!1,l=!1,c;const h=()=>{a.removeEventListener("pointerleave",x)},f=C=>{c&&(c(C),c=void 0),h()},g=C=>{o=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),l&&(l=!1,f(C))},m=()=>{o=!0,window.addEventListener("pointerup",g,i),window.addEventListener("pointercancel",g,i)},x=C=>{if(C.pointerType!=="touch"){if(o){l=!0;return}f(C)}},v=C=>{if(!AUe(C))return;l=!1;const k=t(a,C);typeof k=="function"&&(c=k,a.addEventListener("pointerleave",x,i))};a.addEventListener("pointerenter",v,i),a.addEventListener("pointerdown",m,i)}),s}const Hee=(e,t)=>t?e===t?!0:Hee(e,t.parentElement):!1,j7=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,LUe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function RUe(e){return LUe.has(e.tagName)||e.isContentEditable===!0}const MUe=new Set(["INPUT","SELECT","TEXTAREA"]);function IUe(e){return MUe.has(e.tagName)||e.isContentEditable===!0}const Kb=new WeakSet;function MP(e){return t=>{t.key==="Enter"&&e(t)}}function zT(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const OUe=(e,t)=>{const r=e.currentTarget;if(!r)return;const n=MP(()=>{if(Kb.has(r))return;zT(r,"down");const i=MP(()=>{zT(r,"up")}),s=()=>zT(r,"cancel");r.addEventListener("keyup",i,t),r.addEventListener("blur",s,t)});r.addEventListener("keydown",n,t),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),t)};function IP(e){return j7(e)&&!zee()}const OP=new WeakSet;function BUe(e,t,r={}){const[n,i,s]=$ee(e,r),a=o=>{const l=o.currentTarget;if(!IP(o)||OP.has(o))return;Kb.add(l),r.stopPropagation&&OP.add(o);const c=t(l,o),h=(m,x)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),Kb.has(l)&&Kb.delete(l),IP(m)&&typeof c=="function"&&c(m,{success:x})},f=m=>{h(m,l===window||l===document||r.useGlobalTarget||Hee(l,m.target))},g=m=>{h(m,!1)};window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",g,i)};return n.forEach(o=>{(r.useGlobalTarget?window:o).addEventListener("pointerdown",a,i),_Ue(o)&&(o.addEventListener("focus",c=>OUe(c,i)),!RUe(o)&&!o.hasAttribute("tabindex")&&(o.tabIndex=0))}),s}function F7(e){return VJ(e)&&"ownerSVGElement"in e}const Zb=new WeakMap;let Zc;const Uee=(e,t,r)=>(n,i)=>i&&i[0]?i[0][e+"Size"]:F7(n)&&"getBBox"in n?n.getBBox()[t]:n[r],DUe=Uee("inline","width","offsetWidth"),PUe=Uee("block","height","offsetHeight");function jUe({target:e,borderBoxSize:t}){var r;(r=Zb.get(e))==null||r.forEach(n=>{n(e,{get width(){return DUe(e,t)},get height(){return PUe(e,t)}})})}function FUe(e){e.forEach(jUe)}function zUe(){typeof ResizeObserver>"u"||(Zc=new ResizeObserver(FUe))}function $Ue(e,t){Zc||zUe();const r=jee(e);return r.forEach(n=>{let i=Zb.get(n);i||(i=new Set,Zb.set(n,i)),i.add(t),Zc==null||Zc.observe(n)}),()=>{r.forEach(n=>{const i=Zb.get(n);i==null||i.delete(t),i!=null&&i.size||Zc==null||Zc.unobserve(n)})}}const Qb=new Set;let If;function HUe(){If=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qb.forEach(t=>t(e))},window.addEventListener("resize",If)}function UUe(e){return Qb.add(e),If||HUe(),()=>{Qb.delete(e),!Qb.size&&typeof If=="function"&&(window.removeEventListener("resize",If),If=void 0)}}function BP(e,t){return typeof e=="function"?UUe(e):$Ue(e,t)}function qUe(e){return F7(e)&&e.tagName==="svg"}const VUe=[...Bee,Kn,uo],WUe=e=>VUe.find(Oee(e)),DP=()=>({translate:0,scale:1,origin:0,originPoint:0}),Of=()=>({x:DP(),y:DP()}),PP=()=>({min:0,max:0}),li=()=>({x:PP(),y:PP()}),GUe=new WeakMap;function T3(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function o1(e){return typeof e=="string"||Array.isArray(e)}const z7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],$7=["initial",...z7];function w3(e){return T3(e.animate)||$7.some(t=>o1(e[t]))}function qee(e){return!!(w3(e)||e.variants)}function YUe(e,t,r){for(const n in t){const i=t[n],s=r[n];if(Pi(i))e.addValue(n,i);else if(Pi(s))e.addValue(n,N0(i,{owner:e}));else if(s!==i)if(e.hasValue(n)){const a=e.getValue(n);a.liveStyle===!0?a.jump(i):a.hasAnimated||a.set(i)}else{const a=e.getStaticValue(n);e.addValue(n,N0(a!==void 0?a:i,{owner:e}))}}for(const n in r)t[n]===void 0&&e.removeValue(n);return t}const X6={current:null},Vee={current:!1},XUe=typeof window<"u";function KUe(){if(Vee.current=!0,!!XUe)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>X6.current=e.matches;e.addEventListener("change",t),t()}else X6.current=!1}const jP=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Pv={};function Wee(e){Pv=e}function ZUe(){return Pv}class QUe{scrapeMotionValuesFromProps(t,r,n){return{}}constructor({parent:t,props:r,presenceContext:n,reducedMotionConfig:i,skipAnimations:s,blockInitialAnimation:a,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=R7,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=ds.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,on.render(this.render,!1,!0))};const{latestValues:c,renderState:h}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=r.initial?{...c}:{},this.renderState=h,this.parent=t,this.props=r,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=s,this.options=l,this.blockInitialAnimation=!!a,this.isControllingVariants=w3(r),this.isVariantNode=qee(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:f,...g}=this.scrapeMotionValuesFromProps(r,{},this);for(const m in g){const x=g[m];c[m]!==void 0&&Pi(x)&&x.set(c[m])}}mount(t){var r,n;if(this.hasBeenMounted)for(const i in this.initialValues)(r=this.values.get(i))==null||r.jump(this.initialValues[i]),this.latestValues[i]=this.initialValues[i];this.current=t,GUe.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,s)=>this.bindToMotionValue(s,i)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Vee.current||KUe(),this.shouldReduceMotion=X6.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Mu(this.notifyUpdate),Mu(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,r){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),r.accelerate&&_ee.has(t)&&this.current instanceof HTMLElement){const{factory:a,keyframes:o,times:l,ease:c,duration:h}=r.accelerate,f=new wee({element:this.current,name:t,keyframes:o,times:l,ease:c,duration:sa(h)}),g=a(f);this.valueSubscriptions.set(t,()=>{g(),f.cancel()});return}const n=up.has(t);n&&this.onBindTransform&&this.onBindTransform();const i=r.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&on.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;typeof window<"u"&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,t,r)),this.valueSubscriptions.set(t,()=>{i(),s&&s(),r.owner&&r.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Pv){const r=Pv[t];if(!r)continue;const{isEnabled:n,Feature:i}=r;if(!this.features[t]&&i&&n(this.props)&&(this.features[t]=new i(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):li()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,r){this.latestValues[t]=r}update(t,r){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;n<jP.length;n++){const i=jP[n];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const s="on"+i,a=t[s];a&&(this.propEventSubscriptions[i]=this.on(i,a))}this.prevMotionValues=YUe(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const r=this.getClosestVariantNode();if(r)return r.variantChildren&&r.variantChildren.add(t),()=>r.variantChildren.delete(t)}addValue(t,r){const n=this.values.get(t);r!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,r),this.values.set(t,r),this.latestValues[t]=r.get())}removeValue(t){this.values.delete(t);const r=this.valueSubscriptions.get(t);r&&(r(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,r){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return n===void 0&&r!==void 0&&(n=N0(r===null?void 0:r,{owner:this}),this.addValue(t,n)),n}readValue(t,r){let n=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return n!=null&&(typeof n=="string"&&(qJ(n)||WJ(n))?n=parseFloat(n):!WUe(n)&&uo.test(r)&&(n=Pee(t,r)),this.setBaseTarget(t,Pi(n)?n.get():n)),Pi(n)?n.get():n}setBaseTarget(t,r){this.baseTarget[t]=r}getBaseTarget(t){var s;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const a=O7(this.props,r,(s=this.presenceContext)==null?void 0:s.custom);a&&(n=a[t])}if(r&&n!==void 0)return n;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Pi(i)?i:this.initialValues[t]!==void 0&&n===void 0?void 0:this.baseTarget[t]}on(t,r){return this.events[t]||(this.events[t]=new k7),this.events[t].add(r)}notify(t,...r){this.events[t]&&this.events[t].notify(...r)}scheduleRenderMicrotask(){P7.render(this.render)}}class Gee extends QUe{constructor(){super(...arguments),this.KeyframeResolver=SUe}sortInstanceNodePosition(t,r){return t.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(t,r){const n=t.style;return n?n[r]:void 0}removeValueFromRenderState(t,{vars:r,style:n}){delete r[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Pi(t)&&(this.childSubscription=t.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Vu{constructor(t){this.isMounted=!1,this.node=t}update(){}}function Yee({top:e,left:t,right:r,bottom:n}){return{x:{min:t,max:r},y:{min:e,max:n}}}function JUe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function eqe(e,t){if(!t)return e;const r=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function $T(e){return e===void 0||e===1}function K6({scale:e,scaleX:t,scaleY:r}){return!$T(e)||!$T(t)||!$T(r)}function wh(e){return K6(e)||Xee(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Xee(e){return FP(e.x)||FP(e.y)}function FP(e){return e&&e!=="0%"}function jv(e,t,r){const n=e-r,i=t*n;return r+i}function zP(e,t,r,n,i){return i!==void 0&&(e=jv(e,i,n)),jv(e,r,n)+t}function Z6(e,t=0,r=1,n,i){e.min=zP(e.min,t,r,n,i),e.max=zP(e.max,t,r,n,i)}function Kee(e,{x:t,y:r}){Z6(e.x,t.translate,t.scale,t.originPoint),Z6(e.y,r.translate,r.scale,r.originPoint)}const $P=.999999999999,HP=1.0000000000001;function tqe(e,t,r,n=!1){var o;const i=r.length;if(!i)return;t.x=t.y=1;let s,a;for(let l=0;l<i;l++){s=r[l],a=s.projectionDelta;const{visualElement:c}=s.options;c&&c.props.style&&c.props.style.display==="contents"||(n&&s.options.layoutScroll&&s.scroll&&s!==s.root&&(Fo(e.x,-s.scroll.offset.x),Fo(e.y,-s.scroll.offset.y)),a&&(t.x*=a.x.scale,t.y*=a.y.scale,Kee(e,a)),n&&wh(s.latestValues)&&Jb(e,s.latestValues,(o=s.layout)==null?void 0:o.layoutBox))}t.x<HP&&t.x>$P&&(t.x=1),t.y<HP&&t.y>$P&&(t.y=1)}function Fo(e,t){e.min+=t,e.max+=t}function UP(e,t,r,n,i=.5){const s=gn(e.min,e.max,i);Z6(e,t,r,s,n)}function qP(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Jb(e,t,r){const n=r??e;UP(e.x,qP(t.x,n.x),t.scaleX,t.scale,t.originX),UP(e.y,qP(t.y,n.y),t.scaleY,t.scale,t.originY)}function Zee(e,t){return Yee(eqe(e.getBoundingClientRect(),t))}function rqe(e,t,r){const n=Zee(e,r),{scroll:i}=t;return i&&(Fo(n.x,i.offset.x),Fo(n.y,i.offset.y)),n}const nqe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},iqe=cp.length;function sqe(e,t,r){let n="",i=!0;for(let s=0;s<iqe;s++){const a=cp[s],o=e[a];if(o===void 0)continue;let l=!0;if(typeof o=="number")l=o===(a.startsWith("scale")?1:0);else{const c=parseFloat(o);l=a.startsWith("scale")?c===1:c===0}if(!l||r){const c=Fee(o,D7[a]);if(!l){i=!1;const h=nqe[a]||a;n+=`${h}(${c}) `}r&&(t[a]=c)}}return n=n.trim(),r?n=r(t,i?"":n):i&&(n="none"),n}function H7(e,t,r){const{style:n,vars:i,transformOrigin:s}=e;let a=!1,o=!1;for(const l in t){const c=t[l];if(up.has(l)){a=!0;continue}else if(oee(l)){i[l]=c;continue}else{const h=Fee(c,D7[l]);l.startsWith("origin")?(o=!0,s[l]=h):n[l]=h}}if(t.transform||(a||r?n.transform=sqe(t,e.transform,r):n.transform&&(n.transform="none")),o){const{originX:l="50%",originY:c="50%",originZ:h=0}=s;n.transformOrigin=`${l} ${c} ${h}`}}function Qee(e,{style:t,vars:r},n,i){const s=e.style;let a;for(a in t)s[a]=t[a];i==null||i.applyProjectionStyles(s,n);for(a in r)s.setProperty(a,r[a])}function VP(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Nm={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(_t.test(e))e=parseFloat(e);else return e;const r=VP(e,t.target.x),n=VP(e,t.target.y);return`${r}% ${n}%`}},aqe={correct:(e,{treeScale:t,projectionDelta:r})=>{const n=e,i=uo.parse(e);if(i.length>5)return n;const s=uo.createTransformer(e),a=typeof i[0]!="number"?1:0,o=r.x.scale*t.x,l=r.y.scale*t.y;i[0+a]/=o,i[1+a]/=l;const c=gn(o,l,.5);return typeof i[2+a]=="number"&&(i[2+a]/=c),typeof i[3+a]=="number"&&(i[3+a]/=c),s(i)}},Q6={borderRadius:{...Nm,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Nm,borderTopRightRadius:Nm,borderBottomLeftRadius:Nm,borderBottomRightRadius:Nm,boxShadow:aqe};function Jee(e,{layout:t,layoutId:r}){return up.has(e)||e.startsWith("origin")||(t||r!==void 0)&&(!!Q6[e]||e==="opacity")}function U7(e,t,r){var a;const n=e.style,i=t==null?void 0:t.style,s={};if(!n)return s;for(const o in n)(Pi(n[o])||i&&Pi(i[o])||Jee(o,e)||((a=r==null?void 0:r.getValue(o))==null?void 0:a.liveStyle)!==void 0)&&(s[o]=n[o]);return s}function oqe(e){return window.getComputedStyle(e)}class lqe extends Gee{constructor(){super(...arguments),this.type="html",this.renderInstance=Qee}readValueFromInstance(t,r){var n;if(up.has(r))return(n=this.projection)!=null&&n.isProjecting?j6(r):EHe(t,r);{const i=oqe(t),s=(oee(r)?i.getPropertyValue(r):i[r])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(t,{transformPagePoint:r}){return Zee(t,r)}build(t,r,n){H7(t,r,n.transformTemplate)}scrapeMotionValuesFromProps(t,r,n){return U7(t,r,n)}}const cqe={offset:"stroke-dashoffset",array:"stroke-dasharray"},uqe={offset:"strokeDashoffset",array:"strokeDasharray"};function hqe(e,t,r=1,n=0,i=!0){e.pathLength=1;const s=i?cqe:uqe;e[s.offset]=`${-n}`,e[s.array]=`${t} ${r}`}const dqe=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function ete(e,{attrX:t,attrY:r,attrScale:n,pathLength:i,pathSpacing:s=1,pathOffset:a=0,...o},l,c,h){if(H7(e,o,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:g}=e;f.transform&&(g.transform=f.transform,delete f.transform),(g.transform||f.transformOrigin)&&(g.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),g.transform&&(g.transformBox=(h==null?void 0:h.transformBox)??"fill-box",delete f.transformBox);for(const m of dqe)f[m]!==void 0&&(g[m]=f[m],delete f[m]);t!==void 0&&(f.x=t),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),i!==void 0&&hqe(f,i,s,a,!1)}const tte=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),rte=e=>typeof e=="string"&&e.toLowerCase()==="svg";function fqe(e,t,r,n){Qee(e,t,void 0,n);for(const i in t.attrs)e.setAttribute(tte.has(i)?i:B7(i),t.attrs[i])}function nte(e,t,r){const n=U7(e,t,r);for(const i in e)if(Pi(e[i])||Pi(t[i])){const s=cp.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;n[s]=e[i]}return n}class pqe extends Gee{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=li}getBaseTargetFromProps(t,r){return t[r]}readValueFromInstance(t,r){if(up.has(r)){const n=Dee(r);return n&&n.default||0}return r=tte.has(r)?r:B7(r),t.getAttribute(r)}scrapeMotionValuesFromProps(t,r,n){return nte(t,r,n)}build(t,r,n){ete(t,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(t,r,n,i){fqe(t,r,n,i)}mount(t){this.isSVGTag=rte(t.tagName),super.mount(t)}}const mqe=$7.length;function ite(e){if(!e)return;if(!e.isControllingVariants){const r=e.parent?ite(e.parent)||{}:{};return e.props.initial!==void 0&&(r.initial=e.props.initial),r}const t={};for(let r=0;r<mqe;r++){const n=$7[r],i=e.props[n];(o1(i)||i===!1)&&(t[n]=i)}return t}function ste(e,t){if(!Array.isArray(t))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}const gqe=[...z7].reverse(),yqe=z7.length;function xqe(e){return t=>Promise.all(t.map(({animation:r,options:n})=>pUe(e,r,n)))}function bqe(e){let t=xqe(e),r=WP(),n=!0,i=!1;const s=c=>(h,f)=>{var m;const g=Yh(e,f,c==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(g){const{transition:x,transitionEnd:v,...C}=g;h={...h,...C,...v}}return h};function a(c){t=c(e)}function o(c){const{props:h}=e,f=ite(e.parent)||{},g=[],m=new Set;let x={},v=1/0;for(let k=0;k<yqe;k++){const T=gqe[k],w=r[T],L=h[T]!==void 0?h[T]:f[T],N=o1(L),A=T===c?w.isActive:null;A===!1&&(v=k);let R=L===f[T]&&L!==h[T]&&N;if(R&&(n||i)&&e.manuallyAnimateOnMount&&(R=!1),w.protectedKeys={...x},!w.isActive&&A===null||!L&&!w.prevProp||T3(L)||typeof L=="boolean")continue;if(T==="exit"&&w.isActive&&A!==!0){w.prevResolvedValues&&(x={...x,...w.prevResolvedValues});continue}const P=vqe(w.prevProp,L);let q=P||T===c&&w.isActive&&!R&&N||k>v&&N,j=!1;const U=Array.isArray(L)?L:[L];let W=U.reduce(s(T),{});A===!1&&(W={});const{prevResolvedValues:J={}}=w,G={...J,...W},O=Y=>{q=!0,m.has(Y)&&(j=!0,m.delete(Y)),w.needsAnimating[Y]=!0;const ae=e.getValue(Y);ae&&(ae.liveStyle=!1)};for(const Y in G){const ae=W[Y],z=J[Y];if(x.hasOwnProperty(Y))continue;let K=!1;q6(ae)&&q6(z)?K=!ste(ae,z):K=ae!==z,K?ae!=null?O(Y):m.add(Y):ae!==void 0&&m.has(Y)?O(Y):w.protectedKeys[Y]=!0}w.prevProp=L,w.prevResolvedValues=W,w.isActive&&(x={...x,...W}),(n||i)&&e.blockInitialAnimation&&(q=!1);const D=R&&P;q&&(!D||j)&&g.push(...U.map(Y=>{const ae={type:T};if(typeof Y=="string"&&(n||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){const{parent:z}=e,K=Yh(z,Y);if(z.enteringChildren&&K){const{delayChildren:se}=K.transition||{};ae.delay=Eee(z.enteringChildren,e,se)}}return{animation:Y,options:ae}}))}if(m.size){const k={};if(typeof h.initial!="boolean"){const T=Yh(e,Array.isArray(h.initial)?h.initial[0]:h.initial);T&&T.transition&&(k.transition=T.transition)}m.forEach(T=>{const w=e.getBaseTarget(T),L=e.getValue(T);L&&(L.liveStyle=!0),k[T]=w??null}),g.push({animation:k})}let C=!!g.length;return n&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(C=!1),n=!1,i=!1,C?t(g):Promise.resolve()}function l(c,h){var g;if(r[c].isActive===h)return Promise.resolve();(g=e.variantChildren)==null||g.forEach(m=>{var x;return(x=m.animationState)==null?void 0:x.setActive(c,h)}),r[c].isActive=h;const f=o(c);for(const m in r)r[m].protectedKeys={};return f}return{animateChanges:o,setActive:l,setAnimateFunction:a,getState:()=>r,reset:()=>{r=WP(),i=!0}}}function vqe(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!ste(t,e):!1}function bh(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function WP(){return{animate:bh(!0),whileInView:bh(),whileHover:bh(),whileTap:bh(),whileDrag:bh(),whileFocus:bh(),exit:bh()}}function J6(e,t){e.min=t.min,e.max=t.max}function Qa(e,t){J6(e.x,t.x),J6(e.y,t.y)}function GP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const ate=1e-4,Cqe=1-ate,kqe=1+ate,ote=.01,Tqe=0-ote,wqe=0+ote;function fs(e){return e.max-e.min}function Sqe(e,t,r){return Math.abs(e-t)<=r}function YP(e,t,r,n=.5){e.origin=n,e.originPoint=gn(t.min,t.max,e.origin),e.scale=fs(r)/fs(t),e.translate=gn(r.min,r.max,e.origin)-e.originPoint,(e.scale>=Cqe&&e.scale<=kqe||isNaN(e.scale))&&(e.scale=1),(e.translate>=Tqe&&e.translate<=wqe||isNaN(e.translate))&&(e.translate=0)}function Tg(e,t,r,n){YP(e.x,t.x,r.x,n?n.originX:void 0),YP(e.y,t.y,r.y,n?n.originY:void 0)}function XP(e,t,r,n=0){const i=n?gn(r.min,r.max,n):r.min;e.min=i+t.min,e.max=e.min+fs(t)}function _qe(e,t,r,n){XP(e.x,t.x,r.x,n==null?void 0:n.x),XP(e.y,t.y,r.y,n==null?void 0:n.y)}function KP(e,t,r,n=0){const i=n?gn(r.min,r.max,n):r.min;e.min=t.min-i,e.max=e.min+fs(t)}function Fv(e,t,r,n){KP(e.x,t.x,r.x,n==null?void 0:n.x),KP(e.y,t.y,r.y,n==null?void 0:n.y)}function ZP(e,t,r,n,i){return e-=t,e=jv(e,1/r,n),i!==void 0&&(e=jv(e,1/i,n)),e}function Eqe(e,t=0,r=1,n=.5,i,s=e,a=e){if(Yo.test(t)&&(t=parseFloat(t),t=gn(a.min,a.max,t/100)-a.min),typeof t!="number")return;let o=gn(s.min,s.max,n);e===s&&(o-=t),e.min=ZP(e.min,t,r,o,i),e.max=ZP(e.max,t,r,o,i)}function QP(e,t,[r,n,i],s,a){Eqe(e,t[r],t[n],t[i],t.scale,s,a)}const Aqe=["x","scaleX","originX"],Nqe=["y","scaleY","originY"];function JP(e,t,r,n){QP(e.x,t,Aqe,r?r.x:void 0,n?n.x:void 0),QP(e.y,t,Nqe,r?r.y:void 0,n?n.y:void 0)}function ej(e){return e.translate===0&&e.scale===1}function lte(e){return ej(e.x)&&ej(e.y)}function tj(e,t){return e.min===t.min&&e.max===t.max}function Lqe(e,t){return tj(e.x,t.x)&&tj(e.y,t.y)}function rj(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function cte(e,t){return rj(e.x,t.x)&&rj(e.y,t.y)}function nj(e){return fs(e.x)/fs(e.y)}function ij(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Bo(e){return[e("x"),e("y")]}function Rqe(e,t,r){let n="";const i=e.x.translate/t.x,s=e.y.translate/t.y,a=(r==null?void 0:r.z)||0;if((i||s||a)&&(n=`translate3d(${i}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(n+=`scale(${1/t.x}, ${1/t.y}) `),r){const{transformPerspective:c,rotate:h,rotateX:f,rotateY:g,skewX:m,skewY:x}=r;c&&(n=`perspective(${c}px) ${n}`),h&&(n+=`rotate(${h}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),m&&(n+=`skewX(${m}deg) `),x&&(n+=`skewY(${x}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return(o!==1||l!==1)&&(n+=`scale(${o}, ${l})`),n||"none"}const ute=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Mqe=ute.length,sj=e=>typeof e=="string"?parseFloat(e):e,aj=e=>typeof e=="number"||_t.test(e);function Iqe(e,t,r,n,i,s){i?(e.opacity=gn(0,r.opacity??1,Oqe(n)),e.opacityExit=gn(t.opacity??1,0,Bqe(n))):s&&(e.opacity=gn(t.opacity??1,r.opacity??1,n));for(let a=0;a<Mqe;a++){const o=ute[a];let l=oj(t,o),c=oj(r,o);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||aj(l)===aj(c)?(e[o]=Math.max(gn(sj(l),sj(c),n),0),(Yo.test(c)||Yo.test(l))&&(e[o]+="%")):e[o]=c}(t.rotate||r.rotate)&&(e.rotate=gn(t.rotate||0,r.rotate||0,n))}function oj(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Oqe=hte(0,.5,tee),Bqe=hte(.5,.95,Fa);function hte(e,t,r){return n=>n<e?0:n>t?1:r(s1(e,t,n))}function Dqe(e,t,r){const n=Pi(e)?e:N0(e);return n.start(I7("",n,t,r)),n.animation}function l1(e,t,r,n={passive:!0}){return e.addEventListener(t,r,n),()=>e.removeEventListener(t,r)}const Pqe=(e,t)=>e.depth-t.depth;class jqe{constructor(){this.children=[],this.isDirty=!1}add(t){v7(this.children,t),this.isDirty=!0}remove(t){Mv(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Pqe),this.isDirty=!1,this.children.forEach(t)}}function Fqe(e,t){const r=ds.now(),n=({timestamp:i})=>{const s=i-r;s>=t&&(Mu(n),e(s-t))};return on.setup(n,!0),()=>Mu(n)}function e2(e){return Pi(e)?e.get():e}class zqe{constructor(){this.members=[]}add(t){v7(this.members,t);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===t||n===this.lead||n===this.prevLead)continue;const i=n.instance;(!i||i.isConnected===!1)&&!n.snapshot&&(Mv(this.members,n),n.unmount())}t.scheduleRender()}remove(t){if(Mv(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(t){var r;for(let n=this.members.indexOf(t)-1;n>=0;n--){const i=this.members[n];if(i.isPresent!==!1&&((r=i.instance)==null?void 0:r.isConnected)!==!1)return this.promote(i),!0}return!1}promote(t,r){var i;const n=this.lead;if(t!==n&&(this.prevLead=n,this.lead=t,t.show(),n)){n.updateSnapshot(),t.scheduleRender();const{layoutDependency:s}=n.options,{layoutDependency:a}=t.options;(s===void 0||s!==a)&&(t.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(t.snapshot=n.snapshot,t.snapshot.latestValues=n.animationValues||n.latestValues),(i=t.root)!=null&&i.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var r,n,i,s,a;(n=(r=t.options).onExitComplete)==null||n.call(r),(a=(i=t.resumingFrom)==null?void 0:(s=i.options).onExitComplete)==null||a.call(s)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const t2={hasAnimatedSinceResize:!0,hasEverUpdated:!1},HT=["","X","Y","Z"],$qe=1e3;let Hqe=0;function UT(e,t,r,n){const{latestValues:i}=t;i[e]&&(r[e]=i[e],t.setStaticValue(e,0),n&&(n[e]=0))}function dte(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const r=Mee(t);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:i,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(r,"transform",on,!(i||s))}const{parent:n}=e;n&&!n.hasCheckedOptimisedAppear&&dte(n)}function fte({attachResizeListener:e,defaultParent:t,measureScroll:r,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(a={},o=t==null?void 0:t()){this.id=Hqe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Vqe),this.nodes.forEach(Zqe),this.nodes.forEach(Qqe),this.nodes.forEach(Wqe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new jqe)}addEventListener(a,o){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new k7),this.eventHandlers.get(a).add(o)}notifyListeners(a,...o){const l=this.eventHandlers.get(a);l&&l.notify(...o)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=F7(a)&&!qUe(a),this.instance=a;const{layoutId:o,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),e){let h,f=0;const g=()=>this.root.updateBlockedByResize=!1;on.read(()=>{f=window.innerWidth}),e(a,()=>{const m=window.innerWidth;m!==f&&(f=m,this.root.updateBlockedByResize=!0,h&&h(),h=Fqe(g,250),t2.hasAnimatedSinceResize&&(t2.hasAnimatedSinceResize=!1,this.nodes.forEach(uj)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&c&&(o||l)&&this.addEventListener("didUpdate",({delta:h,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||c.getDefaultTransition()||nVe,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=c.getProps(),k=!this.targetLayout||!cte(this.targetLayout,m),T=!f&&g;if(this.options.layoutRoot||this.resumeFrom||T||f&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...M7(x,"layout"),onPlay:v,onComplete:C};(c.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(h,T)}else f||uj(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Mu(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Jqe),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&dte(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const f=this.path[h];f.shouldResetTransform=!0,(typeof f.latestValues.x=="string"||typeof f.latestValues.y=="string")&&(f.isLayoutDirty=!0),f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const l=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),l&&this.nodes.forEach(Yqe),this.nodes.forEach(lj);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(cj);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Xqe),this.nodes.forEach(Kqe),this.nodes.forEach(Uqe),this.nodes.forEach(qqe)):this.nodes.forEach(cj),this.clearAllSnapshots();const o=ds.now();Bi.delta=nl(0,1e3/60,o-Bi.timestamp),Bi.timestamp=o,Bi.isProcessing=!0,OT.update.process(Bi),OT.preRender.process(Bi),OT.render.process(Bi),Bi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,P7.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Gqe),this.sharedNodes.forEach(eVe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,on.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){on.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!fs(this.snapshot.measuredBox.x)&&!fs(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=li()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(o=!1),o&&this.instance){const l=n(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:l,offset:r(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!lte(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,h=c!==this.prevTransformTemplateValue;a&&this.instance&&(o||wh(this.latestValues)||h)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return a&&(l=this.removeTransform(l)),iVe(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:a}=this.options;if(!a)return li();const o=a.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(sVe))){const{scroll:h}=this.root;h&&(Fo(o.x,h.offset.x),Fo(o.y,h.offset.y))}return o}removeElementScroll(a){var l;const o=li();if(Qa(o,a),(l=this.scroll)!=null&&l.wasRoot)return o;for(let c=0;c<this.path.length;c++){const h=this.path[c],{scroll:f,options:g}=h;h!==this.root&&f&&g.layoutScroll&&(f.wasRoot&&Qa(o,a),Fo(o.x,f.offset.x),Fo(o.y,f.offset.y))}return o}applyTransform(a,o=!1,l){var h,f;const c=l||li();Qa(c,a);for(let g=0;g<this.path.length;g++){const m=this.path[g];!o&&m.options.layoutScroll&&m.scroll&&m!==m.root&&(Fo(c.x,-m.scroll.offset.x),Fo(c.y,-m.scroll.offset.y)),wh(m.latestValues)&&Jb(c,m.latestValues,(h=m.layout)==null?void 0:h.layoutBox)}return wh(this.latestValues)&&Jb(c,this.latestValues,(f=this.layout)==null?void 0:f.layoutBox),c}removeTransform(a){var l;const o=li();Qa(o,a);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!wh(h.latestValues))continue;let f;h.instance&&(K6(h.latestValues)&&h.updateSnapshot(),f=li(),Qa(f,h.measurePageBox())),JP(o,h.latestValues,(l=h.snapshot)==null?void 0:l.layoutBox,f)}return wh(this.latestValues)&&JP(o,this.latestValues),o}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Bi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var m;const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(a||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:h,layoutId:f}=this.options;if(!this.layout||!(h||f))return;this.resolvedRelativeTargetAt=Bi.timestamp;const g=this.getClosestProjectingParent();g&&this.linkedParentVersion!==g.layoutVersion&&!g.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&g&&g.layout?this.createRelativeTarget(g,this.layout.layoutBox,g.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=li(),this.targetWithTransforms=li()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),_qe(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Qa(this.target,this.layout.layoutBox),Kee(this.target,this.targetDelta)):Qa(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&g&&!!g.resumingFrom==!!this.resumingFrom&&!g.options.layoutScroll&&g.target&&this.animationProgress!==1?this.createRelativeTarget(g,this.target,g.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||K6(this.parent.latestValues)||Xee(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,o,l){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=li(),this.relativeTargetOrigin=li(),Fv(this.relativeTargetOrigin,o,l,this.options.layoutAnchor||void 0),Qa(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const a=this.getLead(),o=!!this.resumingFrom||this!==a;let l=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Bi.timestamp&&(l=!1),l)return;const{layout:c,layoutId:h}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||h))return;Qa(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,g=this.treeScale.y;tqe(this.layoutCorrected,this.treeScale,this.path,o),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=li());const{target:m}=a;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(GP(this.prevProjectionDelta.x,this.projectionDelta.x),GP(this.prevProjectionDelta.y,this.projectionDelta.y)),Tg(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==g||!ij(this.projectionDelta.x,this.prevProjectionDelta.x)||!ij(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var o;if((o=this.options.visualElement)==null||o.scheduleRender(),a){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Of(),this.projectionDelta=Of(),this.projectionDeltaWithTransform=Of()}setAnimationOrigin(a,o=!1){const l=this.snapshot,c=l?l.latestValues:{},h={...this.latestValues},f=Of();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const g=li(),m=l?l.source:void 0,x=this.layout?this.layout.source:void 0,v=m!==x,C=this.getStack(),k=!C||C.members.length<=1,T=!!(v&&!k&&this.options.crossfade===!0&&!this.path.some(rVe));this.animationProgress=0;let w;this.mixTargetDelta=L=>{const N=L/1e3;hj(f.x,a.x,N),hj(f.y,a.y,N),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Fv(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tVe(this.relativeTarget,this.relativeTargetOrigin,g,N),w&&Lqe(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=li()),Qa(w,this.relativeTarget)),v&&(this.animationValues=h,Iqe(h,c,this.latestValues,N,T,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var o,l,c;this.notifyListeners("animationStart"),(o=this.currentAnimation)==null||o.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(Mu(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=on.update(()=>{t2.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=N0(0)),this.motionValue.jump(0,!1),this.currentAnimation=Dqe(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),a.onUpdate&&a.onUpdate(h)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta($qe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:l,layout:c,latestValues:h}=a;if(!(!o||!l||!c)){if(this!==a&&this.layout&&c&&pte(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||li();const f=fs(this.layout.layoutBox.x);l.x.min=a.target.x.min,l.x.max=l.x.min+f;const g=fs(this.layout.layoutBox.y);l.y.min=a.target.y.min,l.y.max=l.y.min+g}Qa(o,l),Jb(o,h),Tg(this.projectionDeltaWithTransform,this.layoutCorrected,o,h)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new zqe),this.sharedNodes.get(a).add(o);const c=o.options.initialPromotionConfig;o.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())==null?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())==null?void 0:o.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:l}=a;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const c={};l.z&&UT("z",a,c,this.animationValues);for(let h=0;h<HT.length;h++)UT(`rotate${HT[h]}`,a,c,this.animationValues),UT(`skew${HT[h]}`,a,c,this.animationValues);a.render();for(const h in c)a.setStaticValue(h,c[h]),this.animationValues&&(this.animationValues[h]=c[h]);a.scheduleRender()}applyProjectionStyles(a,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=e2(o==null?void 0:o.pointerEvents)||"",a.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=e2(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!wh(this.latestValues)&&(a.transform=l?l({},""):"none",this.hasProjected=!1);return}a.visibility="";const h=c.animationValues||c.latestValues;this.applyTransformsToTarget();let f=Rqe(this.projectionDeltaWithTransform,this.treeScale,h);l&&(f=l(h,f)),a.transform=f;const{x:g,y:m}=this.projectionDelta;a.transformOrigin=`${g.origin*100}% ${m.origin*100}% 0`,c.animationValues?a.opacity=c===this?h.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:a.opacity=c===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const x in Q6){if(h[x]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:k}=Q6[x],T=f==="none"?h[x]:v(h[x],c);if(C){const w=C.length;for(let L=0;L<w;L++)a[C[L]]=T}else k?this.options.visualElement.renderState.vars[x]=T:a[x]=T}this.options.layoutId&&(a.pointerEvents=c===this?e2(o==null?void 0:o.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var o;return(o=a.currentAnimation)==null?void 0:o.stop()}),this.root.nodes.forEach(lj),this.root.sharedNodes.clear()}}}function Uqe(e){e.updateLayout()}function qqe(e){var r;const t=((r=e.resumeFrom)==null?void 0:r.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:i}=e.layout,{animationType:s}=e.options,a=t.source!==e.layout.source;if(s==="size")Bo(f=>{const g=a?t.measuredBox[f]:t.layoutBox[f],m=fs(g);g.min=n[f].min,g.max=g.min+m});else if(s==="x"||s==="y"){const f=s==="x"?"y":"x";J6(a?t.measuredBox[f]:t.layoutBox[f],n[f])}else pte(s,t.layoutBox,n)&&Bo(f=>{const g=a?t.measuredBox[f]:t.layoutBox[f],m=fs(n[f]);g.max=g.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[f].max=e.relativeTarget[f].min+m)});const o=Of();Tg(o,n,t.layoutBox);const l=Of();a?Tg(l,e.applyTransform(i,!0),t.measuredBox):Tg(l,n,t.layoutBox);const c=!lte(o);let h=!1;if(!e.resumeFrom){const f=e.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:m}=f;if(g&&m){const x=e.options.layoutAnchor||void 0,v=li();Fv(v,t.layoutBox,g.layoutBox,x);const C=li();Fv(C,n,m.layoutBox,x),cte(v,C)||(h=!0),f.options.layoutRoot&&(e.relativeTarget=C,e.relativeTargetOrigin=v,e.relativeParent=f)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function Vqe(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Wqe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Gqe(e){e.clearSnapshot()}function lj(e){e.clearMeasurements()}function Yqe(e){e.isLayoutDirty=!0,e.updateLayout()}function cj(e){e.isLayoutDirty=!1}function Xqe(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Kqe(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function uj(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Zqe(e){e.resolveTargetDelta()}function Qqe(e){e.calcProjection()}function Jqe(e){e.resetSkewAndRotation()}function eVe(e){e.removeLeadSnapshot()}function hj(e,t,r){e.translate=gn(t.translate,0,r),e.scale=gn(t.scale,1,r),e.origin=t.origin,e.originPoint=t.originPoint}function dj(e,t,r,n){e.min=gn(t.min,r.min,n),e.max=gn(t.max,r.max,n)}function tVe(e,t,r,n){dj(e.x,t.x,r.x,n),dj(e.y,t.y,r.y,n)}function rVe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const nVe={duration:.45,ease:[.4,0,.1,1]},fj=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pj=fj("applewebkit/")&&!fj("chrome/")?Math.round:Fa;function mj(e){e.min=pj(e.min),e.max=pj(e.max)}function iVe(e){mj(e.x),mj(e.y)}function pte(e,t,r){return e==="position"||e==="preserve-aspect"&&!Sqe(nj(t),nj(r),.2)}function sVe(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const aVe=fte({attachResizeListener:(e,t)=>l1(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),qT={current:void 0},mte=fte({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!qT.current){const e=new aVe({});e.mount(window),e.setOptions({layoutScroll:!0}),qT.current=e}return qT.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),gte=_.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function oVe(e=!0){const t=_.useContext(b7);if(t===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:i}=t,s=_.useId();_.useEffect(()=>{if(e)return i(s)},[e]);const a=_.useCallback(()=>e&&n&&n(s),[s,n,e]);return!r&&n?[!1,a]:[!0]}const yte=_.createContext({strict:!1}),gj={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let yj=!1;function lVe(){if(yj)return;const e={};for(const t in gj)e[t]={isEnabled:r=>gj[t].some(n=>!!r[n])};Wee(e),yj=!0}function xte(){return lVe(),ZUe()}function cVe(e){const t=xte();for(const r in e)t[r]={...t[r],...e[r]};Wee(t)}const uVe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function zv(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||uVe.has(e)}let bte=e=>!zv(e);function hVe(e){typeof e=="function"&&(bte=t=>t.startsWith("on")?!zv(t):e(t))}try{hVe(require("@emotion/is-prop-valid").default)}catch{}function dVe(e,t,r){const n={};for(const i in e)i==="values"&&typeof e.values=="object"||Pi(e[i])||(bte(i)||r===!0&&zv(i)||!t&&!zv(i)||e.draggable&&i.startsWith("onDrag"))&&(n[i]=e[i]);return n}const S3=_.createContext({});function fVe(e,t){if(w3(e)){const{initial:r,animate:n}=e;return{initial:r===!1||o1(r)?r:void 0,animate:o1(n)?n:void 0}}return e.inherit!==!1?t:{}}function pVe(e){const{initial:t,animate:r}=fVe(e,_.useContext(S3));return _.useMemo(()=>({initial:t,animate:r}),[xj(t),xj(r)])}function xj(e){return Array.isArray(e)?e.join(" "):e}const q7=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function vte(e,t,r){for(const n in t)!Pi(t[n])&&!Jee(n,r)&&(e[n]=t[n])}function mVe({transformTemplate:e},t){return _.useMemo(()=>{const r=q7();return H7(r,t,e),Object.assign({},r.vars,r.style)},[t])}function gVe(e,t){const r=e.style||{},n={};return vte(n,r,e),Object.assign(n,mVe(e,t)),n}function yVe(e,t){const r={},n=gVe(e,t);return e.drag&&e.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(r.tabIndex=0),r.style=n,r}const Cte=()=>({...q7(),attrs:{}});function xVe(e,t,r,n){const i=_.useMemo(()=>{const s=Cte();return ete(s,t,rte(n),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};vte(s,e.style,e),i.style={...s,...i.style}}return i}const bVe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function V7(e){return typeof e!="string"||e.includes("-")?!1:!!(bVe.indexOf(e)>-1||/[A-Z]/u.test(e))}function vVe(e,t,r,{latestValues:n},i,s=!1,a){const l=(a??V7(e)?xVe:yVe)(t,n,i,e),c=dVe(t,typeof e=="string",s),h=e!==_.Fragment?{...c,...l,ref:r}:{},{children:f}=t,g=_.useMemo(()=>Pi(f)?f.get():f,[f]);return _.createElement(e,{...h,children:g})}function CVe({scrapeMotionValuesFromProps:e,createRenderState:t},r,n,i){return{latestValues:kVe(r,n,i,e),renderState:t()}}function kVe(e,t,r,n){const i={},s=n(e,{});for(const g in s)i[g]=e2(s[g]);let{initial:a,animate:o}=e;const l=w3(e),c=qee(e);t&&c&&!l&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let h=r?r.initial===!1:!1;h=h||a===!1;const f=h?o:a;if(f&&typeof f!="boolean"&&!T3(f)){const g=Array.isArray(f)?f:[f];for(let m=0;m<g.length;m++){const x=O7(e,g[m]);if(x){const{transitionEnd:v,transition:C,...k}=x;for(const T in k){let w=k[T];if(Array.isArray(w)){const L=h?w.length-1:0;w=w[L]}w!==null&&(i[T]=w)}for(const T in v)i[T]=v[T]}}}return i}const kte=e=>(t,r)=>{const n=_.useContext(S3),i=_.useContext(b7),s=()=>CVe(e,t,n,i);return r?s():b$e(s)},TVe=kte({scrapeMotionValuesFromProps:U7,createRenderState:q7}),wVe=kte({scrapeMotionValuesFromProps:nte,createRenderState:Cte}),SVe=Symbol.for("motionComponentSymbol");function _Ve(e,t,r){const n=_.useRef(r);_.useInsertionEffect(()=>{n.current=r});const i=_.useRef(null);return _.useCallback(s=>{var o;s&&((o=e.onMount)==null||o.call(e,s));const a=n.current;if(typeof a=="function")if(s){const l=a(s);typeof l=="function"&&(i.current=l)}else i.current?(i.current(),i.current=null):a(s);else a&&(a.current=s);t&&(s?t.mount(s):t.unmount())},[t])}const Tte=_.createContext({});function wf(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function EVe(e,t,r,n,i,s){var w,L;const{visualElement:a}=_.useContext(S3),o=_.useContext(yte),l=_.useContext(b7),c=_.useContext(gte),h=c.reducedMotion,f=c.skipAnimations,g=_.useRef(null),m=_.useRef(!1);n=n||o.renderer,!g.current&&n&&(g.current=n(e,{visualState:t,parent:a,props:r,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:f,isSVG:s}),m.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const x=g.current,v=_.useContext(Tte);x&&!x.projection&&i&&(x.type==="html"||x.type==="svg")&&AVe(g.current,r,i,v);const C=_.useRef(!1);_.useInsertionEffect(()=>{x&&C.current&&x.update(r,l)});const k=r[Ree],T=_.useRef(!!k&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,k))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,k)));return C$e(()=>{m.current=!0,x&&(C.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),T.current&&x.animationState&&x.animationState.animateChanges())}),_.useEffect(()=>{x&&(!T.current&&x.animationState&&x.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{var N;(N=window.MotionHandoffMarkAsComplete)==null||N.call(window,k)}),T.current=!1),x.enteringChildren=void 0)}),x}function AVe(e,t,r,n){const{layoutId:i,layout:s,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutAnchor:h,layoutCrossfade:f}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:wte(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!a||o&&wf(o),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:l,layoutRoot:c,layoutAnchor:h})}function wte(e){if(e)return e.options.allowProjection!==!1?e.projection:wte(e.parent)}function VT(e,{forwardMotionProps:t=!1,type:r}={},n,i){n&&cVe(n);const s=r?r==="svg":V7(e),a=s?wVe:TVe;function o(c,h){let f;const g={..._.useContext(gte),...c,layoutId:NVe(c)},{isStatic:m}=g,x=pVe(c),v=a(c,m);if(!m&&typeof window<"u"){LVe();const C=RVe(g);f=C.MeasureLayout,x.visualElement=EVe(e,v,g,i,C.ProjectionNode,s)}return p.jsxs(S3.Provider,{value:x,children:[f&&x.visualElement?p.jsx(f,{visualElement:x.visualElement,...g}):null,vVe(e,c,_Ve(v,x.visualElement,h),v,m,t,s)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=_.forwardRef(o);return l[SVe]=e,l}function NVe({layoutId:e}){const t=_.useContext(UJ).id;return t&&e!==void 0?t+"-"+e:e}function LVe(e,t){_.useContext(yte).strict}function RVe(e){const t=xte(),{drag:r,layout:n}=t;if(!r&&!n)return{};const i={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function MVe(e,t){if(typeof Proxy>"u")return VT;const r=new Map,n=(s,a)=>VT(s,a,e,t),i=(s,a)=>n(s,a);return new Proxy(i,{get:(s,a)=>a==="create"?n:(r.has(a)||r.set(a,VT(a,void 0,e,t)),r.get(a))})}const IVe=(e,t)=>t.isSVG??V7(e)?new pqe(t):new lqe(t,{allowProjection:e!==_.Fragment});class OVe extends Vu{constructor(t){super(t),t.animationState||(t.animationState=bqe(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();T3(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:r}=this.node.prevProps||{};t!==r&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let BVe=0;class DVe extends Vu{constructor(){super(...arguments),this.id=BVe++,this.isExitComplete=!1}update(){var s;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;if(t&&n===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Yh(this.node,a,o);if(l){const{transition:c,transitionEnd:h,...f}=l;for(const g in f)(s=this.node.getValue(g))==null||s.jump(f[g])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);r&&!t&&i.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:t,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const PVe={animation:{Feature:OVe},exit:{Feature:DVe}};function G1(e){return{point:{x:e.pageX,y:e.pageY}}}const jVe=e=>t=>j7(t)&&e(t,G1(t));function wg(e,t,r,n){return l1(e,t,jVe(r),n)}const Ste=({current:e})=>e?e.ownerDocument.defaultView:null,bj=(e,t)=>Math.abs(e-t);function FVe(e,t){const r=bj(e.x,t.x),n=bj(e.y,t.y);return Math.sqrt(r**2+n**2)}const vj=new Set(["auto","scroll"]);class _te{constructor(t,r,{transformPagePoint:n,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ob(this.lastRawMoveEventInfo,this.transformPagePoint));const m=WT(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,v=FVe(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!v)return;const{point:C}=m,{timestamp:k}=Bi;this.history.push({...C,timestamp:k});const{onStart:T,onMove:w}=this.handlers;x||(T&&T(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,m)},this.handlePointerMove=(m,x)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=ob(x,this.transformPagePoint),on.update(this.updatePoint,!0)},this.handlePointerUp=(m,x)=>{this.end();const{onEnd:v,onSessionEnd:C,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const T=WT(m.type==="pointercancel"?this.lastMoveEventInfo:ob(x,this.transformPagePoint),this.history);this.startEvent&&v&&v(m,T),C&&C(m,T)},!j7(t))return;this.dragSnapToOrigin=s,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=i||window;const l=G1(t),c=ob(l,this.transformPagePoint),{point:h}=c,{timestamp:f}=Bi;this.history=[{...h,timestamp:f}];const{onSessionStart:g}=r;g&&g(t,WT(c,this.history)),this.removeListeners=q1(wg(this.contextWindow,"pointermove",this.handlePointerMove),wg(this.contextWindow,"pointerup",this.handlePointerUp),wg(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(t){let r=t.parentElement;for(;r;){const n=getComputedStyle(r);(vj.has(n.overflowX)||vj.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const r=this.scrollPositions.get(t);if(!r)return;const n=t===window,i=n?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s={x:i.x-r.x,y:i.y-r.y};s.x===0&&s.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(t,i),on.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Mu(this.updatePoint)}}function ob(e,t){return t?{point:t(e.point)}:e}function Cj(e,t){return{x:e.x-t.x,y:e.y-t.y}}function WT({point:e},t){return{point:e,delta:Cj(e,Ete(t)),offset:Cj(e,zVe(t)),velocity:$Ve(t,.1)}}function zVe(e){return e[0]}function Ete(e){return e[e.length-1]}function $Ve(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null;const i=Ete(e);for(;r>=0&&(n=e[r],!(i.timestamp-n.timestamp>sa(t)));)r--;if(!n)return{x:0,y:0};n===e[0]&&e.length>2&&i.timestamp-n.timestamp>sa(t)*2&&(n=e[1]);const s=Pa(i.timestamp-n.timestamp);if(s===0)return{x:0,y:0};const a={x:(i.x-n.x)/s,y:(i.y-n.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function HVe(e,{min:t,max:r},n){return t!==void 0&&e<t?e=n?gn(t,e,n.min):Math.max(e,t):r!==void 0&&e>r&&(e=n?gn(r,e,n.max):Math.min(e,r)),e}function kj(e,t,r){return{min:t!==void 0?e.min+t:void 0,max:r!==void 0?e.max+r-(e.max-e.min):void 0}}function UVe(e,{top:t,left:r,bottom:n,right:i}){return{x:kj(e.x,r,i),y:kj(e.y,t,n)}}function Tj(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([r,n]=[n,r]),{min:r,max:n}}function qVe(e,t){return{x:Tj(e.x,t.x),y:Tj(e.y,t.y)}}function VVe(e,t){let r=.5;const n=fs(e),i=fs(t);return i>n?r=s1(t.min,t.max-n,e.min):n>i&&(r=s1(e.min,e.max-i,t.min)),nl(0,1,r)}function WVe(e,t){const r={};return t.min!==void 0&&(r.min=t.min-e.min),t.max!==void 0&&(r.max=t.max-e.min),r}const e_=.35;function GVe(e=e_){return e===!1?e=0:e===!0&&(e=e_),{x:wj(e,"left","right"),y:wj(e,"top","bottom")}}function wj(e,t,r){return{min:Sj(e,t),max:Sj(e,r)}}function Sj(e,t){return typeof e=="number"?e:e[t]||0}const YVe=new WeakMap;class XVe{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=li(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=f=>{r&&this.snapToCursor(G1(f).point),this.stopAnimation()},a=(f,g)=>{const{drag:m,dragPropagation:x,onDragStart:v}=this.getProps();if(m&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=EUe(m),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bo(k=>{let T=this.getAxisMotionValue(k).get()||0;if(Yo.test(T)){const{projection:w}=this.visualElement;if(w&&w.layout){const L=w.layout.layoutBox[k];L&&(T=fs(L)*(parseFloat(T)/100))}}this.originPoint[k]=T}),v&&on.update(()=>v(f,g),!1,!0),V6(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},o=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:m,dragDirectionLock:x,onDirectionLock:v,onDrag:C}=this.getProps();if(!m&&!this.openDragLock)return;const{offset:k}=g;if(x&&this.currentDirection===null){this.currentDirection=ZVe(k),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",g.point,k),this.updateAxis("y",g.point,k),this.visualElement.render(),C&&on.update(()=>C(f,g),!1,!0)},l=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g,this.stop(f,g),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new _te(t,{onSessionStart:s,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:n,contextWindow:Ste(this.visualElement),element:this.visualElement.current})}stop(t,r){const n=t||this.latestPointerEvent,i=r||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!n)return;const{velocity:a}=i;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&on.postRender(()=>o(n,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:r}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,r,n){const{drag:i}=this.getProps();if(!n||!lb(t,i,this.currentDirection))return;const s=this.getAxisMotionValue(t);let a=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(a=HVe(a,this.constraints[t],this.elastic[t])),s.set(a)}resolveConstraints(){var s;const{dragConstraints:t,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,i=this.constraints;t&&wf(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&n?this.constraints=UVe(n.layoutBox,t):this.constraints=!1,this.elastic=GVe(r),i!==this.constraints&&!wf(t)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bo(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=WVe(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!wf(t))return!1;const n=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=rqe(n,i.root,this.visualElement.getTransformPagePoint());let a=qVe(i.layout.layoutBox,s);if(r){const o=r(JUe(a));this.hasMutatedConstraints=!!o,o&&(a=Yee(o))}return a}startAnimation(t){const{drag:r,dragMomentum:n,dragElastic:i,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},c=Bo(h=>{if(!lb(h,r,this.currentDirection))return;let f=l&&l[h]||{};(a===!0||a===h)&&(f={min:0,max:0});const g=i?200:1e6,m=i?40:1e7,x={type:"inertia",velocity:n?t[h]:0,bounceStiffness:g,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(h,x)});return Promise.all(c).then(o)}startAxisValueAnimation(t,r){const n=this.getAxisMotionValue(t);return V6(this.visualElement,t),n.start(I7(t,n,0,r,this.visualElement,!1))}stopAnimation(){Bo(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const r=`_drag${t.toUpperCase()}`,n=this.visualElement.getProps(),i=n[r];return i||this.visualElement.getValue(t,(n.initial?n.initial[t]:void 0)||0)}snapToCursor(t){Bo(r=>{const{drag:n}=this.getProps();if(!lb(r,n,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(r);if(i&&i.layout){const{min:a,max:o}=i.layout.layoutBox[r],l=s.get()||0;s.set(t[r]-gn(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!wf(r)||!n||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Bo(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();i[a]=VVe({min:l,max:l},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bo(a=>{if(!lb(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:c}=this.constraints[a];o.set(gn(l,c,i[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;YVe.set(this.visualElement,this);const t=this.visualElement.current,r=wg(t,"pointerdown",c=>{const{drag:h,dragListener:f=!0}=this.getProps(),g=c.target,m=g!==t&&IUe(g);h&&f&&!m&&this.start(c)});let n;const i=()=>{const{dragConstraints:c}=this.getProps();wf(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),n||(n=KVe(t,c.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,a=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),on.read(i);const o=l1(window,"resize",()=>this.scalePositionWithinConstraints()),l=s.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Bo(f=>{const g=this.getAxisMotionValue(f);g&&(this.originPoint[f]+=c[f].translate,g.set(g.get()+c[f].translate))}),this.visualElement.render())}));return()=>{o(),r(),a(),l&&l(),n&&n()}}getProps(){const t=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:a=e_,dragMomentum:o=!0}=t;return{...t,drag:r,dragDirectionLock:n,dragPropagation:i,dragConstraints:s,dragElastic:a,dragMomentum:o}}}function _j(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function KVe(e,t,r){const n=BP(e,_j(r)),i=BP(t,_j(r));return()=>{n(),i()}}function lb(e,t,r){return(t===!0||t===e)&&(r===null||r===e)}function ZVe(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}class QVe extends Vu{constructor(t){super(t),this.removeGroupControls=Fa,this.removeListeners=Fa,this.controls=new XVe(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Fa}update(){const{dragControls:t}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};t!==r&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const GT=e=>(t,r)=>{e&&on.update(()=>e(t,r),!1,!0)};class JVe extends Vu{constructor(){super(...arguments),this.removePointerDownListener=Fa}onPointerDown(t){this.session=new _te(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ste(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:r,onPan:n,onPanEnd:i}=this.node.getProps();return{onSessionStart:GT(t),onStart:GT(r),onMove:GT(n),onEnd:(s,a)=>{delete this.session,i&&on.postRender(()=>i(s,a))}}}mount(){this.removePointerDownListener=wg(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let YT=!1;class eWe extends _.Component{componentDidMount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n,layoutId:i}=this.props,{projection:s}=t;s&&(r.group&&r.group.add(s),n&&n.register&&i&&n.register(s),YT&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),t2.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:r,visualElement:n,drag:i,isPresent:s}=this.props,{projection:a}=n;return a&&(a.isPresent=s,t.layoutDependency!==r&&a.setOptions({...a.options,layoutDependency:r}),YT=!0,i||t.layoutDependency!==r||r===void 0||t.isPresent!==s?a.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?a.promote():a.relegate()||on.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:r}=this.props,{projection:n}=t;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),P7.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:i}=t;YT=!0,i&&(i.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(i),n&&n.deregister&&n.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Ate(e){const[t,r]=oVe(),n=_.useContext(UJ);return p.jsx(eWe,{...e,layoutGroup:n,switchLayoutGroup:_.useContext(Tte),isPresent:t,safeToRemove:r})}const tWe={pan:{Feature:JVe},drag:{Feature:QVe,ProjectionNode:mte,MeasureLayout:Ate}};function Ej(e,t,r){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover",r==="Start");const i="onHover"+r,s=n[i];s&&on.postRender(()=>s(t,G1(t)))}class rWe extends Vu{mount(){const{current:t}=this.node;t&&(this.unmount=NUe(t,(r,n)=>(Ej(this.node,n,"Start"),i=>Ej(this.node,i,"End"))))}unmount(){}}class nWe extends Vu{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=q1(l1(this.node.current,"focus",()=>this.onFocus()),l1(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Aj(e,t,r){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap",r==="Start");const i="onTap"+(r==="End"?"":r),s=n[i];s&&on.postRender(()=>s(t,G1(t)))}class iWe extends Vu{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=BUe(t,(i,s)=>(Aj(this.node,s,"Start"),(a,{success:o})=>Aj(this.node,a,o?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const t_=new WeakMap,XT=new WeakMap,sWe=e=>{const t=t_.get(e.target);t&&t(e)},aWe=e=>{e.forEach(sWe)};function oWe({root:e,...t}){const r=e||document;XT.has(r)||XT.set(r,{});const n=XT.get(r),i=JSON.stringify(t);return n[i]||(n[i]=new IntersectionObserver(aWe,{root:e,...t})),n[i]}function lWe(e,t,r){const n=oWe(t);return t_.set(e,r),n.observe(e),()=>{t_.delete(e),n.unobserve(e)}}const cWe={some:0,all:1};class uWe extends Vu{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:t={}}=this.node.getProps(),{root:r,margin:n,amount:i="some",once:s}=t,a={root:r?r.current:void 0,rootMargin:n,threshold:typeof i=="number"?i:cWe[i]},o=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,s&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),m=h?f:g;m&&m(c)};this.stopObserver=lWe(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:r}=this.node;["amount","margin","root"].some(hWe(t,r))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function hWe({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}const dWe={inView:{Feature:uWe},tap:{Feature:iWe},focus:{Feature:nWe},hover:{Feature:rWe}},fWe={layout:{ProjectionNode:mte,MeasureLayout:Ate}},pWe={...PVe,...dWe,...tWe,...fWe},mWe=MVe(pWe,IVe),Nj=new Map,gWe=e=>{let t=Nj.get(e);return t||(t=mWe.create(e),Nj.set(e,t)),t},yWe=({children:e,as:t="p",className:r,duration:n=2,spread:i=2})=>{const s=gWe(t),a=_.useMemo(()=>((e==null?void 0:e.length)??0)*i,[e,i]);return p.jsx(s,{animate:{backgroundPosition:"0% center"},className:kn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",r),initial:{backgroundPosition:"100% center"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{duration:n,ease:"linear",repeat:Number.POSITIVE_INFINITY},children:e})},Nte=_.memo(yWe),Lte=_.createContext(null),xWe=()=>{const e=_.useContext(Lte);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},bWe=1e3,vWe=1e3,Rte=_.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:i,duration:s,children:a,...o})=>{const l=n??t,c=n===!1,[h,f]=oM({defaultProp:l,onChange:i,prop:r}),[g,m]=oM({defaultProp:void 0,prop:s}),x=_.useRef(t),[v,C]=_.useState(!1),k=_.useRef(null);_.useEffect(()=>{t?(x.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(m(Math.ceil((Date.now()-k.current)/vWe)),k.current=null)},[t,m]),_.useEffect(()=>{t&&!h&&!c&&f(!0)},[t,h,f,c]),_.useEffect(()=>{if(x.current&&!t&&h&&!v){const L=setTimeout(()=>{f(!1),C(!0)},bWe);return()=>clearTimeout(L)}},[t,h,f,v]);const T=_.useCallback(L=>{f(L)},[f]),w=_.useMemo(()=>({duration:g,isOpen:h,isStreaming:t,setIsOpen:f}),[g,h,t,f]);return p.jsx(Lte.Provider,{value:w,children:p.jsx(H_,{className:kn("not-prose mb-4",e),onOpenChange:T,open:h,...o,children:a})})}),CWe=(e,t)=>e||t===0?p.jsx(Nte,{duration:1,children:"Thinking..."}):t===void 0?p.jsx("p",{children:"Thought for a few seconds"}):p.jsxs("p",{children:["Thought for ",t," seconds"]}),Mte=_.memo(({className:e,children:t,getThinkingMessage:r=CWe,...n})=>{const{isStreaming:i,isOpen:s,duration:a}=xWe();return p.jsx(U_,{className:kn("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??p.jsxs(p.Fragment,{children:[p.jsx(Lae,{className:"size-4"}),r(i,a),p.jsx(Bu,{className:kn("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),kWe={cjk:v1,code:pE,math:ME,mermaid:B8},Ite=_.memo(({className:e,children:t,...r})=>p.jsx(q_,{className:kn("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...r,children:p.jsx(Ho,{plugins:kWe,children:t})}));Rte.displayName="Reasoning";Mte.displayName="ReasoningTrigger";Ite.displayName="ReasoningContent";const Ote=({className:e,from:t,...r})=>p.jsx("div",{className:kn("group flex w-full max-w-[95%] flex-col gap-2",t==="user"?"is-user ml-auto items-end":"is-assistant items-start",e),...r}),Bte=({children:e,className:t,...r})=>p.jsx("div",{className:kn("is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...r,children:e});_.createContext(null);const TWe={cjk:v1,code:pE,math:ME,mermaid:B8},Dte=_.memo(({className:e,...t})=>p.jsx(Ho,{className:kn("size-full text-[17px] leading-[1.72] font-['SimSun','Songti_SC','STSong',serif] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>p+p]:mt-4",e),plugins:TWe,...t}),(e,t)=>e.children===t.children&&t.isAnimating===e.isAnimating);Dte.displayName="MessageResponse";const r2=_.memo(function({role:t,content:r}){const n=t==="user",i=r.startsWith("✗");return p.jsx(Ote,{from:t,children:p.jsx(Bte,{children:n?p.jsx("div",{className:"text-[17px] leading-[1.72]",children:r}):i?p.jsxs("div",{className:"flex items-center gap-2 text-[17px] leading-[1.72] text-destructive",children:[p.jsx(D0,{size:14,className:"shrink-0"}),p.jsx("span",{children:r.replace(/^\u2717\s*/,"")})]}):p.jsx(Dte,{children:r})})})});r2.displayName="ChatMessage";const wWe=[{icon:p.jsx(qh,{size:12}),labelZh:"写下一章",labelEn:"Write next",labelVi:"Viết chương tiếp theo",commandZh:"写下一章",commandEn:"write next",requestedIntent:"write_next"},{icon:p.jsx(Jv,{size:12}),labelZh:"审计",labelEn:"Audit",labelVi:"Kiểm tra",commandZh:"审计",commandEn:"audit"},{icon:p.jsx(noe,{size:12}),labelZh:"导出",labelEn:"Export",labelVi:"Xuất bản thảo",commandZh:"导出全书",commandEn:"export book"},{icon:p.jsx(m_,{size:12}),labelZh:"市场雷达",labelEn:"Market radar",labelVi:"Radar thị trường",commandZh:"扫描市场趋势",commandEn:"scan market trends"}];function SWe({onAction:e,disabled:t,isZh:r}){return p.jsx("div",{className:"flex gap-2 overflow-x-auto px-1 py-1",children:wWe.map(n=>{const i=V(n.labelZh,n.labelEn,n.labelVi),s=r?n.commandZh:n.commandEn;return p.jsxs("button",{onClick:()=>e(s,n.requestedIntent),disabled:t,className:"shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary/50 border border-border/30 text-xs font-medium text-muted-foreground hover:text-primary hover:border-primary/30 hover:bg-primary/5 transition-all disabled:opacity-40 disabled:pointer-events-none group",children:[p.jsx("span",{className:"group-hover:scale-110 transition-transform",children:n.icon}),i]},i)})})}const Pte="inkos:studio:tool-details-default-open";function Lj(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function _We(e){return(e==null?void 0:e.getItem(Pte))!=="false"}const r_=f_()(e=>({toolDetailsDefaultOpen:_We(Lj()),setToolDetailsDefaultOpen:t=>{var r;try{(r=Lj())==null||r.setItem(Pte,String(t))}catch{}e({toolDetailsDefaultOpen:t})}}));var Pr;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pr||(Pr={}));var Rj;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Rj||(Rj={}));const Nt=Pr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),tu=e=>{switch(typeof e){case"undefined":return Nt.undefined;case"string":return Nt.string;case"number":return Number.isNaN(e)?Nt.nan:Nt.number;case"boolean":return Nt.boolean;case"function":return Nt.function;case"bigint":return Nt.bigint;case"symbol":return Nt.symbol;case"object":return Array.isArray(e)?Nt.array:e===null?Nt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Nt.promise:typeof Map<"u"&&e instanceof Map?Nt.map:typeof Set<"u"&&e instanceof Set?Nt.set:typeof Date<"u"&&e instanceof Date?Nt.date:Nt.object;default:return Nt.unknown}},lt=Pr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class sc extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),n}static assert(t){if(!(t instanceof sc))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}sc.create=e=>new sc(e);const n_=(e,t)=>{let r;switch(e.code){case lt.invalid_type:e.received===Nt.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case lt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Pr.jsonStringifyReplacer)}`;break;case lt.unrecognized_keys:r=`Unrecognized key(s) in object: ${Pr.joinValues(e.keys,", ")}`;break;case lt.invalid_union:r="Invalid input";break;case lt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Pr.joinValues(e.options)}`;break;case lt.invalid_enum_value:r=`Invalid enum value. Expected ${Pr.joinValues(e.options)}, received '${e.received}'`;break;case lt.invalid_arguments:r="Invalid function arguments";break;case lt.invalid_return_type:r="Invalid function return type";break;case lt.invalid_date:r="Invalid date";break;case lt.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Pr.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case lt.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case lt.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case lt.custom:r="Invalid input";break;case lt.invalid_intersection_types:r="Intersection results could not be merged";break;case lt.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case lt.not_finite:r="Number must be finite";break;default:r=t.defaultError,Pr.assertNever(e)}return{message:r}};let EWe=n_;function AWe(){return EWe}const NWe=e=>{const{data:t,path:r,errorMaps:n,issueData:i}=e,s=[...r,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:t,defaultError:o}).message;return{...i,path:s,message:o}};function xt(e,t){const r=AWe(),n=NWe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===n_?void 0:n_].filter(i=>!!i)});e.common.issues.push(n)}class ha{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const i of r){if(i.status==="aborted")return sr;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const i of r){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return ha.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const i of r){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return sr;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:t.value,value:n}}}const sr=Object.freeze({status:"aborted"}),Xm=e=>({status:"dirty",value:e}),Ua=e=>({status:"valid",value:e}),Mj=e=>e.status==="aborted",Ij=e=>e.status==="dirty",L0=e=>e.status==="valid",$v=e=>typeof Promise<"u"&&e instanceof Promise;var Dt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Dt||(Dt={}));class Iu{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Oj=(e,t)=>{if(L0(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new sc(e.common.issues);return this._error=r,this._error}}};function Cr(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,o)=>{const{message:l}=e;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:i}}class Ir{get description(){return this._def.description}_getType(t){return tu(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:tu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ha,ctx:{common:t.parent.common,data:t.data,parsedType:tu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if($v(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)},i=this._parseSync({data:t,path:n.path,parent:n});return Oj(n,i)}"~validate"(t){var n,i;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:r});return L0(s)?{value:s.value}:{issues:r.common.issues}}catch(s){(i=(n=s==null?void 0:s.message)==null?void 0:n.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(s=>L0(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(t,r){const n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)},i=this._parse({data:t,path:n.path,parent:n}),s=await($v(i)?i:Promise.resolve(i));return Oj(n,s)}refine(t,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{const a=t(i),o=()=>s.addIssue({code:lt.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new I0({schema:this,typeName:ar.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return bu.create(this,this._def)}nullable(){return O0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xo.create(this)}promise(){return Vv.create(this,this._def)}or(t){return Uv.create([this,t],this._def)}and(t){return qv.create(this,t,this._def)}transform(t){return new I0({...Cr(this._def),schema:this,typeName:ar.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new a_({...Cr(this._def),innerType:this,defaultValue:r,typeName:ar.ZodDefault})}brand(){return new QWe({typeName:ar.ZodBranded,type:this,...Cr(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new o_({...Cr(this._def),innerType:this,catchValue:r,typeName:ar.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return W7.create(this,t)}readonly(){return l_.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LWe=/^c[^\s-]{8,}$/i,RWe=/^[0-9a-z]+$/,MWe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,IWe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,OWe=/^[a-z0-9_-]{21}$/i,BWe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,DWe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,PWe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jWe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let KT;const FWe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,zWe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$We=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,HWe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,UWe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qWe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jte="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",VWe=new RegExp(`^${jte}$`);function Fte(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function WWe(e){return new RegExp(`^${Fte(e)}$`)}function GWe(e){let t=`${jte}T${Fte(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function YWe(e,t){return!!((t==="v4"||!t)&&FWe.test(e)||(t==="v6"||!t)&&$We.test(e))}function XWe(e,t){if(!BWe.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function KWe(e,t){return!!((t==="v4"||!t)&&zWe.test(e)||(t==="v6"||!t)&&HWe.test(e))}class du extends Ir{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Nt.string){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.string,received:s.parsedType}),sr}const n=new ha;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=t.data.length>s.value,o=t.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(t,i),a?xt(i,{code:lt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&xt(i,{code:lt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")PWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"email",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")KT||(KT=new RegExp(jWe,"u")),KT.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"emoji",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")IWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"uuid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")OWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"nanoid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")LWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cuid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")RWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cuid2",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")MWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"ulid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),xt(i,{validation:"url",code:lt.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"regex",code:lt.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?GWe(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?VWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?WWe(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?DWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"duration",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?YWe(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"ip",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?XWe(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"jwt",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?KWe(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cidr",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?UWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"base64",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?qWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"base64url",code:lt.invalid_string,message:s.message}),n.dirty()):Pr.assertNever(s);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:lt.invalid_string,...Dt.errToObj(n)})}_addCheck(t){return new du({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Dt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Dt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Dt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Dt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Dt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Dt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Dt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Dt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Dt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Dt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Dt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Dt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Dt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Dt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Dt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Dt.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Dt.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r==null?void 0:r.position,...Dt.errToObj(r==null?void 0:r.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Dt.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Dt.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Dt.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Dt.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Dt.errToObj(r)})}nonempty(t){return this.min(1,Dt.errToObj(t))}trim(){return new du({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new du({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new du({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}du.create=e=>new du({checks:[],typeName:ar.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Cr(e)});function ZWe(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}class R0 extends Ir{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Nt.number){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.number,received:s.parsedType}),sr}let n;const i=new ha;for(const s of this._def.checks)s.kind==="int"?Pr.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?ZWe(t.data,s.value)!==0&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_finite,message:s.message}),i.dirty()):Pr.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Dt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Dt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Dt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Dt.toString(r))}setLimit(t,r,n,i){return new R0({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(t){return new R0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Dt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Dt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Dt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Dt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Dt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Dt.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Dt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Dt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Dt.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Pr.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}}R0.create=e=>new R0({checks:[],typeName:ar.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Cr(e)});class c1 extends Ir{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Nt.bigint)return this._getInvalidInput(t);let n;const i=new ha;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Pr.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return xt(r,{code:lt.invalid_type,expected:Nt.bigint,received:r.parsedType}),sr}gte(t,r){return this.setLimit("min",t,!0,Dt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Dt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Dt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Dt.toString(r))}setLimit(t,r,n,i){return new c1({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(t){return new c1({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Dt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Dt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Dt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Dt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Dt.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}c1.create=e=>new c1({checks:[],typeName:ar.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Cr(e)});class Bj extends Ir{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Nt.boolean){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.boolean,received:n.parsedType}),sr}return Ua(t.data)}}Bj.create=e=>new Bj({typeName:ar.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Cr(e)});class Hv extends Ir{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Nt.date){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.date,received:s.parsedType}),sr}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_date}),sr}const n=new ha;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Pr.assertNever(s);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Hv({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Dt.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Dt.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}Hv.create=e=>new Hv({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:ar.ZodDate,...Cr(e)});class Dj extends Ir{_parse(t){if(this._getType(t)!==Nt.symbol){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.symbol,received:n.parsedType}),sr}return Ua(t.data)}}Dj.create=e=>new Dj({typeName:ar.ZodSymbol,...Cr(e)});class Pj extends Ir{_parse(t){if(this._getType(t)!==Nt.undefined){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.undefined,received:n.parsedType}),sr}return Ua(t.data)}}Pj.create=e=>new Pj({typeName:ar.ZodUndefined,...Cr(e)});class jj extends Ir{_parse(t){if(this._getType(t)!==Nt.null){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.null,received:n.parsedType}),sr}return Ua(t.data)}}jj.create=e=>new jj({typeName:ar.ZodNull,...Cr(e)});class Fj extends Ir{constructor(){super(...arguments),this._any=!0}_parse(t){return Ua(t.data)}}Fj.create=e=>new Fj({typeName:ar.ZodAny,...Cr(e)});class zj extends Ir{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ua(t.data)}}zj.create=e=>new zj({typeName:ar.ZodUnknown,...Cr(e)});class Ou extends Ir{_parse(t){const r=this._getOrReturnCtx(t);return xt(r,{code:lt.invalid_type,expected:Nt.never,received:r.parsedType}),sr}}Ou.create=e=>new Ou({typeName:ar.ZodNever,...Cr(e)});class $j extends Ir{_parse(t){if(this._getType(t)!==Nt.undefined){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.void,received:n.parsedType}),sr}return Ua(t.data)}}$j.create=e=>new $j({typeName:ar.ZodVoid,...Cr(e)});class Xo extends Ir{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==Nt.array)return xt(r,{code:lt.invalid_type,expected:Nt.array,received:r.parsedType}),sr;if(i.exactLength!==null){const a=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(a||o)&&(xt(r,{code:a?lt.too_big:lt.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(xt(r,{code:lt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(xt(r,{code:lt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>i.type._parseAsync(new Iu(r,a,r.path,o)))).then(a=>ha.mergeArray(n,a));const s=[...r.data].map((a,o)=>i.type._parseSync(new Iu(r,a,r.path,o)));return ha.mergeArray(n,s)}get element(){return this._def.type}min(t,r){return new Xo({...this._def,minLength:{value:t,message:Dt.toString(r)}})}max(t,r){return new Xo({...this._def,maxLength:{value:t,message:Dt.toString(r)}})}length(t,r){return new Xo({...this._def,exactLength:{value:t,message:Dt.toString(r)}})}nonempty(t){return this.min(1,t)}}Xo.create=(e,t)=>new Xo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ar.ZodArray,...Cr(t)});function Sf(e){if(e instanceof Zn){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=bu.create(Sf(n))}return new Zn({...e._def,shape:()=>t})}else return e instanceof Xo?new Xo({...e._def,type:Sf(e.element)}):e instanceof bu?bu.create(Sf(e.unwrap())):e instanceof O0?O0.create(Sf(e.unwrap())):e instanceof dd?dd.create(e.items.map(t=>Sf(t))):e}class Zn extends Ir{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=Pr.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Nt.object){const c=this._getOrReturnCtx(t);return xt(c,{code:lt.invalid_type,expected:Nt.object,received:c.parsedType}),sr}const{status:n,ctx:i}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ou&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const h=s[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new Iu(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ou){const c=this._def.unknownKeys;if(c==="passthrough")for(const h of o)l.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(c==="strict")o.length>0&&(xt(i,{code:lt.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const h of o){const f=i.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new Iu(i,f,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const h of l){const f=await h.key,g=await h.value;c.push({key:f,value:g,alwaysSet:h.alwaysSet})}return c}).then(c=>ha.mergeObjectSync(n,c)):ha.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return Dt.errToObj,new Zn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var s,a;const i=((a=(s=this._def).errorMap)==null?void 0:a.call(s,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:Dt.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Zn({...this._def,unknownKeys:"strip"})}passthrough(){return new Zn({...this._def,unknownKeys:"passthrough"})}extend(t){return new Zn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Zn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ar.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Zn({...this._def,catchall:t})}pick(t){const r={};for(const n of Pr.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Zn({...this._def,shape:()=>r})}omit(t){const r={};for(const n of Pr.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new Zn({...this._def,shape:()=>r})}deepPartial(){return Sf(this)}partial(t){const r={};for(const n of Pr.objectKeys(this.shape)){const i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new Zn({...this._def,shape:()=>r})}required(t){const r={};for(const n of Pr.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof bu;)s=s._def.innerType;r[n]=s}return new Zn({...this._def,shape:()=>r})}keyof(){return zte(Pr.objectKeys(this.shape))}}Zn.create=(e,t)=>new Zn({shape:()=>e,unknownKeys:"strip",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});Zn.strictCreate=(e,t)=>new Zn({shape:()=>e,unknownKeys:"strict",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});Zn.lazycreate=(e,t)=>new Zn({shape:e,unknownKeys:"strip",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});class Uv extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new sc(o.ctx.common.issues));return xt(r,{code:lt.invalid_union,unionErrors:a}),sr}if(r.common.async)return Promise.all(n.map(async s=>{const a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const l of n){const c={...r,common:{...r.common,issues:[]},parent:null},h=l._parseSync({data:r.data,path:r.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(l=>new sc(l));return xt(r,{code:lt.invalid_union,unionErrors:o}),sr}}get options(){return this._def.options}}Uv.create=(e,t)=>new Uv({options:e,typeName:ar.ZodUnion,...Cr(t)});function i_(e,t){const r=tu(e),n=tu(t);if(e===t)return{valid:!0,data:e};if(r===Nt.object&&n===Nt.object){const i=Pr.objectKeys(t),s=Pr.objectKeys(e).filter(o=>i.indexOf(o)!==-1),a={...e,...t};for(const o of s){const l=i_(e[o],t[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(r===Nt.array&&n===Nt.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const a=e[s],o=t[s],l=i_(a,o);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return r===Nt.date&&n===Nt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class qv extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t),i=(s,a)=>{if(Mj(s)||Mj(a))return sr;const o=i_(s.value,a.value);return o.valid?((Ij(s)||Ij(a))&&r.dirty(),{status:r.value,value:o.data}):(xt(n,{code:lt.invalid_intersection_types}),sr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qv.create=(e,t,r)=>new qv({left:e,right:t,typeName:ar.ZodIntersection,...Cr(r)});class dd extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.array)return xt(n,{code:lt.invalid_type,expected:Nt.array,received:n.parsedType}),sr;if(n.data.length<this._def.items.length)return xt(n,{code:lt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),sr;!this._def.rest&&n.data.length>this._def.items.length&&(xt(n,{code:lt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const s=[...n.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new Iu(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ha.mergeArray(r,a)):ha.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new dd({...this._def,rest:t})}}dd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new dd({items:e,typeName:ar.ZodTuple,rest:null,...Cr(t)})};class Hj extends Ir{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.map)return xt(n,{code:lt.invalid_type,expected:Nt.map,received:n.parsedType}),sr;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,l],c)=>({key:i._parse(new Iu(n,o,n.path,[c,"key"])),value:s._parse(new Iu(n,l,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return sr;(c.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(c.value,h.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return sr;(c.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(c.value,h.value)}return{status:r.value,value:o}}}}Hj.create=(e,t,r)=>new Hj({valueType:t,keyType:e,typeName:ar.ZodMap,...Cr(r)});class u1 extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.set)return xt(n,{code:lt.invalid_type,expected:Nt.set,received:n.parsedType}),sr;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(xt(n,{code:lt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(xt(n,{code:lt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const s=this._def.valueType;function a(l){const c=new Set;for(const h of l){if(h.status==="aborted")return sr;h.status==="dirty"&&r.dirty(),c.add(h.value)}return{status:r.value,value:c}}const o=[...n.data.values()].map((l,c)=>s._parse(new Iu(n,l,n.path,c)));return n.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(t,r){return new u1({...this._def,minSize:{value:t,message:Dt.toString(r)}})}max(t,r){return new u1({...this._def,maxSize:{value:t,message:Dt.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}u1.create=(e,t)=>new u1({valueType:e,minSize:null,maxSize:null,typeName:ar.ZodSet,...Cr(t)});class Uj extends Ir{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Uj.create=(e,t)=>new Uj({getter:e,typeName:ar.ZodLazy,...Cr(t)});class s_ extends Ir{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return xt(r,{received:r.data,code:lt.invalid_literal,expected:this._def.value}),sr}return{status:"valid",value:t.data}}get value(){return this._def.value}}s_.create=(e,t)=>new s_({value:e,typeName:ar.ZodLiteral,...Cr(t)});function zte(e,t){return new M0({values:e,typeName:ar.ZodEnum,...Cr(t)})}class M0 extends Ir{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return xt(r,{expected:Pr.joinValues(n),received:r.parsedType,code:lt.invalid_type}),sr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return xt(r,{received:r.data,code:lt.invalid_enum_value,options:n}),sr}return Ua(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return M0.create(t,{...this._def,...r})}exclude(t,r=this._def){return M0.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}}M0.create=zte;class qj extends Ir{_parse(t){const r=Pr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Nt.string&&n.parsedType!==Nt.number){const i=Pr.objectValues(r);return xt(n,{expected:Pr.joinValues(i),received:n.parsedType,code:lt.invalid_type}),sr}if(this._cache||(this._cache=new Set(Pr.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Pr.objectValues(r);return xt(n,{received:n.data,code:lt.invalid_enum_value,options:i}),sr}return Ua(t.data)}get enum(){return this._def.values}}qj.create=(e,t)=>new qj({values:e,typeName:ar.ZodNativeEnum,...Cr(t)});class Vv extends Ir{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==Nt.promise&&r.common.async===!1)return xt(r,{code:lt.invalid_type,expected:Nt.promise,received:r.parsedType}),sr;const n=r.parsedType===Nt.promise?r.data:Promise.resolve(r.data);return Ua(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Vv.create=(e,t)=>new Vv({type:e,typeName:ar.ZodPromise,...Cr(t)});class I0 extends Ir{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ar.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:a=>{xt(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return sr;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?sr:l.status==="dirty"||r.value==="dirty"?Xm(l.value):l});{if(r.value==="aborted")return sr;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?sr:o.status==="dirty"||r.value==="dirty"?Xm(o.value):o}}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?sr:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?sr:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!L0(a))return sr;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>L0(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:r.value,value:o})):sr);Pr.assertNever(i)}}I0.create=(e,t,r)=>new I0({schema:e,typeName:ar.ZodEffects,effect:t,...Cr(r)});I0.createWithPreprocess=(e,t,r)=>new I0({schema:t,effect:{type:"preprocess",transform:e},typeName:ar.ZodEffects,...Cr(r)});class bu extends Ir{_parse(t){return this._getType(t)===Nt.undefined?Ua(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}bu.create=(e,t)=>new bu({innerType:e,typeName:ar.ZodOptional,...Cr(t)});class O0 extends Ir{_parse(t){return this._getType(t)===Nt.null?Ua(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}O0.create=(e,t)=>new O0({innerType:e,typeName:ar.ZodNullable,...Cr(t)});class a_ extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t);let n=r.data;return r.parsedType===Nt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}a_.create=(e,t)=>new a_({innerType:e,typeName:ar.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Cr(t)});class o_ extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $v(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new sc(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new sc(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}o_.create=(e,t)=>new o_({innerType:e,typeName:ar.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Cr(t)});class Vj extends Ir{_parse(t){if(this._getType(t)!==Nt.nan){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.nan,received:n.parsedType}),sr}return{status:"valid",value:t.data}}}Vj.create=e=>new Vj({typeName:ar.ZodNaN,...Cr(e)});class QWe extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class W7 extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?sr:s.status==="dirty"?(r.dirty(),Xm(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?sr:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new W7({in:t,out:r,typeName:ar.ZodPipeline})}}class l_ extends Ir{_parse(t){const r=this._def.innerType._parse(t),n=i=>(L0(i)&&(i.value=Object.freeze(i.value)),i);return $v(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}l_.create=(e,t)=>new l_({innerType:e,typeName:ar.ZodReadonly,...Cr(t)});var ar;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ar||(ar={}));const _i=du.create,Wv=R0.create;Ou.create;const Uo=Xo.create,Wu=Zn.create;Uv.create;qv.create;dd.create;const JWe=s_.create,G7=M0.create;Vv.create;bu.create;O0.create;const $te=2,Hte=5,eGe=1,tGe=10,rGe=Wu({kind:G7(["continuity","causality","character"]),description:_i().min(1)}),nGe=Wu({chapter:Wv().int().min(1),summary:_i().min(1)}),iGe=Wu({character:_i().min(1),decision:_i().min(1)}),sGe=Wu({characters:Uo(_i()),relationships:Uo(_i()),world:Uo(_i()),hooks:Uo(_i())}),aGe=Wu({score:Wv().min(0).max(100),rationale:_i().min(1)}),Ute=Wu({branchId:_i().regex(/^branch-\d+$/),title:_i().min(1),premise:_i().min(1),beats:Uo(nGe).min(1),characterDecisions:Uo(iGe),projectedChanges:sGe,risks:Uo(rGe),uncertainties:Uo(_i()),intentAlignment:aGe}),oGe=G7(["active","stale"]),lGe=Wu({version:JWe(1),forecastId:_i().min(1),bookId:_i().min(1),createdAt:_i().min(1),language:G7(["zh","en"]),divergence:_i().min(1),horizon:Wv().int().min(eGe).max(tGe),baseChapter:Wv().int().min(0),contextFingerprint:_i().min(1),status:oGe,branches:Uo(Ute).min($te).max(Hte)}).superRefine((e,t)=>{const r=new Set;for(const n of e.branches)r.has(n.branchId)&&t.addIssue({code:lt.custom,message:`duplicate branchId: ${n.branchId}`,path:["branches"]}),r.add(n.branchId)}),cGe=Ute.omit({branchId:!0});Wu({branches:Uo(cGe).min($te).max(Hte)});function uGe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wj(e){return typeof e=="string"&&e.trim()?e:null}function qte(e){if(!["create_narrative_forecast","get_narrative_forecast","select_narrative_branch"].includes(e.tool))return null;const t=uGe(e.details);if(!t)return null;if(t.kind==="narrative_forecast_created"||t.kind==="narrative_forecast"){const r=lGe.safeParse(t.forecast);return r.success?{kind:"forecast",forecast:r.data,stale:t.stale===!0||r.data.status==="stale"}:null}if(t.kind==="narrative_branch_selected"){const r=Wj(t.branchId),n=Wj(t.planPath);return!r||!n?null:{kind:"selected",branchId:r,planPath:n,stale:t.stale===!0}}return null}function hGe(e,t,r){return r==="zh"?`请调用 select_narrative_branch,选择推演 ${e} 的 ${t}。只保存候选计划,不修改正文、大纲或正史状态。`:`Call select_narrative_branch for ${t} in forecast ${e}. Save only the candidate plan; do not modify prose, outlines, or canonical state.`}function dGe(e,t){return t==="zh"?`请调用 get_narrative_forecast,重新核验推演 ${e} 是否已经过期。`:`Call get_narrative_forecast for forecast ${e} and report whether it is stale.`}const fGe={continuity:["连续性","Continuity","Tính liên tục"],causality:["因果","Causality","Nhân quả"],character:["人物","Character","Nhân vật"]};function pGe(e){return V(e[0],e[1],e[2])}function mGe({risks:e,zh:t}){return e.length===0?p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/20 bg-emerald-500/5 px-2 py-0.5 text-[11px] text-emerald-700 dark:text-emerald-300",children:[p.jsx(KF,{size:11}),t?"未发现硬风险":"No hard risks"]}):p.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((r,n)=>p.jsx("span",{title:r.description,className:"inline-flex items-center rounded-full border border-amber-500/25 bg-amber-500/8 px-2 py-0.5 text-[11px] text-amber-800 dark:text-amber-200",children:pGe(fGe[r.kind])},`${r.kind}-${n}`))})}function mf({title:e,items:t}){return t.length===0?null:p.jsxs("div",{children:[p.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground/70",children:e}),p.jsx("ul",{className:"space-y-1 text-xs leading-5 text-muted-foreground",children:t.map((r,n)=>p.jsxs("li",{children:["· ",r]},n))})]})}function gGe({branch:e,forecastId:t,stale:r,zh:n,pending:i,onSelect:s}){return p.jsxs("article",{className:"relative flex min-w-0 flex-col rounded-xl border border-border/55 bg-background/70 p-3.5 shadow-[0_10px_30px_-24px_rgba(0,0,0,0.65)]",children:[p.jsx("div",{className:"absolute -top-[19px] left-1/2 h-4 w-px -translate-x-1/2 bg-primary/35"}),p.jsx("div",{className:"absolute -top-[22px] left-1/2 h-2 w-2 -translate-x-1/2 rounded-full border border-primary/50 bg-card"}),p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.13em] text-primary/75",children:e.branchId}),p.jsx("h4",{className:"mt-1 text-[15px] font-semibold leading-5 text-foreground",children:e.title})]}),p.jsxs("div",{className:"shrink-0 rounded-lg border border-primary/20 bg-primary/5 px-2 py-1 text-right",children:[p.jsx("div",{className:"text-[15px] font-semibold leading-none text-primary",children:e.intentAlignment.score}),p.jsx("div",{className:"mt-1 text-[9px] uppercase tracking-wide text-muted-foreground",children:n?"意图":"intent"})]})]}),p.jsx("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.premise}),p.jsx("ol",{className:"mt-3 space-y-2 border-l border-primary/20 pl-3",children:e.beats.map(a=>p.jsxs("li",{className:"relative text-xs leading-5 text-foreground/90",children:[p.jsx("span",{className:"absolute -left-[15px] top-[7px] h-1.5 w-1.5 rounded-full bg-primary/65"}),p.jsx("span",{className:"font-medium text-primary",children:n?`第 ${a.chapter} 章`:`Ch. ${a.chapter}`}),p.jsx("span",{className:"ml-1.5",children:a.summary})]},`${e.branchId}-${a.chapter}`))}),p.jsx("div",{className:"mt-3",children:p.jsx(mGe,{risks:e.risks,zh:n})}),p.jsxs("details",{className:"group mt-3 border-t border-border/40 pt-2.5",children:[p.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[p.jsx(Kv,{size:13,className:"transition-transform group-open:rotate-90"}),n?"人物决定、变化与不确定性":"Decisions, changes, uncertainties"]}),p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsx(mf,{title:n?"人物决定":"Character decisions",items:e.characterDecisions.map(a=>`${a.character}:${a.decision}`)}),p.jsx(mf,{title:n?"人物变化":"Character changes",items:e.projectedChanges.characters}),p.jsx(mf,{title:n?"关系变化":"Relationship changes",items:e.projectedChanges.relationships}),p.jsx(mf,{title:n?"世界变化":"World changes",items:e.projectedChanges.world}),p.jsx(mf,{title:n?"伏笔变化":"Hook changes",items:e.projectedChanges.hooks}),p.jsx(mf,{title:n?"不确定性":"Uncertainties",items:e.uncertainties}),p.jsx("p",{className:"rounded-lg bg-muted/45 px-2.5 py-2 text-xs leading-5 text-muted-foreground",children:e.intentAlignment.rationale})]})]}),p.jsxs("button",{type:"button","data-forecast-id":t,"data-branch-id":e.branchId,disabled:r||i||!s,onClick:()=>s==null?void 0:s(e.branchId),className:"mt-4 inline-flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/35 bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:border-border/40 disabled:bg-muted/30 disabled:text-muted-foreground/60",children:[i?p.jsx(Eg,{size:13,className:"animate-spin"}):p.jsx(ac,{size:13}),r?n?"过期推演不可采用":"Stale forecast":n?"采用此分支":"Use this branch"]})]})}function yGe({exec:e,onSelectBranch:t,onRecheck:r}){const n=qte(e),[i,s]=_.useState(null),[a,o]=_.useState(!1);if(!n)return null;if(n.kind==="selected")return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/25 bg-primary/5 px-3.5 py-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-primary",children:[p.jsx(ac,{size:15}),V("候选分支已保存","Candidate branch saved","Đã lưu nhánh ứng viên")]}),p.jsx("p",{className:"mt-1.5 text-xs leading-5 text-muted-foreground",children:V(`${n.branchId} 已写入候选计划;正文、大纲和正史状态没有修改。`,`${n.branchId} was written to the candidate plan; prose, outline, and canon were not modified.`,`Đã ghi ${n.branchId} vào kế hoạch ứng viên; bản thảo, dàn ý và chính sử không bị thay đổi.`)}),n.stale&&p.jsx("p",{className:"mt-2 text-xs text-amber-700 dark:text-amber-300",children:V("该推演基于旧正史,请核验后再继续写作。","This forecast is stale; verify it before writing.","Dự đoán này dựa trên chính sử cũ; hãy kiểm chứng trước khi viết tiếp.")})]});const{forecast:l,stale:c}=n,h=l.language==="zh",f=async m=>{if(!(!t||c)){s(m);try{await t(l.forecastId,m)}finally{s(null)}}},g=async()=>{if(r){o(!0);try{await r(l.forecastId)}finally{o(!1)}}};return p.jsxs("section",{className:"mx-3 mb-3 mt-1 overflow-hidden rounded-2xl border border-primary/25 bg-[linear-gradient(145deg,hsl(var(--card))_0%,hsl(var(--muted)/0.32)_100%)]",children:[p.jsxs("header",{className:"border-b border-border/45 px-4 py-3.5",children:[p.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[15px] font-semibold text-foreground",children:[p.jsx(moe,{size:16,className:"text-primary"}),h?"剧情多线推演":"Narrative forecast"]}),p.jsx("span",{className:"rounded-full border border-primary/20 bg-primary/8 px-2 py-0.5 text-[10px] font-medium tracking-wide text-primary",children:h?"非正史规划":"NON-CANONICAL"}),c&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-800 dark:text-amber-200",children:[p.jsx(cw,{size:11}),h?"正史已变化":"Canon changed"]})]}),p.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-foreground/85",children:l.divergence}),p.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[p.jsx("span",{children:h?`基于第 ${l.baseChapter} 章`:`After chapter ${l.baseChapter}`}),p.jsx("span",{children:h?`${l.branches.length} 条候选分支`:`${l.branches.length} branches`}),p.jsx("span",{children:h?`推演未来约 ${l.horizon} 章`:`~${l.horizon} chapters ahead`})]})]}),r&&p.jsxs("button",{type:"button",onClick:()=>{g()},disabled:a,className:"inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:border-primary/30 hover:text-foreground disabled:opacity-50",children:[p.jsx(Eg,{size:12,className:a?"animate-spin":""}),h?"重新核验":"Recheck"]})]}),c&&p.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-amber-500/20 bg-amber-500/8 px-3 py-2 text-xs leading-5 text-amber-900 dark:text-amber-100",children:[p.jsx(cw,{size:14,className:"mt-0.5 shrink-0"}),p.jsx("span",{children:h?"正史输入已在生成后变化。请重新推演,不要继续采用旧分支。":"Canonical inputs changed after generation. Regenerate before selecting a branch."})]})]}),p.jsxs("div",{className:"relative px-4 pb-4 pt-7",children:[p.jsx("div",{className:"pointer-events-none absolute left-8 right-8 top-[17px] h-px bg-gradient-to-r from-transparent via-primary/35 to-transparent"}),p.jsx("div",{className:"pointer-events-none absolute left-1/2 top-[9px] -translate-x-1/2 text-primary/70",children:p.jsx(l2,{size:14})}),p.jsx("div",{className:"grid auto-cols-[minmax(17rem,1fr)] grid-flow-col gap-3 overflow-x-auto pb-1 [scrollbar-width:thin]",children:l.branches.map(m=>p.jsx(gGe,{branch:m,forecastId:l.forecastId,stale:c,zh:h,pending:i===m.branchId,onSelect:t?x=>{f(x)}:void 0},m.branchId))})]})]})}function xGe({status:e}){switch(e){case"running":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-primary",children:[p.jsx(qn,{size:12,className:"animate-spin"}),p.jsx("span",{children:V("执行中","Running","Đang chạy")})]});case"processing":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[p.jsx(qn,{size:12,className:"animate-spin",style:{animationDuration:"2s"}}),p.jsx("span",{children:V("处理结果","Processing result","Đang xử lý kết quả")})]});case"completed":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[p.jsx(B0,{size:12}),p.jsx("span",{children:V("已完成","Completed","Đã hoàn thành")})]});case"error":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-destructive",children:[p.jsx(D0,{size:12}),p.jsx("span",{children:V("失败","Failed","Thất bại")})]})}}function bGe({status:e}){switch(e){case"pending":return p.jsx("span",{className:"w-4 h-4 rounded-full border border-border/60 flex items-center justify-center shrink-0 text-[8px] text-muted-foreground/40",children:"○"});case"active":return p.jsx(qn,{size:14,className:"text-primary animate-spin shrink-0"});case"completed":return p.jsx(B0,{size:14,className:"text-green-600 dark:text-green-400 shrink-0"})}}function vGe(e){const t=Math.round(e.elapsedMs/1e3),r=e.status==="thinking"?V("思考中","Thinking","Đang suy nghĩ"):e.status??"",n=e.totalChars>0?e.chineseChars>0?`${e.totalChars}字`:V(`${e.totalChars} 字符`,`${e.totalChars} chars`,`${e.totalChars} ký tự`):"";return[r,`${t}s`,n].filter(Boolean).join(" · ")}function Gj(e,t){const r=(t??Date.now())-e,n=Math.round(r/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function CGe(e){return e.split("/").map(t=>encodeURIComponent(t)).join("/")}function Yj(e,t){var s;if(!e)return null;const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=e.match(new RegExp(`^${r}:\\s*(.+)$`,"im"));return((s=n==null?void 0:n[1])==null?void 0:s.trim())||null}function yr(e,t){const r=e[t];return typeof r=="string"&&r.trim()?r:void 0}function n2(e,t){const r=e[t];return typeof r=="boolean"?r:void 0}function Ko(e,t){const r=e[t];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function kGe(e,t,r){const n=e[t];if(!(!n||typeof n!="object"||Array.isArray(n)))return Ko(n,r)}function TGe(e){const t=e.actionPayload;if(!(!t||typeof t!="object"||Array.isArray(t)))return t}function Y7(e,t){const r=e[t];if(!Array.isArray(r))return;const n=Array.from(new Set(r.filter(i=>typeof i=="string").map(i=>i.trim().toLowerCase()).filter(Boolean)));return n.length>0?n:void 0}function Nh(e,t){const r=e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean):[]}function wGe(e){return!e.details||typeof e.details!="object"||Array.isArray(e.details)?[]:Nh(e.details,"skillIds")}function SGe({exec:e}){const t=wGe(e);return t.length===0?null:p.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[p.jsx("span",{className:"font-semibold text-foreground/80",children:V("专业 Skill","Professional skills","Skill chuyên môn")}),t.map(r=>p.jsx("span",{className:"rounded-full border border-border/50 bg-background/60 px-2 py-0.5 font-mono text-[11px]",children:r},r))]})}function Xj(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e,n=yr(r,"tracePath");if(!n)return null;const i=r.tokenBudget&&typeof r.tokenBudget=="object"&&!Array.isArray(r.tokenBudget)?r.tokenBudget:{},s=r.retrieval&&typeof r.retrieval=="object"&&!Array.isArray(r.retrieval)?r.retrieval:{},a=r.compression&&typeof r.compression=="object"&&!Array.isArray(r.compression)?r.compression:{};return{chapterNumber:t,tracePath:n,selectedSources:Nh(r,"selectedSources"),protectedSources:Nh(r,"protectedSources"),compressibleSources:Nh(r,"compressibleSources"),protectedTokens:Ko(i,"protectedTokens"),compressibleTokens:Ko(i,"compressibleTokens"),totalSelectedTokens:Ko(i,"totalSelectedTokens"),retrievalEngine:yr(s,"engine"),retrievalCandidateCount:Array.isArray(s.candidates)?s.candidates.length:0,semanticSelectedCount:Nh(s,"semanticSelectedIds").length,compressedSources:Nh(a,"compressedSources")}}function _Ge(e){if(e.tool!=="sub_agent"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return[];const t=e.details;if(t.kind==="chapter_written"){const r=Xj(t.contextTrace,Ko(t,"chapterNumber"));return r?[r]:[]}return t.kind!=="chapters_written"||!Array.isArray(t.chapters)?[]:t.chapters.flatMap(r=>{if(!r||typeof r!="object"||Array.isArray(r))return[];const n=r,i=Xj(n.contextTrace,Ko(n,"chapterNumber"));return i?[i]:[]})}function EGe({exec:e}){const t=_Ge(e);return t.length===0?null:p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-border/50 bg-background/55 px-3 py-2.5 text-xs",children:[p.jsx("div",{className:"font-semibold text-foreground",children:V("本轮参考依据","Context used this turn","Ngữ cảnh dùng ở lượt này")}),p.jsx("div",{className:"mt-2 space-y-2",children:t.map(r=>p.jsxs("details",{className:"rounded-lg border border-border/40 px-2.5 py-2",children:[p.jsxs("summary",{className:"cursor-pointer select-none font-medium text-foreground",children:[r.chapterNumber?V(`第 ${r.chapterNumber} 章`,`Chapter ${r.chapterNumber}`,`Chương ${r.chapterNumber}`):V("章节","Chapter","Chương"),r.retrievalEngine?` · ${r.retrievalEngine}`:""]}),p.jsxs("div",{className:"mt-2 space-y-1.5 text-muted-foreground",children:[p.jsxs("div",{children:[V("预算","Budget","Ngân sách"),": ",r.totalSelectedTokens??0,` · ${V("保护","protected","bảo vệ")} ${r.protectedTokens??0}`,` · ${V("可压缩","compressible","có thể nén")} ${r.compressibleTokens??0}`]}),p.jsxs("div",{children:[V("检索","Retrieval","Truy xuất"),": ",r.retrievalCandidateCount," ",V("个 BM25 候选","BM25 candidates","ứng viên BM25"),r.semanticSelectedCount>0?` · ${r.semanticSelectedCount} ${V("个语义选择","semantic selections","lựa chọn ngữ nghĩa")}`:""]}),r.compressedSources.length>0&&p.jsxs("div",{children:[V("语义压缩","Semantic compaction","Nén ngữ nghĩa"),": ",r.compressedSources.join(" · ")]}),p.jsxs("div",{children:[V("完整来源","All sources","Toàn bộ nguồn"),":"]}),p.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:r.selectedSources.map(n=>p.jsx("li",{children:n},n))}),p.jsx("div",{className:"font-mono text-[11px]",children:r.tracePath})]})]},`${r.chapterNumber??0}:${r.tracePath}`))})]})}function Vte(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];const r=t,n=yr(r,"description");return n?[{severity:yr(r,"severity")??"warning",category:yr(r,"category")??"review",description:n,suggestion:yr(r,"suggestion")}]:[]}):[]}function Wte(e){if(e.tool!=="sub_agent"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return null;const t=e.details;return t.kind!=="chapter_revision"?null:{chapterNumber:Ko(t,"chapterNumber"),applied:t.applied===!0,status:yr(t,"status"),auditPassed:typeof t.auditPassed=="boolean"?t.auditPassed:void 0,fixedIssues:Nh(t,"fixedIssues"),auditIssues:Vte(t.auditIssues),skippedReason:yr(t,"skippedReason")}}function Gte(e){if(e.tool!=="resync_chapter_state"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return null;const t=e.details;return t.kind!=="chapter_state_resynced"?null:{chapterNumber:Ko(t,"chapterNumber"),status:yr(t,"status"),auditPassed:typeof t.auditPassed=="boolean"?t.auditPassed:void 0,auditIssues:Vte(t.auditIssues),summary:yr(t,"summary")}}function Yte({issues:e,title:t}){return e.length===0?null:p.jsxs("div",{className:"mt-2 space-y-1.5",children:[p.jsx("div",{className:"text-[13px] font-medium text-foreground",children:t}),e.map((r,n)=>p.jsxs("div",{className:"rounded-lg border border-border/40 bg-background/55 px-2.5 py-2 text-[12px] leading-5 text-muted-foreground",children:[p.jsxs("div",{className:"font-medium text-foreground",children:["[",r.severity,"] ",r.category]}),p.jsx("div",{children:r.description}),r.suggestion&&p.jsxs("div",{className:"mt-0.5",children:[V("建议","Suggestion","Đề xuất"),V(":",": ",": "),r.suggestion]})]},`${r.category}:${n}`))]})}function AGe({exec:e}){const t=Wte(e);if(!t)return null;const r=t.applied&&t.auditPassed===!0;return p.jsxs("div",{"data-testid":"chapter-revision-preview",className:`mx-3 mb-3 mt-1 rounded-xl border px-3 py-2.5 ${r?"border-emerald-500/25 bg-emerald-500/5":"border-amber-500/25 bg-amber-500/5"}`,children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:t.chapterNumber?V(`第 ${t.chapterNumber} 章修订`,`Chapter ${t.chapterNumber} revision`,`Sửa chương ${t.chapterNumber}`):V("章节修订","Chapter revision","Sửa chương")}),p.jsx("div",{className:`rounded-full px-2 py-0.5 text-[12px] font-semibold ${r?"bg-emerald-500/15 text-emerald-600":"bg-amber-500/15 text-amber-600"}`,children:t.applied?t.auditPassed?V("审稿通过","Audit passed","Đã qua kiểm duyệt"):V("仍需复核","Review required","Cần xem lại"):V("保留原稿","Original kept","Giữ bản gốc")})]}),t.skippedReason&&p.jsx("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:t.skippedReason}),t.fixedIssues.length>0&&p.jsxs("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:[p.jsxs("span",{className:"font-medium text-foreground",children:[V("已处理","Fixed","Đã xử lý"),V(":",": ",": ")]}),t.fixedIssues.join(";")]}),p.jsx(Yte,{issues:t.auditIssues,title:V("剩余审稿问题","Remaining audit issues","Vấn đề kiểm duyệt còn lại")})]})}function NGe({exec:e}){const t=Gte(e);if(!t)return null;const r=t.auditPassed===!0;return p.jsxs("div",{"data-testid":"chapter-state-resync-preview",className:`mx-3 mb-3 mt-1 rounded-xl border px-3 py-2.5 ${r?"border-emerald-500/25 bg-emerald-500/5":"border-amber-500/25 bg-amber-500/5"}`,children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:t.chapterNumber?V(`第 ${t.chapterNumber} 章状态已同步`,`Chapter ${t.chapterNumber} state resynced`,`Đã đồng bộ trạng thái chương ${t.chapterNumber}`):V("章节状态已同步","Chapter state resynced","Đã đồng bộ trạng thái chương")}),p.jsx("div",{className:`rounded-full px-2 py-0.5 text-[12px] font-semibold ${r?"bg-emerald-500/15 text-emerald-600":"bg-amber-500/15 text-amber-600"}`,children:r?V("审稿通过","Audit passed","Đã qua kiểm duyệt"):V("仍需修订","Revision required","Cần sửa lại")})]}),t.summary&&p.jsx("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:t.summary}),p.jsx(Yte,{issues:t.auditIssues,title:V("审稿问题","Audit issues","Vấn đề kiểm duyệt")})]})}function Xte(e){if(!["short_fiction_run","generate_cover","script_create","storyboard_create","interactive_film_create"].includes(e.tool)||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="short_fiction_created"&&t.kind!=="cover_generated"&&t.kind!=="script_created"&&t.kind!=="storyboard_created"&&t.kind!=="interactive_film_created"?null:{kind:t.kind,title:yr(t,"title"),storyId:yr(t,"storyId"),projectId:yr(t,"projectId"),finalMarkdownPath:yr(t,"finalMarkdownPath"),salesPackagePath:yr(t,"salesPackagePath"),coverPromptPath:yr(t,"coverPromptPath"),coverImagePath:yr(t,"coverImagePath"),coverError:yr(t,"coverError"),specPath:yr(t,"specPath"),scriptPath:yr(t,"scriptPath"),storyboardPath:yr(t,"storyboardPath"),storyGraphPath:yr(t,"storyGraphPath"),storyTreePath:yr(t,"storyTreePath"),flagsPath:yr(t,"flagsPath"),imagePromptsPath:yr(t,"imagePromptsPath"),assetsManifestPath:yr(t,"assetsManifestPath"),skillIds:Y7(t,"skillIds")}}function LGe({exec:e,onOpenFilmStudio:t}){const r=Ht(a=>a.openProjectArtifact);if(!["script_create","storyboard_create","interactive_film_create"].includes(e.tool)||e.status!=="completed")return null;const n=Xte(e);if(!n||n.kind!=="script_created"&&n.kind!=="storyboard_created"&&n.kind!=="interactive_film_created")return null;const s=[n.specPath?[V("规格","Spec","Spec"),n.specPath]:null,n.storyGraphPath?[V("剧情图谱","Story graph","Sơ đồ cốt truyện"),n.storyGraphPath]:null,n.storyTreePath?[V("剧情树","Story tree","Cây cốt truyện"),n.storyTreePath]:null,n.flagsPath?[V("变量旗标","Flags","Cờ biến"),n.flagsPath]:null,n.scriptPath?[V("剧本","Script","Kịch bản"),n.scriptPath]:null,n.storyboardPath?[V("分镜","Storyboard","Phân cảnh"),n.storyboardPath]:null,n.imagePromptsPath?[V("图像提示词","Image prompts","Prompt hình ảnh"),n.imagePromptsPath]:null,n.assetsManifestPath?[V("图片资产","Image assets","Tài sản hình ảnh"),n.assetsManifestPath]:null].filter(a=>!!a);return s.length===0&&!(n.kind==="interactive_film_created"&&n.projectId)?null:p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5",children:[p.jsxs("div",{className:"flex items-center justify-between gap-3",children:[p.jsx("div",{className:"text-[16px] leading-6 font-semibold text-primary",children:n.kind==="script_created"?V("剧本已生成","Script generated","Đã tạo kịch bản"):n.kind==="storyboard_created"?V("分镜已生成","Storyboard generated","Đã tạo phân cảnh"):V("互动影游已生成","Interactive film generated","Đã tạo phim tương tác")}),n.kind==="interactive_film_created"&&n.projectId&&t&&p.jsx("button",{type:"button","data-testid":"open-film-studio",onClick:()=>t(n.projectId),className:"shrink-0 rounded-lg bg-primary px-3 py-1 text-[13px] font-semibold text-primary-foreground hover:opacity-90 transition-opacity",children:V("打开创作向导 →","Open creation wizard →","Mở trình hướng dẫn sáng tác →")})]}),s.length>0&&p.jsx("div",{className:"mt-2 space-y-1.5",children:s.map(([a,o])=>p.jsxs("button",{type:"button",onClick:()=>r(o),className:"group flex w-full items-start justify-between gap-3 rounded-lg border border-transparent px-2 py-1.5 text-left transition hover:border-primary/25 hover:bg-background/65",children:[p.jsxs("span",{className:"min-w-0 text-[13px] leading-5 text-muted-foreground break-all",children:[p.jsxs("span",{className:"font-medium text-foreground",children:[a,V(":",": ",": ")]}),o]}),p.jsx("span",{className:"mt-0.5 shrink-0 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[11px] font-semibold text-primary opacity-80 transition group-hover:opacity-100",children:V("查看","View","Xem")})]},a))})]})}function RGe({exec:e}){if(!["short_fiction_run","generate_cover"].includes(e.tool)||e.status!=="completed")return null;const t=Xte(e),r=(t==null?void 0:t.coverImagePath)??Yj(e.result,"Cover image"),n=(t==null?void 0:t.coverError)??Yj(e.result,"Cover image reason");if(!r||!/\.(png|jpe?g|webp)$/iu.test(r))return n?p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:[V("封面未生成:","Cover not generated: ","Chưa tạo ảnh bìa: "),n]}):null;const i=ja(`/project/files/${CGe(r)}`);if(!i)return null;const s=(t==null?void 0:t.title)??(t==null?void 0:t.storyId)??V("短篇封面","Short fiction cover","Ảnh bìa truyện ngắn");return p.jsxs("div",{className:"mx-3 mb-3 mt-1 overflow-hidden rounded-xl border border-border/40 bg-background/70",children:[p.jsx("img",{src:i,alt:s,className:"block max-h-[360px] w-full object-contain bg-muted/20",loading:"lazy"}),p.jsx("div",{className:"border-t border-border/40 px-3 py-2 text-[11px] text-muted-foreground break-all",children:r})]})}function Kte(e){if(!["play_start","play_step","play_revise"].includes(e.tool)||!e.details||typeof e.details!="object")return null;const t=e.details;if(t.kind!=="play_world_started"&&t.kind!=="play_turn_advanced"&&t.kind!=="play_turn_revised"&&t.kind!=="play_variant_restored")return null;const r=Array.isArray(t.suggestedActions)?t.suggestedActions.filter(n=>typeof n=="string"):[];return{kind:t.kind,title:yr(t,"title"),worldId:yr(t,"worldId"),runId:yr(t,"runId"),turn:Ko(t,"turn")??kGe(t,"currentState","turn")??(t.kind==="play_world_started"?0:void 0),sceneImageUrl:yr(t,"sceneImageUrl"),sceneText:yr(t,"sceneText"),suggestedActions:r,variantId:yr(t,"variantId"),skillIds:Y7(t,"skillIds")}}function MGe(e){return e.turn==null?null:`scene-turn-${Math.trunc(e.turn)}`}function Kj(e,t){var i;if(e.sceneImageUrl)return ja(e.sceneImageUrl);const r=MGe(e),n=r?(i=t==null?void 0:t.sceneImageUrls)==null?void 0:i[r]:void 0;return n?ja(n):r==="scene-turn-0"&&(t!=null&&t.sceneImageUrl)?ja(t.sceneImageUrl):null}function IGe(e){return!e.worldId||!e.runId||e.turn==null?null:ja(`/play/runs/${encodeURIComponent(e.worldId)}/${encodeURIComponent(e.runId)}`)}function OGe({details:e}){const t=_.useMemo(()=>IGe(e),[e]),r=_.useMemo(()=>Kj(e),[e]),[n,i]=_.useState(null);return _.useEffect(()=>{if(i(null),r){i(r);return}if(!t)return;let s=!1,a,o=0;const l=40,c=async()=>{try{const h=await fetch(t);if(h.ok){const f=await h.json(),g=Kj(e,f);if(g&&!s){i(g);return}}}catch{}s||(o+=1,o<l&&(a=window.setTimeout(()=>void c(),2e3)))};return c(),()=>{s=!0,a!==void 0&&window.clearTimeout(a)}},[e,r,t]),n?p.jsxs("div",{className:"mt-3 overflow-hidden rounded-xl border border-border/40 bg-background/80",children:[p.jsx("img",{src:n,alt:V("本幕配图","Scene illustration","Ảnh minh họa cảnh"),className:"block max-h-[420px] w-full object-contain bg-muted/20",loading:"lazy"}),e.turn!=null&&p.jsx("div",{className:"border-t border-border/40 px-3 py-2.5 text-[14px] leading-6 text-muted-foreground",children:V(`第 ${Math.trunc(e.turn)} 幕配图`,`Scene ${Math.trunc(e.turn)} illustration`,`Ảnh minh họa cảnh ${Math.trunc(e.turn)}`)})]}):null}function Zte(e){if(e.tool!=="play_edit"||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="play_world_updated"?null:{kind:"play_world_updated",worldId:yr(t,"worldId"),runId:yr(t,"runId"),updatedWorldContract:n2(t,"updatedWorldContract"),updatedVisualContract:n2(t,"updatedVisualContract"),updatedPremise:n2(t,"updatedPremise"),updatedEntities:Ko(t,"updatedEntities")}}function Qte(e){if(e.tool!=="propose_action"||!e.details||typeof e.details!="object")return null;const t=e.details;if(t.kind!=="proposed_action")return null;const r=yr(t,"action"),n=yr(t,"targetSessionKind"),i=yr(t,"instruction");return!r||!n||!i?null:{kind:"proposed_action",execId:e.id,action:r,targetSessionKind:n,sameSession:n2(t,"sameSession"),title:yr(t,"title"),summary:yr(t,"summary"),instruction:i,requestedSkills:Y7(t,"requestedSkills"),actionPayload:TGe(t)}}function BGe(e){var s,a,o;const t=(s=e.actionPayload)==null?void 0:s.playStart;if(e.action!=="play_start"||!t)return[];const r=[],n=(a=t.worldContract)==null?void 0:a.trim();n&&r.push({label:V("世界契约","World contract","Khế ước thế giới"),value:n});const i=(o=t.visualContract)==null?void 0:o.trim();return i&&r.push({label:V("视觉契约","Visual contract","Khế ước hình ảnh"),value:i}),r}function DGe({exec:e,onProposedAction:t,onRejectProposedAction:r}){const n=Ht(h=>h.resolvedProposals),i=Ht(yf.isActiveSessionStreaming);if(e.tool!=="propose_action"||e.status!=="completed")return null;const s=Qte(e);if(!s)return null;const a=n[s.execId],o=i,l=a!==void 0,c=BGe(s);return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/25 bg-primary/5 px-4 py-3.5",children:[p.jsx("div",{className:"text-[17px] leading-6 font-semibold text-foreground",children:s.title??V("确认执行","Confirm action","Xác nhận thực thi")}),s.summary&&p.jsx("div",{className:"mt-1.5 whitespace-pre-wrap break-words text-[15px] leading-7 text-muted-foreground",children:s.summary}),p.jsx("div",{className:"mt-2.5 whitespace-pre-wrap break-words rounded-lg bg-background/70 px-3 py-2.5 text-[15px] leading-7 text-muted-foreground",children:s.instruction}),c.length>0&&p.jsx("div",{className:"mt-2 space-y-1.5",children:c.map(h=>p.jsxs("div",{className:"rounded-lg border border-border/50 bg-background/60 px-3 py-2.5",children:[p.jsx("div",{className:"text-[13px] leading-5 font-semibold text-foreground",children:h.label}),p.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-[15px] leading-7 text-muted-foreground",children:h.value})]},h.label))}),a==="confirmed"?p.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-[15px] leading-6 font-medium text-primary",children:[p.jsx(ac,{size:15,className:"shrink-0"}),V("已执行","Executed","Đã thực thi")]}):a==="rejected"?p.jsx("div",{className:"mt-3 text-[15px] leading-6 font-medium text-muted-foreground",children:V("已取消","Cancelled","Đã hủy")}):p.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[p.jsx("button",{type:"button","data-testid":"confirm-action",onClick:()=>t==null?void 0:t(s),disabled:!t||o||l,className:"rounded-lg bg-primary px-3.5 py-2 text-[15px] leading-6 font-medium text-primary-foreground disabled:opacity-50",children:o?V("执行中…","Running…","Đang chạy…"):V("继续执行","Continue","Tiếp tục")}),p.jsx("button",{type:"button",onClick:()=>r==null?void 0:r(s),disabled:!r||o||l,className:"rounded-lg border border-border/60 bg-background/80 px-3.5 py-2 text-[15px] leading-6 font-medium text-muted-foreground disabled:opacity-50",children:V("取消","Cancel","Hủy")})]})]})}function PGe({exec:e}){if(!["play_start","play_step","play_revise"].includes(e.tool)||e.status!=="completed")return null;const t=Kte(e);if(!(t!=null&&t.sceneText))return null;const r=t.kind==="play_world_started"?V("互动世界已启动","Interactive world started","Đã khởi động thế giới tương tác"):t.kind==="play_turn_revised"?V("互动回合已重做","Play turn redone","Đã làm lại lượt chơi"):t.kind==="play_variant_restored"?V("已切换互动回合版本","Switched play turn variant","Đã chuyển phiên bản lượt chơi"):V("互动世界已推进","Interactive world advanced","Thế giới tương tác đã tiến triển");return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[p.jsx("div",{className:"mb-2 text-[16px] leading-6 font-semibold text-primary",children:r}),p.jsx("div",{className:"whitespace-pre-wrap text-base leading-7 text-foreground",children:t.sceneText}),p.jsx(OGe,{details:t})]})}function jGe({exec:e}){if(e.tool!=="play_edit"||e.status!=="completed")return null;const t=Zte(e);if(!t)return null;const r=[t.updatedWorldContract?V("世界契约","World contract","Khế ước thế giới"):"",t.updatedVisualContract?V("视觉契约","Visual contract","Khế ước hình ảnh"):"",t.updatedPremise?V("世界前提","World premise","Tiền đề thế giới"):"",t.updatedEntities&&t.updatedEntities>0?V(`${t.updatedEntities} 张卡片`,`${t.updatedEntities} cards`,`${t.updatedEntities} thẻ`):""].filter(Boolean);return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5",children:[p.jsx("div",{className:"text-[16px] leading-6 font-semibold text-primary",children:V("互动世界设定已更新","Interactive world settings updated","Đã cập nhật thiết định thế giới tương tác")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:r.length>0?r.join(" · "):V("已写入当前世界。","Written to the current world.","Đã ghi vào thế giới hiện tại.")})]})}function FGe(e){var t;return Qte(e)||(t=Kte(e))!=null&&t.sceneText||Wte(e)||Gte(e)?!0:!!Zte(e)}function zGe(e){return e==="sub_agent"||e==="resync_chapter_state"||e==="context_compression"||e==="propose_action"||e==="short_fiction_run"||e==="script_create"||e==="storyboard_create"||e==="interactive_film_create"||e==="generate_cover"||e==="play_edit"||e==="play_start"||e==="play_revise"||e==="play_step"||e==="create_narrative_forecast"||e==="get_narrative_forecast"||e==="select_narrative_branch"}function $Ge(e,t){const[r,n]=_.useState(()=>t?Date.now()-e:0);return _.useEffect(()=>{if(!t)return;n(Date.now()-e);const i=setInterval(()=>n(Date.now()-e),1e3);return()=>clearInterval(i)},[e,t]),r}function HGe({result:e,defaultOpen:t}){return p.jsxs("details",{open:t,className:"mx-3 mb-3 mt-1 rounded-lg border border-border/40 bg-background/60 px-2.5 py-2 text-xs",children:[p.jsx("summary",{className:"cursor-pointer select-none font-medium text-muted-foreground hover:text-foreground",children:V("查看操作结果","View result","Xem kết quả")}),p.jsx("div",{className:"mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words leading-5 text-foreground",children:e})]},t?"result-default-open":"result-default-collapsed")}function UGe({exec:e,onProposedAction:t,onRejectProposedAction:r,onOpenFilmStudio:n,onSelectNarrativeBranch:i,onRecheckNarrativeForecast:s}){var m;const a=e.status==="running"||e.status==="processing",[o,l]=_.useState(a),c=$Ge(e.startedAt,a),h=r_(x=>x.toolDetailsDefaultOpen);_.useEffect(()=>{if(e.status==="running"&&l(!0),e.status==="completed"){const x=setTimeout(()=>l(!1),500);return()=>clearTimeout(x)}},[e.status]);const f=(m=e.args)==null?void 0:m.bookId,g=qte(e);return p.jsxs(H_,{open:o,onOpenChange:l,className:"rounded-xl border border-border/40 bg-card/60",children:[p.jsxs(U_,{className:"w-full flex items-center justify-between gap-2 px-3 py-2.5 rounded-xl hover:bg-card/80 transition-colors cursor-pointer",children:[p.jsx("div",{className:"flex items-center gap-2 min-w-0",children:p.jsxs("span",{className:"text-[16px] leading-6 font-medium text-foreground truncate",children:[e.label,f&&p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",f]})]})}),p.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p.jsx("span",{className:"text-[12px] text-muted-foreground/60",children:a?Gj(e.startedAt,e.startedAt+c):e.completedAt?Gj(e.startedAt,e.completedAt):""}),p.jsx(xGe,{status:e.status}),p.jsx(Bu,{size:16,className:`text-muted-foreground transition-transform ${o?"rotate-180":""}`})]})]}),p.jsx(DGe,{exec:e,onProposedAction:t,onRejectProposedAction:r}),p.jsx(SGe,{exec:e}),p.jsx(RGe,{exec:e}),p.jsx(LGe,{exec:e,onOpenFilmStudio:n}),p.jsx(PGe,{exec:e}),p.jsx(jGe,{exec:e}),p.jsx(EGe,{exec:e}),p.jsx(AGe,{exec:e}),p.jsx(NGe,{exec:e}),p.jsx(yGe,{exec:e,onSelectBranch:i,onRecheck:s}),!g&&!FGe(e)&&typeof e.result=="string"&&e.result.trim()&&p.jsx(HGe,{result:e.result,defaultOpen:h}),p.jsx(q_,{children:p.jsxs("div",{className:"px-3 pb-3 pt-1",children:[e.stages&&e.stages.length>0&&p.jsx("ol",{className:"mb-2 space-y-1.5",children:e.stages.map(x=>p.jsxs("li",{className:["flex items-start gap-2 rounded-lg px-2 py-1.5 text-xs",x.status==="active"?"bg-primary/5 text-foreground":"text-muted-foreground"].join(" "),children:[p.jsx(bGe,{status:x.status}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate",children:x.label}),x.progress&&p.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground/70",children:vGe(x.progress)})]})]},x.label))}),e.logs&&e.logs.length>0&&p.jsx("ul",{className:"space-y-0.5",children:e.logs.map((x,v)=>{const C=x.startsWith("[error]")||/error/i.test(x),k=x.startsWith("[warning]")||/warning|警告/i.test(x);return p.jsx("li",{className:`text-xs font-mono break-words ${C?"text-destructive":k?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"}`,children:x},v)})}),e.status==="error"&&e.error&&p.jsx("div",{className:"mt-2 text-xs text-destructive bg-destructive/5 rounded-lg px-2.5 py-2",children:e.error})]})})]})}function Zj({status:e}){switch(e){case"completed":return p.jsx(B0,{size:10,className:"text-green-600 dark:text-green-400 shrink-0"});case"error":return p.jsx(D0,{size:10,className:"text-destructive shrink-0"});case"running":case"processing":return p.jsx(qn,{size:10,className:"animate-spin text-primary shrink-0"})}}function qGe({exec:e}){var n,i;const t=`${e.tool} ${String(((n=e.args)==null?void 0:n.path)??((i=e.args)==null?void 0:i.pattern)??"")}`;return typeof e.result=="string"&&e.result.trim().length>0?p.jsxs("details",{className:"group",children:[p.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-2 list-none [&::-webkit-details-marker]:hidden hover:text-foreground transition-colors",children:[p.jsx("span",{className:"font-mono truncate",children:t}),p.jsx(Zj,{status:e.status}),p.jsx(Bu,{size:10,className:"shrink-0 transition-transform group-open:rotate-180"})]}),p.jsx("div",{className:"mt-1 mb-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border/40 bg-background/60 px-2 py-1.5 leading-5",children:e.result})]}):p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"font-mono truncate",children:t}),p.jsx(Zj,{status:e.status})]})}function VGe({execs:e}){const[t,r]=_.useState(!1),n=e.every(s=>s.status==="completed"||s.status==="error"),i=e.some(s=>s.status==="error");return p.jsxs(H_,{open:t,onOpenChange:r,children:[p.jsxs(U_,{className:"flex items-center gap-2 px-2 py-1 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer text-xs text-muted-foreground",children:[p.jsx(ble,{size:12}),p.jsx("span",{children:V(`${e.length} 个文件操作`,`${e.length} file operation${e.length===1?"":"s"}`,`${e.length} thao tác tệp`)}),n&&!i&&p.jsx(B0,{size:10,className:"text-green-600 dark:text-green-400"}),i&&p.jsx(D0,{size:10,className:"text-destructive"}),!n&&p.jsx(qn,{size:10,className:"animate-spin text-primary"}),p.jsx(Bu,{size:10,className:`transition-transform ${t?"rotate-180":""}`})]}),p.jsx(q_,{children:p.jsx("ul",{className:"pl-6 space-y-0.5 py-1",children:e.map(s=>p.jsx("li",{className:"text-xs text-muted-foreground",children:p.jsx(qGe,{exec:s})},s.id))})})]})}function WGe(e){const t=[];let r=[];const n=()=>{r.length>0&&(t.push({type:"utilities",execs:r}),r=[])};for(const i of e)zGe(i.tool)?(n(),t.push({type:"pipeline",exec:i})):r.push(i);return n(),t}const Jte=_.memo(function({executions:t,onProposedAction:r,onRejectProposedAction:n,onOpenFilmStudio:i,onSelectNarrativeBranch:s,onRecheckNarrativeForecast:a}){const o=_.useMemo(()=>WGe(t),[t]);return p.jsx("div",{className:"space-y-2 mt-2",children:o.map((l,c)=>l.type==="pipeline"?p.jsx(UGe,{exec:l.exec,onProposedAction:r,onRejectProposedAction:n,onOpenFilmStudio:i,onSelectNarrativeBranch:s,onRecheckNarrativeForecast:a},l.exec.id):p.jsx(VGe,{execs:l.execs},`utils-${c}`))})});Jte.displayName="ToolExecutionSteps";const GGe={cjk:v1};function Qj(e){return e.split("/").map(encodeURIComponent).join("/")}function YGe(e){return e.split("/").filter(Boolean).at(-1)??e}function XGe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Jj(e,t){return e.endsWith(".json")||t.includes("application/json")}function KGe(){const e=Ht(C=>C.projectArtifactPath),t=Ht(C=>C.closeProjectArtifact),[r,n]=_.useState(null),[i,s]=_.useState(!1),[a,o]=_.useState(null),[l,c]=_.useState(!1),[h,f]=_.useState(""),[g,m]=_.useState(!1);_.useEffect(()=>{if(!e)return;let C=!1;return s(!0),o(null),n(null),c(!1),ct(`/project/artifacts/${Qj(e)}`).then(k=>{C||(n(k),f(k.content))}).catch(k=>{C||o(k instanceof Error?k.message:String(k))}).finally(()=>{C||s(!1)}),()=>{C=!0}},[e]);const x=_.useMemo(()=>r?Jj(r.path,r.contentType)?XGe(r.content):r.content:"",[r]);if(!e)return null;const v=async()=>{m(!0),o(null);try{const C=await ct(`/project/artifacts/${Qj(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});n({path:e,content:h,contentType:(r==null?void 0:r.contentType)??"text/markdown; charset=utf-8",size:C.size}),c(!1)}catch(C){o(C instanceof Error?C.message:String(C))}finally{m(!1)}};return p.jsxs("div",{className:"fixed inset-0 z-[80] flex justify-end bg-background/35 backdrop-blur-[2px]",children:[p.jsx("button",{type:"button","aria-label":V("关闭生成物预览","Close artifact preview","Đóng bản xem trước bản dựng"),className:"absolute inset-0 cursor-default",onClick:t}),p.jsxs("aside",{className:"relative flex h-full w-[min(760px,calc(100vw-24px))] flex-col border-l border-border/55 bg-background shadow-2xl",children:[p.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-border/45 px-6 py-5",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-[13px] font-medium uppercase tracking-[0.18em] text-muted-foreground/65",children:V("生成物","Artifact","Bản dựng")}),p.jsx("h2",{className:"mt-1 truncate text-[22px] font-semibold text-foreground",children:YGe(e)}),p.jsx("p",{className:"mt-1 break-all text-[13px] leading-5 text-muted-foreground/70",children:e})]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r&&!l&&p.jsxs("button",{type:"button",onClick:()=>{f(r.content),c(!0)},className:"inline-flex items-center gap-2 rounded-lg border border-border/60 bg-secondary/35 px-3 py-2 text-[14px] font-medium text-foreground transition hover:border-primary/45 hover:bg-primary/10",children:[p.jsx(Kh,{size:15}),V("编辑","Edit","Chỉnh sửa")]}),l&&p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",onClick:()=>{f((r==null?void 0:r.content)??""),c(!1)},disabled:g,className:"rounded-lg border border-border/60 px-3 py-2 text-[14px] font-medium text-muted-foreground transition hover:bg-secondary/50 disabled:opacity-60",children:V("取消","Cancel","Hủy")}),p.jsxs("button",{type:"button",onClick:v,disabled:g,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-[14px] font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:opacity-60",children:[g?p.jsx(qn,{size:15,className:"animate-spin"}):p.jsx(j0,{size:15}),V("保存","Save","Lưu")]})]}),p.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-border/50 p-2 text-muted-foreground transition hover:bg-secondary/60 hover:text-foreground","aria-label":V("关闭","Close","Đóng"),children:p.jsx(ho,{size:18})})]})]}),a&&p.jsxs("div",{className:"mx-6 mt-4 flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-[14px] leading-6 text-destructive",children:[p.jsx(HF,{size:18,className:"mt-0.5 shrink-0"}),p.jsx("span",{children:a})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:i?p.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[p.jsx(qn,{size:22,className:"mr-2 animate-spin"}),V("正在读取生成物...","Loading artifact...","Đang tải bản dựng...")]}):l?p.jsx("textarea",{value:h,onChange:C=>f(C.target.value),spellCheck:!1,className:"min-h-full w-full resize-none rounded-xl border border-border/55 bg-secondary/20 px-4 py-4 font-mono text-[15px] leading-7 text-foreground outline-none transition focus:border-primary/50 focus:bg-background"}):r?Jj(r.path,r.contentType)?p.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border/45 bg-secondary/25 px-4 py-4 font-mono text-[14px] leading-6 text-foreground",children:x}):p.jsx("article",{className:"prose prose-neutral dark:prose-invert max-w-none text-[16px] leading-8 prose-headings:font-semibold prose-h1:text-[26px] prose-h2:text-[22px] prose-h3:text-[19px] prose-p:my-4 prose-li:my-1 prose-pre:whitespace-pre-wrap",children:p.jsx(Ho,{plugins:GGe,mode:"static",children:x})}):p.jsx("div",{className:"rounded-xl border border-dashed border-border/55 px-4 py-8 text-center text-[14px] text-muted-foreground",children:V("没有可预览内容。","Nothing to preview.","Không có nội dung để xem trước.")})})]})]})}const ere=new Set(["item","evidence","clue","claim","proof_chain"]),eF={item:"🎒",evidence:"📄",clue:"🔍",claim:"💡",proof_chain:"🔗"},tF={timer:"⏳",pressure:"🔥",resource:"🪙",relation:"❤",clue:"🔍",evidence:"📄",flag:"🚩"},tre={item:"物件",evidence:"证据",clue:"线索",claim:"主张",proof_chain:"证据链"},rre={item:"Item",evidence:"Evidence",clue:"Clue",claim:"Claim",proof_chain:"Proof chain"},nre={item:"Vật phẩm",evidence:"Chứng cứ",clue:"Manh mối",claim:"Luận điểm",proof_chain:"Chuỗi chứng cứ"},ZGe=["unknown","hinted","seen","collected","verified","weaponized","exposed","exhausted"],QGe={unknown:"未知",hinted:"有线索",seen:"已看见",collected:"已收集",verified:"已验证",weaponized:"武器化",exposed:"已揭露",exhausted:"已耗尽"},JGe={unknown:"Unknown",hinted:"Hinted",seen:"Seen",collected:"Collected",verified:"Verified",weaponized:"Weaponized",exposed:"Exposed",exhausted:"Exhausted"},eYe={unknown:"Chưa biết",hinted:"Có manh mối",seen:"Đã thấy",collected:"Đã thu thập",verified:"Đã xác minh",weaponized:"Đã vũ khí hóa",exposed:"Đã phơi bày",exhausted:"Đã khai thác hết"};function tYe(e){const{row:t,generating:r,onOpen:n}=e,i=V(tre[t.kind]??t.kind,rre[t.kind]??t.kind,nre[t.kind]??t.kind);return p.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2.5 rounded-lg border border-border/30 bg-secondary/30 px-2.5 py-2 text-left hover:border-border/60",children:[t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"h-8 w-8 shrink-0 rounded object-cover"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded bg-secondary/60 text-sm",children:r?"⏳":t.glyph}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"truncate text-[15px] leading-6 font-semibold text-foreground",children:t.label}),t.isFresh?p.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/20 px-1.5 text-[12px] leading-5 font-medium text-emerald-300",children:V("新","NEW","MỚI")}):null]}),p.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"shrink-0",children:i}),t.preview?p.jsxs("span",{className:"truncate",children:["· ",t.preview]}):null]})]}),p.jsx(Kv,{size:13,className:"shrink-0 text-muted-foreground/50"})]})}function rYe(e,t,r){const n=e.slice(0,6),i=t/2,s=r/2,a=t*.32,o=r*.3;return{nodes:n.map((c,h)=>{const f=-Math.PI/2+2*Math.PI*h/n.length;return{x:i+a*Math.cos(f),y:s+o*Math.sin(f),label:c.targetLabel,type:c.type,strength:c.strength}}),overflow:Math.max(0,e.length-n.length)}}function rF(e,t=6){return e.length>t?`${e.slice(0,t)}…`:e}function nYe(e){const{nodes:s,overflow:a}=rYe(e.relations,300,150);return p.jsxs("svg",{viewBox:"0 0 300 150",className:"block w-full min-w-0",role:"img","aria-label":V("关系网","Relations","Mạng quan hệ"),children:[s.map((o,l)=>p.jsx("line",{x1:150,y1:75,x2:o.x,y2:o.y,className:"stroke-border",strokeWidth:1.5},`l${l}`)),p.jsx("ellipse",{cx:150,cy:75,rx:46,ry:19,className:"fill-secondary stroke-primary"}),p.jsx("text",{x:150,y:79,textAnchor:"middle",fontSize:10,fontWeight:600,className:"fill-foreground",children:rF(e.centerLabel)}),s.map((o,l)=>p.jsxs("g",{children:[p.jsx("ellipse",{cx:o.x,cy:o.y,rx:38,ry:15,className:"fill-card stroke-border"}),p.jsx("text",{x:o.x,y:o.y+3,textAnchor:"middle",fontSize:9,className:"fill-foreground",children:rF(o.label)}),p.jsxs("text",{x:(150+o.x)/2,y:(75+o.y)/2-2,textAnchor:"middle",fontSize:8,className:"fill-muted-foreground",children:[o.type,o.strength!=null?` ${o.strength}`:""]})]},`n${l}`)),a>0?p.jsxs("text",{x:294,y:144,textAnchor:"end",fontSize:9,className:"fill-muted-foreground",children:["+",a]}):null]})}function iYe(e){const{row:t,generating:r,onBack:n}=e,{lifecycle:i}=t,s=V(tre[t.kind]??t.kind,rre[t.kind]??t.kind,nre[t.kind]??t.kind),a=Sg()==="vi"?eYe:Sg()==="en"?JGe:QGe;return p.jsxs("div",{className:"min-w-0 space-y-3",children:[p.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-[14px] leading-6 text-muted-foreground hover:text-foreground",children:[p.jsx(p_,{size:14})," ",V("返回","Back","Quay lại")]}),p.jsxs("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/40 bg-secondary/30",children:[p.jsx("div",{className:"flex min-h-[180px] items-center justify-center bg-gradient-to-b from-secondary/60 to-transparent text-4xl",children:t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"max-h-[320px] w-full object-contain"}):p.jsx("span",{children:r?"⏳":t.glyph})}),p.jsxs("div",{className:"min-w-0 space-y-3 px-3 py-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p.jsx("span",{className:"min-w-0 flex-1 break-words text-[17px] leading-6 font-bold text-foreground",children:t.label}),p.jsx("span",{className:"shrink-0 pt-0.5 text-[13px] text-muted-foreground",children:s})]}),t.summary?p.jsx("p",{className:"mt-1 break-words text-[14px] leading-6 text-muted-foreground",children:t.summary}):null]}),i?p.jsxs("div",{children:[p.jsx("div",{className:"flex gap-1",children:i.stages.map(o=>p.jsx("span",{className:`flex-1 rounded px-1 py-1 text-center text-[11px] leading-4 ${o===i.current?"bg-primary/20 font-bold text-primary":"bg-secondary/40 text-muted-foreground/50"}`,children:a[o]??o},o))}),i.reason?p.jsxs("p",{className:"mt-1.5 break-words text-[13px] leading-5 text-emerald-300",children:["▲ ",i.reason]}):null]}):t.statusPill?p.jsxs("div",{children:[p.jsx("span",{className:"inline-block rounded-full bg-secondary/60 px-2.5 py-1 text-[14px] leading-5 font-medium text-foreground",children:t.statusPill}),t.isFresh?p.jsxs("p",{className:"mt-1.5 text-[13px] leading-5 text-emerald-300",children:["▲ ",V("刚获得","Just acquired","Vừa có được")]}):t.changeReason?p.jsxs("p",{className:"mt-1.5 break-words text-[13px] leading-5 text-emerald-300",children:["▲ ",t.changeReason]}):null]}):null,t.meters.length>0?p.jsxs("div",{className:"space-y-1.5",children:[p.jsx("h4",{className:"text-[13px] leading-5 uppercase tracking-wider text-muted-foreground/60",children:V("属性","Stats","Chỉ số")}),t.meters.map(o=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[14px] leading-6",children:[p.jsx("span",{className:"w-12 shrink-0 break-words text-muted-foreground",children:o.label}),o.ratio!=null?p.jsx("span",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-secondary/60",children:p.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.round(o.ratio*100)}%`}})}):null,p.jsx("span",{className:"ml-auto min-w-0 break-words font-semibold text-primary",children:o.value})]},o.id))]}):null,t.relations.length>0?p.jsxs("div",{className:"min-w-0",children:[p.jsx("h4",{className:"mb-1 text-[13px] leading-5 uppercase tracking-wider text-muted-foreground/60",children:V("牵动","Connections","Liên hệ")}),p.jsx(nYe,{centerLabel:t.label,relations:t.relations,isZh:e.isZh})]}):null,t.provenanceTurn!=null?p.jsx("p",{className:"break-words border-t border-border/30 pt-2 text-[13px] leading-5 text-muted-foreground/70",children:V(`第 ${t.provenanceTurn} 幕 取得`,`Acquired · Turn ${t.provenanceTurn}`,`Có được · Màn ${t.provenanceTurn}`)}):null]})]})]})}function sYe({row:e}){var n;const t=(n=e.details[0])==null?void 0:n.text,r=e.kind==="pressure"&&e.ratio==null;return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2 text-[15px] leading-6",children:[p.jsx("span",{className:"shrink-0 text-[15px]",children:e.glyph}),p.jsx("span",{className:"text-muted-foreground",children:e.label}),e.ratio!=null?p.jsx("span",{className:"ml-2 h-1.5 flex-1 overflow-hidden rounded-full bg-secondary/60",children:p.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.round(e.ratio*100)}%`}})}):null,r?p.jsxs("span",{className:"ml-auto rounded-full bg-amber-500/15 px-2 py-0.5 text-[14px] leading-5 font-semibold text-amber-300",children:["⚠ ",e.value]}):e.value?p.jsx("span",{className:"ml-auto text-[15px] leading-6 font-semibold text-primary",children:e.value}):null]}),t?p.jsx("p",{className:"mt-0.5 pl-6 text-[14px] leading-6 text-muted-foreground/70",children:t}):null]})}function aYe(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return""}}function nF(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){const t=e;if(typeof t.current=="number"){const r=t.current,n=typeof t.min=="number"?t.min:0,i=typeof t.max=="number"?t.max:void 0,s=i!=null?`${r}/${i}`:String(r),a=i!=null&&i>n?Math.max(0,Math.min(1,(r-n)/(i-n))):void 0;return{text:s,ratio:a}}}return{text:aYe(e)}}function oYe(e,t){var r,n,i;return((r=e.value)==null?void 0:r.role)!=="holding"?!1:t.type==="item"?!0:((n=e.value)==null?void 0:n.physical)===!0||((i=e.value)==null?void 0:i.portable)===!0}function lYe(e){var t;return((t=e.value)==null?void 0:t.role)==="relation"}function iF(e,t){return ere.has(e.type)?t.some(r=>r.fromId==="actor_player"&&r.toId===e.id&&oYe(r,e)):!1}function cYe(e,t,r){if(!e)return[];const n=[];return t.actors&&e.actors.forEach(i=>{i.imageUrl||n.push({key:i.id,body:{target:"entity",entityId:i.id}})}),t.inventory&&e.holdings.forEach(i=>{i.imageUrl||n.push({key:i.id,body:{target:"entity",entityId:i.id}})}),t.moments&&e.turn!=null&&!r&&n.push({key:`scene-turn-${e.turn}`,body:{target:"scene"}}),n}function uYe(e){var q,j,U,W,J,G;if(!(e!=null&&e.graph))return null;const{entities:t,edges:r,stateSlots:n,events:i}=e.graph,s=new Map(t.map(O=>[O.id,O.label])),a=new Map(i.map(O=>[O.id,O.outcomeSummary??""])),o=r.filter(O=>O.validUntilEventId==null),l=i.reduce((O,D)=>O&&O.turn>D.turn?O:D,null),c=(l==null?void 0:l.id)??null,h=new Map(i.map(O=>[O.id,O.turn])),f=O=>{var H;const D=(H=O.summary)==null?void 0:H.trim();return D?D===O.label||D===O.status?[]:[{text:D}]:[]},g=O=>{var H;const D=(H=O.status)==null?void 0:H.trim();return!D||D===O.label?null:D},m=O=>o.filter(D=>lYe(D)&&(D.fromId===O||D.toId===O)).map(D=>{const H=D.fromId===O?s.get(D.toId):s.get(D.fromId),Y=typeof D.strength=="number"?` ${D.strength}`:"";return{label:V("关系","Relation","Quan hệ"),text:`${D.type}${Y}${H?` · ${H}`:""}`}}),x=t.filter(O=>O.type==="location").map(O=>({id:O.id,glyph:"📍",label:O.label,note:g(O),details:f(O)})),v=t.filter(O=>O.type==="actor").map(O=>({id:O.id,glyph:"👤",label:O.label,note:g(O),details:[...f(O),...m(O.id)],imageUrl:O.imageUrl})),C=t.filter(O=>ere.has(O.type)&&!iF(O,o)).map(O=>({id:O.id,glyph:eF[O.type]??"•",label:O.label,note:g(O),details:f(O),imageUrl:O.imageUrl})),k=O=>n.filter(D=>D.ownerEntityId===O&&D.kind!=="evidence").map(D=>{const{text:H,ratio:Y}=nF(D.value);return{id:D.id,glyph:tF[D.kind]??"•",label:D.label,value:H,note:null,details:[],ratio:Y}}),T=O=>o.filter(D=>(D.fromId===O||D.toId===O)&&D.fromId!=="actor_player"&&D.toId!=="actor_player").map(D=>{const H=D.fromId===O?D.toId:D.fromId;return{targetLabel:s.get(H)??H,type:D.type,strength:typeof D.strength=="number"?D.strength:void 0}}),w=O=>{const D=n.find(ae=>ae.ownerEntityId===O&&ae.kind==="evidence");if(!D||typeof D.value!="object"||D.value===null)return;const H=D.value,Y=typeof H.status=="string"?H.status:void 0;if(Y)return{stages:ZGe,current:Y,reason:typeof H.reason=="string"&&H.reason?H.reason:void 0}},L=t.filter(O=>iF(O,o)).map(O=>{var ye,we;const D=k(O.id),H=T(O.id),Y=w(O.id),ae=Y?void 0:g(O)??void 0,z=!!O.createdEventId&&O.createdEventId===c,K=!z&&O.updatedEventId&&O.updatedEventId===c&&a.get(O.updatedEventId)||void 0,se=(ye=O.summary)==null?void 0:ye.trim(),X=se&&se!==O.label&&se!==O.status?se:void 0,ke=((we=D[0])==null?void 0:we.value)||(H[0]?`${H[0].type}${H[0].targetLabel?`·${H[0].targetLabel}`:""}`:void 0)||(Y?Y.current:ae);return{id:O.id,kind:O.type,glyph:eF[O.type]??"•",label:O.label,imageUrl:O.imageUrl,summary:X,preview:ke,statusPill:ae,lifecycle:Y,meters:D,relations:H,provenanceTurn:O.createdEventId?h.get(O.createdEventId):void 0,isFresh:z,changeReason:K}}),N=n.filter(O=>!O.ownerEntityId).map(O=>{const D=O.updatedEventId&&a.get(O.updatedEventId)||"",{text:H,ratio:Y}=nF(O.value);return{id:O.id,glyph:tF[O.kind]??"•",label:O.label,kind:O.kind,value:H,ratio:Y,note:null,details:D?[{label:V("因为","Because","Vì"),text:D}]:[]}}),A=((q=e.currentState)==null?void 0:q.timeAdvance)??((j=[...i].reverse().find(O=>O.timeAdvance))==null?void 0:j.timeAdvance)??null,R=A&&(A.elapsed||A.anchor||A.rationale||(((U=A.synchronized)==null?void 0:U.length)??0)>0)?{id:"world-time",glyph:"⏳",label:V("世界时间","World time","Thời gian thế giới"),value:A.anchor||A.elapsed||"",note:A.rationale||null,details:[...A.elapsed&&A.anchor?[{label:V("经过","Elapsed","Đã trôi qua"),text:A.elapsed}]:[],...(A.synchronized??[]).map(O=>({label:V("同步","Synced","Đồng bộ"),text:O}))]}:null,P=i.reduce((O,D)=>Math.max(O,D.turn),0);return{turn:((W=e.currentState)==null?void 0:W.turn)??(i.length>0?P:null),mode:((J=e.currentState)==null?void 0:J.mode)??null,premise:((G=e.currentState)==null?void 0:G.premise)??"",time:R,facing:[...x,...v,...C],actors:v,holdings:L,meters:N}}function hYe(e){var W,J,G;const{sessionId:t,isStreaming:r,isZh:n,open:i,onClose:s}=e,a=`/play/runs/${encodeURIComponent(t)}/main`,[o,l]=_.useState(null),[c,h]=_.useState(null),[f,g]=_.useState(null),[m,x]=_.useState({actors:!1,moments:!1,inventory:!1}),[v,C]=_.useState(!1),[k,T]=_.useState(new Set),w=_.useRef(new Set),L=_.useRef(r),N=_.useCallback(async()=>{try{const O=await ct(a);g(O),O.imageSettings&&x(O.imageSettings)}catch{}},[a]);_.useEffect(()=>{N()},[N]),_.useEffect(()=>{L.current&&!r&&N(),L.current=r},[r,N]),_.useEffect(()=>{ct("/cover/config").then(O=>{const D=O.service??null;C(O.configured??(!!D&&(O.providers??[]).some(H=>H.service===D&&H.connected)))}).catch(()=>C(!1))},[]);const A=_.useCallback(async(O,D)=>{if(!w.current.has(O)){w.current.add(O),T(H=>new Set(H).add(O));try{await ct(`${a}/generate-image`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),await N()}catch{}finally{w.current.delete(O),T(H=>{const Y=new Set(H);return Y.delete(O),Y})}}},[a,N]),R=_.useMemo(()=>uYe(f),[f]),P=e.imageSettings??m,q=(R==null?void 0:R.holdings.find(O=>O.id===o))??null,j=(R==null?void 0:R.facing.find(O=>O.id===c&&O.imageUrl))??null;_.useEffect(()=>{!v||!R||cYe(R,P,f==null?void 0:f.sceneImageUrl).forEach(O=>void A(O.key,O.body))},[v,P,R,f==null?void 0:f.sceneImageUrl,A]);const U=((W=e.sessionTitle)==null?void 0:W.trim())||((J=f==null?void 0:f.title)==null?void 0:J.trim())||V("互动世界","Play World","Thế giới tương tác");return i?p.jsxs("aside",{className:"absolute bottom-28 right-0 top-0 z-20 flex w-[380px] max-w-[calc(100vw-1rem)] flex-col border-l border-border/40 bg-card/95 backdrop-blur shadow-xl",children:[p.jsxs("header",{className:"relative flex min-w-0 items-center gap-2.5 overflow-hidden border-b border-border/40 px-4 py-3",children:[p.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 -bottom-px h-px bg-gradient-to-r from-transparent via-primary/50 to-transparent"}),(R==null?void 0:R.turn)!=null?p.jsxs("div",{className:"flex shrink-0 flex-col items-center leading-none",children:[p.jsx("span",{className:"text-[24px] leading-6 font-extrabold text-primary",children:R.turn}),p.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:V("幕","Turn","Màn")})]}):p.jsx(_g,{size:16,className:"shrink-0 text-primary"}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate text-[16px] leading-6 font-bold text-foreground",children:U}),p.jsx("div",{className:"mt-0.5 text-[14px] leading-5 text-muted-foreground",children:(R==null?void 0:R.turn)==null?V("尚未开始","Not started","Chưa bắt đầu"):R!=null&&R.mode?R.mode==="guided"?V("互动模式","Guided","Chế độ dẫn dắt"):V("开放模式","Open","Chế độ mở"):V("互动世界","Play World","Thế giới tương tác")})]}),(G=R==null?void 0:R.time)!=null&&G.value?p.jsx("span",{className:"max-w-[122px] shrink-0 truncate rounded-full bg-secondary/60 px-2.5 py-1 text-[15px] leading-6 text-muted-foreground",title:R.time.note??R.time.value,children:R.time.value}):null,p.jsx("button",{type:"button",onClick:()=>{s(),l(null),h(null)},className:"shrink-0 text-muted-foreground hover:text-foreground",title:V("收起","Collapse","Thu gọn"),children:p.jsx(ho,{size:15})})]}),p.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4 text-[15px]",children:R?q?p.jsx(iYe,{row:q,isZh:n,generating:k.has(q.id),onBack:()=>l(null)}):j?p.jsx(dYe,{row:j,isZh:n,onBack:()=>h(null)}):p.jsxs(p.Fragment,{children:[R.time&&(R.time.note||R.time.details.length>0)?p.jsx(cb,{title:V("世界时间","World time","Thời gian thế giới"),icon:"⏳",empty:!1,emptyText:"",children:p.jsx(sF,{row:R.time,isZh:n})}):null,p.jsx(cb,{title:V("我面对的","Around me","Xung quanh tôi"),icon:"🧭",empty:R.facing.length===0,emptyText:V("周围还没有出现地点或人物","No places or people around yet","Chưa có địa điểm hay nhân vật nào xuất hiện"),children:R.facing.map(O=>p.jsx(sF,{row:O,isZh:n,generating:k.has(O.id),onOpenVisual:O.imageUrl?()=>{l(null),h(O.id)}:void 0},O.id))}),p.jsx(cb,{title:V("我握有的","What I hold","Những gì tôi có"),icon:"🎒",empty:R.holdings.length===0,emptyText:V("还没有获得物品、证据或线索","No items, evidence, or clues yet","Chưa có vật phẩm, chứng cứ hay manh mối nào"),children:R.holdings.map(O=>p.jsx(tYe,{row:O,isZh:n,generating:k.has(O.id),onOpen:()=>{h(null),l(O.id)}},O.id))}),p.jsx(cb,{title:V("状态","State","Trạng thái"),icon:"📊",empty:R.meters.length===0,emptyText:V("还没有出现数值(压力、资源、关系、倒计时等)","No meters yet (pressure, resources, relations, timers…)","Chưa có chỉ số nào (áp lực, tài nguyên, quan hệ, đếm ngược…)"),children:R.meters.map(O=>p.jsx(sYe,{row:O},O.id))}),R.premise&&p.jsx("div",{className:"rounded-lg border border-border/30 bg-secondary/30 px-3 py-2 text-[15px] leading-7 text-muted-foreground",children:R.premise})]}):p.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-xl border border-dashed border-border/50 bg-secondary/10 px-4 py-8 text-center",children:[p.jsx("span",{className:"text-3xl opacity-80",children:"🎲"}),p.jsx("p",{className:"text-[16px] leading-6 font-semibold text-foreground",children:V("这个世界还在沉睡","This world is still asleep","Thế giới này vẫn còn đang ngủ")}),p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground",children:V("在左边写下你的第一个动作,人物、线索、状态会在这里逐渐点亮。","Take your first action on the left — characters, clues, and state will light up here.","Viết hành động đầu tiên của bạn ở bên trái — nhân vật, manh mối và trạng thái sẽ dần hiện ra ở đây.")})]})})]}):null}function cb(e){return p.jsxs("section",{className:"relative rounded-xl border border-border/40 bg-secondary/20 px-3 pb-3 pt-2.5",children:[p.jsx("span",{"aria-hidden":!0,className:"absolute left-3 top-0 h-0.5 w-5 -translate-y-px rounded-full bg-primary/70"}),p.jsxs("h3",{className:"mb-2 flex items-center gap-1.5 text-[15px] leading-6 font-semibold uppercase tracking-[0.08em] text-muted-foreground/70",children:[p.jsx("span",{className:"text-[16px]",children:e.icon}),e.title]}),e.empty?p.jsx("p",{className:"text-[15px] leading-6 text-muted-foreground/50",children:e.emptyText}):p.jsx("div",{className:"space-y-1.5",children:e.children})]})}function dYe(e){const{row:t,onBack:r}=e;return p.jsxs("div",{className:"min-w-0 space-y-3",children:[p.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-[14px] leading-6 text-muted-foreground hover:text-foreground",children:[p.jsx(p_,{size:14})," ",V("返回","Back","Quay lại")]}),p.jsxs("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/40 bg-secondary/30",children:[p.jsx("div",{className:"flex min-h-[220px] items-center justify-center bg-gradient-to-b from-secondary/60 to-transparent",children:t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"max-h-[420px] w-full object-contain"}):p.jsx("span",{className:"text-4xl",children:t.glyph})}),p.jsxs("div",{className:"min-w-0 space-y-3 px-3 py-3",children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p.jsx("span",{className:"min-w-0 flex-1 break-words text-[18px] leading-7 font-bold text-foreground",children:t.label}),t.value?p.jsx("span",{className:"shrink-0 rounded-full bg-secondary/60 px-2.5 py-1 text-[13px] leading-5 font-medium text-primary",children:t.value}):null]}),t.note?p.jsx("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:t.note}):null,t.details.length>0?p.jsx("div",{className:"space-y-2 border-t border-border/30 pt-2",children:t.details.map((n,i)=>p.jsxs("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:[n.label?p.jsxs("span",{className:"text-muted-foreground/50",children:[n.label," "]}):null,n.text]},i))}):null]})]})]})}function sF({row:e,generating:t,onOpenVisual:r}){const[n,i]=_.useState(!1),s=e.details.length>0,a=!!e.imageUrl,o=a&&!!r,l=s||o;return p.jsxs("div",{className:"min-w-0 rounded-lg border border-border/30 bg-secondary/30",children:[p.jsxs("div",{role:l?"button":void 0,"aria-label":l?`${e.label} ${o?V("查看大图","view image","xem ảnh lớn"):n?V("收起详情","collapse details","thu gọn chi tiết"):V("展开详情","show details","xem chi tiết")}`:void 0,onClick:o?r:s?()=>i(c=>!c):void 0,className:`px-2.5 py-2 ${l?"cursor-pointer":""}`,children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[e.imageUrl?p.jsx("img",{src:e.imageUrl,alt:"","aria-hidden":"true",className:"h-12 w-12 shrink-0 self-center rounded-lg object-cover"}):p.jsx("span",{className:"shrink-0 pt-1 text-base leading-6",children:t?"⏳":e.glyph}),p.jsx("span",{className:"min-w-0 flex-1 break-words text-[15px] leading-6 font-medium text-foreground",children:e.label}),e.value?p.jsx("span",{className:"ml-auto min-w-0 max-w-[58%] truncate text-right text-[15px] leading-6 font-semibold text-primary",title:e.value,children:e.value}):null,s&&!o?p.jsx(Bu,{size:12,className:`${e.value?"ml-1.5":"ml-auto"} shrink-0 text-muted-foreground/50 transition-transform ${n?"rotate-180":""}`}):null]}),e.note?p.jsx("div",{className:`mt-1 break-words text-[14px] leading-6 text-muted-foreground ${a?"pl-[58px]":"pl-6"}`,children:e.note}):null]}),n&&p.jsx("div",{className:`min-w-0 space-y-1 px-2.5 pb-2 ${a?"pl-[68px]":"pl-8"}`,children:e.details.map((c,h)=>p.jsxs("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:[c.label?p.jsxs("span",{className:"text-muted-foreground/50",children:[c.label," "]}):null,c.text]},h))})]})}function fYe(e){return e.choices.length===0?p.jsx("div",{className:"px-4 py-3 text-center text-xs text-muted-foreground/60",children:e.disabled?V("推进中…","Advancing…","Đang xử lý…"):V("等待场景给出选项…","Waiting for choices…","Đang chờ lựa chọn…")}):p.jsx("div",{className:"px-4 py-3",children:p.jsx("div",{className:"mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2.5",children:e.choices.map((t,r)=>p.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>e.onChoose(t),className:"group inline-flex items-center gap-2 rounded-full border border-border/50 bg-secondary/40 px-4 py-2 text-sm leading-5 text-foreground/90 shadow-sm transition-all hover:-translate-y-0.5 hover:border-primary/50 hover:bg-primary/10 hover:text-primary hover:shadow-md hover:shadow-primary/10 active:translate-y-0 disabled:pointer-events-none disabled:opacity-40",children:[p.jsx("span",{"aria-hidden":!0,className:"text-xs text-primary/50 transition-colors group-hover:text-primary",children:"▸"}),t]},`${r}-${t}`))})})}const c_=new Set(["play_start","play_step","play_revise"]);function pYe(e){if(!c_.has(e.tool)||e.status!=="completed")return[];const t=e.details;return Array.isArray(t==null?void 0:t.suggestedActions)?t.suggestedActions.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function aF(e,t){const r=pYe(e);return r.length===0?null:{key:typeof e.id=="string"&&e.id.trim()?e.id:t,choices:r}}function mYe(e){var t,r;for(let n=e.length-1;n>=0;n--){const i=((t=e[n])==null?void 0:t.parts)??[];for(let a=i.length-1;a>=0;a--){const o=i[a];if(!(o.type!=="tool"||!c_.has(o.execution.tool)))return aF(o.execution,`message-${n}-part-${a}`)}const s=((r=e[n])==null?void 0:r.toolExecutions)??[];for(let a=s.length-1;a>=0;a--){const o=s[a];if(c_.has(o.tool))return aF(o,`message-${n}-execution-${a}`)}}return null}const oF=128,lF=2*1024*1024,cF=8*1024*1024;function ire(e){const t=e.trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"");return t?/^[a-z]/.test(t)?t:`skill-${t}`:""}function gYe(e,t){const r=ire(t);return r?e.includes(r)?e.filter(n=>n!==r):[...e,r]:[...e]}function yYe(e){const t=Array.from(new Set(e.map(ire).filter(Boolean)));return t.length>0?t:void 0}async function sre(e){const t=Array.from(e);if(t.length>oF)throw new Error(`A skill may contain at most ${oF} files.`);let r=0;for(const i of t){if(i.size>lF)throw new Error(`${i.name} exceeds ${lF} bytes.`);if(r+=i.size,r>cF)throw new Error(`Skill folder exceeds ${cF} bytes.`)}const n=[];for(const i of t){const s=i.webkitRelativePath||i.name,a=new Uint8Array(await i.arrayBuffer());n.push({path:s,dataUrl:`data:${i.type||"application/octet-stream"};base64,${xYe(a)}`})}return n}function xYe(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}const bYe=8,uF=4*1024*1024,vYe=["image/*","text/plain","text/markdown","application/json","text/csv",".txt",".md",".markdown",".json",".csv",".tsv",".yaml",".yml",".log",".pdf"].join(",");function CYe(e){return new Promise((t,r)=>{const n=new FileReader;n.onerror=()=>r(n.error??new Error("Failed to read file")),n.onload=()=>t(String(n.result??"")),n.readAsDataURL(e)})}async function kYe(e){return Promise.all(e.map(async t=>({id:`${t.name}-${t.size}-${t.lastModified}`,filename:t.name,mediaType:t.type||"application/octet-stream",size:t.size,dataUrl:await CYe(t)})))}function hF(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.ceil(e/1024)} KB`:`${e} B`}function TYe(e){return typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function dF(e){if(typeof e=="number"&&typeof globalThis.cancelAnimationFrame=="function"){globalThis.cancelAnimationFrame(e);return}globalThis.clearTimeout(e)}function wYe({skills:e,diagnostics:t,selectedSkillIds:r,loading:n,error:i,saving:s,createError:a,onToggleSkill:o,onImport:l}){const c=new Set(r),h=_.useRef(null);return p.jsxs("div",{className:"absolute bottom-[calc(100%+10px)] left-0 z-40 w-full overflow-hidden rounded-2xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur",children:[p.jsx("div",{className:"border-b border-border/40 px-4 py-3",children:p.jsxs("div",{className:"flex items-center justify-between gap-3",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-bold",children:V("选择 Agent Skill","Select Agent Skills","Chọn Agent Skill")}),p.jsx("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:V("Agent 会按当前意图自主调用;点选 Skill 可强制它随下一条消息启用。","The agent can choose a skill from your intent; selecting one forces it for the next message.","Agent sẽ tự chọn skill theo ý định hiện tại; chọn thủ công sẽ bắt buộc dùng skill đó ở tin nhắn tiếp theo.")})]}),p.jsxs("div",{className:"flex shrink-0 items-center",children:[p.jsxs("button",{type:"button",onClick:()=>{var f;return(f=h.current)==null?void 0:f.click()},disabled:s,className:"flex items-center gap-1.5 rounded-lg border border-border/50 px-3 py-1.5 text-xs font-semibold text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary disabled:opacity-40",children:[p.jsx(WF,{size:13}),V("导入","Import","Nhập")]}),p.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",webkitdirectory:"",directory:"",onChange:f=>{var g;(g=f.currentTarget.files)!=null&&g.length&&l(f.currentTarget.files),f.currentTarget.value=""}})]})]})}),p.jsxs("div",{className:"max-h-[380px] overflow-y-auto p-3",children:[a?p.jsx("div",{className:"mb-3 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive",children:a}):null,t!=null&&t.length?p.jsxs("div",{className:"mb-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:[p.jsx("div",{className:"font-semibold",children:V("部分外部 Skill 未加载","Some external skills were not loaded","Một số skill bên ngoài chưa được tải")}),t.slice(0,4).map((f,g)=>p.jsxs("div",{className:"mt-1 break-all",children:[f.path?`${f.path}: `:"",f.message??V("格式无效","Invalid format","Định dạng không hợp lệ")]},`${f.path??"skill"}-${g}`))]}):null,n?p.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:V("加载 Skill...","Loading skills...","Đang tải skill...")}):i?p.jsx("div",{className:"rounded-xl bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}):e.length===0?p.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:V("还没有可用 Skill。","No skills available yet.","Chưa có skill nào khả dụng.")}):p.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:e.map(f=>{const g=c.has(f.id);return p.jsx("button",{type:"button",onClick:()=>o(f.id),className:`rounded-xl border p-3 text-left transition-all ${g?"border-primary/60 bg-primary/10":"border-border/50 bg-secondary/20 hover:border-primary/30 hover:bg-secondary/35"}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx("div",{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-md border ${g?"border-primary bg-primary text-primary-foreground":"border-border text-transparent"}`,children:p.jsx(ac,{size:13,strokeWidth:3})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"truncate text-sm font-semibold",children:f.name}),p.jsx("span",{className:"shrink-0 rounded-full bg-secondary px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:f.source??"skill"})]}),p.jsxs("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground/70",children:["@",f.id]}),p.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground",children:f.description})]})]})},f.id)})})]})]})}function ub({activeBookId:e,mode:t=e?"book":"book-create",nav:r,theme:n,t:i,sse:s}){const a=Ht(yf.activeMessages),o=Ht(yf.activeSession),l=Ht(he=>he.activeSessionId),c=Ht(he=>he.input),h=Ht(yf.isActiveSessionStreaming),f=Ht(yf.isActiveSessionChatStreaming),g=Ht(yf.activeSessionLastFailedSend),m=Ht(he=>he.selectedModel),x=Ht(he=>he.selectedService),v=Ht(he=>he.setInput),C=Ht(he=>he.sendMessage),k=Ht(he=>he.retryLastSend),T=Ht(he=>he.abortSession),w=Ht(he=>he.setSelectedModel),L=Ht(he=>he.loadSessionList),N=Ht(he=>he.createSession),A=Ht(he=>he.markProposalResolved),R=Ht(he=>he.loadSessionDetail),P=Ht(he=>he.activateSession),q=Ht(he=>he.setSessionPlayMode),j=_.useRef(null),U=_.useRef(null),W=_.useRef(null),J=_.useRef(null),G=_.useRef(!0),O=i("nav.connected")==="已连接",D=!!e,H=(o==null?void 0:o.sessionKind)??(t==="interactive-film-authoring"?"interactive-film-authoring":t==="book-create"?"book-create":e?"book":"chat"),Y=o==null?void 0:o.playMode,ae=H==="play"&&!Y,z=_.useMemo(()=>H==="play"&&Y==="guided"?mYe(a):null,[H,Y,a]),[K,se]=_.useState(null),X=(z==null?void 0:z.choices)??[],ke=fse({playMode:Y,choiceSetKey:(z==null?void 0:z.key)??null,consumedChoiceKey:K,choiceCount:X.length}),[ye,we]=_.useState(!1),[Fe,ue]=_.useState(null),[Ne,Te]=_.useState(!1),[Ue,Qe]=_.useState({actors:!1,moments:!1,inventory:!1}),[We,de]=_.useState(!1),[te,$e]=_.useState(!1),[Ie,Be]=_.useState([]),[Ee,je]=_.useState(!1),[ge,De]=_.useState(null),[xe,ut]=_.useState([]),[Ut,Oe]=_.useState(null),{data:Ge,loading:pt,error:mt,refetch:Se}=$r("/skills"),st=H==="play"&&ye?"lg:pr-[380px]":"",jt=(Ge==null?void 0:Ge.skills)??[],ft=_.useMemo(()=>Ie.map(he=>jt.find(gt=>gt.id===he)).filter(he=>!!he),[jt,Ie]),wt=_.useMemo(()=>{var gt;const he=a[a.length-1];return!he||he.role!=="assistant"?!1:he.thinkingStreaming===!0||!he.content||(((gt=he.toolExecutions)==null?void 0:gt.some(Gt=>Gt.status==="running"||Gt.status==="processing"))??!1)},[a]),Mt=$n(he=>he.services),qt=$n(he=>he.servicesLoading),Kr=$n(he=>he.bankModelsLoading),cn=$n(he=>he.customModelsLoading),fr=$n(he=>he.modelsByService),Nr=$n(he=>he.fetchServices),un=$n(he=>he.fetchBankModels),dn=$n(he=>he.fetchCustomModels),[qr,Dn]=_.useState(null),[xi,Vr]=_.useState(!1);_.useEffect(()=>{Nr()},[Nr]),_.useEffect(()=>{un(),dn()},[un,dn]),_.useEffect(()=>{let he=!1;return ct("/services/config").then(gt=>{he||Dn({service:gt.service??null,model:gt.defaultModel??null})}).catch(()=>{he||Dn(null)}).finally(()=>{he||Vr(!0)}),()=>{he=!0}},[]);const Pn=_.useMemo(()=>{if(qt||Mt.length===0)return"loading";const he=Mt.filter(kt=>kt.connected);if(he.length===0)return"no-models";if(Kr)return"loading";if(he.some(kt=>{var rr;return(((rr=fr[kt.service])==null?void 0:rr.length)??0)>0}))return"ready";const gt=he.some(kt=>!kt.service.startsWith("custom")),Gt=he.some(kt=>kt.service.startsWith("custom"));return!gt&&Gt&&cn?"loading":"no-models"},[Mt,qt,Kr,cn,fr]),Zi=_.useMemo(()=>Mt.filter(he=>{var gt;return he.connected&&(((gt=fr[he.service])==null?void 0:gt.length)??0)>0}).map(he=>({service:he.service,label:he.label,models:fr[he.service]})),[Mt,fr]),Cs=_.useMemo(()=>{if(!m)return V("选择模型","Select model","Chọn model");const he=Zi.find(kt=>kt.service===x),gt=he==null?void 0:he.models.find(kt=>kt.id===m),Gt=(gt==null?void 0:gt.name)??m;return he?`${he.label} · ${Gt}`:Gt},[Zi,m,x,O]);_.useEffect(()=>{if(!xi)return;const he=hse(Zi,m,x,qr);he&&w(he.model,he.service)},[qr,Zi,m,x,xi,w]),_.useEffect(()=>{const he=W.current;he&&(he.style.height="auto",he.style.height=`${Math.min(he.scrollHeight,200)}px`)},[c]),_.useEffect(()=>{const he=j.current;if(he&&G.current)return U.current!==null&&dF(U.current),U.current=TYe(()=>{he.scrollTo({top:he.scrollHeight,behavior:mse(h||wt)}),U.current=null}),()=>{U.current!==null&&(dF(U.current),U.current=null)}},[a,h,wt]),_.useEffect(()=>{G.current=!0},[l]),_.useEffect(()=>{let he=!1;return(async()=>{if(!e&&t==="project-chat"){const kt=Ht.getState(),rr=kt.activeSessionId?kt.sessions[kt.activeSessionId]:null;if((rr==null?void 0:rr.bookId)===null&&rr.isDraft)return}if(e){if(await L(e),he)return;const kt=Ht.getState(),rr=kt.activeSessionId?kt.sessions[kt.activeSessionId]:null;if((rr==null?void 0:rr.bookId)===e){await R(rr.sessionId);return}const $s=kt.sessionIdsByBook[e]??[];if($s.length>0){P($s[0]),await R($s[0]);return}await N(e,t==="interactive-film-authoring"?"interactive-film-authoring":"book");return}const gt=t==="project-chat"?cse():BF();if(gt){if(await R(gt),he)return;const rr=Ht.getState().sessions[gt];if(rr&&rr.bookId===null&&(t!=="project-chat"||rr.messages.length>0)){P(gt);return}}if(t==="project-chat"){const kt=await L(null);if(he)return;const rr=dse(kt);if(rr){P(rr),await R(rr),he||Qm(rr);return}}const Gt=await N(null,t==="book-create"?"book-create":"chat");he||(t==="project-chat"?Qm(Gt):ose(Gt))})(),()=>{he=!0}},[e,P,N,R,L,t]);const qa=he=>{const gt=Array.from(he),Gt=[],kt=[];for(const rr of gt){if(rr.size>uF){kt.push(`${rr.name} > ${hF(uF)}`);continue}Gt.push(rr)}ut(rr=>[...rr,...Gt].slice(0,bYe)),Oe(kt.length>0?V(`以下文件过大,未添加:${kt.join("、")}`,`Some files were too large: ${kt.join(", ")}`,`Một số tệp quá lớn, chưa được thêm: ${kt.join(", ")}`):null)},vo=async he=>{if(!l)return;if(!(!!he.trim()||xe.length>0)){(f||h)&&await T(l);return}const Gt=yYe(Ie);G.current=!0;const kt=await kYe(xe);f&&await T(l),await C(l,he,{activeBookId:e,sessionKind:H,actionSource:"free-text",requestedSkills:Gt,attachments:kt}),ut([]),Oe(null),Gt!=null&&Gt.length&&(Be([]),$e(!1))},Va=async he=>{je(!0),De(null);try{const gt=await sre(he),Gt=await di("/skills/import",{files:gt});await Se(),Be(kt=>kt.includes(Gt.skill.id)?kt:[...kt,Gt.skill.id])}catch(gt){De(gt instanceof Error?gt.message:String(gt))}finally{je(!1)}},ml=(he,gt)=>{l&&(G.current=!0,C(l,he,{activeBookId:e,sessionKind:H,actionSource:"quick-action",requestedIntent:gt}))},bi=async he=>{var kt,rr;A(he.execId,"confirmed");const gt=he.targetSessionKind==="play"?((rr=(kt=he.actionPayload)==null?void 0:kt.playStart)==null?void 0:rr.mode)??(o==null?void 0:o.playMode)??(he.action==="play_start"?"open":void 0):void 0;if(he.sameSession&&l){G.current=!0,await C(l,he.instruction??"",{activeBookId:e,sessionKind:he.targetSessionKind,playMode:gt,actionSource:"button",requestedIntent:he.action,actionPayload:he.actionPayload,requestedSkills:he.requestedSkills});return}const Gt=await N(null,he.targetSessionKind,gt);G.current=!0,await C(Gt,he.instruction??"",{sessionKind:he.targetSessionKind,playMode:gt,actionSource:"button",requestedIntent:he.action,actionPayload:he.actionPayload,requestedSkills:he.requestedSkills})},Qi=async he=>{if(A(he.execId,"rejected"),!l)return;G.current=!0;const gt=V(`取消这次操作:${he.title??he.instruction}`,`Cancel this action: ${he.title??he.instruction}`,`Hủy thao tác này: ${he.title??he.instruction}`);await C(l,gt,{activeBookId:e,sessionKind:H,actionSource:"button"})},zs=async(he,gt)=>{!l||!e||(G.current=!0,await C(l,hGe(he,gt,O?"zh":"en"),{activeBookId:e,sessionKind:"book",actionSource:"button"}))},gl=async he=>{!l||!e||(G.current=!0,await C(l,dGe(he,O?"zh":"en"),{activeBookId:e,sessionKind:"book",actionSource:"button"}))};_.useEffect(()=>{ue(null)},[l]),_.useEffect(()=>{if(!l||H!=="play")return;let he=!1;return ct(`/play/runs/${encodeURIComponent(l)}/main`).then(gt=>{!he&&gt.imageSettings&&Qe(gt.imageSettings)}).catch(()=>{}),ct("/cover/config").then(gt=>{if(he)return;const Gt=gt.service??null;de(gt.configured??(!!Gt&&(gt.providers??[]).some(kt=>kt.service===Gt&&kt.connected)))}).catch(()=>{he||de(!1)}),()=>{he=!0}},[l,H]);const Fi=async he=>{if(!l||H!=="play"||!We)return;const gt={...Ue,[he]:!Ue[he]};Qe(gt),ue(null);try{await ct(`/play/runs/${encodeURIComponent(l)}/main/image-settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(gt)})}catch(Gt){Qe(Ue),ue(Gt instanceof Error?Gt.message:String(Gt))}},yn=H==="short"?V("说一个短篇方向、标题灵感、人物压力或核心冲突,我会走 InkOS Short 生成正文、简介和封面。","Describe a short-fiction direction, title hook, pressure, or core conflict to run InkOS Short.","Mô tả hướng truyện ngắn, ý tưởng tiêu đề, áp lực nhân vật hoặc xung đột cốt lõi, tôi sẽ chạy InkOS Short để tạo nội dung, giới thiệu và bìa."):H==="play"?V("说一个可玩的世界、角色处境或开场动作,我会启动互动世界;之后你可以自由行动或点建议动作。","Describe a playable world, character situation, or opening action to start an interactive world.","Mô tả một thế giới có thể chơi được, hoàn cảnh nhân vật hoặc hành động mở đầu, tôi sẽ khởi động thế giới tương tác; sau đó bạn có thể tự do hành động hoặc chọn gợi ý."):V("告诉我你想写什么——题材、世界观、主角、核心冲突","Tell me what you want to write — genre, world, protagonist, core conflict","Cho tôi biết bạn muốn viết gì — thể loại, thế giới, nhân vật chính, xung đột cốt lõi");return p.jsxs("div",{className:"flex flex-col h-full flex-1 min-w-0 relative",children:[p.jsx("div",{ref:j,onScroll:he=>{const gt=he.currentTarget;G.current=pse({scrollTop:gt.scrollTop,clientHeight:gt.clientHeight,scrollHeight:gt.scrollHeight})},className:`chat-message-scroll flex-1 overflow-y-auto [scrollbar-gutter:stable] px-4 py-6 transition-[padding] duration-200 ${st}`,children:ae?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center select-none gap-4",children:[p.jsx("div",{className:"w-14 h-14 rounded-2xl border border-dashed border-border flex items-center justify-center bg-secondary/30 opacity-40",children:p.jsx(_g,{size:24,className:"text-muted-foreground"})}),p.jsx("p",{className:"text-sm text-muted-foreground/70 max-w-md leading-7",children:V("选个玩法,进去再聊你想玩的世界。","Pick a playstyle, then describe the world you want in chat.","Chọn cách chơi, sau đó vào chat kể về thế giới bạn muốn.")}),p.jsxs("div",{className:"flex gap-3",children:[p.jsxs("button",{type:"button",onClick:()=>{l&&q(l,"guided")},className:"w-40 rounded-xl border border-border/50 bg-secondary/30 px-4 py-3 text-left transition-all hover:border-primary/40 hover:bg-primary/5",children:[p.jsx("div",{className:"text-sm font-medium text-foreground",children:V("点着玩","Choices","Chọn hành động")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:V("GM 给选项,点着推进","Pick from offered actions","GM đưa ra lựa chọn, bạn chọn để tiếp tục")})]}),p.jsxs("button",{type:"button",onClick:()=>{l&&q(l,"open")},className:"w-40 rounded-xl border border-border/50 bg-secondary/30 px-4 py-3 text-left transition-all hover:border-primary/40 hover:bg-primary/5",children:[p.jsx("div",{className:"text-sm font-medium text-foreground",children:V("自由玩","Free","Chơi tự do")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:V("自己打字,想干嘛干嘛","Type anything you want","Tự gõ, muốn làm gì cũng được")})]})]})]}):a.length===0&&!h?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center select-none",children:[p.jsx("div",{className:"w-14 h-14 rounded-2xl border border-dashed border-border flex items-center justify-center mb-4 bg-secondary/30 opacity-40",children:p.jsx(Sae,{size:24,className:"text-muted-foreground"})}),p.jsx("p",{className:"text-sm text-muted-foreground/70 max-w-md leading-7",children:yn})]}):p.jsxs("div",{className:"max-w-3xl mx-auto space-y-4",children:[a.map((he,gt)=>p.jsx("div",{children:he.role==="user"?p.jsx(r2,{role:"user",content:he.content,timestamp:he.timestamp,theme:n}):he.parts&&he.parts.length>0?p.jsx(p.Fragment,{children:(()=>{const Gt=[];for(let kt=0;kt<he.parts.length;kt++){const rr=he.parts[kt];if(rr.type==="thinking")Gt.push({kind:"thinking",pi:kt,part:rr});else if(rr.type==="text")Gt.push({kind:"text",pi:kt,part:rr});else if(rr.type==="tool"){const $s=Gt[Gt.length-1];($s==null?void 0:$s.kind)==="tools"?$s.parts.push(rr):Gt.push({kind:"tools",parts:[rr],startIdx:kt})}}return Gt.map(kt=>kt.kind==="thinking"?p.jsx("div",{className:"mb-2",children:p.jsxs(Rte,{defaultOpen:!1,isStreaming:kt.part.streaming,children:[p.jsx(Mte,{}),p.jsx(Ite,{children:kt.part.content})]})},`t-${kt.pi}`):kt.kind==="tools"?p.jsx(Jte,{executions:kt.parts.map(rr=>rr.execution),onProposedAction:bi,onRejectProposedAction:Qi,onOpenFilmStudio:r.toFilmStudio,onSelectNarrativeBranch:zs,onRecheckNarrativeForecast:gl},`x-${kt.startIdx}`):kt.kind==="text"&&kt.part.content?p.jsx(r2,{role:"assistant",content:kt.part.content,timestamp:he.timestamp,theme:n},`c-${kt.pi}`):null)})()}):p.jsx(r2,{role:he.role,content:he.content,timestamp:he.timestamp,theme:n})},`${he.timestamp}-${gt}`)),h&&!wt&&p.jsx(Ote,{from:"assistant",children:p.jsx(Bte,{children:p.jsx(Nte,{className:"text-sm",duration:1.5,children:V("思考中...","Thinking...","Đang suy nghĩ...")})})})]})}),D&&!ke&&p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx("div",{className:"max-w-3xl mx-auto w-full px-4",children:p.jsx(SWe,{onAction:ml,disabled:h||!l,isZh:O})})}),H==="play"&&!ae&&ke&&p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx(fYe,{choices:X,disabled:h||!l,isZh:O,onChoose:he=>{!l||!z||(se(z.key),G.current=!0,C(l,he,{activeBookId:e,sessionKind:"play",actionSource:"button"}))}})}),g&&!f&&l?p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx("div",{className:"max-w-3xl mx-auto w-full px-4 pb-2",children:p.jsxs("button",{type:"button",onClick:()=>{G.current=!0,k(l)},className:"flex items-center gap-1.5 rounded-lg border border-border/50 bg-secondary/30 px-3 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary",children:[p.jsx(P0,{size:14}),V("重试上一条消息","Retry last message","Thử lại tin nhắn cuối")]})})}):null,ae?null:p.jsx("div",{className:`shrink-0 border-t border-border/40 px-4 py-3 transition-[padding] duration-200 ${st}`,children:p.jsxs("div",{className:"max-w-3xl mx-auto",children:[p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsxs("div",{className:"relative flex-1 rounded-xl bg-secondary/30 transition-all",children:[te?p.jsx(wYe,{skills:jt,diagnostics:Ge==null?void 0:Ge.diagnostics,selectedSkillIds:Ie,loading:pt,error:mt,saving:Ee,createError:ge,onToggleSkill:he=>Be(gt=>gYe(gt,he)),onImport:he=>void Va(he)}):null,p.jsx("input",{ref:J,type:"file",multiple:!0,accept:vYe,className:"hidden",onChange:he=>{he.currentTarget.files&&qa(he.currentTarget.files),he.currentTarget.value=""}}),ft.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5 border-b border-border/20 px-3 py-2",children:ft.map(he=>p.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary",children:[he.name,p.jsx("button",{type:"button",onClick:()=>Be(gt=>gt.filter(Gt=>Gt!==he.id)),className:"rounded-full p-0.5 hover:bg-primary/20","aria-label":V(`移除 ${he.name}`,`Remove ${he.name}`,`Xóa ${he.name}`),children:p.jsx(ho,{size:12})})]},he.id))}):null,xe.length>0||Ut?p.jsxs("div",{className:"border-b border-border/20 px-3 py-2",children:[xe.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5",children:xe.map(he=>p.jsxs("span",{className:"inline-flex max-w-[220px] items-center gap-1.5 rounded-full border border-border/50 bg-secondary/60 px-2.5 py-1 text-xs text-muted-foreground",title:`${he.name} · ${he.type||"application/octet-stream"} · ${hF(he.size)}`,children:[p.jsx(lR,{size:12}),p.jsx("span",{className:"truncate",children:he.name}),p.jsx("button",{type:"button",onClick:()=>ut(gt=>gt.filter(Gt=>Gt!==he)),className:"rounded-full p-0.5 hover:bg-muted","aria-label":V(`移除 ${he.name}`,`Remove ${he.name}`,`Xóa ${he.name}`),children:p.jsx(ho,{size:12})})]},`${he.name}-${he.size}-${he.lastModified}`))}):null,Ut?p.jsx("div",{className:"mt-1 text-xs leading-5 text-destructive",children:Ut}):null]}):null,p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[p.jsx("button",{type:"button",onClick:()=>$e(he=>!he),disabled:h||!l,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border/50 transition-colors disabled:opacity-30 ${te||Ie.length>0?"bg-primary/10 text-primary":"text-muted-foreground hover:border-primary/40 hover:text-primary"}`,title:V("添加 Skill","Add skill","Thêm skill"),"aria-label":V("添加 Skill","Add skill","Thêm skill"),children:p.jsx(Qo,{size:16,strokeWidth:2.4})}),p.jsx("button",{type:"button",onClick:()=>{var he;return(he=J.current)==null?void 0:he.click()},disabled:!l,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border/50 text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary disabled:opacity-30",title:V("上传图片或资料","Attach files","Đính kèm tệp"),"aria-label":V("上传图片或资料","Attach files","Đính kèm tệp"),children:p.jsx(lR,{size:16,strokeWidth:2.3})}),p.jsx("textarea",{ref:W,value:c,onChange:he=>v(he.target.value),onKeyDown:he=>{he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),vo(c))},placeholder:V("输入指令...","Enter command...","Nhập lệnh..."),disabled:!l,rows:1,className:"flex-1 bg-transparent text-base leading-7 placeholder:text-muted-foreground/50 outline-none! border-none! ring-0! shadow-none focus:outline-none! focus:ring-0! focus:border-none! resize-none disabled:opacity-50 max-h-[200px] overflow-y-auto"}),p.jsx("button",{type:"button",onClick:()=>void vo(c),disabled:!c.trim()&&xe.length===0&&!h||!l,className:"w-8 h-8 rounded-lg bg-primary text-primary-foreground flex items-center justify-center shrink-0 hover:scale-105 active:scale-95 transition-all disabled:opacity-20 disabled:scale-100 shadow-sm shadow-primary/20",title:h&&!c.trim()&&xe.length===0?V("停止当前回复","Stop","Dừng"):void 0,children:h&&!c.trim()&&xe.length===0?p.jsx(rle,{size:13,fill:"currentColor"}):p.jsx(gae,{size:14,strokeWidth:2.5})})]}),p.jsxs("div",{className:"flex items-center gap-2 px-3 pb-2 border-t border-border/20 pt-1.5",children:[Pn==="loading"?p.jsx("span",{className:"text-[15px] text-muted-foreground/40 animate-pulse",children:V("加载模型...","Loading models...","Đang tải model...")}):Pn==="ready"?p.jsxs(_w,{children:[p.jsxs(Ew,{className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-muted text-[16px] transition-colors cursor-pointer",children:[p.jsx("span",{className:"font-medium truncate max-w-[260px]",children:Cs}),p.jsx(Bu,{size:17,className:"text-muted-foreground"})]}),p.jsx(SYe,{groupedModels:Zi,selectedModel:m,selectedService:x,onSelect:w,onManage:()=>r.toServices()})]}):p.jsx("button",{onClick:()=>r.toServices(),className:"text-[15px] text-muted-foreground/50 hover:text-primary transition-colors",children:V("配置模型 →","Set up models →","Cấu hình model →")}),H==="play"&&p.jsxs("button",{type:"button",onClick:()=>we(he=>!he),className:`ml-auto flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[16px] font-medium transition-colors ${ye?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted hover:text-primary"}`,title:V("查看世界:持有 / 状态 / 关系","View world: holdings / state / relations","Xem thế giới: sở hữu / trạng thái / quan hệ"),children:[p.jsx(_g,{size:18}),V("查看世界","View World","Xem thế giới")]})]})]}),H==="play"?p.jsxs("div",{className:"relative mt-1 shrink-0",children:[p.jsx("button",{type:"button",onClick:()=>Te(he=>!he),disabled:h||!l,title:V("自动配图","Auto illustration","Tự động minh họa"),className:`flex h-10 w-10 items-center justify-center rounded-xl border border-border/50 bg-secondary/40 shadow-sm transition-all hover:border-primary/50 hover:bg-primary/10 hover:text-primary active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 ${Ne||Ue.actors||Ue.moments||Ue.inventory?"text-primary":"text-muted-foreground"}`,"aria-label":V("自动配图","Auto illustration","Tự động minh họa"),children:p.jsx(Ioe,{size:17})}),Ne?p.jsxs("div",{className:"absolute bottom-12 right-0 z-30 w-44 rounded-xl border border-border/50 bg-card/95 p-2 shadow-xl backdrop-blur",children:[p.jsx("div",{className:"mb-1.5 px-1 text-[12px] leading-5 font-semibold uppercase tracking-wider text-muted-foreground/60",children:V("自动配图","Auto illustration","Tự động minh họa")}),["actors","moments","inventory"].map(he=>p.jsxs("label",{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[14px] leading-6 ${We?"cursor-pointer text-foreground hover:bg-secondary/50":"cursor-not-allowed text-muted-foreground/40"}`,title:We?void 0:V("先在「模型配置」里配好生图 API 才能开启","Configure an image API in Model Settings first","Cần cấu hình API tạo ảnh trong Cấu hình model trước"),children:[p.jsx("input",{type:"checkbox",disabled:!We,checked:We&&Ue[he],onChange:()=>void Fi(he),className:"h-4 w-4 accent-primary"}),he==="actors"?V("为角色配图","Characters","Minh họa nhân vật"):he==="moments"?V("为时刻配图","Moments","Minh họa khoảnh khắc"):V("为背包配图","Inventory","Minh họa vật phẩm")]},he)),We?null:p.jsx("p",{className:"mt-1 px-1 text-[12px] leading-5 text-muted-foreground/50",children:V("未检测到生图 API。","No image API configured.","Chưa cấu hình API tạo ảnh.")})]}):null]}):null]}),Fe?p.jsx("p",{className:"mt-2 text-right text-[13px] leading-5 text-destructive/80",children:V(`配图失败:${Fe}`,`Image failed: ${Fe}`,`Minh họa thất bại: ${Fe}`)}):null]})}),H==="play"&&l&&p.jsx(hYe,{sessionId:l,isStreaming:h,isZh:O,open:ye,onClose:()=>we(!1),imageSettings:Ue,sessionTitle:(o==null?void 0:o.title)??null}),p.jsx(KGe,{})]})}function SYe({groupedModels:e,selectedModel:t,selectedService:r,onSelect:n,onManage:i}){const[s,a]=_.useState(""),o=_.useMemo(()=>use(e,s),[e,s]);return p.jsxs(Aw,{side:"top",align:"start",className:"w-64 max-h-80 flex flex-col",children:[p.jsx("div",{className:"px-2 py-1.5 border-b border-border/30",children:p.jsx("input",{type:"text",value:s,onChange:l=>a(l.target.value),placeholder:V("搜索模型...","Search models...","Tìm model..."),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/40",onClick:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation()})}),p.jsxs("div",{className:"overflow-y-auto flex-1",children:[o.map(l=>p.jsxs("div",{children:[p.jsx("div",{className:"px-2 py-1.5 text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:l.label}),l.models.map(c=>{const h=t===c.id&&r===l.service;return p.jsx(Ef,{onClick:()=>n(c.id,l.service),className:h?"bg-muted/50":"",children:p.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[p.jsx("span",{className:"text-sm",children:c.name??c.id}),h&&p.jsx(ac,{size:14,className:"text-primary shrink-0"})]})},`${l.service}:${c.id}`)})]},l.service)),o.length===0&&p.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center italic",children:V("无匹配模型","No matching models","Không có model phù hợp")})]}),p.jsx("div",{className:"border-t border-border/30",children:p.jsx(Ef,{onClick:i,className:"text-primary",children:V("管理服务商","Manage providers","Quản lý nhà cung cấp")})})]})}function _Ye(e,t){var n;const r={"ready-for-review":()=>t("chapter.readyForReview"),approved:()=>t("chapter.approved"),drafted:()=>t("chapter.drafted"),"needs-revision":()=>t("chapter.needsRevision"),imported:()=>t("chapter.imported"),"audit-failed":()=>t("chapter.auditFailed")};return((n=r[e])==null?void 0:n.call(r))??e}const fF={"ready-for-review":{color:"text-amber-500 bg-amber-500/10",icon:p.jsx(Qv,{size:12})},approved:{color:"text-emerald-500 bg-emerald-500/10",icon:p.jsx(ac,{size:12})},drafted:{color:"text-muted-foreground bg-muted/20",icon:p.jsx(Uh,{size:12})},"needs-revision":{color:"text-destructive bg-destructive/10",icon:p.jsx(P0,{size:12})},imported:{color:"text-blue-500 bg-blue-500/10",icon:p.jsx(Zv,{size:12})}};function EYe({bookId:e,nav:t,theme:r,t:n,sse:i}){const{data:s,loading:a,error:o,refetch:l}=$r(`/books/${e}`),[c,h]=_.useState(!1),[f,g]=_.useState(!1),[m,x]=_.useState(!1),[v,C]=_.useState(!1),[k,T]=_.useState([]),[w,L]=_.useState([]),[N,A]=_.useState([]),[R,P]=_.useState(!1),[q,j]=_.useState(null),[U,W]=_.useState(null),[J,G]=_.useState(null),[O,D]=_.useState("txt"),[H,Y]=_.useState(!1),[ae,z]=_.useState(null),[K,se]=_.useState("auto");_.useEffect(()=>{ct(`/books/${encodeURIComponent(e)}/chapter-review-mode`).then(Se=>se(Se.mode==="manual"?"manual":"auto")).catch(()=>{})},[e]);const X=_.useMemo(()=>ise(i.messages,e),[e,i.messages]),ke=c||X.writing,ye=f||X.drafting,we=s?s.nextChapter-1:0;_.useEffect(()=>{const Se=i.messages.at(-1);if(!Se)return;const st=Se.data;if((st==null?void 0:st.bookId)===e){if(Se.event==="write:start"){h(!1);return}if(Se.event==="draft:start"){g(!1);return}sse(Se,e)&&(h(!1),g(!1),l())}},[e,l,i.messages]);const Fe=async()=>{h(!0);try{await di(`/books/${e}/write-next`)}catch(Se){h(!1),alert(Se instanceof Error?Se.message:"Failed")}},ue=async()=>{g(!0);try{await di(`/books/${e}/draft`)}catch(Se){g(!1),alert(Se instanceof Error?Se.message:"Failed")}},Ne=async()=>{const Se=K==="manual"?"auto":"manual";se(Se);try{await ct(`/books/${encodeURIComponent(e)}/chapter-review-mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:Se})})}catch{se(K)}},Te=async()=>{C(!1),x(!0);try{const Se=await fetch(`/api/v1/books/${e}`,{method:"DELETE"});if(!Se.ok){const st=await Se.json().catch(()=>({}));throw new Error(st.error??`${Se.status}`)}t.toDashboard()}catch(Se){alert(Se instanceof Error?Se.message:"Delete failed")}finally{x(!1)}},Ue=async Se=>{const st=window.prompt(V("可选:输入这次重写要遵循的补充想法。留空则沿用现有 focus。","Optional rewrite brief for this run only. Leave blank to use existing focus.","Tùy chọn: nhập ý tưởng bổ sung cần theo cho lần viết lại này. Để trống sẽ dùng focus hiện tại."),"");if(st!==null){T(jt=>[...jt,Se]);try{await ct(`/books/${e}/rewrite/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:st.trim()||void 0})}),l()}catch(jt){alert(jt instanceof Error?jt.message:"Rewrite failed")}finally{T(jt=>jt.filter(ft=>ft!==Se))}}},Qe=async(Se,st)=>{const jt=window.prompt(V("可选:输入这次修订要遵循的补充想法。留空则沿用现有 focus。","Optional revise brief for this run only. Leave blank to use existing focus.","Tùy chọn: nhập ý tưởng bổ sung cần theo cho lần chỉnh sửa này. Để trống sẽ dùng focus hiện tại."),"");if(jt!==null){L(ft=>[...ft,Se]);try{await ct(`/books/${e}/revise/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:st,brief:jt.trim()||void 0})}),l()}catch(ft){alert(ft instanceof Error?ft.message:"Revision failed")}finally{L(ft=>ft.filter(wt=>wt!==Se))}}},We=async Se=>{const st=window.prompt(V("可选:输入这次同步时要遵循的补充说明。留空则直接按正文同步。","Optional sync brief for interpreting the edited chapter body. Leave blank to sync directly from the text.","Tùy chọn: nhập ghi chú bổ sung cần theo khi đồng bộ lần này. Để trống sẽ đồng bộ trực tiếp theo nội dung chương."),"");if(st!==null){A(jt=>[...jt,Se]);try{await ct(`/books/${e}/resync/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:st.trim()||void 0})}),l()}catch(jt){alert(jt instanceof Error?jt.message:"Sync failed")}finally{A(jt=>jt.filter(ft=>ft!==Se))}}},de=async()=>{if(s){P(!0);try{const Se={};q!==null&&(Se.chapterWordCount=q),U!==null&&(Se.targetChapters=U),J!==null&&(Se.status=J),await ct(`/books/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Se)}),l()}catch(Se){alert(Se instanceof Error?Se.message:"Save failed")}finally{P(!1)}}},te=async()=>{if(!s)return;const Se=s.chapters.filter(jt=>jt.status==="ready-for-review");let st=0;for(const jt of Se)try{await di(`/books/${e}/chapters/${jt.number}/approve`)}catch{st+=1}st>0&&alert(`${st}/${Se.length} approve(s) failed`),l()},$e=async(Se,st)=>{z(Se);try{alert(await st()),l()}catch(jt){alert(jt instanceof Error?jt.message:"Action failed")}finally{z(null)}},Ie=async()=>{await $e("eval",async()=>{const Se=await ct(`/books/${e}/eval`);return[`${n("book.evaluate")}: ${Se.qualityScore}/100`,`${n("dash.chapters")}: ${Se.totalChapters}`,`${n("book.words")}: ${Se.totalWords.toLocaleString()}`,`Audit: ${Se.auditPassRate}%`,`AI tells: ${Se.avgAiTellDensity}/1k`,`Hooks: ${Se.hookResolveRate}%`].join(`
1407
+ `})}return r},a$e=/([\\`*_~[\]|])/g,o$e=e=>e.replace(a$e,"\\$1"),l$e=(e,t)=>{if(!t.length)return e;let r=e;for(let n of t){let i=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");r=r.replace(i,(s,a,o,l)=>{let c=o$e(o).replace(/\n\n/g,"&#10;&#10;");return a+c+l})}return r},jJ=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(jJ).join(""):"",c$e=e=>t=>{if(!e||e.length===0)return;let r=new Set(e.map(n=>n.toLowerCase()));fo(t,"element",n=>{if(r.has(n.tagName.toLowerCase())){let i=jJ(n);n.children=i?[{type:"text",value:i}]:[]}})},u$e=()=>e=>{fo(e,"code",t=>{var r,n;t.meta&&(t.data=(r=t.data)!=null?r:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta})})},h$e=/^[ \t]*<[\w!/?-]/,d$e=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,f$e=e=>typeof e!="string"||e.length===0||!h$e.test(e)?e:e.replace(d$e,"$1"),uP,hP,dP,fP,Yb={...Eh,protocols:{...Eh.protocols,href:[...(hP=(uP=Eh.protocols)==null?void 0:uP.href)!=null?hP:[],"tel"]},attributes:{...Eh.attributes,code:[...(fP=(dP=Eh.attributes)==null?void 0:dP.code)!=null?fP:[],"metastring"]}},R6={raw:m6,sanitize:[YZ,Yb],harden:[R9e,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},p$e={gfm:[ABe,{}],codeMeta:u$e},pP=Object.values(R6),m$e=Object.values(p$e),g$e={block:" ▋",circle:" ●"},FJ=["github-light","github-dark"],zJ={enabled:!0},y$e={shikiTheme:FJ,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:zJ},ua=_.createContext(y$e),$J=_.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:r,index:n,isIncomplete:i,dir:s,animatePlugin:a,...o})=>{if(a){let h=a.getLastRenderCharCount();a.setPrevContentLength(h)}let l=typeof e=="string"&&r?f$e(e):e,c=p.jsx(PJ,{...o,children:l});return p.jsx(iJ.Provider,{value:i,children:s?p.jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let r=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(r.length!==n.length||r.some(i=>{var s,a;return((s=e.components)==null?void 0:s[i])!==((a=t.components)==null?void 0:a[i])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});$J.displayName="Block";var Ho=_.memo(({children:e,mode:t="streaming",dir:r,parseIncompleteMarkdown:n=!0,normalizeHtmlIndentation:i=!1,components:s,rehypePlugins:a=pP,remarkPlugins:o=m$e,className:l,shikiTheme:c=FJ,mermaid:h,controls:f=!0,isAnimating:g=!1,animated:m,BlockComponent:x=$J,parseMarkdownIntoBlocksFn:v=i$e,caret:C,plugins:k,remend:T,linkSafety:w=zJ,lineNumbers:L=!0,allowedTags:N,literalTagContent:A,translations:R,icons:P,prefix:q,onAnimationStart:j,onAnimationEnd:U,...W})=>{let J=_.useId(),[G,O]=_.useTransition(),D=_.useMemo(()=>QFe(q),[q]),H=_.useRef(null),Y=_.useRef(j),ae=_.useRef(U);Y.current=j,ae.current=U,_.useEffect(()=>{var Be,Ee,je;if(t==="static")return;let ge=H.current;if(H.current=g,ge===null){g&&((Be=Y.current)==null||Be.call(Y));return}g&&!ge?(Ee=Y.current)==null||Ee.call(Y):!g&&ge&&((je=ae.current)==null||je.call(ae))},[g,t]);let z=_.useMemo(()=>N?Object.keys(N):[],[N]),K=_.useMemo(()=>{if(typeof e!="string")return"";let Be=t==="streaming"&&n?FDe(e,T):e;return A&&A.length>0&&(Be=l$e(Be,A)),z.length>0&&(Be=s$e(Be,z)),Be},[e,t,n,T,z,A]),se=_.useMemo(()=>v(K),[K,v]),[X,ke]=_.useState(se);_.useEffect(()=>{t==="streaming"&&!Ne?O(()=>{ke(se)}):ke(se)},[se,t]);let ye=t==="streaming"?X:se,we=_.useMemo(()=>r==="auto"?ye.map(tP):void 0,[ye,r]),Fe=_.useMemo(()=>ye.map((Be,Ee)=>`${J}-${Ee}`),[ye.length,J]),ue=_.useMemo(()=>m===!0?"true":m?JSON.stringify(m):"",[m]),Ne=_.useMemo(()=>ue?ue==="true"?S6():S6(m):null,[ue]),Te=_.useMemo(()=>{var Be,Ee;return{shikiTheme:(Ee=(Be=k==null?void 0:k.code)==null?void 0:Be.getThemes())!=null?Ee:c,controls:f,isAnimating:g,lineNumbers:L,mode:t,mermaid:h,linkSafety:w}},[c,f,g,L,t,h,w,k==null?void 0:k.code]),Ue=_.useMemo(()=>R?JSON.stringify(R):"",[R]),Qe=_.useMemo(()=>({...lJ,...R}),[Ue]),We=_.useMemo(()=>{let{inlineCode:Be,...Ee}=s??{},je={...Bze,...Ee};if(Be){let ge=je.code;je.code=De=>"data-block"in De?ge?_.createElement(ge,De):null:_.createElement(Be,De)}return je},[s]),de=_.useMemo(()=>{let Be=[];return k!=null&&k.cjk&&(Be=[...Be,...k.cjk.remarkPluginsBefore]),Be=[...Be,...o],k!=null&&k.cjk&&(Be=[...Be,...k.cjk.remarkPluginsAfter]),k!=null&&k.math&&(Be=[...Be,k.math.remarkPlugin]),Be},[o,k==null?void 0:k.math,k==null?void 0:k.cjk]),te=_.useMemo(()=>{var Be;let Ee=a;if(N&&Object.keys(N).length>0&&a===pP){let je={...Yb,tagNames:[...(Be=Yb.tagNames)!=null?Be:[],...Object.keys(N)],attributes:{...Yb.attributes,...N}};Ee=[R6.raw,[YZ,je],R6.harden]}return A&&A.length>0&&(Ee=[...Ee,[c$e,A]]),k!=null&&k.math&&(Ee=[...Ee,k.math.rehypePlugin]),Ne&&g&&(Ee=[...Ee,Ne.rehypePlugin]),Ee},[a,k==null?void 0:k.math,Ne,g,N,A]),$e=_.useMemo(()=>{if(!g||ye.length===0)return!1;let Be=ye.at(-1);return rP(Be)||zze(Be)},[g,ye]),Ie=_.useMemo(()=>C&&g&&!$e?{"--streamdown-caret":`"${g$e[C]}"`}:void 0,[C,g,$e]);return t==="static"?p.jsx(E6.Provider,{value:Qe,children:p.jsx(A6.Provider,{value:k??null,children:p.jsx(ua.Provider,{value:Te,children:p.jsx(KD,{icons:P,children:p.jsx(_6.Provider,{value:D,children:p.jsx("div",{className:D("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:r==="auto"?tP(K):r,children:p.jsx(PJ,{components:We,rehypePlugins:te,remarkPlugins:de,...W,children:K})})})})})})}):p.jsx(E6.Provider,{value:Qe,children:p.jsx(A6.Provider,{value:k??null,children:p.jsx(ua.Provider,{value:Te,children:p.jsx(KD,{icons:P,children:p.jsx(_6.Provider,{value:D,children:p.jsxs("div",{className:D("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",C&&!$e?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),style:Ie,children:[ye.length===0&&C&&g&&p.jsx("span",{}),ye.map((Be,Ee)=>{var je;let ge=Ee===ye.length-1,De=g&&ge&&rP(Be);return p.jsx(x,{animatePlugin:Ne,components:We,content:Be,dir:(je=we==null?void 0:we[Ee])!=null?je:r!=="auto"?r:void 0,index:Ee,isIncomplete:De,rehypePlugins:te,remarkPlugins:de,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:n,...W},Fe[Ee])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Ho.displayName="Streamdown";var x$e=({children:e,className:t,minZoom:r=.5,maxZoom:n=3,zoomStep:i=.1,showControls:s=!0,initialZoom:a=1,fullscreen:o=!1})=>{let{RotateCcwIcon:l,ZoomInIcon:c,ZoomOutIcon:h}=bo(),f=kr(),g=_.useRef(null),m=_.useRef(null),[x,v]=_.useState(a),[C,k]=_.useState({x:0,y:0}),[T,w]=_.useState(!1),[L,N]=_.useState({x:0,y:0}),[A,R]=_.useState({x:0,y:0}),P=_.useCallback(D=>{v(H=>Math.max(r,Math.min(n,H+D)))},[r,n]),q=_.useCallback(()=>{P(i)},[P,i]),j=_.useCallback(()=>{P(-i)},[P,i]),U=_.useCallback(()=>{v(a),k({x:0,y:0})},[a]),W=_.useCallback(D=>{D.preventDefault();let H=D.deltaY>0?-i:i;P(H)},[P,i]),J=_.useCallback(D=>{if(D.button!==0||D.isPrimary===!1)return;w(!0),N({x:D.clientX,y:D.clientY}),R(C);let H=D.currentTarget;H instanceof HTMLElement&&H.setPointerCapture(D.pointerId)},[C]),G=_.useCallback(D=>{if(!T)return;D.preventDefault();let H=D.clientX-L.x,Y=D.clientY-L.y;k({x:A.x+H,y:A.y+Y})},[T,L,A]),O=_.useCallback(D=>{w(!1);let H=D.currentTarget;H instanceof HTMLElement&&H.releasePointerCapture(D.pointerId)},[]);return _.useEffect(()=>{let D=g.current;if(D)return D.addEventListener("wheel",W,{passive:!1}),()=>{D.removeEventListener("wheel",W)}},[W]),_.useEffect(()=>{let D=m.current;if(D&&T)return document.body.style.userSelect="none",D.addEventListener("pointermove",G,{passive:!1}),D.addEventListener("pointerup",O),D.addEventListener("pointercancel",O),()=>{document.body.style.userSelect="",D.removeEventListener("pointermove",G),D.removeEventListener("pointerup",O),D.removeEventListener("pointercancel",O)}},[T,G,O]),p.jsxs("div",{className:f("relative flex flex-col",o?"h-full w-full":"min-h-28 w-full",t),ref:g,style:{cursor:T?"grabbing":"grab"},children:[s?p.jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",o?"bottom-4 left-4":"bottom-2 left-2"),children:[p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:x>=n,onClick:q,title:"Zoom in",type:"button",children:p.jsx(c,{size:16})}),p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:x<=r,onClick:j,title:"Zoom out",type:"button",children:p.jsx(h,{size:16})}),p.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:U,title:"Reset zoom and pan",type:"button",children:p.jsx(l,{size:16})})]}):null,p.jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",o?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:J,ref:m,role:"application",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${x})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},HJ=({chart:e,className:t,config:r,fullscreen:n=!1,showControls:i=!0})=>{let s=kr(),[a,o]=_.useState(null),[l,c]=_.useState(!1),[h,f]=_.useState(""),[g,m]=_.useState(""),[x,v]=_.useState(0),{mermaid:C}=_.useContext(ua),k=y7(),T=C==null?void 0:C.errorComponent,{shouldRender:w,containerRef:L}=zFe({immediate:n});if(_.useEffect(()=>{if(w){if(!k){o("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{o(null),c(!0);let A=k.getMermaid(r),R=e.split("").reduce((j,U)=>(j<<5)-j+U.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(R)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:q}=await A.render(P,e);f(q),m(q)}catch(A){if(!(g||h)){let R=A instanceof Error?A.message:"Failed to render Mermaid chart";o(R)}}finally{c(!1)}})()}},[e,r,x,w,k]),!(w||h||g))return p.jsx("div",{className:s("my-4 min-h-[200px]",t),ref:L});if(l&&!h&&!g)return p.jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:L,children:p.jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[p.jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),p.jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!h&&!g){let A=()=>v(R=>R+1);return T?p.jsx("div",{ref:L,children:p.jsx(T,{chart:e,error:a,retry:A})}):p.jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:L,children:[p.jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),p.jsxs("details",{className:s("mt-2"),children:[p.jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),p.jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let N=h||g;return p.jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:L,children:p.jsx(x$e,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:p.jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:N},role:"img"})})})};const UJ=_.createContext({});function b$e(e){const t=_.useRef(null);return t.current===null&&(t.current=e()),t.current}const v$e=typeof window<"u",C$e=v$e?_.useLayoutEffect:_.useEffect,b7=_.createContext(null);function v7(e,t){e.indexOf(t)===-1&&e.push(t)}function Mv(e,t){const r=e.indexOf(t);r>-1&&e.splice(r,1)}const nl=(e,t,r)=>r>t?t:r<e?e:r;let C7=()=>{};const Ru={},qJ=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function VJ(e){return typeof e=="object"&&e!==null}const WJ=e=>/^0[^.\s]+$/u.test(e);function GJ(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fa=e=>e,k$e=(e,t)=>r=>t(e(r)),q1=(...e)=>e.reduce(k$e),s1=(e,t,r)=>{const n=t-e;return n===0?1:(r-e)/n};class k7{constructor(){this.subscriptions=[]}add(t){return v7(this.subscriptions,t),()=>Mv(this.subscriptions,t)}notify(t,r,n){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,r,n);else for(let s=0;s<i;s++){const a=this.subscriptions[s];a&&a(t,r,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const sa=e=>e*1e3,Pa=e=>e/1e3;function YJ(e,t){return t?e*(1e3/t):0}const XJ=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,T$e=1e-7,w$e=12;function S$e(e,t,r,n,i){let s,a,o=0;do a=t+(r-t)/2,s=XJ(a,n,i)-e,s>0?r=a:t=a;while(Math.abs(s)>T$e&&++o<w$e);return a}function V1(e,t,r,n){if(e===t&&r===n)return Fa;const i=s=>S$e(s,0,1,e,r);return s=>s===0||s===1?s:XJ(i(s),t,n)}const KJ=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ZJ=e=>t=>1-e(1-t),QJ=V1(.33,1.53,.69,.99),T7=ZJ(QJ),JJ=KJ(T7),eee=e=>e>=1?1:(e*=2)<1?.5*T7(e):.5*(2-Math.pow(2,-10*(e-1))),w7=e=>1-Math.sin(Math.acos(e)),tee=ZJ(w7),ree=KJ(w7),_$e=V1(.42,0,1,1),E$e=V1(0,0,.58,1),nee=V1(.42,0,.58,1),A$e=e=>Array.isArray(e)&&typeof e[0]!="number",iee=e=>Array.isArray(e)&&typeof e[0]=="number",N$e={linear:Fa,easeIn:_$e,easeInOut:nee,easeOut:E$e,circIn:w7,circInOut:ree,circOut:tee,backIn:T7,backInOut:JJ,backOut:QJ,anticipate:eee},L$e=e=>typeof e=="string",mP=e=>{if(iee(e)){C7(e.length===4);const[t,r,n,i]=e;return V1(t,r,n,i)}else if(L$e(e))return N$e[e];return e},sb=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function R$e(e,t){let r=new Set,n=new Set,i=!1,s=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){a.has(h)&&(c.schedule(h),e()),h(o)}const c={schedule:(h,f=!1,g=!1)=>{const x=g&&i?r:n;return f&&a.add(h),x.add(h),h},cancel:h=>{n.delete(h),a.delete(h)},process:h=>{if(o=h,i){s=!0;return}i=!0;const f=r;r=n,n=f,r.forEach(l),r.clear(),i=!1,s&&(s=!1,c.process(h))}};return c}const M$e=40;function see(e,t){let r=!1,n=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>r=!0,a=sb.reduce((w,L)=>(w[L]=R$e(s),w),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:h,update:f,preRender:g,render:m,postRender:x}=a,v=()=>{const w=Ru.useManualTiming,L=w?i.timestamp:performance.now();r=!1,w||(i.delta=n?1e3/60:Math.max(Math.min(L-i.timestamp,M$e),1)),i.timestamp=L,i.isProcessing=!0,o.process(i),l.process(i),c.process(i),h.process(i),f.process(i),g.process(i),m.process(i),x.process(i),i.isProcessing=!1,r&&t&&(n=!1,e(v))},C=()=>{r=!0,n=!0,i.isProcessing||e(v)};return{schedule:sb.reduce((w,L)=>{const N=a[L];return w[L]=(A,R=!1,P=!1)=>(r||C(),N.schedule(A,R,P)),w},{}),cancel:w=>{for(let L=0;L<sb.length;L++)a[sb[L]].cancel(w)},state:i,steps:a}}const{schedule:on,cancel:Mu,state:Bi,steps:OT}=see(typeof requestAnimationFrame<"u"?requestAnimationFrame:Fa,!0);let Xb;function I$e(){Xb=void 0}const ds={now:()=>(Xb===void 0&&ds.set(Bi.isProcessing||Ru.useManualTiming?Bi.timestamp:performance.now()),Xb),set:e=>{Xb=e,queueMicrotask(I$e)}},aee=e=>t=>typeof t=="string"&&t.startsWith(e),oee=aee("--"),O$e=aee("var(--"),S7=e=>O$e(e)?B$e.test(e.split("/*")[0].trim()):!1,B$e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function gP(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const lp={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},a1={...lp,transform:e=>nl(0,1,e)},ab={...lp,default:1},Cg=e=>Math.round(e*1e5)/1e5,_7=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function D$e(e){return e==null}const P$e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,E7=(e,t)=>r=>!!(typeof r=="string"&&P$e.test(r)&&r.startsWith(e)||t&&!D$e(r)&&Object.prototype.hasOwnProperty.call(r,t)),lee=(e,t,r)=>n=>{if(typeof n!="string")return n;const[i,s,a,o]=n.match(_7);return{[e]:parseFloat(i),[t]:parseFloat(s),[r]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},j$e=e=>nl(0,255,e),BT={...lp,transform:e=>Math.round(j$e(e))},Fh={test:E7("rgb","red"),parse:lee("red","green","blue"),transform:({red:e,green:t,blue:r,alpha:n=1})=>"rgba("+BT.transform(e)+", "+BT.transform(t)+", "+BT.transform(r)+", "+Cg(a1.transform(n))+")"};function F$e(e){let t="",r="",n="",i="";return e.length>5?(t=e.substring(1,3),r=e.substring(3,5),n=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),r=e.substring(2,3),n=e.substring(3,4),i=e.substring(4,5),t+=t,r+=r,n+=n,i+=i),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const M6={test:E7("#"),parse:F$e,transform:Fh.transform},W1=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Kc=W1("deg"),Yo=W1("%"),_t=W1("px"),z$e=W1("vh"),$$e=W1("vw"),yP={...Yo,parse:e=>Yo.parse(e)/100,transform:e=>Yo.transform(e*100)},Mf={test:E7("hsl","hue"),parse:lee("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:r,alpha:n=1})=>"hsla("+Math.round(e)+", "+Yo.transform(Cg(t))+", "+Yo.transform(Cg(r))+", "+Cg(a1.transform(n))+")"},Kn={test:e=>Fh.test(e)||M6.test(e)||Mf.test(e),parse:e=>Fh.test(e)?Fh.parse(e):Mf.test(e)?Mf.parse(e):M6.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Fh.transform(e):Mf.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},H$e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function U$e(e){var t,r;return isNaN(e)&&typeof e=="string"&&(((t=e.match(_7))==null?void 0:t.length)||0)+(((r=e.match(H$e))==null?void 0:r.length)||0)>0}const cee="number",uee="color",q$e="var",V$e="var(",xP="${}",W$e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function A0(e){const t=e.toString(),r=[],n={color:[],number:[],var:[]},i=[];let s=0;const o=t.replace(W$e,l=>(Kn.test(l)?(n.color.push(s),i.push(uee),r.push(Kn.parse(l))):l.startsWith(V$e)?(n.var.push(s),i.push(q$e),r.push(l)):(n.number.push(s),i.push(cee),r.push(parseFloat(l))),++s,xP)).split(xP);return{values:r,split:o,indexes:n,types:i}}function G$e(e){return A0(e).values}function hee({split:e,types:t}){const r=e.length;return n=>{let i="";for(let s=0;s<r;s++)if(i+=e[s],n[s]!==void 0){const a=t[s];a===cee?i+=Cg(n[s]):a===uee?i+=Kn.transform(n[s]):i+=n[s]}return i}}function Y$e(e){return hee(A0(e))}const X$e=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,K$e=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:X$e(e);function Z$e(e){const t=A0(e);return hee(t)(t.values.map((n,i)=>K$e(n,t.split[i])))}const uo={test:U$e,parse:G$e,createTransformer:Y$e,getAnimatableNone:Z$e};function DT(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function Q$e({hue:e,saturation:t,lightness:r,alpha:n}){e/=360,t/=100,r/=100;let i=0,s=0,a=0;if(!t)i=s=a=r;else{const o=r<.5?r*(1+t):r+t-r*t,l=2*r-o;i=DT(l,o,e+1/3),s=DT(l,o,e),a=DT(l,o,e-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:n}}function Iv(e,t){return r=>r>0?t:e}const gn=(e,t,r)=>e+(t-e)*r,PT=(e,t,r)=>{const n=e*e,i=r*(t*t-n)+n;return i<0?0:Math.sqrt(i)},J$e=[M6,Fh,Mf],eHe=e=>J$e.find(t=>t.test(e));function bP(e){const t=eHe(e);if(!t)return!1;let r=t.parse(e);return t===Mf&&(r=Q$e(r)),r}const vP=(e,t)=>{const r=bP(e),n=bP(t);if(!r||!n)return Iv(e,t);const i={...r};return s=>(i.red=PT(r.red,n.red,s),i.green=PT(r.green,n.green,s),i.blue=PT(r.blue,n.blue,s),i.alpha=gn(r.alpha,n.alpha,s),Fh.transform(i))},I6=new Set(["none","hidden"]);function tHe(e,t){return I6.has(e)?r=>r<=0?e:t:r=>r>=1?t:e}function rHe(e,t){return r=>gn(e,t,r)}function A7(e){return typeof e=="number"?rHe:typeof e=="string"?S7(e)?Iv:Kn.test(e)?vP:sHe:Array.isArray(e)?dee:typeof e=="object"?Kn.test(e)?vP:nHe:Iv}function dee(e,t){const r=[...e],n=r.length,i=e.map((s,a)=>A7(s)(s,t[a]));return s=>{for(let a=0;a<n;a++)r[a]=i[a](s);return r}}function nHe(e,t){const r={...e,...t},n={};for(const i in r)e[i]!==void 0&&t[i]!==void 0&&(n[i]=A7(e[i])(e[i],t[i]));return i=>{for(const s in n)r[s]=n[s](i);return r}}function iHe(e,t){const r=[],n={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const s=t.types[i],a=e.indexes[s][n[s]],o=e.values[a]??0;r[i]=o,n[s]++}return r}const sHe=(e,t)=>{const r=uo.createTransformer(t),n=A0(e),i=A0(t);return n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length?I6.has(e)&&!i.values.length||I6.has(t)&&!n.values.length?tHe(e,t):q1(dee(iHe(n,i),i.values),r):Iv(e,t)};function fee(e,t,r){return typeof e=="number"&&typeof t=="number"&&typeof r=="number"?gn(e,t,r):A7(e)(e,t)}const aHe=e=>{const t=({timestamp:r})=>e(r);return{start:(r=!0)=>on.update(t,r),stop:()=>Mu(t),now:()=>Bi.isProcessing?Bi.timestamp:ds.now()}},pee=(e,t,r=10)=>{let n="";const i=Math.max(Math.round(t/r),2);for(let s=0;s<i;s++)n+=Math.round(e(s/(i-1))*1e4)/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},Ov=2e4;function N7(e){let t=0;const r=50;let n=e.next(t);for(;!n.done&&t<Ov;)t+=r,n=e.next(t);return t>=Ov?1/0:t}function oHe(e,t=100,r){const n=r({...e,keyframes:[0,t]}),i=Math.min(N7(n),Ov);return{type:"keyframes",ease:s=>n.next(i*s).value/t,duration:Pa(i)}}const In={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function O6(e,t){return e*Math.sqrt(1-t*t)}const lHe=12;function cHe(e,t,r){let n=r;for(let i=1;i<lHe;i++)n=n-e(n)/t(n);return n}const jT=.001;function uHe({duration:e=In.duration,bounce:t=In.bounce,velocity:r=In.velocity,mass:n=In.mass}){let i,s,a=1-t;a=nl(In.minDamping,In.maxDamping,a),e=nl(In.minDuration,In.maxDuration,Pa(e)),a<1?(i=c=>{const h=c*a,f=h*e,g=h-r,m=O6(c,a),x=Math.exp(-f);return jT-g/m*x},s=c=>{const f=c*a*e,g=f*r+r,m=Math.pow(a,2)*Math.pow(c,2)*e,x=Math.exp(-f),v=O6(Math.pow(c,2),a);return(-i(c)+jT>0?-1:1)*((g-m)*x)/v}):(i=c=>{const h=Math.exp(-c*e),f=(c-r)*e+1;return-jT+h*f},s=c=>{const h=Math.exp(-c*e),f=(r-c)*(e*e);return h*f});const o=5/e,l=cHe(i,s,o);if(e=sa(e),isNaN(l))return{stiffness:In.stiffness,damping:In.damping,duration:e};{const c=Math.pow(l,2)*n;return{stiffness:c,damping:a*2*Math.sqrt(n*c),duration:e}}}const hHe=["duration","bounce"],dHe=["stiffness","damping","mass"];function CP(e,t){return t.some(r=>e[r]!==void 0)}function fHe(e){let t={velocity:In.velocity,stiffness:In.stiffness,damping:In.damping,mass:In.mass,isResolvedFromDuration:!1,...e};if(!CP(e,dHe)&&CP(e,hHe))if(t.velocity=0,e.visualDuration){const r=e.visualDuration,n=2*Math.PI/(r*1.2),i=n*n,s=2*nl(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:In.mass,stiffness:i,damping:s}}else{const r=uHe({...e,velocity:0});t={...t,...r,mass:In.mass},t.isResolvedFromDuration=!0}return t}function Bv(e=In.visualDuration,t=In.bounce){const r=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:n,restDelta:i}=r;const s=r.keyframes[0],a=r.keyframes[r.keyframes.length-1],o={done:!1,value:s},{stiffness:l,damping:c,mass:h,duration:f,velocity:g,isResolvedFromDuration:m}=fHe({...r,velocity:-Pa(r.velocity||0)}),x=g||0,v=c/(2*Math.sqrt(l*h)),C=a-s,k=Pa(Math.sqrt(l/h)),T=Math.abs(C)<5;n||(n=T?In.restSpeed.granular:In.restSpeed.default),i||(i=T?In.restDelta.granular:In.restDelta.default);let w,L,N,A,R,P;if(v<1)N=O6(k,v),A=(x+v*k*C)/N,w=j=>{const U=Math.exp(-v*k*j);return a-U*(A*Math.sin(N*j)+C*Math.cos(N*j))},R=v*k*A+C*N,P=v*k*C-A*N,L=j=>Math.exp(-v*k*j)*(R*Math.sin(N*j)+P*Math.cos(N*j));else if(v===1){w=U=>a-Math.exp(-k*U)*(C+(x+k*C)*U);const j=x+k*C;L=U=>Math.exp(-k*U)*(k*j*U-x)}else{const j=k*Math.sqrt(v*v-1);w=G=>{const O=Math.exp(-v*k*G),D=Math.min(j*G,300);return a-O*((x+v*k*C)*Math.sinh(D)+j*C*Math.cosh(D))/j};const U=(x+v*k*C)/j,W=v*k*U-C*j,J=v*k*C-U*j;L=G=>{const O=Math.exp(-v*k*G),D=Math.min(j*G,300);return O*(W*Math.sinh(D)+J*Math.cosh(D))}}const q={calculatedDuration:m&&f||null,velocity:j=>sa(L(j)),next:j=>{if(!m&&v<1){const W=Math.exp(-v*k*j),J=Math.sin(N*j),G=Math.cos(N*j),O=a-W*(A*J+C*G),D=sa(W*(R*J+P*G));return o.done=Math.abs(D)<=n&&Math.abs(a-O)<=i,o.value=o.done?a:O,o}const U=w(j);if(m)o.done=j>=f;else{const W=sa(L(j));o.done=Math.abs(W)<=n&&Math.abs(a-U)<=i}return o.value=o.done?a:U,o},toString:()=>{const j=Math.min(N7(q),Ov),U=pee(W=>q.next(j*W).value,j,30);return j+"ms "+U},toTransition:()=>{}};return q}Bv.applyToOptions=e=>{const t=oHe(e,100,Bv);return e.ease=t.ease,e.duration=sa(t.duration),e.type="keyframes",e};const pHe=5;function mee(e,t,r){const n=Math.max(t-pHe,0);return YJ(r-e(n),t-n)}function B6({keyframes:e,velocity:t=0,power:r=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:h}){const f=e[0],g={done:!1,value:f},m=P=>o!==void 0&&P<o||l!==void 0&&P>l,x=P=>o===void 0?l:l===void 0||Math.abs(o-P)<Math.abs(l-P)?o:l;let v=r*t;const C=f+v,k=a===void 0?C:a(C);k!==C&&(v=k-f);const T=P=>-v*Math.exp(-P/n),w=P=>k+T(P),L=P=>{const q=T(P),j=w(P);g.done=Math.abs(q)<=c,g.value=g.done?k:j};let N,A;const R=P=>{m(g.value)&&(N=P,A=Bv({keyframes:[g.value,x(g.value)],velocity:mee(w,P,g.value),damping:i,stiffness:s,restDelta:c,restSpeed:h}))};return R(0),{calculatedDuration:null,next:P=>{let q=!1;return!A&&N===void 0&&(q=!0,L(P),R(P)),N!==void 0&&P>=N?A.next(P-N):(!q&&L(P),g)}}}function mHe(e,t,r){const n=[],i=r||Ru.mix||fee,s=e.length-1;for(let a=0;a<s;a++){let o=i(e[a],e[a+1]);if(t){const l=Array.isArray(t)?t[a]||Fa:t;o=q1(l,o)}n.push(o)}return n}function gHe(e,t,{clamp:r=!0,ease:n,mixer:i}={}){const s=e.length;if(C7(s===t.length),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=mHe(t,n,i),l=o.length,c=h=>{if(a&&h<e[0])return t[0];let f=0;if(l>1)for(;f<e.length-2&&!(h<e[f+1]);f++);const g=s1(e[f],e[f+1],h);return o[f](g)};return r?h=>c(nl(e[0],e[s-1],h)):c}function yHe(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const i=s1(0,t,n);e.push(gn(r,1,i))}}function xHe(e){const t=[0];return yHe(t,e.length-1),t}function bHe(e,t){return e.map(r=>r*t)}function vHe(e,t){return e.map(()=>t||nee).splice(0,e.length-1)}function kg({duration:e=300,keyframes:t,times:r,ease:n="easeInOut"}){const i=A$e(n)?n.map(mP):mP(n),s={done:!1,value:t[0]},a=bHe(r&&r.length===t.length?r:xHe(t),e),o=gHe(a,t,{ease:Array.isArray(i)?i:vHe(t,i)});return{calculatedDuration:e,next:l=>(s.value=o(l),s.done=l>=e,s)}}const CHe=e=>e!==null;function k3(e,{repeat:t,repeatType:r="loop"},n,i=1){const s=e.filter(CHe),o=i<0||t&&r!=="loop"&&t%2===1?0:s.length-1;return!o||n===void 0?s[o]:n}const kHe={decay:B6,inertia:B6,tween:kg,keyframes:kg,spring:Bv};function gee(e){typeof e.type=="string"&&(e.type=kHe[e.type])}class L7{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,r){return this.finished.then(t,r)}}const THe=e=>e/100;class Dv extends L7{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,i;const{motionValue:r}=this.options;r&&r.updatedAt!==ds.now()&&this.tick(ds.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(n=this.options).onStop)==null||i.call(n))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;gee(t);const{type:r=kg,repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:a=0}=t;let{keyframes:o}=t;const l=r||kg;l!==kg&&typeof o[0]!="number"&&(this.mixKeyframes=q1(THe,fee(o[0],o[1])),o=[0,100]);const c=l({...t,keyframes:o});s==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=N7(c));const{calculatedDuration:h}=c;this.calculatedDuration=h,this.resolvedDuration=h+i,this.totalDuration=this.resolvedDuration*(n+1)-i,this.generator=c}updateTime(t){const r=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(t,r=!1){const{generator:n,totalDuration:i,mixKeyframes:s,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:l}=this;if(this.startTime===null)return n.next(0);const{delay:c=0,keyframes:h,repeat:f,repeatType:g,repeatDelay:m,type:x,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),r?this.currentTime=t:this.updateTime(t);const k=this.currentTime-c*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?k<0:k>i;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let w=this.currentTime,L=n;if(f){const P=Math.min(this.currentTime,i)/o;let q=Math.floor(P),j=P%1;!j&&P>=1&&(j=1),j===1&&q--,q=Math.min(q,f+1),!!(q%2)&&(g==="reverse"?(j=1-j,m&&(j-=m/o)):g==="mirror"&&(L=a)),w=nl(0,1,j)*o}let N;T?(this.delayState.value=h[0],N=this.delayState):N=L.next(w),s&&!T&&(N.value=s(N.value));let{done:A}=N;!T&&l!==null&&(A=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&A);return R&&x!==B6&&(N.value=k3(h,this.options,C,this.speed)),v&&v(N.value),R&&this.finish(),N}then(t,r){return this.finished.then(t,r)}get duration(){return Pa(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pa(t)}get time(){return Pa(this.currentTime)}set time(t){t=sa(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const r=this.generator.next(t).value;return mee(n=>this.generator.next(n).value,t,r)}get speed(){return this.playbackSpeed}set speed(t){const r=this.playbackSpeed!==t;r&&this.driver&&this.updateTime(ds.now()),this.playbackSpeed=t,r&&this.driver&&(this.time=Pa(this.currentTime))}play(){var i,s;if(this.isStopped)return;const{driver:t=aHe,startTime:r}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),(s=(i=this.options).onPlay)==null||s.call(i);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(ds.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(t=this.options).onComplete)==null||r.call(t)}cancel(){var t,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(t=this.options).onCancel)==null||r.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),t.observe(this)}}function wHe(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const zh=e=>e*180/Math.PI,D6=e=>{const t=zh(Math.atan2(e[1],e[0]));return P6(t)},SHe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:D6,rotateZ:D6,skewX:e=>zh(Math.atan(e[1])),skewY:e=>zh(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},P6=e=>(e=e%360,e<0&&(e+=360),e),kP=D6,TP=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),wP=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),_He={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:TP,scaleY:wP,scale:e=>(TP(e)+wP(e))/2,rotateX:e=>P6(zh(Math.atan2(e[6],e[5]))),rotateY:e=>P6(zh(Math.atan2(-e[2],e[0]))),rotateZ:kP,rotate:kP,skewX:e=>zh(Math.atan(e[4])),skewY:e=>zh(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function j6(e){return e.includes("scale")?1:0}function F6(e,t){if(!e||e==="none")return j6(t);const r=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,i;if(r)n=_He,i=r;else{const o=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=SHe,i=o}if(!i)return j6(t);const s=n[t],a=i[1].split(",").map(AHe);return typeof s=="function"?s(a):a[s]}const EHe=(e,t)=>{const{transform:r="none"}=getComputedStyle(e);return F6(r,t)};function AHe(e){return parseFloat(e.trim())}const cp=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],up=new Set(cp),SP=e=>e===lp||e===_t,NHe=new Set(["x","y","z"]),LHe=cp.filter(e=>!NHe.has(e));function RHe(e){const t=[];return LHe.forEach(r=>{const n=e.getValue(r);n!==void 0&&(t.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),t}const hu={width:({x:e},{paddingLeft:t="0",paddingRight:r="0",boxSizing:n})=>{const i=e.max-e.min;return n==="border-box"?i:i-parseFloat(t)-parseFloat(r)},height:({y:e},{paddingTop:t="0",paddingBottom:r="0",boxSizing:n})=>{const i=e.max-e.min;return n==="border-box"?i:i-parseFloat(t)-parseFloat(r)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>F6(t,"x"),y:(e,{transform:t})=>F6(t,"y")};hu.translateX=hu.x;hu.translateY=hu.y;const Gh=new Set;let z6=!1,$6=!1,H6=!1;function yee(){if($6){const e=Array.from(Gh).filter(n=>n.needsMeasurement),t=new Set(e.map(n=>n.element)),r=new Map;t.forEach(n=>{const i=RHe(n);i.length&&(r.set(n,i),n.render())}),e.forEach(n=>n.measureInitialState()),t.forEach(n=>{n.render();const i=r.get(n);i&&i.forEach(([s,a])=>{var o;(o=n.getValue(s))==null||o.set(a)})}),e.forEach(n=>n.measureEndState()),e.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}$6=!1,z6=!1,Gh.forEach(e=>e.complete(H6)),Gh.clear()}function xee(){Gh.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&($6=!0)})}function MHe(){H6=!0,xee(),yee(),H6=!1}class R7{constructor(t,r,n,i,s,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=r,this.name=n,this.motionValue=i,this.element=s,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Gh.add(this),z6||(z6=!0,on.read(xee),on.resolveKeyframes(yee))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:r,element:n,motionValue:i}=this;if(t[0]===null){const s=i==null?void 0:i.get(),a=t[t.length-1];if(s!==void 0)t[0]=s;else if(n&&r){const o=n.readValue(r,a);o!=null&&(t[0]=o)}t[0]===void 0&&(t[0]=a),i&&s===void 0&&i.set(t[0])}wHe(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Gh.delete(this)}cancel(){this.state==="scheduled"&&(Gh.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const IHe=e=>e.startsWith("--");function bee(e,t,r){IHe(t)?e.style.setProperty(t,r):e.style[t]=r}const OHe={};function vee(e,t){const r=GJ(e);return()=>OHe[t]??r()}const BHe=vee(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Cee=vee(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ym=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`,_P={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ym([0,.65,.55,1]),circOut:Ym([.55,0,1,.45]),backIn:Ym([.31,.01,.66,-.59]),backOut:Ym([.33,1.53,.69,.99])};function kee(e,t){if(e)return typeof e=="function"?Cee()?pee(e,t):"ease-out":iee(e)?Ym(e):Array.isArray(e)?e.map(r=>kee(r,t)||_P.easeOut):_P[e]}function DHe(e,t,r,{delay:n=0,duration:i=300,repeat:s=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c=void 0){const h={[t]:r};l&&(h.offset=l);const f=kee(o,i);Array.isArray(f)&&(h.easing=f);const g={delay:n,duration:i,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"};return c&&(g.pseudoElement=c),e.animate(h,g)}function Tee(e){return typeof e=="function"&&"applyToOptions"in e}function PHe({type:e,...t}){return Tee(e)&&Cee()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class wee extends L7{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:r,name:n,keyframes:i,pseudoElement:s,allowFlatten:a=!1,finalKeyframe:o,onComplete:l}=t;this.isPseudoElement=!!s,this.allowFlatten=a,this.options=t,C7(typeof t.type!="string");const c=PHe(t);this.animation=DHe(r,n,i,c,s),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const h=k3(i,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(h),bee(r,n,h),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,r;(r=(t=this.animation).finish)==null||r.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,i;const t=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((i=(n=this.animation).commitStyles)==null||i.call(n))}get duration(){var r,n;const t=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return Pa(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pa(t)}get time(){return Pa(Number(this.animation.currentTime)||0)}set time(t){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=sa(t),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:r,rangeEnd:n,observe:i}){var s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&BHe()?(this.animation.timeline=t,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Fa):i(this)}}const See={anticipate:eee,backInOut:JJ,circInOut:ree};function jHe(e){return e in See}function FHe(e){typeof e.ease=="string"&&jHe(e.ease)&&(e.ease=See[e.ease])}const FT=10;class zHe extends wee{constructor(t){FHe(t),gee(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:r,onUpdate:n,onComplete:i,element:s,...a}=this.options;if(!r)return;if(t!==void 0){r.set(t);return}const o=new Dv({...a,autoplay:!1}),l=Math.max(FT,ds.now()-this.startTime),c=nl(0,FT,l-FT),h=o.sample(l).value,{name:f}=this.options;s&&f&&bee(s,f,h),r.setWithVelocity(o.sample(Math.max(0,l-c)).value,h,c),o.stop()}}const EP=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(uo.test(e)||e==="0")&&!e.startsWith("url("));function $He(e){const t=e[0];if(e.length===1)return!0;for(let r=0;r<e.length;r++)if(e[r]!==t)return!0}function HHe(e,t,r,n){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const s=e[e.length-1],a=EP(i,t),o=EP(s,t);return!a||!o?!1:$He(e)||(r==="spring"||Tee(r))&&n}function U6(e){e.duration=0,e.type="keyframes"}const _ee=new Set(["opacity","clipPath","filter","transform"]),UHe=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function qHe(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&UHe.test(e[t]))return!0;return!1}const VHe=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),WHe=GJ(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function GHe(e){var f;const{motionValue:t,name:r,repeatDelay:n,repeatType:i,damping:s,type:a,keyframes:o}=e;if(!(((f=t==null?void 0:t.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=t.owner.getProps();return WHe()&&r&&(_ee.has(r)||VHe.has(r)&&qHe(o))&&(r!=="transform"||!h)&&!c&&!n&&i!=="mirror"&&s!==0&&a!=="inertia"}const YHe=40;class XHe extends L7{constructor({autoplay:t=!0,delay:r=0,type:n="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:a="loop",keyframes:o,name:l,motionValue:c,element:h,...f}){var x;super(),this.stop=()=>{var v,C;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(C=this.keyframeResolver)==null||C.cancel()},this.createdAt=ds.now();const g={autoplay:t,delay:r,type:n,repeat:i,repeatDelay:s,repeatType:a,name:l,motionValue:c,element:h,...f},m=(h==null?void 0:h.KeyframeResolver)||R7;this.keyframeResolver=new m(o,(v,C,k)=>this.onKeyframesResolved(v,C,g,!k),l,c,h),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,r,n,i){var k,T;this.keyframeResolver=void 0;const{name:s,type:a,velocity:o,delay:l,isHandoff:c,onUpdate:h}=n;this.resolvedAt=ds.now();let f=!0;HHe(t,s,a,o)||(f=!1,(Ru.instantAnimations||!l)&&(h==null||h(k3(t,n,r))),t[0]=t[t.length-1],U6(n),n.repeat=0);const m={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>YHe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:t},x=f&&!c&&GHe(m),v=(T=(k=m.motionValue)==null?void 0:k.owner)==null?void 0:T.current;let C;if(x)try{C=new zHe({...m,element:v})}catch{C=new Dv(m)}else C=new Dv(m);C.finished.then(()=>{this.notifyFinished()}).catch(Fa),this.pendingTimeline&&(this.stopTimeline=C.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=C}get finished(){return this._animation?this.animation.finished:this._finished}then(t,r){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),MHe()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function Eee(e,t,r,n=0,i=1){const s=Array.from(e).sort((c,h)=>c.sortNodePosition(h)).indexOf(t),a=e.size,o=(a-1)*n;return typeof r=="function"?r(s,a):i===1?s*n:o-s*n}const KHe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ZHe(e){const t=KHe.exec(e);if(!t)return[,];const[,r,n,i]=t;return[`--${r??n}`,i]}function Aee(e,t,r=1){const[n,i]=ZHe(e);if(!n)return;const s=window.getComputedStyle(t).getPropertyValue(n);if(s){const a=s.trim();return qJ(a)?parseFloat(a):a}return S7(i)?Aee(i,t,r+1):i}const QHe={type:"spring",stiffness:500,damping:25,restSpeed:10},JHe=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),eUe={type:"keyframes",duration:.8},tUe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rUe=(e,{keyframes:t})=>t.length>2?eUe:up.has(e)?e.startsWith("scale")?JHe(t[1]):QHe:tUe;function Nee(e,t){if(e!=null&&e.inherit&&t){const{inherit:r,...n}=e;return{...t,...n}}return e}function M7(e,t){const r=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return r!==e?Nee(r,e):r}const nUe=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function iUe(e){for(const t in e)if(!nUe.has(t))return!0;return!1}const I7=(e,t,r,n={},i,s)=>a=>{const o=M7(n,e)||{},l=o.delay||n.delay||0;let{elapsed:c=0}=n;c=c-sa(l);const h={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:g=>{t.set(g),o.onUpdate&&o.onUpdate(g)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:s?void 0:i};iUe(o)||Object.assign(h,rUe(e,h)),h.duration&&(h.duration=sa(h.duration)),h.repeatDelay&&(h.repeatDelay=sa(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let f=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(U6(h),h.delay===0&&(f=!0)),(Ru.instantAnimations||Ru.skipAnimations||i!=null&&i.shouldSkipAnimations)&&(f=!0,U6(h),h.delay=0),h.allowFlatten=!o.type&&!o.ease,f&&!s&&t.get()!==void 0){const g=k3(h.keyframes,o);if(g!==void 0){on.update(()=>{h.onUpdate(g),h.onComplete()});return}}return o.isSync?new Dv(h):new XHe(h)};function AP(e){const t=[{},{}];return e==null||e.values.forEach((r,n)=>{t[0][n]=r.get(),t[1][n]=r.getVelocity()}),t}function O7(e,t,r,n){if(typeof t=="function"){const[i,s]=AP(n);t=t(r!==void 0?r:e.custom,i,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,s]=AP(n);t=t(r!==void 0?r:e.custom,i,s)}return t}function Yh(e,t,r){const n=e.getProps();return O7(n,t,r!==void 0?r:n.custom,e)}const Lee=new Set(["width","height","top","left","right","bottom",...cp]),NP=30,sUe=e=>!isNaN(parseFloat(e));class aUe{constructor(t,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var s;const i=ds.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((s=this.events.change)==null||s.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=r.owner}setCurrent(t){this.current=t,this.updatedAt=ds.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=sUe(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,r){this.events[t]||(this.events[t]=new k7);const n=this.events[t].add(r);return t==="change"?()=>{n(),on.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,r){this.passiveEffect=t,this.stopPassiveEffect=r}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,r=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=ds.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>NP)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,NP);return YJ(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(t){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=t(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,r;(t=this.dependents)==null||t.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function N0(e,t){return new aUe(e,t)}const q6=e=>Array.isArray(e);function oUe(e,t,r){e.hasValue(t)?e.getValue(t).set(r):e.addValue(t,N0(r))}function lUe(e){return q6(e)?e[e.length-1]||0:e}function cUe(e,t){const r=Yh(e,t);let{transitionEnd:n={},transition:i={},...s}=r||{};s={...s,...n};for(const a in s){const o=lUe(s[a]);oUe(e,a,o)}}const Pi=e=>!!(e&&e.getVelocity);function uUe(e){return!!(Pi(e)&&e.add)}function V6(e,t){const r=e.getValue("willChange");if(uUe(r))return r.add(t);if(!r&&Ru.WillChange){const n=new Ru.WillChange("auto");e.addValue("willChange",n),n.add(t)}}function B7(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const hUe="framerAppearId",Ree="data-"+B7(hUe);function Mee(e){return e.props[Ree]}function dUe({protectedKeys:e,needsAnimating:t},r){const n=e.hasOwnProperty(r)&&t[r]!==!0;return t[r]=!1,n}function Iee(e,t,{delay:r=0,transitionOverride:n,type:i}={}){let{transition:s,transitionEnd:a,...o}=t;const l=e.getDefaultTransition();s=s?Nee(s,l):l;const c=s==null?void 0:s.reduceMotion;n&&(s=n);const h=[],f=i&&e.animationState&&e.animationState.getState()[i];for(const g in o){const m=e.getValue(g,e.latestValues[g]??null),x=o[g];if(x===void 0||f&&dUe(f,g))continue;const v={delay:r,...M7(s||{},g)},C=m.get();if(C!==void 0&&!m.isAnimating()&&!Array.isArray(x)&&x===C&&!v.velocity){on.update(()=>m.set(x));continue}let k=!1;if(window.MotionHandoffAnimation){const L=Mee(e);if(L){const N=window.MotionHandoffAnimation(L,g,on);N!==null&&(v.startTime=N,k=!0)}}V6(e,g);const T=c??e.shouldReduceMotion;m.start(I7(g,m,x,T&&Lee.has(g)?{type:!1}:v,e,k));const w=m.animation;w&&h.push(w)}if(a){const g=()=>on.update(()=>{a&&cUe(e,a)});h.length?Promise.all(h).then(g):g()}return h}function W6(e,t,r={}){var l;const n=Yh(e,t,r.type==="exit"?(l=e.presenceContext)==null?void 0:l.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(i=r.transitionOverride);const s=n?()=>Promise.all(Iee(e,n,r)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:f,staggerDirection:g}=i;return fUe(e,t,c,h,f,g,r)}:()=>Promise.resolve(),{when:o}=i;if(o){const[c,h]=o==="beforeChildren"?[s,a]:[a,s];return c().then(()=>h())}else return Promise.all([s(),a(r.delay)])}function fUe(e,t,r=0,n=0,i=0,s=1,a){const o=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),o.push(W6(l,t,{...a,delay:r+(typeof n=="function"?0:n)+Eee(e.variantChildren,l,n,i,s)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}function pUe(e,t,r={}){e.notify("AnimationStart",t);let n;if(Array.isArray(t)){const i=t.map(s=>W6(e,s,r));n=Promise.all(i)}else if(typeof t=="string")n=W6(e,t,r);else{const i=typeof t=="function"?Yh(e,t,r.custom):t;n=Promise.all(Iee(e,i,r))}return n.then(()=>{e.notify("AnimationComplete",t)})}const mUe={test:e=>e==="auto",parse:e=>e},Oee=e=>t=>t.test(e),Bee=[lp,_t,Yo,Kc,$$e,z$e,mUe],LP=e=>Bee.find(Oee(e));function gUe(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||WJ(e):!0}const yUe=new Set(["brightness","contrast","saturate","opacity"]);function xUe(e){const[t,r]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[n]=r.match(_7)||[];if(!n)return e;const i=r.replace(n,"");let s=yUe.has(t)?1:0;return n!==r&&(s*=100),t+"("+s+i+")"}const bUe=/\b([a-z-]*)\(.*?\)/gu,G6={...uo,getAnimatableNone:e=>{const t=e.match(bUe);return t?t.map(xUe).join(" "):e}},Y6={...uo,getAnimatableNone:e=>{const t=uo.parse(e);return uo.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},RP={...lp,transform:Math.round},vUe={rotate:Kc,rotateX:Kc,rotateY:Kc,rotateZ:Kc,scale:ab,scaleX:ab,scaleY:ab,scaleZ:ab,skew:Kc,skewX:Kc,skewY:Kc,distance:_t,translateX:_t,translateY:_t,translateZ:_t,x:_t,y:_t,z:_t,perspective:_t,transformPerspective:_t,opacity:a1,originX:yP,originY:yP,originZ:_t},D7={borderWidth:_t,borderTopWidth:_t,borderRightWidth:_t,borderBottomWidth:_t,borderLeftWidth:_t,borderRadius:_t,borderTopLeftRadius:_t,borderTopRightRadius:_t,borderBottomRightRadius:_t,borderBottomLeftRadius:_t,width:_t,maxWidth:_t,height:_t,maxHeight:_t,top:_t,right:_t,bottom:_t,left:_t,inset:_t,insetBlock:_t,insetBlockStart:_t,insetBlockEnd:_t,insetInline:_t,insetInlineStart:_t,insetInlineEnd:_t,padding:_t,paddingTop:_t,paddingRight:_t,paddingBottom:_t,paddingLeft:_t,paddingBlock:_t,paddingBlockStart:_t,paddingBlockEnd:_t,paddingInline:_t,paddingInlineStart:_t,paddingInlineEnd:_t,margin:_t,marginTop:_t,marginRight:_t,marginBottom:_t,marginLeft:_t,marginBlock:_t,marginBlockStart:_t,marginBlockEnd:_t,marginInline:_t,marginInlineStart:_t,marginInlineEnd:_t,fontSize:_t,backgroundPositionX:_t,backgroundPositionY:_t,...vUe,zIndex:RP,fillOpacity:a1,strokeOpacity:a1,numOctaves:RP},CUe={...D7,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:G6,WebkitFilter:G6,mask:Y6,WebkitMask:Y6},Dee=e=>CUe[e],kUe=new Set([G6,Y6]);function Pee(e,t){let r=Dee(e);return kUe.has(r)||(r=uo),r.getAnimatableNone?r.getAnimatableNone(t):void 0}const TUe=new Set(["auto","none","0"]);function wUe(e,t,r){let n=0,i;for(;n<e.length&&!i;){const s=e[n];typeof s=="string"&&!TUe.has(s)&&A0(s).values.length&&(i=e[n]),n++}if(i&&r)for(const s of t)e[s]=Pee(r,i)}class SUe extends R7{constructor(t,r,n,i,s){super(t,r,n,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:r,name:n}=this;if(!r||!r.current)return;super.readKeyframes();for(let h=0;h<t.length;h++){let f=t[h];if(typeof f=="string"&&(f=f.trim(),S7(f))){const g=Aee(f,r.current);g!==void 0&&(t[h]=g),h===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!Lee.has(n)||t.length!==2)return;const[i,s]=t,a=LP(i),o=LP(s),l=gP(i),c=gP(s);if(l!==c&&hu[n]){this.needsMeasurement=!0;return}if(a!==o)if(SP(a)&&SP(o))for(let h=0;h<t.length;h++){const f=t[h];typeof f=="string"&&(t[h]=parseFloat(f))}else hu[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:r}=this,n=[];for(let i=0;i<t.length;i++)(t[i]===null||gUe(t[i]))&&n.push(i);n.length&&wUe(t,n,r)}measureInitialState(){const{element:t,unresolvedKeyframes:r,name:n}=this;if(!t||!t.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=hu[n](t.measureViewportBox(),window.getComputedStyle(t.current)),r[0]=this.measuredOrigin;const i=r[r.length-1];i!==void 0&&t.getValue(n,i).jump(i,!1)}measureEndState(){var o;const{element:t,name:r,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const i=t.getValue(r);i&&i.jump(this.measuredOrigin,!1);const s=n.length-1,a=n[s];n[s]=hu[r](t.measureViewportBox(),window.getComputedStyle(t.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(o=this.removedTransforms)!=null&&o.length&&this.removedTransforms.forEach(([l,c])=>{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function jee(e,t,r){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let n=document;const i=(r==null?void 0:r[e])??n.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(n=>n!=null)}const Fee=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function _Ue(e){return VJ(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:P7}=see(queueMicrotask,!1),Ja={x:!1,y:!1};function zee(){return Ja.x||Ja.y}function EUe(e){return e==="x"||e==="y"?Ja[e]?null:(Ja[e]=!0,()=>{Ja[e]=!1}):Ja.x||Ja.y?null:(Ja.x=Ja.y=!0,()=>{Ja.x=Ja.y=!1})}function $ee(e,t){const r=jee(e),n=new AbortController,i={passive:!0,...t,signal:n.signal};return[r,i,()=>n.abort()]}function AUe(e){return!(e.pointerType==="touch"||zee())}function NUe(e,t,r={}){const[n,i,s]=$ee(e,r);return n.forEach(a=>{let o=!1,l=!1,c;const h=()=>{a.removeEventListener("pointerleave",x)},f=C=>{c&&(c(C),c=void 0),h()},g=C=>{o=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),l&&(l=!1,f(C))},m=()=>{o=!0,window.addEventListener("pointerup",g,i),window.addEventListener("pointercancel",g,i)},x=C=>{if(C.pointerType!=="touch"){if(o){l=!0;return}f(C)}},v=C=>{if(!AUe(C))return;l=!1;const k=t(a,C);typeof k=="function"&&(c=k,a.addEventListener("pointerleave",x,i))};a.addEventListener("pointerenter",v,i),a.addEventListener("pointerdown",m,i)}),s}const Hee=(e,t)=>t?e===t?!0:Hee(e,t.parentElement):!1,j7=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,LUe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function RUe(e){return LUe.has(e.tagName)||e.isContentEditable===!0}const MUe=new Set(["INPUT","SELECT","TEXTAREA"]);function IUe(e){return MUe.has(e.tagName)||e.isContentEditable===!0}const Kb=new WeakSet;function MP(e){return t=>{t.key==="Enter"&&e(t)}}function zT(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const OUe=(e,t)=>{const r=e.currentTarget;if(!r)return;const n=MP(()=>{if(Kb.has(r))return;zT(r,"down");const i=MP(()=>{zT(r,"up")}),s=()=>zT(r,"cancel");r.addEventListener("keyup",i,t),r.addEventListener("blur",s,t)});r.addEventListener("keydown",n,t),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),t)};function IP(e){return j7(e)&&!zee()}const OP=new WeakSet;function BUe(e,t,r={}){const[n,i,s]=$ee(e,r),a=o=>{const l=o.currentTarget;if(!IP(o)||OP.has(o))return;Kb.add(l),r.stopPropagation&&OP.add(o);const c=t(l,o),h=(m,x)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),Kb.has(l)&&Kb.delete(l),IP(m)&&typeof c=="function"&&c(m,{success:x})},f=m=>{h(m,l===window||l===document||r.useGlobalTarget||Hee(l,m.target))},g=m=>{h(m,!1)};window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",g,i)};return n.forEach(o=>{(r.useGlobalTarget?window:o).addEventListener("pointerdown",a,i),_Ue(o)&&(o.addEventListener("focus",c=>OUe(c,i)),!RUe(o)&&!o.hasAttribute("tabindex")&&(o.tabIndex=0))}),s}function F7(e){return VJ(e)&&"ownerSVGElement"in e}const Zb=new WeakMap;let Zc;const Uee=(e,t,r)=>(n,i)=>i&&i[0]?i[0][e+"Size"]:F7(n)&&"getBBox"in n?n.getBBox()[t]:n[r],DUe=Uee("inline","width","offsetWidth"),PUe=Uee("block","height","offsetHeight");function jUe({target:e,borderBoxSize:t}){var r;(r=Zb.get(e))==null||r.forEach(n=>{n(e,{get width(){return DUe(e,t)},get height(){return PUe(e,t)}})})}function FUe(e){e.forEach(jUe)}function zUe(){typeof ResizeObserver>"u"||(Zc=new ResizeObserver(FUe))}function $Ue(e,t){Zc||zUe();const r=jee(e);return r.forEach(n=>{let i=Zb.get(n);i||(i=new Set,Zb.set(n,i)),i.add(t),Zc==null||Zc.observe(n)}),()=>{r.forEach(n=>{const i=Zb.get(n);i==null||i.delete(t),i!=null&&i.size||Zc==null||Zc.unobserve(n)})}}const Qb=new Set;let If;function HUe(){If=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qb.forEach(t=>t(e))},window.addEventListener("resize",If)}function UUe(e){return Qb.add(e),If||HUe(),()=>{Qb.delete(e),!Qb.size&&typeof If=="function"&&(window.removeEventListener("resize",If),If=void 0)}}function BP(e,t){return typeof e=="function"?UUe(e):$Ue(e,t)}function qUe(e){return F7(e)&&e.tagName==="svg"}const VUe=[...Bee,Kn,uo],WUe=e=>VUe.find(Oee(e)),DP=()=>({translate:0,scale:1,origin:0,originPoint:0}),Of=()=>({x:DP(),y:DP()}),PP=()=>({min:0,max:0}),li=()=>({x:PP(),y:PP()}),GUe=new WeakMap;function T3(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function o1(e){return typeof e=="string"||Array.isArray(e)}const z7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],$7=["initial",...z7];function w3(e){return T3(e.animate)||$7.some(t=>o1(e[t]))}function qee(e){return!!(w3(e)||e.variants)}function YUe(e,t,r){for(const n in t){const i=t[n],s=r[n];if(Pi(i))e.addValue(n,i);else if(Pi(s))e.addValue(n,N0(i,{owner:e}));else if(s!==i)if(e.hasValue(n)){const a=e.getValue(n);a.liveStyle===!0?a.jump(i):a.hasAnimated||a.set(i)}else{const a=e.getStaticValue(n);e.addValue(n,N0(a!==void 0?a:i,{owner:e}))}}for(const n in r)t[n]===void 0&&e.removeValue(n);return t}const X6={current:null},Vee={current:!1},XUe=typeof window<"u";function KUe(){if(Vee.current=!0,!!XUe)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>X6.current=e.matches;e.addEventListener("change",t),t()}else X6.current=!1}const jP=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Pv={};function Wee(e){Pv=e}function ZUe(){return Pv}class QUe{scrapeMotionValuesFromProps(t,r,n){return{}}constructor({parent:t,props:r,presenceContext:n,reducedMotionConfig:i,skipAnimations:s,blockInitialAnimation:a,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=R7,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=ds.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,on.render(this.render,!1,!0))};const{latestValues:c,renderState:h}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=r.initial?{...c}:{},this.renderState=h,this.parent=t,this.props=r,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=s,this.options=l,this.blockInitialAnimation=!!a,this.isControllingVariants=w3(r),this.isVariantNode=qee(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:f,...g}=this.scrapeMotionValuesFromProps(r,{},this);for(const m in g){const x=g[m];c[m]!==void 0&&Pi(x)&&x.set(c[m])}}mount(t){var r,n;if(this.hasBeenMounted)for(const i in this.initialValues)(r=this.values.get(i))==null||r.jump(this.initialValues[i]),this.latestValues[i]=this.initialValues[i];this.current=t,GUe.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,s)=>this.bindToMotionValue(s,i)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Vee.current||KUe(),this.shouldReduceMotion=X6.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Mu(this.notifyUpdate),Mu(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,r){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),r.accelerate&&_ee.has(t)&&this.current instanceof HTMLElement){const{factory:a,keyframes:o,times:l,ease:c,duration:h}=r.accelerate,f=new wee({element:this.current,name:t,keyframes:o,times:l,ease:c,duration:sa(h)}),g=a(f);this.valueSubscriptions.set(t,()=>{g(),f.cancel()});return}const n=up.has(t);n&&this.onBindTransform&&this.onBindTransform();const i=r.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&on.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;typeof window<"u"&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,t,r)),this.valueSubscriptions.set(t,()=>{i(),s&&s(),r.owner&&r.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Pv){const r=Pv[t];if(!r)continue;const{isEnabled:n,Feature:i}=r;if(!this.features[t]&&i&&n(this.props)&&(this.features[t]=new i(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):li()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,r){this.latestValues[t]=r}update(t,r){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;n<jP.length;n++){const i=jP[n];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const s="on"+i,a=t[s];a&&(this.propEventSubscriptions[i]=this.on(i,a))}this.prevMotionValues=YUe(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const r=this.getClosestVariantNode();if(r)return r.variantChildren&&r.variantChildren.add(t),()=>r.variantChildren.delete(t)}addValue(t,r){const n=this.values.get(t);r!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,r),this.values.set(t,r),this.latestValues[t]=r.get())}removeValue(t){this.values.delete(t);const r=this.valueSubscriptions.get(t);r&&(r(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,r){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return n===void 0&&r!==void 0&&(n=N0(r===null?void 0:r,{owner:this}),this.addValue(t,n)),n}readValue(t,r){let n=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return n!=null&&(typeof n=="string"&&(qJ(n)||WJ(n))?n=parseFloat(n):!WUe(n)&&uo.test(r)&&(n=Pee(t,r)),this.setBaseTarget(t,Pi(n)?n.get():n)),Pi(n)?n.get():n}setBaseTarget(t,r){this.baseTarget[t]=r}getBaseTarget(t){var s;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const a=O7(this.props,r,(s=this.presenceContext)==null?void 0:s.custom);a&&(n=a[t])}if(r&&n!==void 0)return n;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Pi(i)?i:this.initialValues[t]!==void 0&&n===void 0?void 0:this.baseTarget[t]}on(t,r){return this.events[t]||(this.events[t]=new k7),this.events[t].add(r)}notify(t,...r){this.events[t]&&this.events[t].notify(...r)}scheduleRenderMicrotask(){P7.render(this.render)}}class Gee extends QUe{constructor(){super(...arguments),this.KeyframeResolver=SUe}sortInstanceNodePosition(t,r){return t.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(t,r){const n=t.style;return n?n[r]:void 0}removeValueFromRenderState(t,{vars:r,style:n}){delete r[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Pi(t)&&(this.childSubscription=t.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Vu{constructor(t){this.isMounted=!1,this.node=t}update(){}}function Yee({top:e,left:t,right:r,bottom:n}){return{x:{min:t,max:r},y:{min:e,max:n}}}function JUe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function eqe(e,t){if(!t)return e;const r=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function $T(e){return e===void 0||e===1}function K6({scale:e,scaleX:t,scaleY:r}){return!$T(e)||!$T(t)||!$T(r)}function wh(e){return K6(e)||Xee(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Xee(e){return FP(e.x)||FP(e.y)}function FP(e){return e&&e!=="0%"}function jv(e,t,r){const n=e-r,i=t*n;return r+i}function zP(e,t,r,n,i){return i!==void 0&&(e=jv(e,i,n)),jv(e,r,n)+t}function Z6(e,t=0,r=1,n,i){e.min=zP(e.min,t,r,n,i),e.max=zP(e.max,t,r,n,i)}function Kee(e,{x:t,y:r}){Z6(e.x,t.translate,t.scale,t.originPoint),Z6(e.y,r.translate,r.scale,r.originPoint)}const $P=.999999999999,HP=1.0000000000001;function tqe(e,t,r,n=!1){var o;const i=r.length;if(!i)return;t.x=t.y=1;let s,a;for(let l=0;l<i;l++){s=r[l],a=s.projectionDelta;const{visualElement:c}=s.options;c&&c.props.style&&c.props.style.display==="contents"||(n&&s.options.layoutScroll&&s.scroll&&s!==s.root&&(Fo(e.x,-s.scroll.offset.x),Fo(e.y,-s.scroll.offset.y)),a&&(t.x*=a.x.scale,t.y*=a.y.scale,Kee(e,a)),n&&wh(s.latestValues)&&Jb(e,s.latestValues,(o=s.layout)==null?void 0:o.layoutBox))}t.x<HP&&t.x>$P&&(t.x=1),t.y<HP&&t.y>$P&&(t.y=1)}function Fo(e,t){e.min+=t,e.max+=t}function UP(e,t,r,n,i=.5){const s=gn(e.min,e.max,i);Z6(e,t,r,s,n)}function qP(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Jb(e,t,r){const n=r??e;UP(e.x,qP(t.x,n.x),t.scaleX,t.scale,t.originX),UP(e.y,qP(t.y,n.y),t.scaleY,t.scale,t.originY)}function Zee(e,t){return Yee(eqe(e.getBoundingClientRect(),t))}function rqe(e,t,r){const n=Zee(e,r),{scroll:i}=t;return i&&(Fo(n.x,i.offset.x),Fo(n.y,i.offset.y)),n}const nqe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},iqe=cp.length;function sqe(e,t,r){let n="",i=!0;for(let s=0;s<iqe;s++){const a=cp[s],o=e[a];if(o===void 0)continue;let l=!0;if(typeof o=="number")l=o===(a.startsWith("scale")?1:0);else{const c=parseFloat(o);l=a.startsWith("scale")?c===1:c===0}if(!l||r){const c=Fee(o,D7[a]);if(!l){i=!1;const h=nqe[a]||a;n+=`${h}(${c}) `}r&&(t[a]=c)}}return n=n.trim(),r?n=r(t,i?"":n):i&&(n="none"),n}function H7(e,t,r){const{style:n,vars:i,transformOrigin:s}=e;let a=!1,o=!1;for(const l in t){const c=t[l];if(up.has(l)){a=!0;continue}else if(oee(l)){i[l]=c;continue}else{const h=Fee(c,D7[l]);l.startsWith("origin")?(o=!0,s[l]=h):n[l]=h}}if(t.transform||(a||r?n.transform=sqe(t,e.transform,r):n.transform&&(n.transform="none")),o){const{originX:l="50%",originY:c="50%",originZ:h=0}=s;n.transformOrigin=`${l} ${c} ${h}`}}function Qee(e,{style:t,vars:r},n,i){const s=e.style;let a;for(a in t)s[a]=t[a];i==null||i.applyProjectionStyles(s,n);for(a in r)s.setProperty(a,r[a])}function VP(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Nm={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(_t.test(e))e=parseFloat(e);else return e;const r=VP(e,t.target.x),n=VP(e,t.target.y);return`${r}% ${n}%`}},aqe={correct:(e,{treeScale:t,projectionDelta:r})=>{const n=e,i=uo.parse(e);if(i.length>5)return n;const s=uo.createTransformer(e),a=typeof i[0]!="number"?1:0,o=r.x.scale*t.x,l=r.y.scale*t.y;i[0+a]/=o,i[1+a]/=l;const c=gn(o,l,.5);return typeof i[2+a]=="number"&&(i[2+a]/=c),typeof i[3+a]=="number"&&(i[3+a]/=c),s(i)}},Q6={borderRadius:{...Nm,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Nm,borderTopRightRadius:Nm,borderBottomLeftRadius:Nm,borderBottomRightRadius:Nm,boxShadow:aqe};function Jee(e,{layout:t,layoutId:r}){return up.has(e)||e.startsWith("origin")||(t||r!==void 0)&&(!!Q6[e]||e==="opacity")}function U7(e,t,r){var a;const n=e.style,i=t==null?void 0:t.style,s={};if(!n)return s;for(const o in n)(Pi(n[o])||i&&Pi(i[o])||Jee(o,e)||((a=r==null?void 0:r.getValue(o))==null?void 0:a.liveStyle)!==void 0)&&(s[o]=n[o]);return s}function oqe(e){return window.getComputedStyle(e)}class lqe extends Gee{constructor(){super(...arguments),this.type="html",this.renderInstance=Qee}readValueFromInstance(t,r){var n;if(up.has(r))return(n=this.projection)!=null&&n.isProjecting?j6(r):EHe(t,r);{const i=oqe(t),s=(oee(r)?i.getPropertyValue(r):i[r])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(t,{transformPagePoint:r}){return Zee(t,r)}build(t,r,n){H7(t,r,n.transformTemplate)}scrapeMotionValuesFromProps(t,r,n){return U7(t,r,n)}}const cqe={offset:"stroke-dashoffset",array:"stroke-dasharray"},uqe={offset:"strokeDashoffset",array:"strokeDasharray"};function hqe(e,t,r=1,n=0,i=!0){e.pathLength=1;const s=i?cqe:uqe;e[s.offset]=`${-n}`,e[s.array]=`${t} ${r}`}const dqe=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function ete(e,{attrX:t,attrY:r,attrScale:n,pathLength:i,pathSpacing:s=1,pathOffset:a=0,...o},l,c,h){if(H7(e,o,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:g}=e;f.transform&&(g.transform=f.transform,delete f.transform),(g.transform||f.transformOrigin)&&(g.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),g.transform&&(g.transformBox=(h==null?void 0:h.transformBox)??"fill-box",delete f.transformBox);for(const m of dqe)f[m]!==void 0&&(g[m]=f[m],delete f[m]);t!==void 0&&(f.x=t),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),i!==void 0&&hqe(f,i,s,a,!1)}const tte=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),rte=e=>typeof e=="string"&&e.toLowerCase()==="svg";function fqe(e,t,r,n){Qee(e,t,void 0,n);for(const i in t.attrs)e.setAttribute(tte.has(i)?i:B7(i),t.attrs[i])}function nte(e,t,r){const n=U7(e,t,r);for(const i in e)if(Pi(e[i])||Pi(t[i])){const s=cp.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;n[s]=e[i]}return n}class pqe extends Gee{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=li}getBaseTargetFromProps(t,r){return t[r]}readValueFromInstance(t,r){if(up.has(r)){const n=Dee(r);return n&&n.default||0}return r=tte.has(r)?r:B7(r),t.getAttribute(r)}scrapeMotionValuesFromProps(t,r,n){return nte(t,r,n)}build(t,r,n){ete(t,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(t,r,n,i){fqe(t,r,n,i)}mount(t){this.isSVGTag=rte(t.tagName),super.mount(t)}}const mqe=$7.length;function ite(e){if(!e)return;if(!e.isControllingVariants){const r=e.parent?ite(e.parent)||{}:{};return e.props.initial!==void 0&&(r.initial=e.props.initial),r}const t={};for(let r=0;r<mqe;r++){const n=$7[r],i=e.props[n];(o1(i)||i===!1)&&(t[n]=i)}return t}function ste(e,t){if(!Array.isArray(t))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}const gqe=[...z7].reverse(),yqe=z7.length;function xqe(e){return t=>Promise.all(t.map(({animation:r,options:n})=>pUe(e,r,n)))}function bqe(e){let t=xqe(e),r=WP(),n=!0,i=!1;const s=c=>(h,f)=>{var m;const g=Yh(e,f,c==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(g){const{transition:x,transitionEnd:v,...C}=g;h={...h,...C,...v}}return h};function a(c){t=c(e)}function o(c){const{props:h}=e,f=ite(e.parent)||{},g=[],m=new Set;let x={},v=1/0;for(let k=0;k<yqe;k++){const T=gqe[k],w=r[T],L=h[T]!==void 0?h[T]:f[T],N=o1(L),A=T===c?w.isActive:null;A===!1&&(v=k);let R=L===f[T]&&L!==h[T]&&N;if(R&&(n||i)&&e.manuallyAnimateOnMount&&(R=!1),w.protectedKeys={...x},!w.isActive&&A===null||!L&&!w.prevProp||T3(L)||typeof L=="boolean")continue;if(T==="exit"&&w.isActive&&A!==!0){w.prevResolvedValues&&(x={...x,...w.prevResolvedValues});continue}const P=vqe(w.prevProp,L);let q=P||T===c&&w.isActive&&!R&&N||k>v&&N,j=!1;const U=Array.isArray(L)?L:[L];let W=U.reduce(s(T),{});A===!1&&(W={});const{prevResolvedValues:J={}}=w,G={...J,...W},O=Y=>{q=!0,m.has(Y)&&(j=!0,m.delete(Y)),w.needsAnimating[Y]=!0;const ae=e.getValue(Y);ae&&(ae.liveStyle=!1)};for(const Y in G){const ae=W[Y],z=J[Y];if(x.hasOwnProperty(Y))continue;let K=!1;q6(ae)&&q6(z)?K=!ste(ae,z):K=ae!==z,K?ae!=null?O(Y):m.add(Y):ae!==void 0&&m.has(Y)?O(Y):w.protectedKeys[Y]=!0}w.prevProp=L,w.prevResolvedValues=W,w.isActive&&(x={...x,...W}),(n||i)&&e.blockInitialAnimation&&(q=!1);const D=R&&P;q&&(!D||j)&&g.push(...U.map(Y=>{const ae={type:T};if(typeof Y=="string"&&(n||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){const{parent:z}=e,K=Yh(z,Y);if(z.enteringChildren&&K){const{delayChildren:se}=K.transition||{};ae.delay=Eee(z.enteringChildren,e,se)}}return{animation:Y,options:ae}}))}if(m.size){const k={};if(typeof h.initial!="boolean"){const T=Yh(e,Array.isArray(h.initial)?h.initial[0]:h.initial);T&&T.transition&&(k.transition=T.transition)}m.forEach(T=>{const w=e.getBaseTarget(T),L=e.getValue(T);L&&(L.liveStyle=!0),k[T]=w??null}),g.push({animation:k})}let C=!!g.length;return n&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(C=!1),n=!1,i=!1,C?t(g):Promise.resolve()}function l(c,h){var g;if(r[c].isActive===h)return Promise.resolve();(g=e.variantChildren)==null||g.forEach(m=>{var x;return(x=m.animationState)==null?void 0:x.setActive(c,h)}),r[c].isActive=h;const f=o(c);for(const m in r)r[m].protectedKeys={};return f}return{animateChanges:o,setActive:l,setAnimateFunction:a,getState:()=>r,reset:()=>{r=WP(),i=!0}}}function vqe(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!ste(t,e):!1}function bh(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function WP(){return{animate:bh(!0),whileInView:bh(),whileHover:bh(),whileTap:bh(),whileDrag:bh(),whileFocus:bh(),exit:bh()}}function J6(e,t){e.min=t.min,e.max=t.max}function Qa(e,t){J6(e.x,t.x),J6(e.y,t.y)}function GP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const ate=1e-4,Cqe=1-ate,kqe=1+ate,ote=.01,Tqe=0-ote,wqe=0+ote;function fs(e){return e.max-e.min}function Sqe(e,t,r){return Math.abs(e-t)<=r}function YP(e,t,r,n=.5){e.origin=n,e.originPoint=gn(t.min,t.max,e.origin),e.scale=fs(r)/fs(t),e.translate=gn(r.min,r.max,e.origin)-e.originPoint,(e.scale>=Cqe&&e.scale<=kqe||isNaN(e.scale))&&(e.scale=1),(e.translate>=Tqe&&e.translate<=wqe||isNaN(e.translate))&&(e.translate=0)}function Tg(e,t,r,n){YP(e.x,t.x,r.x,n?n.originX:void 0),YP(e.y,t.y,r.y,n?n.originY:void 0)}function XP(e,t,r,n=0){const i=n?gn(r.min,r.max,n):r.min;e.min=i+t.min,e.max=e.min+fs(t)}function _qe(e,t,r,n){XP(e.x,t.x,r.x,n==null?void 0:n.x),XP(e.y,t.y,r.y,n==null?void 0:n.y)}function KP(e,t,r,n=0){const i=n?gn(r.min,r.max,n):r.min;e.min=t.min-i,e.max=e.min+fs(t)}function Fv(e,t,r,n){KP(e.x,t.x,r.x,n==null?void 0:n.x),KP(e.y,t.y,r.y,n==null?void 0:n.y)}function ZP(e,t,r,n,i){return e-=t,e=jv(e,1/r,n),i!==void 0&&(e=jv(e,1/i,n)),e}function Eqe(e,t=0,r=1,n=.5,i,s=e,a=e){if(Yo.test(t)&&(t=parseFloat(t),t=gn(a.min,a.max,t/100)-a.min),typeof t!="number")return;let o=gn(s.min,s.max,n);e===s&&(o-=t),e.min=ZP(e.min,t,r,o,i),e.max=ZP(e.max,t,r,o,i)}function QP(e,t,[r,n,i],s,a){Eqe(e,t[r],t[n],t[i],t.scale,s,a)}const Aqe=["x","scaleX","originX"],Nqe=["y","scaleY","originY"];function JP(e,t,r,n){QP(e.x,t,Aqe,r?r.x:void 0,n?n.x:void 0),QP(e.y,t,Nqe,r?r.y:void 0,n?n.y:void 0)}function ej(e){return e.translate===0&&e.scale===1}function lte(e){return ej(e.x)&&ej(e.y)}function tj(e,t){return e.min===t.min&&e.max===t.max}function Lqe(e,t){return tj(e.x,t.x)&&tj(e.y,t.y)}function rj(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function cte(e,t){return rj(e.x,t.x)&&rj(e.y,t.y)}function nj(e){return fs(e.x)/fs(e.y)}function ij(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Bo(e){return[e("x"),e("y")]}function Rqe(e,t,r){let n="";const i=e.x.translate/t.x,s=e.y.translate/t.y,a=(r==null?void 0:r.z)||0;if((i||s||a)&&(n=`translate3d(${i}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(n+=`scale(${1/t.x}, ${1/t.y}) `),r){const{transformPerspective:c,rotate:h,rotateX:f,rotateY:g,skewX:m,skewY:x}=r;c&&(n=`perspective(${c}px) ${n}`),h&&(n+=`rotate(${h}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),m&&(n+=`skewX(${m}deg) `),x&&(n+=`skewY(${x}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return(o!==1||l!==1)&&(n+=`scale(${o}, ${l})`),n||"none"}const ute=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Mqe=ute.length,sj=e=>typeof e=="string"?parseFloat(e):e,aj=e=>typeof e=="number"||_t.test(e);function Iqe(e,t,r,n,i,s){i?(e.opacity=gn(0,r.opacity??1,Oqe(n)),e.opacityExit=gn(t.opacity??1,0,Bqe(n))):s&&(e.opacity=gn(t.opacity??1,r.opacity??1,n));for(let a=0;a<Mqe;a++){const o=ute[a];let l=oj(t,o),c=oj(r,o);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||aj(l)===aj(c)?(e[o]=Math.max(gn(sj(l),sj(c),n),0),(Yo.test(c)||Yo.test(l))&&(e[o]+="%")):e[o]=c}(t.rotate||r.rotate)&&(e.rotate=gn(t.rotate||0,r.rotate||0,n))}function oj(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Oqe=hte(0,.5,tee),Bqe=hte(.5,.95,Fa);function hte(e,t,r){return n=>n<e?0:n>t?1:r(s1(e,t,n))}function Dqe(e,t,r){const n=Pi(e)?e:N0(e);return n.start(I7("",n,t,r)),n.animation}function l1(e,t,r,n={passive:!0}){return e.addEventListener(t,r,n),()=>e.removeEventListener(t,r)}const Pqe=(e,t)=>e.depth-t.depth;class jqe{constructor(){this.children=[],this.isDirty=!1}add(t){v7(this.children,t),this.isDirty=!0}remove(t){Mv(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Pqe),this.isDirty=!1,this.children.forEach(t)}}function Fqe(e,t){const r=ds.now(),n=({timestamp:i})=>{const s=i-r;s>=t&&(Mu(n),e(s-t))};return on.setup(n,!0),()=>Mu(n)}function e2(e){return Pi(e)?e.get():e}class zqe{constructor(){this.members=[]}add(t){v7(this.members,t);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===t||n===this.lead||n===this.prevLead)continue;const i=n.instance;(!i||i.isConnected===!1)&&!n.snapshot&&(Mv(this.members,n),n.unmount())}t.scheduleRender()}remove(t){if(Mv(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(t){var r;for(let n=this.members.indexOf(t)-1;n>=0;n--){const i=this.members[n];if(i.isPresent!==!1&&((r=i.instance)==null?void 0:r.isConnected)!==!1)return this.promote(i),!0}return!1}promote(t,r){var i;const n=this.lead;if(t!==n&&(this.prevLead=n,this.lead=t,t.show(),n)){n.updateSnapshot(),t.scheduleRender();const{layoutDependency:s}=n.options,{layoutDependency:a}=t.options;(s===void 0||s!==a)&&(t.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(t.snapshot=n.snapshot,t.snapshot.latestValues=n.animationValues||n.latestValues),(i=t.root)!=null&&i.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var r,n,i,s,a;(n=(r=t.options).onExitComplete)==null||n.call(r),(a=(i=t.resumingFrom)==null?void 0:(s=i.options).onExitComplete)==null||a.call(s)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const t2={hasAnimatedSinceResize:!0,hasEverUpdated:!1},HT=["","X","Y","Z"],$qe=1e3;let Hqe=0;function UT(e,t,r,n){const{latestValues:i}=t;i[e]&&(r[e]=i[e],t.setStaticValue(e,0),n&&(n[e]=0))}function dte(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const r=Mee(t);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:i,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(r,"transform",on,!(i||s))}const{parent:n}=e;n&&!n.hasCheckedOptimisedAppear&&dte(n)}function fte({attachResizeListener:e,defaultParent:t,measureScroll:r,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(a={},o=t==null?void 0:t()){this.id=Hqe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Vqe),this.nodes.forEach(Zqe),this.nodes.forEach(Qqe),this.nodes.forEach(Wqe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new jqe)}addEventListener(a,o){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new k7),this.eventHandlers.get(a).add(o)}notifyListeners(a,...o){const l=this.eventHandlers.get(a);l&&l.notify(...o)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=F7(a)&&!qUe(a),this.instance=a;const{layoutId:o,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),e){let h,f=0;const g=()=>this.root.updateBlockedByResize=!1;on.read(()=>{f=window.innerWidth}),e(a,()=>{const m=window.innerWidth;m!==f&&(f=m,this.root.updateBlockedByResize=!0,h&&h(),h=Fqe(g,250),t2.hasAnimatedSinceResize&&(t2.hasAnimatedSinceResize=!1,this.nodes.forEach(uj)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&c&&(o||l)&&this.addEventListener("didUpdate",({delta:h,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||c.getDefaultTransition()||nVe,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=c.getProps(),k=!this.targetLayout||!cte(this.targetLayout,m),T=!f&&g;if(this.options.layoutRoot||this.resumeFrom||T||f&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...M7(x,"layout"),onPlay:v,onComplete:C};(c.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(h,T)}else f||uj(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Mu(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Jqe),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&dte(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const f=this.path[h];f.shouldResetTransform=!0,(typeof f.latestValues.x=="string"||typeof f.latestValues.y=="string")&&(f.isLayoutDirty=!0),f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const l=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),l&&this.nodes.forEach(Yqe),this.nodes.forEach(lj);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(cj);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Xqe),this.nodes.forEach(Kqe),this.nodes.forEach(Uqe),this.nodes.forEach(qqe)):this.nodes.forEach(cj),this.clearAllSnapshots();const o=ds.now();Bi.delta=nl(0,1e3/60,o-Bi.timestamp),Bi.timestamp=o,Bi.isProcessing=!0,OT.update.process(Bi),OT.preRender.process(Bi),OT.render.process(Bi),Bi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,P7.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Gqe),this.sharedNodes.forEach(eVe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,on.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){on.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!fs(this.snapshot.measuredBox.x)&&!fs(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=li()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(o=!1),o&&this.instance){const l=n(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:l,offset:r(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!lte(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,h=c!==this.prevTransformTemplateValue;a&&this.instance&&(o||wh(this.latestValues)||h)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return a&&(l=this.removeTransform(l)),iVe(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:a}=this.options;if(!a)return li();const o=a.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(sVe))){const{scroll:h}=this.root;h&&(Fo(o.x,h.offset.x),Fo(o.y,h.offset.y))}return o}removeElementScroll(a){var l;const o=li();if(Qa(o,a),(l=this.scroll)!=null&&l.wasRoot)return o;for(let c=0;c<this.path.length;c++){const h=this.path[c],{scroll:f,options:g}=h;h!==this.root&&f&&g.layoutScroll&&(f.wasRoot&&Qa(o,a),Fo(o.x,f.offset.x),Fo(o.y,f.offset.y))}return o}applyTransform(a,o=!1,l){var h,f;const c=l||li();Qa(c,a);for(let g=0;g<this.path.length;g++){const m=this.path[g];!o&&m.options.layoutScroll&&m.scroll&&m!==m.root&&(Fo(c.x,-m.scroll.offset.x),Fo(c.y,-m.scroll.offset.y)),wh(m.latestValues)&&Jb(c,m.latestValues,(h=m.layout)==null?void 0:h.layoutBox)}return wh(this.latestValues)&&Jb(c,this.latestValues,(f=this.layout)==null?void 0:f.layoutBox),c}removeTransform(a){var l;const o=li();Qa(o,a);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!wh(h.latestValues))continue;let f;h.instance&&(K6(h.latestValues)&&h.updateSnapshot(),f=li(),Qa(f,h.measurePageBox())),JP(o,h.latestValues,(l=h.snapshot)==null?void 0:l.layoutBox,f)}return wh(this.latestValues)&&JP(o,this.latestValues),o}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Bi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var m;const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(a||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:h,layoutId:f}=this.options;if(!this.layout||!(h||f))return;this.resolvedRelativeTargetAt=Bi.timestamp;const g=this.getClosestProjectingParent();g&&this.linkedParentVersion!==g.layoutVersion&&!g.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&g&&g.layout?this.createRelativeTarget(g,this.layout.layoutBox,g.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=li(),this.targetWithTransforms=li()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),_qe(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Qa(this.target,this.layout.layoutBox),Kee(this.target,this.targetDelta)):Qa(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&g&&!!g.resumingFrom==!!this.resumingFrom&&!g.options.layoutScroll&&g.target&&this.animationProgress!==1?this.createRelativeTarget(g,this.target,g.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||K6(this.parent.latestValues)||Xee(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,o,l){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=li(),this.relativeTargetOrigin=li(),Fv(this.relativeTargetOrigin,o,l,this.options.layoutAnchor||void 0),Qa(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const a=this.getLead(),o=!!this.resumingFrom||this!==a;let l=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Bi.timestamp&&(l=!1),l)return;const{layout:c,layoutId:h}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||h))return;Qa(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,g=this.treeScale.y;tqe(this.layoutCorrected,this.treeScale,this.path,o),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=li());const{target:m}=a;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(GP(this.prevProjectionDelta.x,this.projectionDelta.x),GP(this.prevProjectionDelta.y,this.projectionDelta.y)),Tg(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==g||!ij(this.projectionDelta.x,this.prevProjectionDelta.x)||!ij(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var o;if((o=this.options.visualElement)==null||o.scheduleRender(),a){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Of(),this.projectionDelta=Of(),this.projectionDeltaWithTransform=Of()}setAnimationOrigin(a,o=!1){const l=this.snapshot,c=l?l.latestValues:{},h={...this.latestValues},f=Of();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const g=li(),m=l?l.source:void 0,x=this.layout?this.layout.source:void 0,v=m!==x,C=this.getStack(),k=!C||C.members.length<=1,T=!!(v&&!k&&this.options.crossfade===!0&&!this.path.some(rVe));this.animationProgress=0;let w;this.mixTargetDelta=L=>{const N=L/1e3;hj(f.x,a.x,N),hj(f.y,a.y,N),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Fv(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tVe(this.relativeTarget,this.relativeTargetOrigin,g,N),w&&Lqe(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=li()),Qa(w,this.relativeTarget)),v&&(this.animationValues=h,Iqe(h,c,this.latestValues,N,T,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var o,l,c;this.notifyListeners("animationStart"),(o=this.currentAnimation)==null||o.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(Mu(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=on.update(()=>{t2.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=N0(0)),this.motionValue.jump(0,!1),this.currentAnimation=Dqe(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),a.onUpdate&&a.onUpdate(h)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta($qe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:l,layout:c,latestValues:h}=a;if(!(!o||!l||!c)){if(this!==a&&this.layout&&c&&pte(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||li();const f=fs(this.layout.layoutBox.x);l.x.min=a.target.x.min,l.x.max=l.x.min+f;const g=fs(this.layout.layoutBox.y);l.y.min=a.target.y.min,l.y.max=l.y.min+g}Qa(o,l),Jb(o,h),Tg(this.projectionDeltaWithTransform,this.layoutCorrected,o,h)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new zqe),this.sharedNodes.get(a).add(o);const c=o.options.initialPromotionConfig;o.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())==null?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())==null?void 0:o.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:l}=a;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const c={};l.z&&UT("z",a,c,this.animationValues);for(let h=0;h<HT.length;h++)UT(`rotate${HT[h]}`,a,c,this.animationValues),UT(`skew${HT[h]}`,a,c,this.animationValues);a.render();for(const h in c)a.setStaticValue(h,c[h]),this.animationValues&&(this.animationValues[h]=c[h]);a.scheduleRender()}applyProjectionStyles(a,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=e2(o==null?void 0:o.pointerEvents)||"",a.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=e2(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!wh(this.latestValues)&&(a.transform=l?l({},""):"none",this.hasProjected=!1);return}a.visibility="";const h=c.animationValues||c.latestValues;this.applyTransformsToTarget();let f=Rqe(this.projectionDeltaWithTransform,this.treeScale,h);l&&(f=l(h,f)),a.transform=f;const{x:g,y:m}=this.projectionDelta;a.transformOrigin=`${g.origin*100}% ${m.origin*100}% 0`,c.animationValues?a.opacity=c===this?h.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:a.opacity=c===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const x in Q6){if(h[x]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:k}=Q6[x],T=f==="none"?h[x]:v(h[x],c);if(C){const w=C.length;for(let L=0;L<w;L++)a[C[L]]=T}else k?this.options.visualElement.renderState.vars[x]=T:a[x]=T}this.options.layoutId&&(a.pointerEvents=c===this?e2(o==null?void 0:o.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var o;return(o=a.currentAnimation)==null?void 0:o.stop()}),this.root.nodes.forEach(lj),this.root.sharedNodes.clear()}}}function Uqe(e){e.updateLayout()}function qqe(e){var r;const t=((r=e.resumeFrom)==null?void 0:r.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:i}=e.layout,{animationType:s}=e.options,a=t.source!==e.layout.source;if(s==="size")Bo(f=>{const g=a?t.measuredBox[f]:t.layoutBox[f],m=fs(g);g.min=n[f].min,g.max=g.min+m});else if(s==="x"||s==="y"){const f=s==="x"?"y":"x";J6(a?t.measuredBox[f]:t.layoutBox[f],n[f])}else pte(s,t.layoutBox,n)&&Bo(f=>{const g=a?t.measuredBox[f]:t.layoutBox[f],m=fs(n[f]);g.max=g.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[f].max=e.relativeTarget[f].min+m)});const o=Of();Tg(o,n,t.layoutBox);const l=Of();a?Tg(l,e.applyTransform(i,!0),t.measuredBox):Tg(l,n,t.layoutBox);const c=!lte(o);let h=!1;if(!e.resumeFrom){const f=e.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:m}=f;if(g&&m){const x=e.options.layoutAnchor||void 0,v=li();Fv(v,t.layoutBox,g.layoutBox,x);const C=li();Fv(C,n,m.layoutBox,x),cte(v,C)||(h=!0),f.options.layoutRoot&&(e.relativeTarget=C,e.relativeTargetOrigin=v,e.relativeParent=f)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function Vqe(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Wqe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Gqe(e){e.clearSnapshot()}function lj(e){e.clearMeasurements()}function Yqe(e){e.isLayoutDirty=!0,e.updateLayout()}function cj(e){e.isLayoutDirty=!1}function Xqe(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Kqe(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function uj(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Zqe(e){e.resolveTargetDelta()}function Qqe(e){e.calcProjection()}function Jqe(e){e.resetSkewAndRotation()}function eVe(e){e.removeLeadSnapshot()}function hj(e,t,r){e.translate=gn(t.translate,0,r),e.scale=gn(t.scale,1,r),e.origin=t.origin,e.originPoint=t.originPoint}function dj(e,t,r,n){e.min=gn(t.min,r.min,n),e.max=gn(t.max,r.max,n)}function tVe(e,t,r,n){dj(e.x,t.x,r.x,n),dj(e.y,t.y,r.y,n)}function rVe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const nVe={duration:.45,ease:[.4,0,.1,1]},fj=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pj=fj("applewebkit/")&&!fj("chrome/")?Math.round:Fa;function mj(e){e.min=pj(e.min),e.max=pj(e.max)}function iVe(e){mj(e.x),mj(e.y)}function pte(e,t,r){return e==="position"||e==="preserve-aspect"&&!Sqe(nj(t),nj(r),.2)}function sVe(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const aVe=fte({attachResizeListener:(e,t)=>l1(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),qT={current:void 0},mte=fte({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!qT.current){const e=new aVe({});e.mount(window),e.setOptions({layoutScroll:!0}),qT.current=e}return qT.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),gte=_.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function oVe(e=!0){const t=_.useContext(b7);if(t===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:i}=t,s=_.useId();_.useEffect(()=>{if(e)return i(s)},[e]);const a=_.useCallback(()=>e&&n&&n(s),[s,n,e]);return!r&&n?[!1,a]:[!0]}const yte=_.createContext({strict:!1}),gj={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let yj=!1;function lVe(){if(yj)return;const e={};for(const t in gj)e[t]={isEnabled:r=>gj[t].some(n=>!!r[n])};Wee(e),yj=!0}function xte(){return lVe(),ZUe()}function cVe(e){const t=xte();for(const r in e)t[r]={...t[r],...e[r]};Wee(t)}const uVe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function zv(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||uVe.has(e)}let bte=e=>!zv(e);function hVe(e){typeof e=="function"&&(bte=t=>t.startsWith("on")?!zv(t):e(t))}try{hVe(require("@emotion/is-prop-valid").default)}catch{}function dVe(e,t,r){const n={};for(const i in e)i==="values"&&typeof e.values=="object"||Pi(e[i])||(bte(i)||r===!0&&zv(i)||!t&&!zv(i)||e.draggable&&i.startsWith("onDrag"))&&(n[i]=e[i]);return n}const S3=_.createContext({});function fVe(e,t){if(w3(e)){const{initial:r,animate:n}=e;return{initial:r===!1||o1(r)?r:void 0,animate:o1(n)?n:void 0}}return e.inherit!==!1?t:{}}function pVe(e){const{initial:t,animate:r}=fVe(e,_.useContext(S3));return _.useMemo(()=>({initial:t,animate:r}),[xj(t),xj(r)])}function xj(e){return Array.isArray(e)?e.join(" "):e}const q7=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function vte(e,t,r){for(const n in t)!Pi(t[n])&&!Jee(n,r)&&(e[n]=t[n])}function mVe({transformTemplate:e},t){return _.useMemo(()=>{const r=q7();return H7(r,t,e),Object.assign({},r.vars,r.style)},[t])}function gVe(e,t){const r=e.style||{},n={};return vte(n,r,e),Object.assign(n,mVe(e,t)),n}function yVe(e,t){const r={},n=gVe(e,t);return e.drag&&e.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(r.tabIndex=0),r.style=n,r}const Cte=()=>({...q7(),attrs:{}});function xVe(e,t,r,n){const i=_.useMemo(()=>{const s=Cte();return ete(s,t,rte(n),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};vte(s,e.style,e),i.style={...s,...i.style}}return i}const bVe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function V7(e){return typeof e!="string"||e.includes("-")?!1:!!(bVe.indexOf(e)>-1||/[A-Z]/u.test(e))}function vVe(e,t,r,{latestValues:n},i,s=!1,a){const l=(a??V7(e)?xVe:yVe)(t,n,i,e),c=dVe(t,typeof e=="string",s),h=e!==_.Fragment?{...c,...l,ref:r}:{},{children:f}=t,g=_.useMemo(()=>Pi(f)?f.get():f,[f]);return _.createElement(e,{...h,children:g})}function CVe({scrapeMotionValuesFromProps:e,createRenderState:t},r,n,i){return{latestValues:kVe(r,n,i,e),renderState:t()}}function kVe(e,t,r,n){const i={},s=n(e,{});for(const g in s)i[g]=e2(s[g]);let{initial:a,animate:o}=e;const l=w3(e),c=qee(e);t&&c&&!l&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let h=r?r.initial===!1:!1;h=h||a===!1;const f=h?o:a;if(f&&typeof f!="boolean"&&!T3(f)){const g=Array.isArray(f)?f:[f];for(let m=0;m<g.length;m++){const x=O7(e,g[m]);if(x){const{transitionEnd:v,transition:C,...k}=x;for(const T in k){let w=k[T];if(Array.isArray(w)){const L=h?w.length-1:0;w=w[L]}w!==null&&(i[T]=w)}for(const T in v)i[T]=v[T]}}}return i}const kte=e=>(t,r)=>{const n=_.useContext(S3),i=_.useContext(b7),s=()=>CVe(e,t,n,i);return r?s():b$e(s)},TVe=kte({scrapeMotionValuesFromProps:U7,createRenderState:q7}),wVe=kte({scrapeMotionValuesFromProps:nte,createRenderState:Cte}),SVe=Symbol.for("motionComponentSymbol");function _Ve(e,t,r){const n=_.useRef(r);_.useInsertionEffect(()=>{n.current=r});const i=_.useRef(null);return _.useCallback(s=>{var o;s&&((o=e.onMount)==null||o.call(e,s));const a=n.current;if(typeof a=="function")if(s){const l=a(s);typeof l=="function"&&(i.current=l)}else i.current?(i.current(),i.current=null):a(s);else a&&(a.current=s);t&&(s?t.mount(s):t.unmount())},[t])}const Tte=_.createContext({});function wf(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function EVe(e,t,r,n,i,s){var w,L;const{visualElement:a}=_.useContext(S3),o=_.useContext(yte),l=_.useContext(b7),c=_.useContext(gte),h=c.reducedMotion,f=c.skipAnimations,g=_.useRef(null),m=_.useRef(!1);n=n||o.renderer,!g.current&&n&&(g.current=n(e,{visualState:t,parent:a,props:r,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:f,isSVG:s}),m.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const x=g.current,v=_.useContext(Tte);x&&!x.projection&&i&&(x.type==="html"||x.type==="svg")&&AVe(g.current,r,i,v);const C=_.useRef(!1);_.useInsertionEffect(()=>{x&&C.current&&x.update(r,l)});const k=r[Ree],T=_.useRef(!!k&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,k))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,k)));return C$e(()=>{m.current=!0,x&&(C.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),T.current&&x.animationState&&x.animationState.animateChanges())}),_.useEffect(()=>{x&&(!T.current&&x.animationState&&x.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{var N;(N=window.MotionHandoffMarkAsComplete)==null||N.call(window,k)}),T.current=!1),x.enteringChildren=void 0)}),x}function AVe(e,t,r,n){const{layoutId:i,layout:s,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutAnchor:h,layoutCrossfade:f}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:wte(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!a||o&&wf(o),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:l,layoutRoot:c,layoutAnchor:h})}function wte(e){if(e)return e.options.allowProjection!==!1?e.projection:wte(e.parent)}function VT(e,{forwardMotionProps:t=!1,type:r}={},n,i){n&&cVe(n);const s=r?r==="svg":V7(e),a=s?wVe:TVe;function o(c,h){let f;const g={..._.useContext(gte),...c,layoutId:NVe(c)},{isStatic:m}=g,x=pVe(c),v=a(c,m);if(!m&&typeof window<"u"){LVe();const C=RVe(g);f=C.MeasureLayout,x.visualElement=EVe(e,v,g,i,C.ProjectionNode,s)}return p.jsxs(S3.Provider,{value:x,children:[f&&x.visualElement?p.jsx(f,{visualElement:x.visualElement,...g}):null,vVe(e,c,_Ve(v,x.visualElement,h),v,m,t,s)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=_.forwardRef(o);return l[SVe]=e,l}function NVe({layoutId:e}){const t=_.useContext(UJ).id;return t&&e!==void 0?t+"-"+e:e}function LVe(e,t){_.useContext(yte).strict}function RVe(e){const t=xte(),{drag:r,layout:n}=t;if(!r&&!n)return{};const i={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function MVe(e,t){if(typeof Proxy>"u")return VT;const r=new Map,n=(s,a)=>VT(s,a,e,t),i=(s,a)=>n(s,a);return new Proxy(i,{get:(s,a)=>a==="create"?n:(r.has(a)||r.set(a,VT(a,void 0,e,t)),r.get(a))})}const IVe=(e,t)=>t.isSVG??V7(e)?new pqe(t):new lqe(t,{allowProjection:e!==_.Fragment});class OVe extends Vu{constructor(t){super(t),t.animationState||(t.animationState=bqe(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();T3(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:r}=this.node.prevProps||{};t!==r&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let BVe=0;class DVe extends Vu{constructor(){super(...arguments),this.id=BVe++,this.isExitComplete=!1}update(){var s;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;if(t&&n===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Yh(this.node,a,o);if(l){const{transition:c,transitionEnd:h,...f}=l;for(const g in f)(s=this.node.getValue(g))==null||s.jump(f[g])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);r&&!t&&i.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:t,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const PVe={animation:{Feature:OVe},exit:{Feature:DVe}};function G1(e){return{point:{x:e.pageX,y:e.pageY}}}const jVe=e=>t=>j7(t)&&e(t,G1(t));function wg(e,t,r,n){return l1(e,t,jVe(r),n)}const Ste=({current:e})=>e?e.ownerDocument.defaultView:null,bj=(e,t)=>Math.abs(e-t);function FVe(e,t){const r=bj(e.x,t.x),n=bj(e.y,t.y);return Math.sqrt(r**2+n**2)}const vj=new Set(["auto","scroll"]);class _te{constructor(t,r,{transformPagePoint:n,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ob(this.lastRawMoveEventInfo,this.transformPagePoint));const m=WT(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,v=FVe(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!v)return;const{point:C}=m,{timestamp:k}=Bi;this.history.push({...C,timestamp:k});const{onStart:T,onMove:w}=this.handlers;x||(T&&T(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,m)},this.handlePointerMove=(m,x)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=ob(x,this.transformPagePoint),on.update(this.updatePoint,!0)},this.handlePointerUp=(m,x)=>{this.end();const{onEnd:v,onSessionEnd:C,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const T=WT(m.type==="pointercancel"?this.lastMoveEventInfo:ob(x,this.transformPagePoint),this.history);this.startEvent&&v&&v(m,T),C&&C(m,T)},!j7(t))return;this.dragSnapToOrigin=s,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=i||window;const l=G1(t),c=ob(l,this.transformPagePoint),{point:h}=c,{timestamp:f}=Bi;this.history=[{...h,timestamp:f}];const{onSessionStart:g}=r;g&&g(t,WT(c,this.history)),this.removeListeners=q1(wg(this.contextWindow,"pointermove",this.handlePointerMove),wg(this.contextWindow,"pointerup",this.handlePointerUp),wg(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(t){let r=t.parentElement;for(;r;){const n=getComputedStyle(r);(vj.has(n.overflowX)||vj.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const r=this.scrollPositions.get(t);if(!r)return;const n=t===window,i=n?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s={x:i.x-r.x,y:i.y-r.y};s.x===0&&s.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(t,i),on.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Mu(this.updatePoint)}}function ob(e,t){return t?{point:t(e.point)}:e}function Cj(e,t){return{x:e.x-t.x,y:e.y-t.y}}function WT({point:e},t){return{point:e,delta:Cj(e,Ete(t)),offset:Cj(e,zVe(t)),velocity:$Ve(t,.1)}}function zVe(e){return e[0]}function Ete(e){return e[e.length-1]}function $Ve(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null;const i=Ete(e);for(;r>=0&&(n=e[r],!(i.timestamp-n.timestamp>sa(t)));)r--;if(!n)return{x:0,y:0};n===e[0]&&e.length>2&&i.timestamp-n.timestamp>sa(t)*2&&(n=e[1]);const s=Pa(i.timestamp-n.timestamp);if(s===0)return{x:0,y:0};const a={x:(i.x-n.x)/s,y:(i.y-n.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function HVe(e,{min:t,max:r},n){return t!==void 0&&e<t?e=n?gn(t,e,n.min):Math.max(e,t):r!==void 0&&e>r&&(e=n?gn(r,e,n.max):Math.min(e,r)),e}function kj(e,t,r){return{min:t!==void 0?e.min+t:void 0,max:r!==void 0?e.max+r-(e.max-e.min):void 0}}function UVe(e,{top:t,left:r,bottom:n,right:i}){return{x:kj(e.x,r,i),y:kj(e.y,t,n)}}function Tj(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([r,n]=[n,r]),{min:r,max:n}}function qVe(e,t){return{x:Tj(e.x,t.x),y:Tj(e.y,t.y)}}function VVe(e,t){let r=.5;const n=fs(e),i=fs(t);return i>n?r=s1(t.min,t.max-n,e.min):n>i&&(r=s1(e.min,e.max-i,t.min)),nl(0,1,r)}function WVe(e,t){const r={};return t.min!==void 0&&(r.min=t.min-e.min),t.max!==void 0&&(r.max=t.max-e.min),r}const e_=.35;function GVe(e=e_){return e===!1?e=0:e===!0&&(e=e_),{x:wj(e,"left","right"),y:wj(e,"top","bottom")}}function wj(e,t,r){return{min:Sj(e,t),max:Sj(e,r)}}function Sj(e,t){return typeof e=="number"?e:e[t]||0}const YVe=new WeakMap;class XVe{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=li(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=f=>{r&&this.snapToCursor(G1(f).point),this.stopAnimation()},a=(f,g)=>{const{drag:m,dragPropagation:x,onDragStart:v}=this.getProps();if(m&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=EUe(m),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bo(k=>{let T=this.getAxisMotionValue(k).get()||0;if(Yo.test(T)){const{projection:w}=this.visualElement;if(w&&w.layout){const L=w.layout.layoutBox[k];L&&(T=fs(L)*(parseFloat(T)/100))}}this.originPoint[k]=T}),v&&on.update(()=>v(f,g),!1,!0),V6(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},o=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:m,dragDirectionLock:x,onDirectionLock:v,onDrag:C}=this.getProps();if(!m&&!this.openDragLock)return;const{offset:k}=g;if(x&&this.currentDirection===null){this.currentDirection=ZVe(k),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",g.point,k),this.updateAxis("y",g.point,k),this.visualElement.render(),C&&on.update(()=>C(f,g),!1,!0)},l=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g,this.stop(f,g),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new _te(t,{onSessionStart:s,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:n,contextWindow:Ste(this.visualElement),element:this.visualElement.current})}stop(t,r){const n=t||this.latestPointerEvent,i=r||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!n)return;const{velocity:a}=i;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&on.postRender(()=>o(n,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:r}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,r,n){const{drag:i}=this.getProps();if(!n||!lb(t,i,this.currentDirection))return;const s=this.getAxisMotionValue(t);let a=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(a=HVe(a,this.constraints[t],this.elastic[t])),s.set(a)}resolveConstraints(){var s;const{dragConstraints:t,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,i=this.constraints;t&&wf(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&n?this.constraints=UVe(n.layoutBox,t):this.constraints=!1,this.elastic=GVe(r),i!==this.constraints&&!wf(t)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bo(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=WVe(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!wf(t))return!1;const n=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=rqe(n,i.root,this.visualElement.getTransformPagePoint());let a=qVe(i.layout.layoutBox,s);if(r){const o=r(JUe(a));this.hasMutatedConstraints=!!o,o&&(a=Yee(o))}return a}startAnimation(t){const{drag:r,dragMomentum:n,dragElastic:i,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},c=Bo(h=>{if(!lb(h,r,this.currentDirection))return;let f=l&&l[h]||{};(a===!0||a===h)&&(f={min:0,max:0});const g=i?200:1e6,m=i?40:1e7,x={type:"inertia",velocity:n?t[h]:0,bounceStiffness:g,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(h,x)});return Promise.all(c).then(o)}startAxisValueAnimation(t,r){const n=this.getAxisMotionValue(t);return V6(this.visualElement,t),n.start(I7(t,n,0,r,this.visualElement,!1))}stopAnimation(){Bo(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const r=`_drag${t.toUpperCase()}`,n=this.visualElement.getProps(),i=n[r];return i||this.visualElement.getValue(t,(n.initial?n.initial[t]:void 0)||0)}snapToCursor(t){Bo(r=>{const{drag:n}=this.getProps();if(!lb(r,n,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(r);if(i&&i.layout){const{min:a,max:o}=i.layout.layoutBox[r],l=s.get()||0;s.set(t[r]-gn(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!wf(r)||!n||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Bo(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();i[a]=VVe({min:l,max:l},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bo(a=>{if(!lb(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:c}=this.constraints[a];o.set(gn(l,c,i[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;YVe.set(this.visualElement,this);const t=this.visualElement.current,r=wg(t,"pointerdown",c=>{const{drag:h,dragListener:f=!0}=this.getProps(),g=c.target,m=g!==t&&IUe(g);h&&f&&!m&&this.start(c)});let n;const i=()=>{const{dragConstraints:c}=this.getProps();wf(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),n||(n=KVe(t,c.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,a=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),on.read(i);const o=l1(window,"resize",()=>this.scalePositionWithinConstraints()),l=s.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Bo(f=>{const g=this.getAxisMotionValue(f);g&&(this.originPoint[f]+=c[f].translate,g.set(g.get()+c[f].translate))}),this.visualElement.render())}));return()=>{o(),r(),a(),l&&l(),n&&n()}}getProps(){const t=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:a=e_,dragMomentum:o=!0}=t;return{...t,drag:r,dragDirectionLock:n,dragPropagation:i,dragConstraints:s,dragElastic:a,dragMomentum:o}}}function _j(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function KVe(e,t,r){const n=BP(e,_j(r)),i=BP(t,_j(r));return()=>{n(),i()}}function lb(e,t,r){return(t===!0||t===e)&&(r===null||r===e)}function ZVe(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}class QVe extends Vu{constructor(t){super(t),this.removeGroupControls=Fa,this.removeListeners=Fa,this.controls=new XVe(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Fa}update(){const{dragControls:t}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};t!==r&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const GT=e=>(t,r)=>{e&&on.update(()=>e(t,r),!1,!0)};class JVe extends Vu{constructor(){super(...arguments),this.removePointerDownListener=Fa}onPointerDown(t){this.session=new _te(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ste(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:r,onPan:n,onPanEnd:i}=this.node.getProps();return{onSessionStart:GT(t),onStart:GT(r),onMove:GT(n),onEnd:(s,a)=>{delete this.session,i&&on.postRender(()=>i(s,a))}}}mount(){this.removePointerDownListener=wg(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let YT=!1;class eWe extends _.Component{componentDidMount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n,layoutId:i}=this.props,{projection:s}=t;s&&(r.group&&r.group.add(s),n&&n.register&&i&&n.register(s),YT&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),t2.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:r,visualElement:n,drag:i,isPresent:s}=this.props,{projection:a}=n;return a&&(a.isPresent=s,t.layoutDependency!==r&&a.setOptions({...a.options,layoutDependency:r}),YT=!0,i||t.layoutDependency!==r||r===void 0||t.isPresent!==s?a.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?a.promote():a.relegate()||on.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:r}=this.props,{projection:n}=t;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),P7.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:i}=t;YT=!0,i&&(i.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(i),n&&n.deregister&&n.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Ate(e){const[t,r]=oVe(),n=_.useContext(UJ);return p.jsx(eWe,{...e,layoutGroup:n,switchLayoutGroup:_.useContext(Tte),isPresent:t,safeToRemove:r})}const tWe={pan:{Feature:JVe},drag:{Feature:QVe,ProjectionNode:mte,MeasureLayout:Ate}};function Ej(e,t,r){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover",r==="Start");const i="onHover"+r,s=n[i];s&&on.postRender(()=>s(t,G1(t)))}class rWe extends Vu{mount(){const{current:t}=this.node;t&&(this.unmount=NUe(t,(r,n)=>(Ej(this.node,n,"Start"),i=>Ej(this.node,i,"End"))))}unmount(){}}class nWe extends Vu{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=q1(l1(this.node.current,"focus",()=>this.onFocus()),l1(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Aj(e,t,r){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap",r==="Start");const i="onTap"+(r==="End"?"":r),s=n[i];s&&on.postRender(()=>s(t,G1(t)))}class iWe extends Vu{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=BUe(t,(i,s)=>(Aj(this.node,s,"Start"),(a,{success:o})=>Aj(this.node,a,o?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const t_=new WeakMap,XT=new WeakMap,sWe=e=>{const t=t_.get(e.target);t&&t(e)},aWe=e=>{e.forEach(sWe)};function oWe({root:e,...t}){const r=e||document;XT.has(r)||XT.set(r,{});const n=XT.get(r),i=JSON.stringify(t);return n[i]||(n[i]=new IntersectionObserver(aWe,{root:e,...t})),n[i]}function lWe(e,t,r){const n=oWe(t);return t_.set(e,r),n.observe(e),()=>{t_.delete(e),n.unobserve(e)}}const cWe={some:0,all:1};class uWe extends Vu{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:t={}}=this.node.getProps(),{root:r,margin:n,amount:i="some",once:s}=t,a={root:r?r.current:void 0,rootMargin:n,threshold:typeof i=="number"?i:cWe[i]},o=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,s&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),m=h?f:g;m&&m(c)};this.stopObserver=lWe(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:r}=this.node;["amount","margin","root"].some(hWe(t,r))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function hWe({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}const dWe={inView:{Feature:uWe},tap:{Feature:iWe},focus:{Feature:nWe},hover:{Feature:rWe}},fWe={layout:{ProjectionNode:mte,MeasureLayout:Ate}},pWe={...PVe,...dWe,...tWe,...fWe},mWe=MVe(pWe,IVe),Nj=new Map,gWe=e=>{let t=Nj.get(e);return t||(t=mWe.create(e),Nj.set(e,t)),t},yWe=({children:e,as:t="p",className:r,duration:n=2,spread:i=2})=>{const s=gWe(t),a=_.useMemo(()=>((e==null?void 0:e.length)??0)*i,[e,i]);return p.jsx(s,{animate:{backgroundPosition:"0% center"},className:kn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",r),initial:{backgroundPosition:"100% center"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{duration:n,ease:"linear",repeat:Number.POSITIVE_INFINITY},children:e})},Nte=_.memo(yWe),Lte=_.createContext(null),xWe=()=>{const e=_.useContext(Lte);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},bWe=1e3,vWe=1e3,Rte=_.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:i,duration:s,children:a,...o})=>{const l=n??t,c=n===!1,[h,f]=oM({defaultProp:l,onChange:i,prop:r}),[g,m]=oM({defaultProp:void 0,prop:s}),x=_.useRef(t),[v,C]=_.useState(!1),k=_.useRef(null);_.useEffect(()=>{t?(x.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(m(Math.ceil((Date.now()-k.current)/vWe)),k.current=null)},[t,m]),_.useEffect(()=>{t&&!h&&!c&&f(!0)},[t,h,f,c]),_.useEffect(()=>{if(x.current&&!t&&h&&!v){const L=setTimeout(()=>{f(!1),C(!0)},bWe);return()=>clearTimeout(L)}},[t,h,f,v]);const T=_.useCallback(L=>{f(L)},[f]),w=_.useMemo(()=>({duration:g,isOpen:h,isStreaming:t,setIsOpen:f}),[g,h,t,f]);return p.jsx(Lte.Provider,{value:w,children:p.jsx(H_,{className:kn("not-prose mb-4",e),onOpenChange:T,open:h,...o,children:a})})}),CWe=(e,t)=>e||t===0?p.jsx(Nte,{duration:1,children:"Thinking..."}):t===void 0?p.jsx("p",{children:"Thought for a few seconds"}):p.jsxs("p",{children:["Thought for ",t," seconds"]}),Mte=_.memo(({className:e,children:t,getThinkingMessage:r=CWe,...n})=>{const{isStreaming:i,isOpen:s,duration:a}=xWe();return p.jsx(U_,{className:kn("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??p.jsxs(p.Fragment,{children:[p.jsx(Lae,{className:"size-4"}),r(i,a),p.jsx(Bu,{className:kn("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),kWe={cjk:v1,code:pE,math:ME,mermaid:B8},Ite=_.memo(({className:e,children:t,...r})=>p.jsx(q_,{className:kn("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...r,children:p.jsx(Ho,{plugins:kWe,children:t})}));Rte.displayName="Reasoning";Mte.displayName="ReasoningTrigger";Ite.displayName="ReasoningContent";const Ote=({className:e,from:t,...r})=>p.jsx("div",{className:kn("group flex w-full max-w-[95%] flex-col gap-2",t==="user"?"is-user ml-auto items-end":"is-assistant items-start",e),...r}),Bte=({children:e,className:t,...r})=>p.jsx("div",{className:kn("is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...r,children:e});_.createContext(null);const TWe={cjk:v1,code:pE,math:ME,mermaid:B8},Dte=_.memo(({className:e,...t})=>p.jsx(Ho,{className:kn("size-full font-sans text-[17px] leading-[1.72] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>p+p]:mt-4",e),plugins:TWe,...t}),(e,t)=>e.children===t.children&&t.isAnimating===e.isAnimating);Dte.displayName="MessageResponse";const r2=_.memo(function({role:t,content:r}){const n=t==="user",i=r.startsWith("✗"),s=n?r.replace(/\n{3,}/g,`
1408
+
1409
+ `):r;return p.jsx(Ote,{from:t,children:p.jsx(Bte,{children:n?p.jsx("div",{className:"whitespace-pre-wrap break-words text-[17px] leading-[1.72]",children:s}):i?p.jsxs("div",{className:"flex items-center gap-2 text-[17px] leading-[1.72] text-destructive",children:[p.jsx(D0,{size:14,className:"shrink-0"}),p.jsx("span",{children:r.replace(/^\u2717\s*/,"")})]}):p.jsx(Dte,{children:r})})})});r2.displayName="ChatMessage";const wWe=[{icon:p.jsx(qh,{size:12}),labelZh:"写下一章",labelEn:"Write next",labelVi:"Viết chương tiếp theo",commandZh:"写下一章",commandEn:"write next",requestedIntent:"write_next"},{icon:p.jsx(Jv,{size:12}),labelZh:"审计",labelEn:"Audit",labelVi:"Kiểm tra",commandZh:"审计",commandEn:"audit"},{icon:p.jsx(noe,{size:12}),labelZh:"导出",labelEn:"Export",labelVi:"Xuất bản thảo",commandZh:"导出全书",commandEn:"export book"},{icon:p.jsx(m_,{size:12}),labelZh:"市场雷达",labelEn:"Market radar",labelVi:"Radar thị trường",commandZh:"扫描市场趋势",commandEn:"scan market trends"}];function SWe({onAction:e,disabled:t,isZh:r}){return p.jsx("div",{className:"flex gap-2 overflow-x-auto px-1 py-1",children:wWe.map(n=>{const i=V(n.labelZh,n.labelEn,n.labelVi),s=r?n.commandZh:n.commandEn;return p.jsxs("button",{onClick:()=>e(s,n.requestedIntent),disabled:t,className:"shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary/50 border border-border/30 text-xs font-medium text-muted-foreground hover:text-primary hover:border-primary/30 hover:bg-primary/5 transition-all disabled:opacity-40 disabled:pointer-events-none group",children:[p.jsx("span",{className:"group-hover:scale-110 transition-transform",children:n.icon}),i]},i)})})}const Pte="inkos:studio:tool-details-default-open";function Lj(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function _We(e){return(e==null?void 0:e.getItem(Pte))!=="false"}const r_=f_()(e=>({toolDetailsDefaultOpen:_We(Lj()),setToolDetailsDefaultOpen:t=>{var r;try{(r=Lj())==null||r.setItem(Pte,String(t))}catch{}e({toolDetailsDefaultOpen:t})}}));var Pr;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pr||(Pr={}));var Rj;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Rj||(Rj={}));const Nt=Pr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),tu=e=>{switch(typeof e){case"undefined":return Nt.undefined;case"string":return Nt.string;case"number":return Number.isNaN(e)?Nt.nan:Nt.number;case"boolean":return Nt.boolean;case"function":return Nt.function;case"bigint":return Nt.bigint;case"symbol":return Nt.symbol;case"object":return Array.isArray(e)?Nt.array:e===null?Nt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Nt.promise:typeof Map<"u"&&e instanceof Map?Nt.map:typeof Set<"u"&&e instanceof Set?Nt.set:typeof Date<"u"&&e instanceof Date?Nt.date:Nt.object;default:return Nt.unknown}},lt=Pr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class sc extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),n}static assert(t){if(!(t instanceof sc))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}sc.create=e=>new sc(e);const n_=(e,t)=>{let r;switch(e.code){case lt.invalid_type:e.received===Nt.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case lt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Pr.jsonStringifyReplacer)}`;break;case lt.unrecognized_keys:r=`Unrecognized key(s) in object: ${Pr.joinValues(e.keys,", ")}`;break;case lt.invalid_union:r="Invalid input";break;case lt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Pr.joinValues(e.options)}`;break;case lt.invalid_enum_value:r=`Invalid enum value. Expected ${Pr.joinValues(e.options)}, received '${e.received}'`;break;case lt.invalid_arguments:r="Invalid function arguments";break;case lt.invalid_return_type:r="Invalid function return type";break;case lt.invalid_date:r="Invalid date";break;case lt.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Pr.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case lt.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case lt.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case lt.custom:r="Invalid input";break;case lt.invalid_intersection_types:r="Intersection results could not be merged";break;case lt.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case lt.not_finite:r="Number must be finite";break;default:r=t.defaultError,Pr.assertNever(e)}return{message:r}};let EWe=n_;function AWe(){return EWe}const NWe=e=>{const{data:t,path:r,errorMaps:n,issueData:i}=e,s=[...r,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:t,defaultError:o}).message;return{...i,path:s,message:o}};function xt(e,t){const r=AWe(),n=NWe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===n_?void 0:n_].filter(i=>!!i)});e.common.issues.push(n)}class ha{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const i of r){if(i.status==="aborted")return sr;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const i of r){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return ha.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const i of r){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return sr;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:t.value,value:n}}}const sr=Object.freeze({status:"aborted"}),Xm=e=>({status:"dirty",value:e}),Ua=e=>({status:"valid",value:e}),Mj=e=>e.status==="aborted",Ij=e=>e.status==="dirty",L0=e=>e.status==="valid",$v=e=>typeof Promise<"u"&&e instanceof Promise;var Dt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Dt||(Dt={}));class Iu{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Oj=(e,t)=>{if(L0(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new sc(e.common.issues);return this._error=r,this._error}}};function Cr(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,o)=>{const{message:l}=e;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:i}}class Ir{get description(){return this._def.description}_getType(t){return tu(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:tu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ha,ctx:{common:t.parent.common,data:t.data,parsedType:tu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if($v(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)},i=this._parseSync({data:t,path:n.path,parent:n});return Oj(n,i)}"~validate"(t){var n,i;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:r});return L0(s)?{value:s.value}:{issues:r.common.issues}}catch(s){(i=(n=s==null?void 0:s.message)==null?void 0:n.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(s=>L0(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(t,r){const n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:tu(t)},i=this._parse({data:t,path:n.path,parent:n}),s=await($v(i)?i:Promise.resolve(i));return Oj(n,s)}refine(t,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{const a=t(i),o=()=>s.addIssue({code:lt.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new I0({schema:this,typeName:ar.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return bu.create(this,this._def)}nullable(){return O0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xo.create(this)}promise(){return Vv.create(this,this._def)}or(t){return Uv.create([this,t],this._def)}and(t){return qv.create(this,t,this._def)}transform(t){return new I0({...Cr(this._def),schema:this,typeName:ar.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new a_({...Cr(this._def),innerType:this,defaultValue:r,typeName:ar.ZodDefault})}brand(){return new QWe({typeName:ar.ZodBranded,type:this,...Cr(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new o_({...Cr(this._def),innerType:this,catchValue:r,typeName:ar.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return W7.create(this,t)}readonly(){return l_.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LWe=/^c[^\s-]{8,}$/i,RWe=/^[0-9a-z]+$/,MWe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,IWe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,OWe=/^[a-z0-9_-]{21}$/i,BWe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,DWe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,PWe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jWe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let KT;const FWe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,zWe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$We=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,HWe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,UWe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qWe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jte="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",VWe=new RegExp(`^${jte}$`);function Fte(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function WWe(e){return new RegExp(`^${Fte(e)}$`)}function GWe(e){let t=`${jte}T${Fte(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function YWe(e,t){return!!((t==="v4"||!t)&&FWe.test(e)||(t==="v6"||!t)&&$We.test(e))}function XWe(e,t){if(!BWe.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function KWe(e,t){return!!((t==="v4"||!t)&&zWe.test(e)||(t==="v6"||!t)&&HWe.test(e))}class du extends Ir{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Nt.string){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.string,received:s.parsedType}),sr}const n=new ha;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=t.data.length>s.value,o=t.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(t,i),a?xt(i,{code:lt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&xt(i,{code:lt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")PWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"email",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")KT||(KT=new RegExp(jWe,"u")),KT.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"emoji",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")IWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"uuid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")OWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"nanoid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")LWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cuid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")RWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cuid2",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")MWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"ulid",code:lt.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),xt(i,{validation:"url",code:lt.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"regex",code:lt.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?GWe(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?VWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?WWe(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?DWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"duration",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?YWe(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"ip",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?XWe(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"jwt",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?KWe(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"cidr",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?UWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"base64",code:lt.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?qWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xt(i,{validation:"base64url",code:lt.invalid_string,message:s.message}),n.dirty()):Pr.assertNever(s);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:lt.invalid_string,...Dt.errToObj(n)})}_addCheck(t){return new du({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Dt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Dt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Dt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Dt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Dt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Dt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Dt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Dt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Dt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Dt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Dt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Dt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Dt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Dt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Dt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Dt.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Dt.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r==null?void 0:r.position,...Dt.errToObj(r==null?void 0:r.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Dt.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Dt.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Dt.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Dt.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Dt.errToObj(r)})}nonempty(t){return this.min(1,Dt.errToObj(t))}trim(){return new du({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new du({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new du({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}du.create=e=>new du({checks:[],typeName:ar.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Cr(e)});function ZWe(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}class R0 extends Ir{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Nt.number){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.number,received:s.parsedType}),sr}let n;const i=new ha;for(const s of this._def.checks)s.kind==="int"?Pr.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?ZWe(t.data,s.value)!==0&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_finite,message:s.message}),i.dirty()):Pr.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Dt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Dt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Dt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Dt.toString(r))}setLimit(t,r,n,i){return new R0({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(t){return new R0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Dt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Dt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Dt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Dt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Dt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Dt.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Dt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Dt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Dt.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Pr.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}}R0.create=e=>new R0({checks:[],typeName:ar.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Cr(e)});class c1 extends Ir{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Nt.bigint)return this._getInvalidInput(t);let n;const i=new ha;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),xt(n,{code:lt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Pr.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return xt(r,{code:lt.invalid_type,expected:Nt.bigint,received:r.parsedType}),sr}gte(t,r){return this.setLimit("min",t,!0,Dt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Dt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Dt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Dt.toString(r))}setLimit(t,r,n,i){return new c1({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(t){return new c1({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Dt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Dt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Dt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Dt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Dt.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}c1.create=e=>new c1({checks:[],typeName:ar.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Cr(e)});class Bj extends Ir{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Nt.boolean){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.boolean,received:n.parsedType}),sr}return Ua(t.data)}}Bj.create=e=>new Bj({typeName:ar.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Cr(e)});class Hv extends Ir{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Nt.date){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_type,expected:Nt.date,received:s.parsedType}),sr}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return xt(s,{code:lt.invalid_date}),sr}const n=new ha;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),xt(i,{code:lt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Pr.assertNever(s);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Hv({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Dt.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Dt.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}Hv.create=e=>new Hv({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:ar.ZodDate,...Cr(e)});class Dj extends Ir{_parse(t){if(this._getType(t)!==Nt.symbol){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.symbol,received:n.parsedType}),sr}return Ua(t.data)}}Dj.create=e=>new Dj({typeName:ar.ZodSymbol,...Cr(e)});class Pj extends Ir{_parse(t){if(this._getType(t)!==Nt.undefined){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.undefined,received:n.parsedType}),sr}return Ua(t.data)}}Pj.create=e=>new Pj({typeName:ar.ZodUndefined,...Cr(e)});class jj extends Ir{_parse(t){if(this._getType(t)!==Nt.null){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.null,received:n.parsedType}),sr}return Ua(t.data)}}jj.create=e=>new jj({typeName:ar.ZodNull,...Cr(e)});class Fj extends Ir{constructor(){super(...arguments),this._any=!0}_parse(t){return Ua(t.data)}}Fj.create=e=>new Fj({typeName:ar.ZodAny,...Cr(e)});class zj extends Ir{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ua(t.data)}}zj.create=e=>new zj({typeName:ar.ZodUnknown,...Cr(e)});class Ou extends Ir{_parse(t){const r=this._getOrReturnCtx(t);return xt(r,{code:lt.invalid_type,expected:Nt.never,received:r.parsedType}),sr}}Ou.create=e=>new Ou({typeName:ar.ZodNever,...Cr(e)});class $j extends Ir{_parse(t){if(this._getType(t)!==Nt.undefined){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.void,received:n.parsedType}),sr}return Ua(t.data)}}$j.create=e=>new $j({typeName:ar.ZodVoid,...Cr(e)});class Xo extends Ir{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==Nt.array)return xt(r,{code:lt.invalid_type,expected:Nt.array,received:r.parsedType}),sr;if(i.exactLength!==null){const a=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(a||o)&&(xt(r,{code:a?lt.too_big:lt.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(xt(r,{code:lt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(xt(r,{code:lt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>i.type._parseAsync(new Iu(r,a,r.path,o)))).then(a=>ha.mergeArray(n,a));const s=[...r.data].map((a,o)=>i.type._parseSync(new Iu(r,a,r.path,o)));return ha.mergeArray(n,s)}get element(){return this._def.type}min(t,r){return new Xo({...this._def,minLength:{value:t,message:Dt.toString(r)}})}max(t,r){return new Xo({...this._def,maxLength:{value:t,message:Dt.toString(r)}})}length(t,r){return new Xo({...this._def,exactLength:{value:t,message:Dt.toString(r)}})}nonempty(t){return this.min(1,t)}}Xo.create=(e,t)=>new Xo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ar.ZodArray,...Cr(t)});function Sf(e){if(e instanceof Zn){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=bu.create(Sf(n))}return new Zn({...e._def,shape:()=>t})}else return e instanceof Xo?new Xo({...e._def,type:Sf(e.element)}):e instanceof bu?bu.create(Sf(e.unwrap())):e instanceof O0?O0.create(Sf(e.unwrap())):e instanceof dd?dd.create(e.items.map(t=>Sf(t))):e}class Zn extends Ir{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=Pr.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Nt.object){const c=this._getOrReturnCtx(t);return xt(c,{code:lt.invalid_type,expected:Nt.object,received:c.parsedType}),sr}const{status:n,ctx:i}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ou&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const h=s[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new Iu(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ou){const c=this._def.unknownKeys;if(c==="passthrough")for(const h of o)l.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(c==="strict")o.length>0&&(xt(i,{code:lt.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const h of o){const f=i.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new Iu(i,f,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const h of l){const f=await h.key,g=await h.value;c.push({key:f,value:g,alwaysSet:h.alwaysSet})}return c}).then(c=>ha.mergeObjectSync(n,c)):ha.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return Dt.errToObj,new Zn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var s,a;const i=((a=(s=this._def).errorMap)==null?void 0:a.call(s,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:Dt.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Zn({...this._def,unknownKeys:"strip"})}passthrough(){return new Zn({...this._def,unknownKeys:"passthrough"})}extend(t){return new Zn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Zn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ar.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Zn({...this._def,catchall:t})}pick(t){const r={};for(const n of Pr.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Zn({...this._def,shape:()=>r})}omit(t){const r={};for(const n of Pr.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new Zn({...this._def,shape:()=>r})}deepPartial(){return Sf(this)}partial(t){const r={};for(const n of Pr.objectKeys(this.shape)){const i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new Zn({...this._def,shape:()=>r})}required(t){const r={};for(const n of Pr.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof bu;)s=s._def.innerType;r[n]=s}return new Zn({...this._def,shape:()=>r})}keyof(){return zte(Pr.objectKeys(this.shape))}}Zn.create=(e,t)=>new Zn({shape:()=>e,unknownKeys:"strip",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});Zn.strictCreate=(e,t)=>new Zn({shape:()=>e,unknownKeys:"strict",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});Zn.lazycreate=(e,t)=>new Zn({shape:e,unknownKeys:"strip",catchall:Ou.create(),typeName:ar.ZodObject,...Cr(t)});class Uv extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new sc(o.ctx.common.issues));return xt(r,{code:lt.invalid_union,unionErrors:a}),sr}if(r.common.async)return Promise.all(n.map(async s=>{const a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const l of n){const c={...r,common:{...r.common,issues:[]},parent:null},h=l._parseSync({data:r.data,path:r.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(l=>new sc(l));return xt(r,{code:lt.invalid_union,unionErrors:o}),sr}}get options(){return this._def.options}}Uv.create=(e,t)=>new Uv({options:e,typeName:ar.ZodUnion,...Cr(t)});function i_(e,t){const r=tu(e),n=tu(t);if(e===t)return{valid:!0,data:e};if(r===Nt.object&&n===Nt.object){const i=Pr.objectKeys(t),s=Pr.objectKeys(e).filter(o=>i.indexOf(o)!==-1),a={...e,...t};for(const o of s){const l=i_(e[o],t[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(r===Nt.array&&n===Nt.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const a=e[s],o=t[s],l=i_(a,o);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return r===Nt.date&&n===Nt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class qv extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t),i=(s,a)=>{if(Mj(s)||Mj(a))return sr;const o=i_(s.value,a.value);return o.valid?((Ij(s)||Ij(a))&&r.dirty(),{status:r.value,value:o.data}):(xt(n,{code:lt.invalid_intersection_types}),sr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qv.create=(e,t,r)=>new qv({left:e,right:t,typeName:ar.ZodIntersection,...Cr(r)});class dd extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.array)return xt(n,{code:lt.invalid_type,expected:Nt.array,received:n.parsedType}),sr;if(n.data.length<this._def.items.length)return xt(n,{code:lt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),sr;!this._def.rest&&n.data.length>this._def.items.length&&(xt(n,{code:lt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const s=[...n.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new Iu(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ha.mergeArray(r,a)):ha.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new dd({...this._def,rest:t})}}dd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new dd({items:e,typeName:ar.ZodTuple,rest:null,...Cr(t)})};class Hj extends Ir{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.map)return xt(n,{code:lt.invalid_type,expected:Nt.map,received:n.parsedType}),sr;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,l],c)=>({key:i._parse(new Iu(n,o,n.path,[c,"key"])),value:s._parse(new Iu(n,l,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return sr;(c.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(c.value,h.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return sr;(c.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(c.value,h.value)}return{status:r.value,value:o}}}}Hj.create=(e,t,r)=>new Hj({valueType:t,keyType:e,typeName:ar.ZodMap,...Cr(r)});class u1 extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Nt.set)return xt(n,{code:lt.invalid_type,expected:Nt.set,received:n.parsedType}),sr;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(xt(n,{code:lt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(xt(n,{code:lt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const s=this._def.valueType;function a(l){const c=new Set;for(const h of l){if(h.status==="aborted")return sr;h.status==="dirty"&&r.dirty(),c.add(h.value)}return{status:r.value,value:c}}const o=[...n.data.values()].map((l,c)=>s._parse(new Iu(n,l,n.path,c)));return n.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(t,r){return new u1({...this._def,minSize:{value:t,message:Dt.toString(r)}})}max(t,r){return new u1({...this._def,maxSize:{value:t,message:Dt.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}u1.create=(e,t)=>new u1({valueType:e,minSize:null,maxSize:null,typeName:ar.ZodSet,...Cr(t)});class Uj extends Ir{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Uj.create=(e,t)=>new Uj({getter:e,typeName:ar.ZodLazy,...Cr(t)});class s_ extends Ir{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return xt(r,{received:r.data,code:lt.invalid_literal,expected:this._def.value}),sr}return{status:"valid",value:t.data}}get value(){return this._def.value}}s_.create=(e,t)=>new s_({value:e,typeName:ar.ZodLiteral,...Cr(t)});function zte(e,t){return new M0({values:e,typeName:ar.ZodEnum,...Cr(t)})}class M0 extends Ir{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return xt(r,{expected:Pr.joinValues(n),received:r.parsedType,code:lt.invalid_type}),sr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return xt(r,{received:r.data,code:lt.invalid_enum_value,options:n}),sr}return Ua(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return M0.create(t,{...this._def,...r})}exclude(t,r=this._def){return M0.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}}M0.create=zte;class qj extends Ir{_parse(t){const r=Pr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Nt.string&&n.parsedType!==Nt.number){const i=Pr.objectValues(r);return xt(n,{expected:Pr.joinValues(i),received:n.parsedType,code:lt.invalid_type}),sr}if(this._cache||(this._cache=new Set(Pr.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Pr.objectValues(r);return xt(n,{received:n.data,code:lt.invalid_enum_value,options:i}),sr}return Ua(t.data)}get enum(){return this._def.values}}qj.create=(e,t)=>new qj({values:e,typeName:ar.ZodNativeEnum,...Cr(t)});class Vv extends Ir{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==Nt.promise&&r.common.async===!1)return xt(r,{code:lt.invalid_type,expected:Nt.promise,received:r.parsedType}),sr;const n=r.parsedType===Nt.promise?r.data:Promise.resolve(r.data);return Ua(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Vv.create=(e,t)=>new Vv({type:e,typeName:ar.ZodPromise,...Cr(t)});class I0 extends Ir{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ar.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:a=>{xt(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return sr;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?sr:l.status==="dirty"||r.value==="dirty"?Xm(l.value):l});{if(r.value==="aborted")return sr;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?sr:o.status==="dirty"||r.value==="dirty"?Xm(o.value):o}}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?sr:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?sr:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!L0(a))return sr;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>L0(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:r.value,value:o})):sr);Pr.assertNever(i)}}I0.create=(e,t,r)=>new I0({schema:e,typeName:ar.ZodEffects,effect:t,...Cr(r)});I0.createWithPreprocess=(e,t,r)=>new I0({schema:t,effect:{type:"preprocess",transform:e},typeName:ar.ZodEffects,...Cr(r)});class bu extends Ir{_parse(t){return this._getType(t)===Nt.undefined?Ua(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}bu.create=(e,t)=>new bu({innerType:e,typeName:ar.ZodOptional,...Cr(t)});class O0 extends Ir{_parse(t){return this._getType(t)===Nt.null?Ua(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}O0.create=(e,t)=>new O0({innerType:e,typeName:ar.ZodNullable,...Cr(t)});class a_ extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t);let n=r.data;return r.parsedType===Nt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}a_.create=(e,t)=>new a_({innerType:e,typeName:ar.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Cr(t)});class o_ extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $v(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new sc(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new sc(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}o_.create=(e,t)=>new o_({innerType:e,typeName:ar.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Cr(t)});class Vj extends Ir{_parse(t){if(this._getType(t)!==Nt.nan){const n=this._getOrReturnCtx(t);return xt(n,{code:lt.invalid_type,expected:Nt.nan,received:n.parsedType}),sr}return{status:"valid",value:t.data}}}Vj.create=e=>new Vj({typeName:ar.ZodNaN,...Cr(e)});class QWe extends Ir{_parse(t){const{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class W7 extends Ir{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?sr:s.status==="dirty"?(r.dirty(),Xm(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?sr:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new W7({in:t,out:r,typeName:ar.ZodPipeline})}}class l_ extends Ir{_parse(t){const r=this._def.innerType._parse(t),n=i=>(L0(i)&&(i.value=Object.freeze(i.value)),i);return $v(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}l_.create=(e,t)=>new l_({innerType:e,typeName:ar.ZodReadonly,...Cr(t)});var ar;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ar||(ar={}));const _i=du.create,Wv=R0.create;Ou.create;const Uo=Xo.create,Wu=Zn.create;Uv.create;qv.create;dd.create;const JWe=s_.create,G7=M0.create;Vv.create;bu.create;O0.create;const $te=2,Hte=5,eGe=1,tGe=10,rGe=Wu({kind:G7(["continuity","causality","character"]),description:_i().min(1)}),nGe=Wu({chapter:Wv().int().min(1),summary:_i().min(1)}),iGe=Wu({character:_i().min(1),decision:_i().min(1)}),sGe=Wu({characters:Uo(_i()),relationships:Uo(_i()),world:Uo(_i()),hooks:Uo(_i())}),aGe=Wu({score:Wv().min(0).max(100),rationale:_i().min(1)}),Ute=Wu({branchId:_i().regex(/^branch-\d+$/),title:_i().min(1),premise:_i().min(1),beats:Uo(nGe).min(1),characterDecisions:Uo(iGe),projectedChanges:sGe,risks:Uo(rGe),uncertainties:Uo(_i()),intentAlignment:aGe}),oGe=G7(["active","stale"]),lGe=Wu({version:JWe(1),forecastId:_i().min(1),bookId:_i().min(1),createdAt:_i().min(1),language:G7(["zh","en"]),divergence:_i().min(1),horizon:Wv().int().min(eGe).max(tGe),baseChapter:Wv().int().min(0),contextFingerprint:_i().min(1),status:oGe,branches:Uo(Ute).min($te).max(Hte)}).superRefine((e,t)=>{const r=new Set;for(const n of e.branches)r.has(n.branchId)&&t.addIssue({code:lt.custom,message:`duplicate branchId: ${n.branchId}`,path:["branches"]}),r.add(n.branchId)}),cGe=Ute.omit({branchId:!0});Wu({branches:Uo(cGe).min($te).max(Hte)});function uGe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wj(e){return typeof e=="string"&&e.trim()?e:null}function qte(e){if(!["create_narrative_forecast","get_narrative_forecast","select_narrative_branch"].includes(e.tool))return null;const t=uGe(e.details);if(!t)return null;if(t.kind==="narrative_forecast_created"||t.kind==="narrative_forecast"){const r=lGe.safeParse(t.forecast);return r.success?{kind:"forecast",forecast:r.data,stale:t.stale===!0||r.data.status==="stale"}:null}if(t.kind==="narrative_branch_selected"){const r=Wj(t.branchId),n=Wj(t.planPath);return!r||!n?null:{kind:"selected",branchId:r,planPath:n,stale:t.stale===!0}}return null}function hGe(e,t,r){return r==="zh"?`请调用 select_narrative_branch,选择推演 ${e} 的 ${t}。只保存候选计划,不修改正文、大纲或正史状态。`:`Call select_narrative_branch for ${t} in forecast ${e}. Save only the candidate plan; do not modify prose, outlines, or canonical state.`}function dGe(e,t){return t==="zh"?`请调用 get_narrative_forecast,重新核验推演 ${e} 是否已经过期。`:`Call get_narrative_forecast for forecast ${e} and report whether it is stale.`}const fGe={continuity:["连续性","Continuity","Tính liên tục"],causality:["因果","Causality","Nhân quả"],character:["人物","Character","Nhân vật"]};function pGe(e){return V(e[0],e[1],e[2])}function mGe({risks:e,zh:t}){return e.length===0?p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/20 bg-emerald-500/5 px-2 py-0.5 text-[11px] text-emerald-700 dark:text-emerald-300",children:[p.jsx(KF,{size:11}),t?"未发现硬风险":"No hard risks"]}):p.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((r,n)=>p.jsx("span",{title:r.description,className:"inline-flex items-center rounded-full border border-amber-500/25 bg-amber-500/8 px-2 py-0.5 text-[11px] text-amber-800 dark:text-amber-200",children:pGe(fGe[r.kind])},`${r.kind}-${n}`))})}function mf({title:e,items:t}){return t.length===0?null:p.jsxs("div",{children:[p.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground/70",children:e}),p.jsx("ul",{className:"space-y-1 text-xs leading-5 text-muted-foreground",children:t.map((r,n)=>p.jsxs("li",{children:["· ",r]},n))})]})}function gGe({branch:e,forecastId:t,stale:r,zh:n,pending:i,onSelect:s}){return p.jsxs("article",{className:"relative flex min-w-0 flex-col rounded-xl border border-border/55 bg-background/70 p-3.5 shadow-[0_10px_30px_-24px_rgba(0,0,0,0.65)]",children:[p.jsx("div",{className:"absolute -top-[19px] left-1/2 h-4 w-px -translate-x-1/2 bg-primary/35"}),p.jsx("div",{className:"absolute -top-[22px] left-1/2 h-2 w-2 -translate-x-1/2 rounded-full border border-primary/50 bg-card"}),p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.13em] text-primary/75",children:e.branchId}),p.jsx("h4",{className:"mt-1 text-[15px] font-semibold leading-5 text-foreground",children:e.title})]}),p.jsxs("div",{className:"shrink-0 rounded-lg border border-primary/20 bg-primary/5 px-2 py-1 text-right",children:[p.jsx("div",{className:"text-[15px] font-semibold leading-none text-primary",children:e.intentAlignment.score}),p.jsx("div",{className:"mt-1 text-[9px] uppercase tracking-wide text-muted-foreground",children:n?"意图":"intent"})]})]}),p.jsx("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.premise}),p.jsx("ol",{className:"mt-3 space-y-2 border-l border-primary/20 pl-3",children:e.beats.map(a=>p.jsxs("li",{className:"relative text-xs leading-5 text-foreground/90",children:[p.jsx("span",{className:"absolute -left-[15px] top-[7px] h-1.5 w-1.5 rounded-full bg-primary/65"}),p.jsx("span",{className:"font-medium text-primary",children:n?`第 ${a.chapter} 章`:`Ch. ${a.chapter}`}),p.jsx("span",{className:"ml-1.5",children:a.summary})]},`${e.branchId}-${a.chapter}`))}),p.jsx("div",{className:"mt-3",children:p.jsx(mGe,{risks:e.risks,zh:n})}),p.jsxs("details",{className:"group mt-3 border-t border-border/40 pt-2.5",children:[p.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[p.jsx(Kv,{size:13,className:"transition-transform group-open:rotate-90"}),n?"人物决定、变化与不确定性":"Decisions, changes, uncertainties"]}),p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsx(mf,{title:n?"人物决定":"Character decisions",items:e.characterDecisions.map(a=>`${a.character}:${a.decision}`)}),p.jsx(mf,{title:n?"人物变化":"Character changes",items:e.projectedChanges.characters}),p.jsx(mf,{title:n?"关系变化":"Relationship changes",items:e.projectedChanges.relationships}),p.jsx(mf,{title:n?"世界变化":"World changes",items:e.projectedChanges.world}),p.jsx(mf,{title:n?"伏笔变化":"Hook changes",items:e.projectedChanges.hooks}),p.jsx(mf,{title:n?"不确定性":"Uncertainties",items:e.uncertainties}),p.jsx("p",{className:"rounded-lg bg-muted/45 px-2.5 py-2 text-xs leading-5 text-muted-foreground",children:e.intentAlignment.rationale})]})]}),p.jsxs("button",{type:"button","data-forecast-id":t,"data-branch-id":e.branchId,disabled:r||i||!s,onClick:()=>s==null?void 0:s(e.branchId),className:"mt-4 inline-flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/35 bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:border-border/40 disabled:bg-muted/30 disabled:text-muted-foreground/60",children:[i?p.jsx(Eg,{size:13,className:"animate-spin"}):p.jsx(ac,{size:13}),r?n?"过期推演不可采用":"Stale forecast":n?"采用此分支":"Use this branch"]})]})}function yGe({exec:e,onSelectBranch:t,onRecheck:r}){const n=qte(e),[i,s]=_.useState(null),[a,o]=_.useState(!1);if(!n)return null;if(n.kind==="selected")return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/25 bg-primary/5 px-3.5 py-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-primary",children:[p.jsx(ac,{size:15}),V("候选分支已保存","Candidate branch saved","Đã lưu nhánh ứng viên")]}),p.jsx("p",{className:"mt-1.5 text-xs leading-5 text-muted-foreground",children:V(`${n.branchId} 已写入候选计划;正文、大纲和正史状态没有修改。`,`${n.branchId} was written to the candidate plan; prose, outline, and canon were not modified.`,`Đã ghi ${n.branchId} vào kế hoạch ứng viên; bản thảo, dàn ý và chính sử không bị thay đổi.`)}),n.stale&&p.jsx("p",{className:"mt-2 text-xs text-amber-700 dark:text-amber-300",children:V("该推演基于旧正史,请核验后再继续写作。","This forecast is stale; verify it before writing.","Dự đoán này dựa trên chính sử cũ; hãy kiểm chứng trước khi viết tiếp.")})]});const{forecast:l,stale:c}=n,h=l.language==="zh",f=async m=>{if(!(!t||c)){s(m);try{await t(l.forecastId,m)}finally{s(null)}}},g=async()=>{if(r){o(!0);try{await r(l.forecastId)}finally{o(!1)}}};return p.jsxs("section",{className:"mx-3 mb-3 mt-1 overflow-hidden rounded-2xl border border-primary/25 bg-[linear-gradient(145deg,hsl(var(--card))_0%,hsl(var(--muted)/0.32)_100%)]",children:[p.jsxs("header",{className:"border-b border-border/45 px-4 py-3.5",children:[p.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[15px] font-semibold text-foreground",children:[p.jsx(moe,{size:16,className:"text-primary"}),h?"剧情多线推演":"Narrative forecast"]}),p.jsx("span",{className:"rounded-full border border-primary/20 bg-primary/8 px-2 py-0.5 text-[10px] font-medium tracking-wide text-primary",children:h?"非正史规划":"NON-CANONICAL"}),c&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-800 dark:text-amber-200",children:[p.jsx(cw,{size:11}),h?"正史已变化":"Canon changed"]})]}),p.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-foreground/85",children:l.divergence}),p.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[p.jsx("span",{children:h?`基于第 ${l.baseChapter} 章`:`After chapter ${l.baseChapter}`}),p.jsx("span",{children:h?`${l.branches.length} 条候选分支`:`${l.branches.length} branches`}),p.jsx("span",{children:h?`推演未来约 ${l.horizon} 章`:`~${l.horizon} chapters ahead`})]})]}),r&&p.jsxs("button",{type:"button",onClick:()=>{g()},disabled:a,className:"inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:border-primary/30 hover:text-foreground disabled:opacity-50",children:[p.jsx(Eg,{size:12,className:a?"animate-spin":""}),h?"重新核验":"Recheck"]})]}),c&&p.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-amber-500/20 bg-amber-500/8 px-3 py-2 text-xs leading-5 text-amber-900 dark:text-amber-100",children:[p.jsx(cw,{size:14,className:"mt-0.5 shrink-0"}),p.jsx("span",{children:h?"正史输入已在生成后变化。请重新推演,不要继续采用旧分支。":"Canonical inputs changed after generation. Regenerate before selecting a branch."})]})]}),p.jsxs("div",{className:"relative px-4 pb-4 pt-7",children:[p.jsx("div",{className:"pointer-events-none absolute left-8 right-8 top-[17px] h-px bg-gradient-to-r from-transparent via-primary/35 to-transparent"}),p.jsx("div",{className:"pointer-events-none absolute left-1/2 top-[9px] -translate-x-1/2 text-primary/70",children:p.jsx(l2,{size:14})}),p.jsx("div",{className:"grid auto-cols-[minmax(17rem,1fr)] grid-flow-col gap-3 overflow-x-auto pb-1 [scrollbar-width:thin]",children:l.branches.map(m=>p.jsx(gGe,{branch:m,forecastId:l.forecastId,stale:c,zh:h,pending:i===m.branchId,onSelect:t?x=>{f(x)}:void 0},m.branchId))})]})]})}function xGe({status:e}){switch(e){case"running":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-primary",children:[p.jsx(qn,{size:12,className:"animate-spin"}),p.jsx("span",{children:V("执行中","Running","Đang chạy")})]});case"processing":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[p.jsx(qn,{size:12,className:"animate-spin",style:{animationDuration:"2s"}}),p.jsx("span",{children:V("处理结果","Processing result","Đang xử lý kết quả")})]});case"completed":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[p.jsx(B0,{size:12}),p.jsx("span",{children:V("已完成","Completed","Đã hoàn thành")})]});case"error":return p.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-destructive",children:[p.jsx(D0,{size:12}),p.jsx("span",{children:V("失败","Failed","Thất bại")})]})}}function bGe({status:e}){switch(e){case"pending":return p.jsx("span",{className:"w-4 h-4 rounded-full border border-border/60 flex items-center justify-center shrink-0 text-[8px] text-muted-foreground/40",children:"○"});case"active":return p.jsx(qn,{size:14,className:"text-primary animate-spin shrink-0"});case"completed":return p.jsx(B0,{size:14,className:"text-green-600 dark:text-green-400 shrink-0"})}}function vGe(e){const t=Math.round(e.elapsedMs/1e3),r=e.status==="thinking"?V("思考中","Thinking","Đang suy nghĩ"):e.status??"",n=e.totalChars>0?e.chineseChars>0?`${e.totalChars}字`:V(`${e.totalChars} 字符`,`${e.totalChars} chars`,`${e.totalChars} ký tự`):"";return[r,`${t}s`,n].filter(Boolean).join(" · ")}function Gj(e,t){const r=(t??Date.now())-e,n=Math.round(r/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function CGe(e){return e.split("/").map(t=>encodeURIComponent(t)).join("/")}function Yj(e,t){var s;if(!e)return null;const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=e.match(new RegExp(`^${r}:\\s*(.+)$`,"im"));return((s=n==null?void 0:n[1])==null?void 0:s.trim())||null}function yr(e,t){const r=e[t];return typeof r=="string"&&r.trim()?r:void 0}function n2(e,t){const r=e[t];return typeof r=="boolean"?r:void 0}function Ko(e,t){const r=e[t];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function kGe(e,t,r){const n=e[t];if(!(!n||typeof n!="object"||Array.isArray(n)))return Ko(n,r)}function TGe(e){const t=e.actionPayload;if(!(!t||typeof t!="object"||Array.isArray(t)))return t}function Y7(e,t){const r=e[t];if(!Array.isArray(r))return;const n=Array.from(new Set(r.filter(i=>typeof i=="string").map(i=>i.trim().toLowerCase()).filter(Boolean)));return n.length>0?n:void 0}function Nh(e,t){const r=e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean):[]}function wGe(e){return!e.details||typeof e.details!="object"||Array.isArray(e.details)?[]:Nh(e.details,"skillIds")}function SGe({exec:e}){const t=wGe(e);return t.length===0?null:p.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[p.jsx("span",{className:"font-semibold text-foreground/80",children:V("专业 Skill","Professional skills","Skill chuyên môn")}),t.map(r=>p.jsx("span",{className:"rounded-full border border-border/50 bg-background/60 px-2 py-0.5 font-mono text-[11px]",children:r},r))]})}function Xj(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e,n=yr(r,"tracePath");if(!n)return null;const i=r.tokenBudget&&typeof r.tokenBudget=="object"&&!Array.isArray(r.tokenBudget)?r.tokenBudget:{},s=r.retrieval&&typeof r.retrieval=="object"&&!Array.isArray(r.retrieval)?r.retrieval:{},a=r.compression&&typeof r.compression=="object"&&!Array.isArray(r.compression)?r.compression:{};return{chapterNumber:t,tracePath:n,selectedSources:Nh(r,"selectedSources"),protectedSources:Nh(r,"protectedSources"),compressibleSources:Nh(r,"compressibleSources"),protectedTokens:Ko(i,"protectedTokens"),compressibleTokens:Ko(i,"compressibleTokens"),totalSelectedTokens:Ko(i,"totalSelectedTokens"),retrievalEngine:yr(s,"engine"),retrievalCandidateCount:Array.isArray(s.candidates)?s.candidates.length:0,semanticSelectedCount:Nh(s,"semanticSelectedIds").length,compressedSources:Nh(a,"compressedSources")}}function _Ge(e){if(e.tool!=="sub_agent"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return[];const t=e.details;if(t.kind==="chapter_written"){const r=Xj(t.contextTrace,Ko(t,"chapterNumber"));return r?[r]:[]}return t.kind!=="chapters_written"||!Array.isArray(t.chapters)?[]:t.chapters.flatMap(r=>{if(!r||typeof r!="object"||Array.isArray(r))return[];const n=r,i=Xj(n.contextTrace,Ko(n,"chapterNumber"));return i?[i]:[]})}function EGe({exec:e}){const t=_Ge(e);return t.length===0?null:p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-border/50 bg-background/55 px-3 py-2.5 text-xs",children:[p.jsx("div",{className:"font-semibold text-foreground",children:V("本轮参考依据","Context used this turn","Ngữ cảnh dùng ở lượt này")}),p.jsx("div",{className:"mt-2 space-y-2",children:t.map(r=>p.jsxs("details",{className:"rounded-lg border border-border/40 px-2.5 py-2",children:[p.jsxs("summary",{className:"cursor-pointer select-none font-medium text-foreground",children:[r.chapterNumber?V(`第 ${r.chapterNumber} 章`,`Chapter ${r.chapterNumber}`,`Chương ${r.chapterNumber}`):V("章节","Chapter","Chương"),r.retrievalEngine?` · ${r.retrievalEngine}`:""]}),p.jsxs("div",{className:"mt-2 space-y-1.5 text-muted-foreground",children:[p.jsxs("div",{children:[V("预算","Budget","Ngân sách"),": ",r.totalSelectedTokens??0,` · ${V("保护","protected","bảo vệ")} ${r.protectedTokens??0}`,` · ${V("可压缩","compressible","có thể nén")} ${r.compressibleTokens??0}`]}),p.jsxs("div",{children:[V("检索","Retrieval","Truy xuất"),": ",r.retrievalCandidateCount," ",V("个 BM25 候选","BM25 candidates","ứng viên BM25"),r.semanticSelectedCount>0?` · ${r.semanticSelectedCount} ${V("个语义选择","semantic selections","lựa chọn ngữ nghĩa")}`:""]}),r.compressedSources.length>0&&p.jsxs("div",{children:[V("语义压缩","Semantic compaction","Nén ngữ nghĩa"),": ",r.compressedSources.join(" · ")]}),p.jsxs("div",{children:[V("完整来源","All sources","Toàn bộ nguồn"),":"]}),p.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:r.selectedSources.map(n=>p.jsx("li",{children:n},n))}),p.jsx("div",{className:"font-mono text-[11px]",children:r.tracePath})]})]},`${r.chapterNumber??0}:${r.tracePath}`))})]})}function Vte(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];const r=t,n=yr(r,"description");return n?[{severity:yr(r,"severity")??"warning",category:yr(r,"category")??"review",description:n,suggestion:yr(r,"suggestion")}]:[]}):[]}function Wte(e){if(e.tool!=="sub_agent"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return null;const t=e.details;return t.kind!=="chapter_revision"?null:{chapterNumber:Ko(t,"chapterNumber"),applied:t.applied===!0,status:yr(t,"status"),auditPassed:typeof t.auditPassed=="boolean"?t.auditPassed:void 0,fixedIssues:Nh(t,"fixedIssues"),auditIssues:Vte(t.auditIssues),skippedReason:yr(t,"skippedReason")}}function Gte(e){if(e.tool!=="resync_chapter_state"||!e.details||typeof e.details!="object"||Array.isArray(e.details))return null;const t=e.details;return t.kind!=="chapter_state_resynced"?null:{chapterNumber:Ko(t,"chapterNumber"),status:yr(t,"status"),auditPassed:typeof t.auditPassed=="boolean"?t.auditPassed:void 0,auditIssues:Vte(t.auditIssues),summary:yr(t,"summary")}}function Yte({issues:e,title:t}){return e.length===0?null:p.jsxs("div",{className:"mt-2 space-y-1.5",children:[p.jsx("div",{className:"text-[13px] font-medium text-foreground",children:t}),e.map((r,n)=>p.jsxs("div",{className:"rounded-lg border border-border/40 bg-background/55 px-2.5 py-2 text-[12px] leading-5 text-muted-foreground",children:[p.jsxs("div",{className:"font-medium text-foreground",children:["[",r.severity,"] ",r.category]}),p.jsx("div",{children:r.description}),r.suggestion&&p.jsxs("div",{className:"mt-0.5",children:[V("建议","Suggestion","Đề xuất"),V(":",": ",": "),r.suggestion]})]},`${r.category}:${n}`))]})}function AGe({exec:e}){const t=Wte(e);if(!t)return null;const r=t.applied&&t.auditPassed===!0;return p.jsxs("div",{"data-testid":"chapter-revision-preview",className:`mx-3 mb-3 mt-1 rounded-xl border px-3 py-2.5 ${r?"border-emerald-500/25 bg-emerald-500/5":"border-amber-500/25 bg-amber-500/5"}`,children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:t.chapterNumber?V(`第 ${t.chapterNumber} 章修订`,`Chapter ${t.chapterNumber} revision`,`Sửa chương ${t.chapterNumber}`):V("章节修订","Chapter revision","Sửa chương")}),p.jsx("div",{className:`rounded-full px-2 py-0.5 text-[12px] font-semibold ${r?"bg-emerald-500/15 text-emerald-600":"bg-amber-500/15 text-amber-600"}`,children:t.applied?t.auditPassed?V("审稿通过","Audit passed","Đã qua kiểm duyệt"):V("仍需复核","Review required","Cần xem lại"):V("保留原稿","Original kept","Giữ bản gốc")})]}),t.skippedReason&&p.jsx("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:t.skippedReason}),t.fixedIssues.length>0&&p.jsxs("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:[p.jsxs("span",{className:"font-medium text-foreground",children:[V("已处理","Fixed","Đã xử lý"),V(":",": ",": ")]}),t.fixedIssues.join(";")]}),p.jsx(Yte,{issues:t.auditIssues,title:V("剩余审稿问题","Remaining audit issues","Vấn đề kiểm duyệt còn lại")})]})}function NGe({exec:e}){const t=Gte(e);if(!t)return null;const r=t.auditPassed===!0;return p.jsxs("div",{"data-testid":"chapter-state-resync-preview",className:`mx-3 mb-3 mt-1 rounded-xl border px-3 py-2.5 ${r?"border-emerald-500/25 bg-emerald-500/5":"border-amber-500/25 bg-amber-500/5"}`,children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:t.chapterNumber?V(`第 ${t.chapterNumber} 章状态已同步`,`Chapter ${t.chapterNumber} state resynced`,`Đã đồng bộ trạng thái chương ${t.chapterNumber}`):V("章节状态已同步","Chapter state resynced","Đã đồng bộ trạng thái chương")}),p.jsx("div",{className:`rounded-full px-2 py-0.5 text-[12px] font-semibold ${r?"bg-emerald-500/15 text-emerald-600":"bg-amber-500/15 text-amber-600"}`,children:r?V("审稿通过","Audit passed","Đã qua kiểm duyệt"):V("仍需修订","Revision required","Cần sửa lại")})]}),t.summary&&p.jsx("div",{className:"mt-2 text-[13px] leading-5 text-muted-foreground",children:t.summary}),p.jsx(Yte,{issues:t.auditIssues,title:V("审稿问题","Audit issues","Vấn đề kiểm duyệt")})]})}function Xte(e){if(!["short_fiction_run","generate_cover","script_create","storyboard_create","interactive_film_create"].includes(e.tool)||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="short_fiction_created"&&t.kind!=="cover_generated"&&t.kind!=="script_created"&&t.kind!=="storyboard_created"&&t.kind!=="interactive_film_created"?null:{kind:t.kind,title:yr(t,"title"),storyId:yr(t,"storyId"),projectId:yr(t,"projectId"),finalMarkdownPath:yr(t,"finalMarkdownPath"),salesPackagePath:yr(t,"salesPackagePath"),coverPromptPath:yr(t,"coverPromptPath"),coverImagePath:yr(t,"coverImagePath"),coverError:yr(t,"coverError"),specPath:yr(t,"specPath"),scriptPath:yr(t,"scriptPath"),storyboardPath:yr(t,"storyboardPath"),storyGraphPath:yr(t,"storyGraphPath"),storyTreePath:yr(t,"storyTreePath"),flagsPath:yr(t,"flagsPath"),imagePromptsPath:yr(t,"imagePromptsPath"),assetsManifestPath:yr(t,"assetsManifestPath"),skillIds:Y7(t,"skillIds")}}function LGe({exec:e,onOpenFilmStudio:t}){const r=Ht(a=>a.openProjectArtifact);if(!["script_create","storyboard_create","interactive_film_create"].includes(e.tool)||e.status!=="completed")return null;const n=Xte(e);if(!n||n.kind!=="script_created"&&n.kind!=="storyboard_created"&&n.kind!=="interactive_film_created")return null;const s=[n.specPath?[V("规格","Spec","Spec"),n.specPath]:null,n.storyGraphPath?[V("剧情图谱","Story graph","Sơ đồ cốt truyện"),n.storyGraphPath]:null,n.storyTreePath?[V("剧情树","Story tree","Cây cốt truyện"),n.storyTreePath]:null,n.flagsPath?[V("变量旗标","Flags","Cờ biến"),n.flagsPath]:null,n.scriptPath?[V("剧本","Script","Kịch bản"),n.scriptPath]:null,n.storyboardPath?[V("分镜","Storyboard","Phân cảnh"),n.storyboardPath]:null,n.imagePromptsPath?[V("图像提示词","Image prompts","Prompt hình ảnh"),n.imagePromptsPath]:null,n.assetsManifestPath?[V("图片资产","Image assets","Tài sản hình ảnh"),n.assetsManifestPath]:null].filter(a=>!!a);return s.length===0&&!(n.kind==="interactive_film_created"&&n.projectId)?null:p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5",children:[p.jsxs("div",{className:"flex items-center justify-between gap-3",children:[p.jsx("div",{className:"text-[16px] leading-6 font-semibold text-primary",children:n.kind==="script_created"?V("剧本已生成","Script generated","Đã tạo kịch bản"):n.kind==="storyboard_created"?V("分镜已生成","Storyboard generated","Đã tạo phân cảnh"):V("互动影游已生成","Interactive film generated","Đã tạo phim tương tác")}),n.kind==="interactive_film_created"&&n.projectId&&t&&p.jsx("button",{type:"button","data-testid":"open-film-studio",onClick:()=>t(n.projectId),className:"shrink-0 rounded-lg bg-primary px-3 py-1 text-[13px] font-semibold text-primary-foreground hover:opacity-90 transition-opacity",children:V("打开创作向导 →","Open creation wizard →","Mở trình hướng dẫn sáng tác →")})]}),s.length>0&&p.jsx("div",{className:"mt-2 space-y-1.5",children:s.map(([a,o])=>p.jsxs("button",{type:"button",onClick:()=>r(o),className:"group flex w-full items-start justify-between gap-3 rounded-lg border border-transparent px-2 py-1.5 text-left transition hover:border-primary/25 hover:bg-background/65",children:[p.jsxs("span",{className:"min-w-0 text-[13px] leading-5 text-muted-foreground break-all",children:[p.jsxs("span",{className:"font-medium text-foreground",children:[a,V(":",": ",": ")]}),o]}),p.jsx("span",{className:"mt-0.5 shrink-0 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[11px] font-semibold text-primary opacity-80 transition group-hover:opacity-100",children:V("查看","View","Xem")})]},a))})]})}function RGe({exec:e}){if(!["short_fiction_run","generate_cover"].includes(e.tool)||e.status!=="completed")return null;const t=Xte(e),r=(t==null?void 0:t.coverImagePath)??Yj(e.result,"Cover image"),n=(t==null?void 0:t.coverError)??Yj(e.result,"Cover image reason");if(!r||!/\.(png|jpe?g|webp)$/iu.test(r))return n?p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:[V("封面未生成:","Cover not generated: ","Chưa tạo ảnh bìa: "),n]}):null;const i=ja(`/project/files/${CGe(r)}`);if(!i)return null;const s=(t==null?void 0:t.title)??(t==null?void 0:t.storyId)??V("短篇封面","Short fiction cover","Ảnh bìa truyện ngắn");return p.jsxs("div",{className:"mx-3 mb-3 mt-1 overflow-hidden rounded-xl border border-border/40 bg-background/70",children:[p.jsx("img",{src:i,alt:s,className:"block max-h-[360px] w-full object-contain bg-muted/20",loading:"lazy"}),p.jsx("div",{className:"border-t border-border/40 px-3 py-2 text-[11px] text-muted-foreground break-all",children:r})]})}function Kte(e){if(!["play_start","play_step","play_revise"].includes(e.tool)||!e.details||typeof e.details!="object")return null;const t=e.details;if(t.kind!=="play_world_started"&&t.kind!=="play_turn_advanced"&&t.kind!=="play_turn_revised"&&t.kind!=="play_variant_restored")return null;const r=Array.isArray(t.suggestedActions)?t.suggestedActions.filter(n=>typeof n=="string"):[];return{kind:t.kind,title:yr(t,"title"),worldId:yr(t,"worldId"),runId:yr(t,"runId"),turn:Ko(t,"turn")??kGe(t,"currentState","turn")??(t.kind==="play_world_started"?0:void 0),sceneImageUrl:yr(t,"sceneImageUrl"),sceneText:yr(t,"sceneText"),suggestedActions:r,variantId:yr(t,"variantId"),skillIds:Y7(t,"skillIds")}}function MGe(e){return e.turn==null?null:`scene-turn-${Math.trunc(e.turn)}`}function Kj(e,t){var i;if(e.sceneImageUrl)return ja(e.sceneImageUrl);const r=MGe(e),n=r?(i=t==null?void 0:t.sceneImageUrls)==null?void 0:i[r]:void 0;return n?ja(n):r==="scene-turn-0"&&(t!=null&&t.sceneImageUrl)?ja(t.sceneImageUrl):null}function IGe(e){return!e.worldId||!e.runId||e.turn==null?null:ja(`/play/runs/${encodeURIComponent(e.worldId)}/${encodeURIComponent(e.runId)}`)}function OGe({details:e}){const t=_.useMemo(()=>IGe(e),[e]),r=_.useMemo(()=>Kj(e),[e]),[n,i]=_.useState(null);return _.useEffect(()=>{if(i(null),r){i(r);return}if(!t)return;let s=!1,a,o=0;const l=40,c=async()=>{try{const h=await fetch(t);if(h.ok){const f=await h.json(),g=Kj(e,f);if(g&&!s){i(g);return}}}catch{}s||(o+=1,o<l&&(a=window.setTimeout(()=>void c(),2e3)))};return c(),()=>{s=!0,a!==void 0&&window.clearTimeout(a)}},[e,r,t]),n?p.jsxs("div",{className:"mt-3 overflow-hidden rounded-xl border border-border/40 bg-background/80",children:[p.jsx("img",{src:n,alt:V("本幕配图","Scene illustration","Ảnh minh họa cảnh"),className:"block max-h-[420px] w-full object-contain bg-muted/20",loading:"lazy"}),e.turn!=null&&p.jsx("div",{className:"border-t border-border/40 px-3 py-2.5 text-[14px] leading-6 text-muted-foreground",children:V(`第 ${Math.trunc(e.turn)} 幕配图`,`Scene ${Math.trunc(e.turn)} illustration`,`Ảnh minh họa cảnh ${Math.trunc(e.turn)}`)})]}):null}function Zte(e){if(e.tool!=="play_edit"||!e.details||typeof e.details!="object")return null;const t=e.details;return t.kind!=="play_world_updated"?null:{kind:"play_world_updated",worldId:yr(t,"worldId"),runId:yr(t,"runId"),updatedWorldContract:n2(t,"updatedWorldContract"),updatedVisualContract:n2(t,"updatedVisualContract"),updatedPremise:n2(t,"updatedPremise"),updatedEntities:Ko(t,"updatedEntities")}}function Qte(e){if(e.tool!=="propose_action"||!e.details||typeof e.details!="object")return null;const t=e.details;if(t.kind!=="proposed_action")return null;const r=yr(t,"action"),n=yr(t,"targetSessionKind"),i=yr(t,"instruction");return!r||!n||!i?null:{kind:"proposed_action",execId:e.id,action:r,targetSessionKind:n,sameSession:n2(t,"sameSession"),title:yr(t,"title"),summary:yr(t,"summary"),instruction:i,requestedSkills:Y7(t,"requestedSkills"),actionPayload:TGe(t)}}function BGe(e){var s,a,o;const t=(s=e.actionPayload)==null?void 0:s.playStart;if(e.action!=="play_start"||!t)return[];const r=[],n=(a=t.worldContract)==null?void 0:a.trim();n&&r.push({label:V("世界契约","World contract","Khế ước thế giới"),value:n});const i=(o=t.visualContract)==null?void 0:o.trim();return i&&r.push({label:V("视觉契约","Visual contract","Khế ước hình ảnh"),value:i}),r}function DGe({exec:e,onProposedAction:t,onRejectProposedAction:r}){const n=Ht(h=>h.resolvedProposals),i=Ht(yf.isActiveSessionStreaming);if(e.tool!=="propose_action"||e.status!=="completed")return null;const s=Qte(e);if(!s)return null;const a=n[s.execId],o=i,l=a!==void 0,c=BGe(s);return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/25 bg-primary/5 px-4 py-3.5",children:[p.jsx("div",{className:"text-[17px] leading-6 font-semibold text-foreground",children:s.title??V("确认执行","Confirm action","Xác nhận thực thi")}),s.summary&&p.jsx("div",{className:"mt-1.5 whitespace-pre-wrap break-words text-[15px] leading-7 text-muted-foreground",children:s.summary}),p.jsx("div",{className:"mt-2.5 whitespace-pre-wrap break-words rounded-lg bg-background/70 px-3 py-2.5 text-[15px] leading-7 text-muted-foreground",children:s.instruction}),c.length>0&&p.jsx("div",{className:"mt-2 space-y-1.5",children:c.map(h=>p.jsxs("div",{className:"rounded-lg border border-border/50 bg-background/60 px-3 py-2.5",children:[p.jsx("div",{className:"text-[13px] leading-5 font-semibold text-foreground",children:h.label}),p.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-[15px] leading-7 text-muted-foreground",children:h.value})]},h.label))}),a==="confirmed"?p.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-[15px] leading-6 font-medium text-primary",children:[p.jsx(ac,{size:15,className:"shrink-0"}),V("已执行","Executed","Đã thực thi")]}):a==="rejected"?p.jsx("div",{className:"mt-3 text-[15px] leading-6 font-medium text-muted-foreground",children:V("已取消","Cancelled","Đã hủy")}):p.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[p.jsx("button",{type:"button","data-testid":"confirm-action",onClick:()=>t==null?void 0:t(s),disabled:!t||o||l,className:"rounded-lg bg-primary px-3.5 py-2 text-[15px] leading-6 font-medium text-primary-foreground disabled:opacity-50",children:o?V("执行中…","Running…","Đang chạy…"):V("继续执行","Continue","Tiếp tục")}),p.jsx("button",{type:"button",onClick:()=>r==null?void 0:r(s),disabled:!r||o||l,className:"rounded-lg border border-border/60 bg-background/80 px-3.5 py-2 text-[15px] leading-6 font-medium text-muted-foreground disabled:opacity-50",children:V("取消","Cancel","Hủy")})]})]})}function PGe({exec:e}){if(!["play_start","play_step","play_revise"].includes(e.tool)||e.status!=="completed")return null;const t=Kte(e);if(!(t!=null&&t.sceneText))return null;const r=t.kind==="play_world_started"?V("互动世界已启动","Interactive world started","Đã khởi động thế giới tương tác"):t.kind==="play_turn_revised"?V("互动回合已重做","Play turn redone","Đã làm lại lượt chơi"):t.kind==="play_variant_restored"?V("已切换互动回合版本","Switched play turn variant","Đã chuyển phiên bản lượt chơi"):V("互动世界已推进","Interactive world advanced","Thế giới tương tác đã tiến triển");return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[p.jsx("div",{className:"mb-2 text-[16px] leading-6 font-semibold text-primary",children:r}),p.jsx("div",{className:"whitespace-pre-wrap text-base leading-7 text-foreground",children:t.sceneText}),p.jsx(OGe,{details:t})]})}function jGe({exec:e}){if(e.tool!=="play_edit"||e.status!=="completed")return null;const t=Zte(e);if(!t)return null;const r=[t.updatedWorldContract?V("世界契约","World contract","Khế ước thế giới"):"",t.updatedVisualContract?V("视觉契约","Visual contract","Khế ước hình ảnh"):"",t.updatedPremise?V("世界前提","World premise","Tiền đề thế giới"):"",t.updatedEntities&&t.updatedEntities>0?V(`${t.updatedEntities} 张卡片`,`${t.updatedEntities} cards`,`${t.updatedEntities} thẻ`):""].filter(Boolean);return p.jsxs("div",{className:"mx-3 mb-3 mt-1 rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5",children:[p.jsx("div",{className:"text-[16px] leading-6 font-semibold text-primary",children:V("互动世界设定已更新","Interactive world settings updated","Đã cập nhật thiết định thế giới tương tác")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:r.length>0?r.join(" · "):V("已写入当前世界。","Written to the current world.","Đã ghi vào thế giới hiện tại.")})]})}function FGe(e){var t;return Qte(e)||(t=Kte(e))!=null&&t.sceneText||Wte(e)||Gte(e)?!0:!!Zte(e)}function zGe(e){return e==="sub_agent"||e==="resync_chapter_state"||e==="context_compression"||e==="propose_action"||e==="short_fiction_run"||e==="script_create"||e==="storyboard_create"||e==="interactive_film_create"||e==="generate_cover"||e==="play_edit"||e==="play_start"||e==="play_revise"||e==="play_step"||e==="create_narrative_forecast"||e==="get_narrative_forecast"||e==="select_narrative_branch"}function $Ge(e,t){const[r,n]=_.useState(()=>t?Date.now()-e:0);return _.useEffect(()=>{if(!t)return;n(Date.now()-e);const i=setInterval(()=>n(Date.now()-e),1e3);return()=>clearInterval(i)},[e,t]),r}function HGe({result:e,defaultOpen:t}){return p.jsxs("details",{open:t,className:"mx-3 mb-3 mt-1 rounded-lg border border-border/40 bg-background/60 px-2.5 py-2 text-xs",children:[p.jsx("summary",{className:"cursor-pointer select-none font-medium text-muted-foreground hover:text-foreground",children:V("查看操作结果","View result","Xem kết quả")}),p.jsx("div",{className:"mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words leading-5 text-foreground",children:e})]},t?"result-default-open":"result-default-collapsed")}function UGe({exec:e,onProposedAction:t,onRejectProposedAction:r,onOpenFilmStudio:n,onSelectNarrativeBranch:i,onRecheckNarrativeForecast:s}){var m;const a=e.status==="running"||e.status==="processing",[o,l]=_.useState(a),c=$Ge(e.startedAt,a),h=r_(x=>x.toolDetailsDefaultOpen);_.useEffect(()=>{if(e.status==="running"&&l(!0),e.status==="completed"){const x=setTimeout(()=>l(!1),500);return()=>clearTimeout(x)}},[e.status]);const f=(m=e.args)==null?void 0:m.bookId,g=qte(e);return p.jsxs(H_,{open:o,onOpenChange:l,className:"rounded-xl border border-border/40 bg-card/60",children:[p.jsxs(U_,{className:"w-full flex items-center justify-between gap-2 px-3 py-2.5 rounded-xl hover:bg-card/80 transition-colors cursor-pointer",children:[p.jsx("div",{className:"flex items-center gap-2 min-w-0",children:p.jsxs("span",{className:"text-[16px] leading-6 font-medium text-foreground truncate",children:[e.label,f&&p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",f]})]})}),p.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p.jsx("span",{className:"text-[12px] text-muted-foreground/60",children:a?Gj(e.startedAt,e.startedAt+c):e.completedAt?Gj(e.startedAt,e.completedAt):""}),p.jsx(xGe,{status:e.status}),p.jsx(Bu,{size:16,className:`text-muted-foreground transition-transform ${o?"rotate-180":""}`})]})]}),p.jsx(DGe,{exec:e,onProposedAction:t,onRejectProposedAction:r}),p.jsx(SGe,{exec:e}),p.jsx(RGe,{exec:e}),p.jsx(LGe,{exec:e,onOpenFilmStudio:n}),p.jsx(PGe,{exec:e}),p.jsx(jGe,{exec:e}),p.jsx(EGe,{exec:e}),p.jsx(AGe,{exec:e}),p.jsx(NGe,{exec:e}),p.jsx(yGe,{exec:e,onSelectBranch:i,onRecheck:s}),!g&&!FGe(e)&&typeof e.result=="string"&&e.result.trim()&&p.jsx(HGe,{result:e.result,defaultOpen:h}),p.jsx(q_,{children:p.jsxs("div",{className:"px-3 pb-3 pt-1",children:[e.stages&&e.stages.length>0&&p.jsx("ol",{className:"mb-2 space-y-1.5",children:e.stages.map(x=>p.jsxs("li",{className:["flex items-start gap-2 rounded-lg px-2 py-1.5 text-xs",x.status==="active"?"bg-primary/5 text-foreground":"text-muted-foreground"].join(" "),children:[p.jsx(bGe,{status:x.status}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate",children:x.label}),x.progress&&p.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground/70",children:vGe(x.progress)})]})]},x.label))}),e.logs&&e.logs.length>0&&p.jsx("ul",{className:"space-y-0.5",children:e.logs.map((x,v)=>{const C=x.startsWith("[error]")||/error/i.test(x),k=x.startsWith("[warning]")||/warning|警告/i.test(x);return p.jsx("li",{className:`text-xs font-mono break-words ${C?"text-destructive":k?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"}`,children:x},v)})}),e.status==="error"&&e.error&&p.jsx("div",{className:"mt-2 text-xs text-destructive bg-destructive/5 rounded-lg px-2.5 py-2",children:e.error})]})})]})}function Zj({status:e}){switch(e){case"completed":return p.jsx(B0,{size:10,className:"text-green-600 dark:text-green-400 shrink-0"});case"error":return p.jsx(D0,{size:10,className:"text-destructive shrink-0"});case"running":case"processing":return p.jsx(qn,{size:10,className:"animate-spin text-primary shrink-0"})}}function qGe({exec:e}){var n,i;const t=`${e.tool} ${String(((n=e.args)==null?void 0:n.path)??((i=e.args)==null?void 0:i.pattern)??"")}`;return typeof e.result=="string"&&e.result.trim().length>0?p.jsxs("details",{className:"group",children:[p.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-2 list-none [&::-webkit-details-marker]:hidden hover:text-foreground transition-colors",children:[p.jsx("span",{className:"font-mono truncate",children:t}),p.jsx(Zj,{status:e.status}),p.jsx(Bu,{size:10,className:"shrink-0 transition-transform group-open:rotate-180"})]}),p.jsx("div",{className:"mt-1 mb-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border/40 bg-background/60 px-2 py-1.5 leading-5",children:e.result})]}):p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"font-mono truncate",children:t}),p.jsx(Zj,{status:e.status})]})}function VGe({execs:e}){const[t,r]=_.useState(!1),n=e.every(s=>s.status==="completed"||s.status==="error"),i=e.some(s=>s.status==="error");return p.jsxs(H_,{open:t,onOpenChange:r,children:[p.jsxs(U_,{className:"flex items-center gap-2 px-2 py-1 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer text-xs text-muted-foreground",children:[p.jsx(ble,{size:12}),p.jsx("span",{children:V(`${e.length} 个文件操作`,`${e.length} file operation${e.length===1?"":"s"}`,`${e.length} thao tác tệp`)}),n&&!i&&p.jsx(B0,{size:10,className:"text-green-600 dark:text-green-400"}),i&&p.jsx(D0,{size:10,className:"text-destructive"}),!n&&p.jsx(qn,{size:10,className:"animate-spin text-primary"}),p.jsx(Bu,{size:10,className:`transition-transform ${t?"rotate-180":""}`})]}),p.jsx(q_,{children:p.jsx("ul",{className:"pl-6 space-y-0.5 py-1",children:e.map(s=>p.jsx("li",{className:"text-xs text-muted-foreground",children:p.jsx(qGe,{exec:s})},s.id))})})]})}function WGe(e){const t=[];let r=[];const n=()=>{r.length>0&&(t.push({type:"utilities",execs:r}),r=[])};for(const i of e)zGe(i.tool)?(n(),t.push({type:"pipeline",exec:i})):r.push(i);return n(),t}const Jte=_.memo(function({executions:t,onProposedAction:r,onRejectProposedAction:n,onOpenFilmStudio:i,onSelectNarrativeBranch:s,onRecheckNarrativeForecast:a}){const o=_.useMemo(()=>WGe(t),[t]);return p.jsx("div",{className:"space-y-2 mt-2",children:o.map((l,c)=>l.type==="pipeline"?p.jsx(UGe,{exec:l.exec,onProposedAction:r,onRejectProposedAction:n,onOpenFilmStudio:i,onSelectNarrativeBranch:s,onRecheckNarrativeForecast:a},l.exec.id):p.jsx(VGe,{execs:l.execs},`utils-${c}`))})});Jte.displayName="ToolExecutionSteps";const GGe={cjk:v1};function Qj(e){return e.split("/").map(encodeURIComponent).join("/")}function YGe(e){return e.split("/").filter(Boolean).at(-1)??e}function XGe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Jj(e,t){return e.endsWith(".json")||t.includes("application/json")}function KGe(){const e=Ht(C=>C.projectArtifactPath),t=Ht(C=>C.closeProjectArtifact),[r,n]=_.useState(null),[i,s]=_.useState(!1),[a,o]=_.useState(null),[l,c]=_.useState(!1),[h,f]=_.useState(""),[g,m]=_.useState(!1);_.useEffect(()=>{if(!e)return;let C=!1;return s(!0),o(null),n(null),c(!1),ct(`/project/artifacts/${Qj(e)}`).then(k=>{C||(n(k),f(k.content))}).catch(k=>{C||o(k instanceof Error?k.message:String(k))}).finally(()=>{C||s(!1)}),()=>{C=!0}},[e]);const x=_.useMemo(()=>r?Jj(r.path,r.contentType)?XGe(r.content):r.content:"",[r]);if(!e)return null;const v=async()=>{m(!0),o(null);try{const C=await ct(`/project/artifacts/${Qj(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});n({path:e,content:h,contentType:(r==null?void 0:r.contentType)??"text/markdown; charset=utf-8",size:C.size}),c(!1)}catch(C){o(C instanceof Error?C.message:String(C))}finally{m(!1)}};return p.jsxs("div",{className:"fixed inset-0 z-[80] flex justify-end bg-background/35 backdrop-blur-[2px]",children:[p.jsx("button",{type:"button","aria-label":V("关闭生成物预览","Close artifact preview","Đóng bản xem trước bản dựng"),className:"absolute inset-0 cursor-default",onClick:t}),p.jsxs("aside",{className:"relative flex h-full w-[min(760px,calc(100vw-24px))] flex-col border-l border-border/55 bg-background shadow-2xl",children:[p.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-border/45 px-6 py-5",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-[13px] font-medium uppercase tracking-[0.18em] text-muted-foreground/65",children:V("生成物","Artifact","Bản dựng")}),p.jsx("h2",{className:"mt-1 truncate text-[22px] font-semibold text-foreground",children:YGe(e)}),p.jsx("p",{className:"mt-1 break-all text-[13px] leading-5 text-muted-foreground/70",children:e})]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r&&!l&&p.jsxs("button",{type:"button",onClick:()=>{f(r.content),c(!0)},className:"inline-flex items-center gap-2 rounded-lg border border-border/60 bg-secondary/35 px-3 py-2 text-[14px] font-medium text-foreground transition hover:border-primary/45 hover:bg-primary/10",children:[p.jsx(Kh,{size:15}),V("编辑","Edit","Chỉnh sửa")]}),l&&p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",onClick:()=>{f((r==null?void 0:r.content)??""),c(!1)},disabled:g,className:"rounded-lg border border-border/60 px-3 py-2 text-[14px] font-medium text-muted-foreground transition hover:bg-secondary/50 disabled:opacity-60",children:V("取消","Cancel","Hủy")}),p.jsxs("button",{type:"button",onClick:v,disabled:g,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-[14px] font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:opacity-60",children:[g?p.jsx(qn,{size:15,className:"animate-spin"}):p.jsx(j0,{size:15}),V("保存","Save","Lưu")]})]}),p.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-border/50 p-2 text-muted-foreground transition hover:bg-secondary/60 hover:text-foreground","aria-label":V("关闭","Close","Đóng"),children:p.jsx(ho,{size:18})})]})]}),a&&p.jsxs("div",{className:"mx-6 mt-4 flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-[14px] leading-6 text-destructive",children:[p.jsx(HF,{size:18,className:"mt-0.5 shrink-0"}),p.jsx("span",{children:a})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:i?p.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[p.jsx(qn,{size:22,className:"mr-2 animate-spin"}),V("正在读取生成物...","Loading artifact...","Đang tải bản dựng...")]}):l?p.jsx("textarea",{value:h,onChange:C=>f(C.target.value),spellCheck:!1,className:"min-h-full w-full resize-none rounded-xl border border-border/55 bg-secondary/20 px-4 py-4 font-mono text-[15px] leading-7 text-foreground outline-none transition focus:border-primary/50 focus:bg-background"}):r?Jj(r.path,r.contentType)?p.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border/45 bg-secondary/25 px-4 py-4 font-mono text-[14px] leading-6 text-foreground",children:x}):p.jsx("article",{className:"prose prose-neutral dark:prose-invert max-w-none text-[16px] leading-8 prose-headings:font-semibold prose-h1:text-[26px] prose-h2:text-[22px] prose-h3:text-[19px] prose-p:my-4 prose-li:my-1 prose-pre:whitespace-pre-wrap",children:p.jsx(Ho,{plugins:GGe,mode:"static",children:x})}):p.jsx("div",{className:"rounded-xl border border-dashed border-border/55 px-4 py-8 text-center text-[14px] text-muted-foreground",children:V("没有可预览内容。","Nothing to preview.","Không có nội dung để xem trước.")})})]})]})}const ere=new Set(["item","evidence","clue","claim","proof_chain"]),eF={item:"🎒",evidence:"📄",clue:"🔍",claim:"💡",proof_chain:"🔗"},tF={timer:"⏳",pressure:"🔥",resource:"🪙",relation:"❤",clue:"🔍",evidence:"📄",flag:"🚩"},tre={item:"物件",evidence:"证据",clue:"线索",claim:"主张",proof_chain:"证据链"},rre={item:"Item",evidence:"Evidence",clue:"Clue",claim:"Claim",proof_chain:"Proof chain"},nre={item:"Vật phẩm",evidence:"Chứng cứ",clue:"Manh mối",claim:"Luận điểm",proof_chain:"Chuỗi chứng cứ"},ZGe=["unknown","hinted","seen","collected","verified","weaponized","exposed","exhausted"],QGe={unknown:"未知",hinted:"有线索",seen:"已看见",collected:"已收集",verified:"已验证",weaponized:"武器化",exposed:"已揭露",exhausted:"已耗尽"},JGe={unknown:"Unknown",hinted:"Hinted",seen:"Seen",collected:"Collected",verified:"Verified",weaponized:"Weaponized",exposed:"Exposed",exhausted:"Exhausted"},eYe={unknown:"Chưa biết",hinted:"Có manh mối",seen:"Đã thấy",collected:"Đã thu thập",verified:"Đã xác minh",weaponized:"Đã vũ khí hóa",exposed:"Đã phơi bày",exhausted:"Đã khai thác hết"};function tYe(e){const{row:t,generating:r,onOpen:n}=e,i=V(tre[t.kind]??t.kind,rre[t.kind]??t.kind,nre[t.kind]??t.kind);return p.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2.5 rounded-lg border border-border/30 bg-secondary/30 px-2.5 py-2 text-left hover:border-border/60",children:[t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"h-8 w-8 shrink-0 rounded object-cover"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded bg-secondary/60 text-sm",children:r?"⏳":t.glyph}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"truncate text-[15px] leading-6 font-semibold text-foreground",children:t.label}),t.isFresh?p.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/20 px-1.5 text-[12px] leading-5 font-medium text-emerald-300",children:V("新","NEW","MỚI")}):null]}),p.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"shrink-0",children:i}),t.preview?p.jsxs("span",{className:"truncate",children:["· ",t.preview]}):null]})]}),p.jsx(Kv,{size:13,className:"shrink-0 text-muted-foreground/50"})]})}function rYe(e,t,r){const n=e.slice(0,6),i=t/2,s=r/2,a=t*.32,o=r*.3;return{nodes:n.map((c,h)=>{const f=-Math.PI/2+2*Math.PI*h/n.length;return{x:i+a*Math.cos(f),y:s+o*Math.sin(f),label:c.targetLabel,type:c.type,strength:c.strength}}),overflow:Math.max(0,e.length-n.length)}}function rF(e,t=6){return e.length>t?`${e.slice(0,t)}…`:e}function nYe(e){const{nodes:s,overflow:a}=rYe(e.relations,300,150);return p.jsxs("svg",{viewBox:"0 0 300 150",className:"block w-full min-w-0",role:"img","aria-label":V("关系网","Relations","Mạng quan hệ"),children:[s.map((o,l)=>p.jsx("line",{x1:150,y1:75,x2:o.x,y2:o.y,className:"stroke-border",strokeWidth:1.5},`l${l}`)),p.jsx("ellipse",{cx:150,cy:75,rx:46,ry:19,className:"fill-secondary stroke-primary"}),p.jsx("text",{x:150,y:79,textAnchor:"middle",fontSize:10,fontWeight:600,className:"fill-foreground",children:rF(e.centerLabel)}),s.map((o,l)=>p.jsxs("g",{children:[p.jsx("ellipse",{cx:o.x,cy:o.y,rx:38,ry:15,className:"fill-card stroke-border"}),p.jsx("text",{x:o.x,y:o.y+3,textAnchor:"middle",fontSize:9,className:"fill-foreground",children:rF(o.label)}),p.jsxs("text",{x:(150+o.x)/2,y:(75+o.y)/2-2,textAnchor:"middle",fontSize:8,className:"fill-muted-foreground",children:[o.type,o.strength!=null?` ${o.strength}`:""]})]},`n${l}`)),a>0?p.jsxs("text",{x:294,y:144,textAnchor:"end",fontSize:9,className:"fill-muted-foreground",children:["+",a]}):null]})}function iYe(e){const{row:t,generating:r,onBack:n}=e,{lifecycle:i}=t,s=V(tre[t.kind]??t.kind,rre[t.kind]??t.kind,nre[t.kind]??t.kind),a=Sg()==="vi"?eYe:Sg()==="en"?JGe:QGe;return p.jsxs("div",{className:"min-w-0 space-y-3",children:[p.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-[14px] leading-6 text-muted-foreground hover:text-foreground",children:[p.jsx(p_,{size:14})," ",V("返回","Back","Quay lại")]}),p.jsxs("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/40 bg-secondary/30",children:[p.jsx("div",{className:"flex min-h-[180px] items-center justify-center bg-gradient-to-b from-secondary/60 to-transparent text-4xl",children:t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"max-h-[320px] w-full object-contain"}):p.jsx("span",{children:r?"⏳":t.glyph})}),p.jsxs("div",{className:"min-w-0 space-y-3 px-3 py-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p.jsx("span",{className:"min-w-0 flex-1 break-words text-[17px] leading-6 font-bold text-foreground",children:t.label}),p.jsx("span",{className:"shrink-0 pt-0.5 text-[13px] text-muted-foreground",children:s})]}),t.summary?p.jsx("p",{className:"mt-1 break-words text-[14px] leading-6 text-muted-foreground",children:t.summary}):null]}),i?p.jsxs("div",{children:[p.jsx("div",{className:"flex gap-1",children:i.stages.map(o=>p.jsx("span",{className:`flex-1 rounded px-1 py-1 text-center text-[11px] leading-4 ${o===i.current?"bg-primary/20 font-bold text-primary":"bg-secondary/40 text-muted-foreground/50"}`,children:a[o]??o},o))}),i.reason?p.jsxs("p",{className:"mt-1.5 break-words text-[13px] leading-5 text-emerald-300",children:["▲ ",i.reason]}):null]}):t.statusPill?p.jsxs("div",{children:[p.jsx("span",{className:"inline-block rounded-full bg-secondary/60 px-2.5 py-1 text-[14px] leading-5 font-medium text-foreground",children:t.statusPill}),t.isFresh?p.jsxs("p",{className:"mt-1.5 text-[13px] leading-5 text-emerald-300",children:["▲ ",V("刚获得","Just acquired","Vừa có được")]}):t.changeReason?p.jsxs("p",{className:"mt-1.5 break-words text-[13px] leading-5 text-emerald-300",children:["▲ ",t.changeReason]}):null]}):null,t.meters.length>0?p.jsxs("div",{className:"space-y-1.5",children:[p.jsx("h4",{className:"text-[13px] leading-5 uppercase tracking-wider text-muted-foreground/60",children:V("属性","Stats","Chỉ số")}),t.meters.map(o=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[14px] leading-6",children:[p.jsx("span",{className:"w-12 shrink-0 break-words text-muted-foreground",children:o.label}),o.ratio!=null?p.jsx("span",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-secondary/60",children:p.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.round(o.ratio*100)}%`}})}):null,p.jsx("span",{className:"ml-auto min-w-0 break-words font-semibold text-primary",children:o.value})]},o.id))]}):null,t.relations.length>0?p.jsxs("div",{className:"min-w-0",children:[p.jsx("h4",{className:"mb-1 text-[13px] leading-5 uppercase tracking-wider text-muted-foreground/60",children:V("牵动","Connections","Liên hệ")}),p.jsx(nYe,{centerLabel:t.label,relations:t.relations,isZh:e.isZh})]}):null,t.provenanceTurn!=null?p.jsx("p",{className:"break-words border-t border-border/30 pt-2 text-[13px] leading-5 text-muted-foreground/70",children:V(`第 ${t.provenanceTurn} 幕 取得`,`Acquired · Turn ${t.provenanceTurn}`,`Có được · Màn ${t.provenanceTurn}`)}):null]})]})]})}function sYe({row:e}){var n;const t=(n=e.details[0])==null?void 0:n.text,r=e.kind==="pressure"&&e.ratio==null;return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2 text-[15px] leading-6",children:[p.jsx("span",{className:"shrink-0 text-[15px]",children:e.glyph}),p.jsx("span",{className:"text-muted-foreground",children:e.label}),e.ratio!=null?p.jsx("span",{className:"ml-2 h-1.5 flex-1 overflow-hidden rounded-full bg-secondary/60",children:p.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.round(e.ratio*100)}%`}})}):null,r?p.jsxs("span",{className:"ml-auto rounded-full bg-amber-500/15 px-2 py-0.5 text-[14px] leading-5 font-semibold text-amber-300",children:["⚠ ",e.value]}):e.value?p.jsx("span",{className:"ml-auto text-[15px] leading-6 font-semibold text-primary",children:e.value}):null]}),t?p.jsx("p",{className:"mt-0.5 pl-6 text-[14px] leading-6 text-muted-foreground/70",children:t}):null]})}function aYe(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return""}}function nF(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){const t=e;if(typeof t.current=="number"){const r=t.current,n=typeof t.min=="number"?t.min:0,i=typeof t.max=="number"?t.max:void 0,s=i!=null?`${r}/${i}`:String(r),a=i!=null&&i>n?Math.max(0,Math.min(1,(r-n)/(i-n))):void 0;return{text:s,ratio:a}}}return{text:aYe(e)}}function oYe(e,t){var r,n,i;return((r=e.value)==null?void 0:r.role)!=="holding"?!1:t.type==="item"?!0:((n=e.value)==null?void 0:n.physical)===!0||((i=e.value)==null?void 0:i.portable)===!0}function lYe(e){var t;return((t=e.value)==null?void 0:t.role)==="relation"}function iF(e,t){return ere.has(e.type)?t.some(r=>r.fromId==="actor_player"&&r.toId===e.id&&oYe(r,e)):!1}function cYe(e,t,r){if(!e)return[];const n=[];return t.actors&&e.actors.forEach(i=>{i.imageUrl||n.push({key:i.id,body:{target:"entity",entityId:i.id}})}),t.inventory&&e.holdings.forEach(i=>{i.imageUrl||n.push({key:i.id,body:{target:"entity",entityId:i.id}})}),t.moments&&e.turn!=null&&!r&&n.push({key:`scene-turn-${e.turn}`,body:{target:"scene"}}),n}function uYe(e){var q,j,U,W,J,G;if(!(e!=null&&e.graph))return null;const{entities:t,edges:r,stateSlots:n,events:i}=e.graph,s=new Map(t.map(O=>[O.id,O.label])),a=new Map(i.map(O=>[O.id,O.outcomeSummary??""])),o=r.filter(O=>O.validUntilEventId==null),l=i.reduce((O,D)=>O&&O.turn>D.turn?O:D,null),c=(l==null?void 0:l.id)??null,h=new Map(i.map(O=>[O.id,O.turn])),f=O=>{var H;const D=(H=O.summary)==null?void 0:H.trim();return D?D===O.label||D===O.status?[]:[{text:D}]:[]},g=O=>{var H;const D=(H=O.status)==null?void 0:H.trim();return!D||D===O.label?null:D},m=O=>o.filter(D=>lYe(D)&&(D.fromId===O||D.toId===O)).map(D=>{const H=D.fromId===O?s.get(D.toId):s.get(D.fromId),Y=typeof D.strength=="number"?` ${D.strength}`:"";return{label:V("关系","Relation","Quan hệ"),text:`${D.type}${Y}${H?` · ${H}`:""}`}}),x=t.filter(O=>O.type==="location").map(O=>({id:O.id,glyph:"📍",label:O.label,note:g(O),details:f(O)})),v=t.filter(O=>O.type==="actor").map(O=>({id:O.id,glyph:"👤",label:O.label,note:g(O),details:[...f(O),...m(O.id)],imageUrl:O.imageUrl})),C=t.filter(O=>ere.has(O.type)&&!iF(O,o)).map(O=>({id:O.id,glyph:eF[O.type]??"•",label:O.label,note:g(O),details:f(O),imageUrl:O.imageUrl})),k=O=>n.filter(D=>D.ownerEntityId===O&&D.kind!=="evidence").map(D=>{const{text:H,ratio:Y}=nF(D.value);return{id:D.id,glyph:tF[D.kind]??"•",label:D.label,value:H,note:null,details:[],ratio:Y}}),T=O=>o.filter(D=>(D.fromId===O||D.toId===O)&&D.fromId!=="actor_player"&&D.toId!=="actor_player").map(D=>{const H=D.fromId===O?D.toId:D.fromId;return{targetLabel:s.get(H)??H,type:D.type,strength:typeof D.strength=="number"?D.strength:void 0}}),w=O=>{const D=n.find(ae=>ae.ownerEntityId===O&&ae.kind==="evidence");if(!D||typeof D.value!="object"||D.value===null)return;const H=D.value,Y=typeof H.status=="string"?H.status:void 0;if(Y)return{stages:ZGe,current:Y,reason:typeof H.reason=="string"&&H.reason?H.reason:void 0}},L=t.filter(O=>iF(O,o)).map(O=>{var ye,we;const D=k(O.id),H=T(O.id),Y=w(O.id),ae=Y?void 0:g(O)??void 0,z=!!O.createdEventId&&O.createdEventId===c,K=!z&&O.updatedEventId&&O.updatedEventId===c&&a.get(O.updatedEventId)||void 0,se=(ye=O.summary)==null?void 0:ye.trim(),X=se&&se!==O.label&&se!==O.status?se:void 0,ke=((we=D[0])==null?void 0:we.value)||(H[0]?`${H[0].type}${H[0].targetLabel?`·${H[0].targetLabel}`:""}`:void 0)||(Y?Y.current:ae);return{id:O.id,kind:O.type,glyph:eF[O.type]??"•",label:O.label,imageUrl:O.imageUrl,summary:X,preview:ke,statusPill:ae,lifecycle:Y,meters:D,relations:H,provenanceTurn:O.createdEventId?h.get(O.createdEventId):void 0,isFresh:z,changeReason:K}}),N=n.filter(O=>!O.ownerEntityId).map(O=>{const D=O.updatedEventId&&a.get(O.updatedEventId)||"",{text:H,ratio:Y}=nF(O.value);return{id:O.id,glyph:tF[O.kind]??"•",label:O.label,kind:O.kind,value:H,ratio:Y,note:null,details:D?[{label:V("因为","Because","Vì"),text:D}]:[]}}),A=((q=e.currentState)==null?void 0:q.timeAdvance)??((j=[...i].reverse().find(O=>O.timeAdvance))==null?void 0:j.timeAdvance)??null,R=A&&(A.elapsed||A.anchor||A.rationale||(((U=A.synchronized)==null?void 0:U.length)??0)>0)?{id:"world-time",glyph:"⏳",label:V("世界时间","World time","Thời gian thế giới"),value:A.anchor||A.elapsed||"",note:A.rationale||null,details:[...A.elapsed&&A.anchor?[{label:V("经过","Elapsed","Đã trôi qua"),text:A.elapsed}]:[],...(A.synchronized??[]).map(O=>({label:V("同步","Synced","Đồng bộ"),text:O}))]}:null,P=i.reduce((O,D)=>Math.max(O,D.turn),0);return{turn:((W=e.currentState)==null?void 0:W.turn)??(i.length>0?P:null),mode:((J=e.currentState)==null?void 0:J.mode)??null,premise:((G=e.currentState)==null?void 0:G.premise)??"",time:R,facing:[...x,...v,...C],actors:v,holdings:L,meters:N}}function hYe(e){var W,J,G;const{sessionId:t,isStreaming:r,isZh:n,open:i,onClose:s}=e,a=`/play/runs/${encodeURIComponent(t)}/main`,[o,l]=_.useState(null),[c,h]=_.useState(null),[f,g]=_.useState(null),[m,x]=_.useState({actors:!1,moments:!1,inventory:!1}),[v,C]=_.useState(!1),[k,T]=_.useState(new Set),w=_.useRef(new Set),L=_.useRef(r),N=_.useCallback(async()=>{try{const O=await ct(a);g(O),O.imageSettings&&x(O.imageSettings)}catch{}},[a]);_.useEffect(()=>{N()},[N]),_.useEffect(()=>{L.current&&!r&&N(),L.current=r},[r,N]),_.useEffect(()=>{ct("/cover/config").then(O=>{const D=O.service??null;C(O.configured??(!!D&&(O.providers??[]).some(H=>H.service===D&&H.connected)))}).catch(()=>C(!1))},[]);const A=_.useCallback(async(O,D)=>{if(!w.current.has(O)){w.current.add(O),T(H=>new Set(H).add(O));try{await ct(`${a}/generate-image`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),await N()}catch{}finally{w.current.delete(O),T(H=>{const Y=new Set(H);return Y.delete(O),Y})}}},[a,N]),R=_.useMemo(()=>uYe(f),[f]),P=e.imageSettings??m,q=(R==null?void 0:R.holdings.find(O=>O.id===o))??null,j=(R==null?void 0:R.facing.find(O=>O.id===c&&O.imageUrl))??null;_.useEffect(()=>{!v||!R||cYe(R,P,f==null?void 0:f.sceneImageUrl).forEach(O=>void A(O.key,O.body))},[v,P,R,f==null?void 0:f.sceneImageUrl,A]);const U=((W=e.sessionTitle)==null?void 0:W.trim())||((J=f==null?void 0:f.title)==null?void 0:J.trim())||V("互动世界","Play World","Thế giới tương tác");return i?p.jsxs("aside",{className:"absolute bottom-28 right-0 top-0 z-20 flex w-[380px] max-w-[calc(100vw-1rem)] flex-col border-l border-border/40 bg-card/95 backdrop-blur shadow-xl",children:[p.jsxs("header",{className:"relative flex min-w-0 items-center gap-2.5 overflow-hidden border-b border-border/40 px-4 py-3",children:[p.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 -bottom-px h-px bg-gradient-to-r from-transparent via-primary/50 to-transparent"}),(R==null?void 0:R.turn)!=null?p.jsxs("div",{className:"flex shrink-0 flex-col items-center leading-none",children:[p.jsx("span",{className:"text-[24px] leading-6 font-extrabold text-primary",children:R.turn}),p.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:V("幕","Turn","Màn")})]}):p.jsx(_g,{size:16,className:"shrink-0 text-primary"}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate text-[16px] leading-6 font-bold text-foreground",children:U}),p.jsx("div",{className:"mt-0.5 text-[14px] leading-5 text-muted-foreground",children:(R==null?void 0:R.turn)==null?V("尚未开始","Not started","Chưa bắt đầu"):R!=null&&R.mode?R.mode==="guided"?V("互动模式","Guided","Chế độ dẫn dắt"):V("开放模式","Open","Chế độ mở"):V("互动世界","Play World","Thế giới tương tác")})]}),(G=R==null?void 0:R.time)!=null&&G.value?p.jsx("span",{className:"max-w-[122px] shrink-0 truncate rounded-full bg-secondary/60 px-2.5 py-1 text-[15px] leading-6 text-muted-foreground",title:R.time.note??R.time.value,children:R.time.value}):null,p.jsx("button",{type:"button",onClick:()=>{s(),l(null),h(null)},className:"shrink-0 text-muted-foreground hover:text-foreground",title:V("收起","Collapse","Thu gọn"),children:p.jsx(ho,{size:15})})]}),p.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4 text-[15px]",children:R?q?p.jsx(iYe,{row:q,isZh:n,generating:k.has(q.id),onBack:()=>l(null)}):j?p.jsx(dYe,{row:j,isZh:n,onBack:()=>h(null)}):p.jsxs(p.Fragment,{children:[R.time&&(R.time.note||R.time.details.length>0)?p.jsx(cb,{title:V("世界时间","World time","Thời gian thế giới"),icon:"⏳",empty:!1,emptyText:"",children:p.jsx(sF,{row:R.time,isZh:n})}):null,p.jsx(cb,{title:V("我面对的","Around me","Xung quanh tôi"),icon:"🧭",empty:R.facing.length===0,emptyText:V("周围还没有出现地点或人物","No places or people around yet","Chưa có địa điểm hay nhân vật nào xuất hiện"),children:R.facing.map(O=>p.jsx(sF,{row:O,isZh:n,generating:k.has(O.id),onOpenVisual:O.imageUrl?()=>{l(null),h(O.id)}:void 0},O.id))}),p.jsx(cb,{title:V("我握有的","What I hold","Những gì tôi có"),icon:"🎒",empty:R.holdings.length===0,emptyText:V("还没有获得物品、证据或线索","No items, evidence, or clues yet","Chưa có vật phẩm, chứng cứ hay manh mối nào"),children:R.holdings.map(O=>p.jsx(tYe,{row:O,isZh:n,generating:k.has(O.id),onOpen:()=>{h(null),l(O.id)}},O.id))}),p.jsx(cb,{title:V("状态","State","Trạng thái"),icon:"📊",empty:R.meters.length===0,emptyText:V("还没有出现数值(压力、资源、关系、倒计时等)","No meters yet (pressure, resources, relations, timers…)","Chưa có chỉ số nào (áp lực, tài nguyên, quan hệ, đếm ngược…)"),children:R.meters.map(O=>p.jsx(sYe,{row:O},O.id))}),R.premise&&p.jsx("div",{className:"rounded-lg border border-border/30 bg-secondary/30 px-3 py-2 text-[15px] leading-7 text-muted-foreground",children:R.premise})]}):p.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-xl border border-dashed border-border/50 bg-secondary/10 px-4 py-8 text-center",children:[p.jsx("span",{className:"text-3xl opacity-80",children:"🎲"}),p.jsx("p",{className:"text-[16px] leading-6 font-semibold text-foreground",children:V("这个世界还在沉睡","This world is still asleep","Thế giới này vẫn còn đang ngủ")}),p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground",children:V("在左边写下你的第一个动作,人物、线索、状态会在这里逐渐点亮。","Take your first action on the left — characters, clues, and state will light up here.","Viết hành động đầu tiên của bạn ở bên trái — nhân vật, manh mối và trạng thái sẽ dần hiện ra ở đây.")})]})})]}):null}function cb(e){return p.jsxs("section",{className:"relative rounded-xl border border-border/40 bg-secondary/20 px-3 pb-3 pt-2.5",children:[p.jsx("span",{"aria-hidden":!0,className:"absolute left-3 top-0 h-0.5 w-5 -translate-y-px rounded-full bg-primary/70"}),p.jsxs("h3",{className:"mb-2 flex items-center gap-1.5 text-[15px] leading-6 font-semibold uppercase tracking-[0.08em] text-muted-foreground/70",children:[p.jsx("span",{className:"text-[16px]",children:e.icon}),e.title]}),e.empty?p.jsx("p",{className:"text-[15px] leading-6 text-muted-foreground/50",children:e.emptyText}):p.jsx("div",{className:"space-y-1.5",children:e.children})]})}function dYe(e){const{row:t,onBack:r}=e;return p.jsxs("div",{className:"min-w-0 space-y-3",children:[p.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-[14px] leading-6 text-muted-foreground hover:text-foreground",children:[p.jsx(p_,{size:14})," ",V("返回","Back","Quay lại")]}),p.jsxs("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/40 bg-secondary/30",children:[p.jsx("div",{className:"flex min-h-[220px] items-center justify-center bg-gradient-to-b from-secondary/60 to-transparent",children:t.imageUrl?p.jsx("img",{src:t.imageUrl,alt:"","aria-hidden":"true",className:"max-h-[420px] w-full object-contain"}):p.jsx("span",{className:"text-4xl",children:t.glyph})}),p.jsxs("div",{className:"min-w-0 space-y-3 px-3 py-3",children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p.jsx("span",{className:"min-w-0 flex-1 break-words text-[18px] leading-7 font-bold text-foreground",children:t.label}),t.value?p.jsx("span",{className:"shrink-0 rounded-full bg-secondary/60 px-2.5 py-1 text-[13px] leading-5 font-medium text-primary",children:t.value}):null]}),t.note?p.jsx("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:t.note}):null,t.details.length>0?p.jsx("div",{className:"space-y-2 border-t border-border/30 pt-2",children:t.details.map((n,i)=>p.jsxs("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:[n.label?p.jsxs("span",{className:"text-muted-foreground/50",children:[n.label," "]}):null,n.text]},i))}):null]})]})]})}function sF({row:e,generating:t,onOpenVisual:r}){const[n,i]=_.useState(!1),s=e.details.length>0,a=!!e.imageUrl,o=a&&!!r,l=s||o;return p.jsxs("div",{className:"min-w-0 rounded-lg border border-border/30 bg-secondary/30",children:[p.jsxs("div",{role:l?"button":void 0,"aria-label":l?`${e.label} ${o?V("查看大图","view image","xem ảnh lớn"):n?V("收起详情","collapse details","thu gọn chi tiết"):V("展开详情","show details","xem chi tiết")}`:void 0,onClick:o?r:s?()=>i(c=>!c):void 0,className:`px-2.5 py-2 ${l?"cursor-pointer":""}`,children:[p.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[e.imageUrl?p.jsx("img",{src:e.imageUrl,alt:"","aria-hidden":"true",className:"h-12 w-12 shrink-0 self-center rounded-lg object-cover"}):p.jsx("span",{className:"shrink-0 pt-1 text-base leading-6",children:t?"⏳":e.glyph}),p.jsx("span",{className:"min-w-0 flex-1 break-words text-[15px] leading-6 font-medium text-foreground",children:e.label}),e.value?p.jsx("span",{className:"ml-auto min-w-0 max-w-[58%] truncate text-right text-[15px] leading-6 font-semibold text-primary",title:e.value,children:e.value}):null,s&&!o?p.jsx(Bu,{size:12,className:`${e.value?"ml-1.5":"ml-auto"} shrink-0 text-muted-foreground/50 transition-transform ${n?"rotate-180":""}`}):null]}),e.note?p.jsx("div",{className:`mt-1 break-words text-[14px] leading-6 text-muted-foreground ${a?"pl-[58px]":"pl-6"}`,children:e.note}):null]}),n&&p.jsx("div",{className:`min-w-0 space-y-1 px-2.5 pb-2 ${a?"pl-[68px]":"pl-8"}`,children:e.details.map((c,h)=>p.jsxs("p",{className:"break-words text-[14px] leading-6 text-muted-foreground",children:[c.label?p.jsxs("span",{className:"text-muted-foreground/50",children:[c.label," "]}):null,c.text]},h))})]})}function fYe(e){return e.choices.length===0?p.jsx("div",{className:"px-4 py-3 text-center text-xs text-muted-foreground/60",children:e.disabled?V("推进中…","Advancing…","Đang xử lý…"):V("等待场景给出选项…","Waiting for choices…","Đang chờ lựa chọn…")}):p.jsx("div",{className:"px-4 py-3",children:p.jsx("div",{className:"mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2.5",children:e.choices.map((t,r)=>p.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>e.onChoose(t),className:"group inline-flex items-center gap-2 rounded-full border border-border/50 bg-secondary/40 px-4 py-2 text-sm leading-5 text-foreground/90 shadow-sm transition-all hover:-translate-y-0.5 hover:border-primary/50 hover:bg-primary/10 hover:text-primary hover:shadow-md hover:shadow-primary/10 active:translate-y-0 disabled:pointer-events-none disabled:opacity-40",children:[p.jsx("span",{"aria-hidden":!0,className:"text-xs text-primary/50 transition-colors group-hover:text-primary",children:"▸"}),t]},`${r}-${t}`))})})}const c_=new Set(["play_start","play_step","play_revise"]);function pYe(e){if(!c_.has(e.tool)||e.status!=="completed")return[];const t=e.details;return Array.isArray(t==null?void 0:t.suggestedActions)?t.suggestedActions.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function aF(e,t){const r=pYe(e);return r.length===0?null:{key:typeof e.id=="string"&&e.id.trim()?e.id:t,choices:r}}function mYe(e){var t,r;for(let n=e.length-1;n>=0;n--){const i=((t=e[n])==null?void 0:t.parts)??[];for(let a=i.length-1;a>=0;a--){const o=i[a];if(!(o.type!=="tool"||!c_.has(o.execution.tool)))return aF(o.execution,`message-${n}-part-${a}`)}const s=((r=e[n])==null?void 0:r.toolExecutions)??[];for(let a=s.length-1;a>=0;a--){const o=s[a];if(c_.has(o.tool))return aF(o,`message-${n}-execution-${a}`)}}return null}const oF=128,lF=2*1024*1024,cF=8*1024*1024;function ire(e){const t=e.trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"");return t?/^[a-z]/.test(t)?t:`skill-${t}`:""}function gYe(e,t){const r=ire(t);return r?e.includes(r)?e.filter(n=>n!==r):[...e,r]:[...e]}function yYe(e){const t=Array.from(new Set(e.map(ire).filter(Boolean)));return t.length>0?t:void 0}async function sre(e){const t=Array.from(e);if(t.length>oF)throw new Error(`A skill may contain at most ${oF} files.`);let r=0;for(const i of t){if(i.size>lF)throw new Error(`${i.name} exceeds ${lF} bytes.`);if(r+=i.size,r>cF)throw new Error(`Skill folder exceeds ${cF} bytes.`)}const n=[];for(const i of t){const s=i.webkitRelativePath||i.name,a=new Uint8Array(await i.arrayBuffer());n.push({path:s,dataUrl:`data:${i.type||"application/octet-stream"};base64,${xYe(a)}`})}return n}function xYe(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}const bYe=8,uF=4*1024*1024,vYe=["image/*","text/plain","text/markdown","application/json","text/csv",".txt",".md",".markdown",".json",".csv",".tsv",".yaml",".yml",".log",".pdf"].join(",");function CYe(e){return new Promise((t,r)=>{const n=new FileReader;n.onerror=()=>r(n.error??new Error("Failed to read file")),n.onload=()=>t(String(n.result??"")),n.readAsDataURL(e)})}async function kYe(e){return Promise.all(e.map(async t=>({id:`${t.name}-${t.size}-${t.lastModified}`,filename:t.name,mediaType:t.type||"application/octet-stream",size:t.size,dataUrl:await CYe(t)})))}function hF(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.ceil(e/1024)} KB`:`${e} B`}function TYe(e){return typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function dF(e){if(typeof e=="number"&&typeof globalThis.cancelAnimationFrame=="function"){globalThis.cancelAnimationFrame(e);return}globalThis.clearTimeout(e)}function wYe({skills:e,diagnostics:t,selectedSkillIds:r,loading:n,error:i,saving:s,createError:a,onToggleSkill:o,onImport:l}){const c=new Set(r),h=_.useRef(null);return p.jsxs("div",{className:"absolute bottom-[calc(100%+10px)] left-0 z-40 w-full overflow-hidden rounded-2xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur",children:[p.jsx("div",{className:"border-b border-border/40 px-4 py-3",children:p.jsxs("div",{className:"flex items-center justify-between gap-3",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-bold",children:V("选择 Agent Skill","Select Agent Skills","Chọn Agent Skill")}),p.jsx("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:V("Agent 会按当前意图自主调用;点选 Skill 可强制它随下一条消息启用。","The agent can choose a skill from your intent; selecting one forces it for the next message.","Agent sẽ tự chọn skill theo ý định hiện tại; chọn thủ công sẽ bắt buộc dùng skill đó ở tin nhắn tiếp theo.")})]}),p.jsxs("div",{className:"flex shrink-0 items-center",children:[p.jsxs("button",{type:"button",onClick:()=>{var f;return(f=h.current)==null?void 0:f.click()},disabled:s,className:"flex items-center gap-1.5 rounded-lg border border-border/50 px-3 py-1.5 text-xs font-semibold text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary disabled:opacity-40",children:[p.jsx(WF,{size:13}),V("导入","Import","Nhập")]}),p.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",webkitdirectory:"",directory:"",onChange:f=>{var g;(g=f.currentTarget.files)!=null&&g.length&&l(f.currentTarget.files),f.currentTarget.value=""}})]})]})}),p.jsxs("div",{className:"max-h-[380px] overflow-y-auto p-3",children:[a?p.jsx("div",{className:"mb-3 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive",children:a}):null,t!=null&&t.length?p.jsxs("div",{className:"mb-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:[p.jsx("div",{className:"font-semibold",children:V("部分外部 Skill 未加载","Some external skills were not loaded","Một số skill bên ngoài chưa được tải")}),t.slice(0,4).map((f,g)=>p.jsxs("div",{className:"mt-1 break-all",children:[f.path?`${f.path}: `:"",f.message??V("格式无效","Invalid format","Định dạng không hợp lệ")]},`${f.path??"skill"}-${g}`))]}):null,n?p.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:V("加载 Skill...","Loading skills...","Đang tải skill...")}):i?p.jsx("div",{className:"rounded-xl bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}):e.length===0?p.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:V("还没有可用 Skill。","No skills available yet.","Chưa có skill nào khả dụng.")}):p.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:e.map(f=>{const g=c.has(f.id);return p.jsx("button",{type:"button",onClick:()=>o(f.id),className:`rounded-xl border p-3 text-left transition-all ${g?"border-primary/60 bg-primary/10":"border-border/50 bg-secondary/20 hover:border-primary/30 hover:bg-secondary/35"}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx("div",{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-md border ${g?"border-primary bg-primary text-primary-foreground":"border-border text-transparent"}`,children:p.jsx(ac,{size:13,strokeWidth:3})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"truncate text-sm font-semibold",children:f.name}),p.jsx("span",{className:"shrink-0 rounded-full bg-secondary px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:f.source??"skill"})]}),p.jsxs("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground/70",children:["@",f.id]}),p.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground",children:f.description})]})]})},f.id)})})]})]})}function ub({activeBookId:e,mode:t=e?"book":"book-create",nav:r,theme:n,t:i,sse:s}){const a=Ht(yf.activeMessages),o=Ht(yf.activeSession),l=Ht(he=>he.activeSessionId),c=Ht(he=>he.input),h=Ht(yf.isActiveSessionStreaming),f=Ht(yf.isActiveSessionChatStreaming),g=Ht(yf.activeSessionLastFailedSend),m=Ht(he=>he.selectedModel),x=Ht(he=>he.selectedService),v=Ht(he=>he.setInput),C=Ht(he=>he.sendMessage),k=Ht(he=>he.retryLastSend),T=Ht(he=>he.abortSession),w=Ht(he=>he.setSelectedModel),L=Ht(he=>he.loadSessionList),N=Ht(he=>he.createSession),A=Ht(he=>he.markProposalResolved),R=Ht(he=>he.loadSessionDetail),P=Ht(he=>he.activateSession),q=Ht(he=>he.setSessionPlayMode),j=_.useRef(null),U=_.useRef(null),W=_.useRef(null),J=_.useRef(null),G=_.useRef(!0),O=i("nav.connected")==="已连接",D=!!e,H=(o==null?void 0:o.sessionKind)??(t==="interactive-film-authoring"?"interactive-film-authoring":t==="book-create"?"book-create":e?"book":"chat"),Y=o==null?void 0:o.playMode,ae=H==="play"&&!Y,z=_.useMemo(()=>H==="play"&&Y==="guided"?mYe(a):null,[H,Y,a]),[K,se]=_.useState(null),X=(z==null?void 0:z.choices)??[],ke=fse({playMode:Y,choiceSetKey:(z==null?void 0:z.key)??null,consumedChoiceKey:K,choiceCount:X.length}),[ye,we]=_.useState(!1),[Fe,ue]=_.useState(null),[Ne,Te]=_.useState(!1),[Ue,Qe]=_.useState({actors:!1,moments:!1,inventory:!1}),[We,de]=_.useState(!1),[te,$e]=_.useState(!1),[Ie,Be]=_.useState([]),[Ee,je]=_.useState(!1),[ge,De]=_.useState(null),[xe,ut]=_.useState([]),[Ut,Oe]=_.useState(null),{data:Ge,loading:pt,error:mt,refetch:Se}=$r("/skills"),st=H==="play"&&ye?"lg:pr-[380px]":"",jt=(Ge==null?void 0:Ge.skills)??[],ft=_.useMemo(()=>Ie.map(he=>jt.find(gt=>gt.id===he)).filter(he=>!!he),[jt,Ie]),wt=_.useMemo(()=>{var gt;const he=a[a.length-1];return!he||he.role!=="assistant"?!1:he.thinkingStreaming===!0||!he.content||(((gt=he.toolExecutions)==null?void 0:gt.some(Gt=>Gt.status==="running"||Gt.status==="processing"))??!1)},[a]),Mt=$n(he=>he.services),qt=$n(he=>he.servicesLoading),Kr=$n(he=>he.bankModelsLoading),cn=$n(he=>he.customModelsLoading),fr=$n(he=>he.modelsByService),Nr=$n(he=>he.fetchServices),un=$n(he=>he.fetchBankModels),dn=$n(he=>he.fetchCustomModels),[qr,Dn]=_.useState(null),[xi,Vr]=_.useState(!1);_.useEffect(()=>{Nr()},[Nr]),_.useEffect(()=>{un(),dn()},[un,dn]),_.useEffect(()=>{let he=!1;return ct("/services/config").then(gt=>{he||Dn({service:gt.service??null,model:gt.defaultModel??null})}).catch(()=>{he||Dn(null)}).finally(()=>{he||Vr(!0)}),()=>{he=!0}},[]);const Pn=_.useMemo(()=>{if(qt||Mt.length===0)return"loading";const he=Mt.filter(kt=>kt.connected);if(he.length===0)return"no-models";if(Kr)return"loading";if(he.some(kt=>{var rr;return(((rr=fr[kt.service])==null?void 0:rr.length)??0)>0}))return"ready";const gt=he.some(kt=>!kt.service.startsWith("custom")),Gt=he.some(kt=>kt.service.startsWith("custom"));return!gt&&Gt&&cn?"loading":"no-models"},[Mt,qt,Kr,cn,fr]),Zi=_.useMemo(()=>Mt.filter(he=>{var gt;return he.connected&&(((gt=fr[he.service])==null?void 0:gt.length)??0)>0}).map(he=>({service:he.service,label:he.label,models:fr[he.service]})),[Mt,fr]),Cs=_.useMemo(()=>{if(!m)return V("选择模型","Select model","Chọn model");const he=Zi.find(kt=>kt.service===x),gt=he==null?void 0:he.models.find(kt=>kt.id===m),Gt=(gt==null?void 0:gt.name)??m;return he?`${he.label} · ${Gt}`:Gt},[Zi,m,x,O]);_.useEffect(()=>{if(!xi)return;const he=hse(Zi,m,x,qr);he&&w(he.model,he.service)},[qr,Zi,m,x,xi,w]),_.useEffect(()=>{const he=W.current;he&&(he.style.height="auto",he.style.height=`${Math.min(he.scrollHeight,200)}px`)},[c]),_.useEffect(()=>{const he=j.current;if(he&&G.current)return U.current!==null&&dF(U.current),U.current=TYe(()=>{he.scrollTo({top:he.scrollHeight,behavior:mse(h||wt)}),U.current=null}),()=>{U.current!==null&&(dF(U.current),U.current=null)}},[a,h,wt]),_.useEffect(()=>{G.current=!0},[l]),_.useEffect(()=>{let he=!1;return(async()=>{if(!e&&t==="project-chat"){const kt=Ht.getState(),rr=kt.activeSessionId?kt.sessions[kt.activeSessionId]:null;if((rr==null?void 0:rr.bookId)===null&&rr.isDraft)return}if(e){if(await L(e),he)return;const kt=Ht.getState(),rr=kt.activeSessionId?kt.sessions[kt.activeSessionId]:null;if((rr==null?void 0:rr.bookId)===e){await R(rr.sessionId);return}const $s=kt.sessionIdsByBook[e]??[];if($s.length>0){P($s[0]),await R($s[0]);return}await N(e,t==="interactive-film-authoring"?"interactive-film-authoring":"book");return}const gt=t==="project-chat"?cse():BF();if(gt){if(await R(gt),he)return;const rr=Ht.getState().sessions[gt];if(rr&&rr.bookId===null&&(t!=="project-chat"||rr.messages.length>0)){P(gt);return}}if(t==="project-chat"){const kt=await L(null);if(he)return;const rr=dse(kt);if(rr){P(rr),await R(rr),he||Qm(rr);return}}const Gt=await N(null,t==="book-create"?"book-create":"chat");he||(t==="project-chat"?Qm(Gt):ose(Gt))})(),()=>{he=!0}},[e,P,N,R,L,t]);const qa=he=>{const gt=Array.from(he),Gt=[],kt=[];for(const rr of gt){if(rr.size>uF){kt.push(`${rr.name} > ${hF(uF)}`);continue}Gt.push(rr)}ut(rr=>[...rr,...Gt].slice(0,bYe)),Oe(kt.length>0?V(`以下文件过大,未添加:${kt.join("、")}`,`Some files were too large: ${kt.join(", ")}`,`Một số tệp quá lớn, chưa được thêm: ${kt.join(", ")}`):null)},vo=async he=>{if(!l)return;if(!(!!he.trim()||xe.length>0)){(f||h)&&await T(l);return}const Gt=yYe(Ie);G.current=!0;const kt=await kYe(xe);f&&await T(l),await C(l,he,{activeBookId:e,sessionKind:H,actionSource:"free-text",requestedSkills:Gt,attachments:kt}),ut([]),Oe(null),Gt!=null&&Gt.length&&(Be([]),$e(!1))},Va=async he=>{je(!0),De(null);try{const gt=await sre(he),Gt=await di("/skills/import",{files:gt});await Se(),Be(kt=>kt.includes(Gt.skill.id)?kt:[...kt,Gt.skill.id])}catch(gt){De(gt instanceof Error?gt.message:String(gt))}finally{je(!1)}},ml=(he,gt)=>{l&&(G.current=!0,C(l,he,{activeBookId:e,sessionKind:H,actionSource:"quick-action",requestedIntent:gt}))},bi=async he=>{var kt,rr;A(he.execId,"confirmed");const gt=he.targetSessionKind==="play"?((rr=(kt=he.actionPayload)==null?void 0:kt.playStart)==null?void 0:rr.mode)??(o==null?void 0:o.playMode)??(he.action==="play_start"?"open":void 0):void 0;if(he.sameSession&&l){G.current=!0,await C(l,he.instruction??"",{activeBookId:e,sessionKind:he.targetSessionKind,playMode:gt,actionSource:"button",requestedIntent:he.action,actionPayload:he.actionPayload,requestedSkills:he.requestedSkills});return}const Gt=await N(null,he.targetSessionKind,gt);G.current=!0,await C(Gt,he.instruction??"",{sessionKind:he.targetSessionKind,playMode:gt,actionSource:"button",requestedIntent:he.action,actionPayload:he.actionPayload,requestedSkills:he.requestedSkills})},Qi=async he=>{if(A(he.execId,"rejected"),!l)return;G.current=!0;const gt=V(`取消这次操作:${he.title??he.instruction}`,`Cancel this action: ${he.title??he.instruction}`,`Hủy thao tác này: ${he.title??he.instruction}`);await C(l,gt,{activeBookId:e,sessionKind:H,actionSource:"button"})},zs=async(he,gt)=>{!l||!e||(G.current=!0,await C(l,hGe(he,gt,O?"zh":"en"),{activeBookId:e,sessionKind:"book",actionSource:"button"}))},gl=async he=>{!l||!e||(G.current=!0,await C(l,dGe(he,O?"zh":"en"),{activeBookId:e,sessionKind:"book",actionSource:"button"}))};_.useEffect(()=>{ue(null)},[l]),_.useEffect(()=>{if(!l||H!=="play")return;let he=!1;return ct(`/play/runs/${encodeURIComponent(l)}/main`).then(gt=>{!he&&gt.imageSettings&&Qe(gt.imageSettings)}).catch(()=>{}),ct("/cover/config").then(gt=>{if(he)return;const Gt=gt.service??null;de(gt.configured??(!!Gt&&(gt.providers??[]).some(kt=>kt.service===Gt&&kt.connected)))}).catch(()=>{he||de(!1)}),()=>{he=!0}},[l,H]);const Fi=async he=>{if(!l||H!=="play"||!We)return;const gt={...Ue,[he]:!Ue[he]};Qe(gt),ue(null);try{await ct(`/play/runs/${encodeURIComponent(l)}/main/image-settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(gt)})}catch(Gt){Qe(Ue),ue(Gt instanceof Error?Gt.message:String(Gt))}},yn=H==="short"?V("说一个短篇方向、标题灵感、人物压力或核心冲突,我会走 InkOS Short 生成正文、简介和封面。","Describe a short-fiction direction, title hook, pressure, or core conflict to run InkOS Short.","Mô tả hướng truyện ngắn, ý tưởng tiêu đề, áp lực nhân vật hoặc xung đột cốt lõi, tôi sẽ chạy InkOS Short để tạo nội dung, giới thiệu và bìa."):H==="play"?V("说一个可玩的世界、角色处境或开场动作,我会启动互动世界;之后你可以自由行动或点建议动作。","Describe a playable world, character situation, or opening action to start an interactive world.","Mô tả một thế giới có thể chơi được, hoàn cảnh nhân vật hoặc hành động mở đầu, tôi sẽ khởi động thế giới tương tác; sau đó bạn có thể tự do hành động hoặc chọn gợi ý."):V("告诉我你想写什么——题材、世界观、主角、核心冲突","Tell me what you want to write — genre, world, protagonist, core conflict","Cho tôi biết bạn muốn viết gì — thể loại, thế giới, nhân vật chính, xung đột cốt lõi");return p.jsxs("div",{className:"flex flex-col h-full flex-1 min-w-0 relative",children:[p.jsx("div",{ref:j,onScroll:he=>{const gt=he.currentTarget;G.current=pse({scrollTop:gt.scrollTop,clientHeight:gt.clientHeight,scrollHeight:gt.scrollHeight})},className:`chat-message-scroll flex-1 overflow-y-auto [scrollbar-gutter:stable] px-4 py-6 transition-[padding] duration-200 ${st}`,children:ae?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center select-none gap-4",children:[p.jsx("div",{className:"w-14 h-14 rounded-2xl border border-dashed border-border flex items-center justify-center bg-secondary/30 opacity-40",children:p.jsx(_g,{size:24,className:"text-muted-foreground"})}),p.jsx("p",{className:"text-sm text-muted-foreground/70 max-w-md leading-7",children:V("选个玩法,进去再聊你想玩的世界。","Pick a playstyle, then describe the world you want in chat.","Chọn cách chơi, sau đó vào chat kể về thế giới bạn muốn.")}),p.jsxs("div",{className:"flex gap-3",children:[p.jsxs("button",{type:"button",onClick:()=>{l&&q(l,"guided")},className:"w-40 rounded-xl border border-border/50 bg-secondary/30 px-4 py-3 text-left transition-all hover:border-primary/40 hover:bg-primary/5",children:[p.jsx("div",{className:"text-sm font-medium text-foreground",children:V("点着玩","Choices","Chọn hành động")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:V("GM 给选项,点着推进","Pick from offered actions","GM đưa ra lựa chọn, bạn chọn để tiếp tục")})]}),p.jsxs("button",{type:"button",onClick:()=>{l&&q(l,"open")},className:"w-40 rounded-xl border border-border/50 bg-secondary/30 px-4 py-3 text-left transition-all hover:border-primary/40 hover:bg-primary/5",children:[p.jsx("div",{className:"text-sm font-medium text-foreground",children:V("自由玩","Free","Chơi tự do")}),p.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:V("自己打字,想干嘛干嘛","Type anything you want","Tự gõ, muốn làm gì cũng được")})]})]})]}):a.length===0&&!h?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center select-none",children:[p.jsx("div",{className:"w-14 h-14 rounded-2xl border border-dashed border-border flex items-center justify-center mb-4 bg-secondary/30 opacity-40",children:p.jsx(Sae,{size:24,className:"text-muted-foreground"})}),p.jsx("p",{className:"text-sm text-muted-foreground/70 max-w-md leading-7",children:yn})]}):p.jsxs("div",{className:"max-w-3xl mx-auto space-y-4",children:[a.map((he,gt)=>p.jsx("div",{children:he.role==="user"?p.jsx(r2,{role:"user",content:he.content,timestamp:he.timestamp,theme:n}):he.parts&&he.parts.length>0?p.jsx(p.Fragment,{children:(()=>{const Gt=[];for(let kt=0;kt<he.parts.length;kt++){const rr=he.parts[kt];if(rr.type==="thinking")Gt.push({kind:"thinking",pi:kt,part:rr});else if(rr.type==="text")Gt.push({kind:"text",pi:kt,part:rr});else if(rr.type==="tool"){const $s=Gt[Gt.length-1];($s==null?void 0:$s.kind)==="tools"?$s.parts.push(rr):Gt.push({kind:"tools",parts:[rr],startIdx:kt})}}return Gt.map(kt=>kt.kind==="thinking"?p.jsx("div",{className:"mb-2",children:p.jsxs(Rte,{defaultOpen:!1,isStreaming:kt.part.streaming,children:[p.jsx(Mte,{}),p.jsx(Ite,{children:kt.part.content})]})},`t-${kt.pi}`):kt.kind==="tools"?p.jsx(Jte,{executions:kt.parts.map(rr=>rr.execution),onProposedAction:bi,onRejectProposedAction:Qi,onOpenFilmStudio:r.toFilmStudio,onSelectNarrativeBranch:zs,onRecheckNarrativeForecast:gl},`x-${kt.startIdx}`):kt.kind==="text"&&kt.part.content?p.jsx(r2,{role:"assistant",content:kt.part.content,timestamp:he.timestamp,theme:n},`c-${kt.pi}`):null)})()}):p.jsx(r2,{role:he.role,content:he.content,timestamp:he.timestamp,theme:n})},`${he.timestamp}-${gt}`)),h&&!wt&&p.jsx(Ote,{from:"assistant",children:p.jsx(Bte,{children:p.jsx(Nte,{className:"text-sm",duration:1.5,children:V("思考中...","Thinking...","Đang suy nghĩ...")})})})]})}),D&&!ke&&p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx("div",{className:"max-w-3xl mx-auto w-full px-4",children:p.jsx(SWe,{onAction:ml,disabled:h||!l,isZh:O})})}),H==="play"&&!ae&&ke&&p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx(fYe,{choices:X,disabled:h||!l,isZh:O,onChoose:he=>{!l||!z||(se(z.key),G.current=!0,C(l,he,{activeBookId:e,sessionKind:"play",actionSource:"button"}))}})}),g&&!f&&l?p.jsx("div",{className:`shrink-0 transition-[padding] duration-200 ${st}`,children:p.jsx("div",{className:"max-w-3xl mx-auto w-full px-4 pb-2",children:p.jsxs("button",{type:"button",onClick:()=>{G.current=!0,k(l)},className:"flex items-center gap-1.5 rounded-lg border border-border/50 bg-secondary/30 px-3 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary",children:[p.jsx(P0,{size:14}),V("重试上一条消息","Retry last message","Thử lại tin nhắn cuối")]})})}):null,ae?null:p.jsx("div",{className:`shrink-0 border-t border-border/40 px-4 py-3 transition-[padding] duration-200 ${st}`,children:p.jsxs("div",{className:"max-w-3xl mx-auto",children:[p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsxs("div",{className:"relative flex-1 rounded-xl bg-secondary/30 transition-all",children:[te?p.jsx(wYe,{skills:jt,diagnostics:Ge==null?void 0:Ge.diagnostics,selectedSkillIds:Ie,loading:pt,error:mt,saving:Ee,createError:ge,onToggleSkill:he=>Be(gt=>gYe(gt,he)),onImport:he=>void Va(he)}):null,p.jsx("input",{ref:J,type:"file",multiple:!0,accept:vYe,className:"hidden",onChange:he=>{he.currentTarget.files&&qa(he.currentTarget.files),he.currentTarget.value=""}}),ft.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5 border-b border-border/20 px-3 py-2",children:ft.map(he=>p.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary",children:[he.name,p.jsx("button",{type:"button",onClick:()=>Be(gt=>gt.filter(Gt=>Gt!==he.id)),className:"rounded-full p-0.5 hover:bg-primary/20","aria-label":V(`移除 ${he.name}`,`Remove ${he.name}`,`Xóa ${he.name}`),children:p.jsx(ho,{size:12})})]},he.id))}):null,xe.length>0||Ut?p.jsxs("div",{className:"border-b border-border/20 px-3 py-2",children:[xe.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5",children:xe.map(he=>p.jsxs("span",{className:"inline-flex max-w-[220px] items-center gap-1.5 rounded-full border border-border/50 bg-secondary/60 px-2.5 py-1 text-xs text-muted-foreground",title:`${he.name} · ${he.type||"application/octet-stream"} · ${hF(he.size)}`,children:[p.jsx(lR,{size:12}),p.jsx("span",{className:"truncate",children:he.name}),p.jsx("button",{type:"button",onClick:()=>ut(gt=>gt.filter(Gt=>Gt!==he)),className:"rounded-full p-0.5 hover:bg-muted","aria-label":V(`移除 ${he.name}`,`Remove ${he.name}`,`Xóa ${he.name}`),children:p.jsx(ho,{size:12})})]},`${he.name}-${he.size}-${he.lastModified}`))}):null,Ut?p.jsx("div",{className:"mt-1 text-xs leading-5 text-destructive",children:Ut}):null]}):null,p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[p.jsx("button",{type:"button",onClick:()=>$e(he=>!he),disabled:h||!l,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border/50 transition-colors disabled:opacity-30 ${te||Ie.length>0?"bg-primary/10 text-primary":"text-muted-foreground hover:border-primary/40 hover:text-primary"}`,title:V("添加 Skill","Add skill","Thêm skill"),"aria-label":V("添加 Skill","Add skill","Thêm skill"),children:p.jsx(Qo,{size:16,strokeWidth:2.4})}),p.jsx("button",{type:"button",onClick:()=>{var he;return(he=J.current)==null?void 0:he.click()},disabled:!l,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border/50 text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary disabled:opacity-30",title:V("上传图片或资料","Attach files","Đính kèm tệp"),"aria-label":V("上传图片或资料","Attach files","Đính kèm tệp"),children:p.jsx(lR,{size:16,strokeWidth:2.3})}),p.jsx("textarea",{ref:W,value:c,onChange:he=>v(he.target.value),onKeyDown:he=>{he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),vo(c))},placeholder:V("输入指令...","Enter command...","Nhập lệnh..."),disabled:!l,rows:1,className:"flex-1 bg-transparent text-base leading-7 placeholder:text-muted-foreground/50 outline-none! border-none! ring-0! shadow-none focus:outline-none! focus:ring-0! focus:border-none! resize-none disabled:opacity-50 max-h-[200px] overflow-y-auto"}),p.jsx("button",{type:"button",onClick:()=>void vo(c),disabled:!c.trim()&&xe.length===0&&!h||!l,className:"w-8 h-8 rounded-lg bg-primary text-primary-foreground flex items-center justify-center shrink-0 hover:scale-105 active:scale-95 transition-all disabled:opacity-20 disabled:scale-100 shadow-sm shadow-primary/20",title:h&&!c.trim()&&xe.length===0?V("停止当前回复","Stop","Dừng"):void 0,children:h&&!c.trim()&&xe.length===0?p.jsx(rle,{size:13,fill:"currentColor"}):p.jsx(gae,{size:14,strokeWidth:2.5})})]}),p.jsxs("div",{className:"flex items-center gap-2 px-3 pb-2 border-t border-border/20 pt-1.5",children:[Pn==="loading"?p.jsx("span",{className:"text-[15px] text-muted-foreground/40 animate-pulse",children:V("加载模型...","Loading models...","Đang tải model...")}):Pn==="ready"?p.jsxs(_w,{children:[p.jsxs(Ew,{className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-muted text-[16px] transition-colors cursor-pointer",children:[p.jsx("span",{className:"font-medium truncate max-w-[260px]",children:Cs}),p.jsx(Bu,{size:17,className:"text-muted-foreground"})]}),p.jsx(SYe,{groupedModels:Zi,selectedModel:m,selectedService:x,onSelect:w,onManage:()=>r.toServices()})]}):p.jsx("button",{onClick:()=>r.toServices(),className:"text-[15px] text-muted-foreground/50 hover:text-primary transition-colors",children:V("配置模型 →","Set up models →","Cấu hình model →")}),H==="play"&&p.jsxs("button",{type:"button",onClick:()=>we(he=>!he),className:`ml-auto flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[16px] font-medium transition-colors ${ye?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted hover:text-primary"}`,title:V("查看世界:持有 / 状态 / 关系","View world: holdings / state / relations","Xem thế giới: sở hữu / trạng thái / quan hệ"),children:[p.jsx(_g,{size:18}),V("查看世界","View World","Xem thế giới")]})]})]}),H==="play"?p.jsxs("div",{className:"relative mt-1 shrink-0",children:[p.jsx("button",{type:"button",onClick:()=>Te(he=>!he),disabled:h||!l,title:V("自动配图","Auto illustration","Tự động minh họa"),className:`flex h-10 w-10 items-center justify-center rounded-xl border border-border/50 bg-secondary/40 shadow-sm transition-all hover:border-primary/50 hover:bg-primary/10 hover:text-primary active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 ${Ne||Ue.actors||Ue.moments||Ue.inventory?"text-primary":"text-muted-foreground"}`,"aria-label":V("自动配图","Auto illustration","Tự động minh họa"),children:p.jsx(Ioe,{size:17})}),Ne?p.jsxs("div",{className:"absolute bottom-12 right-0 z-30 w-44 rounded-xl border border-border/50 bg-card/95 p-2 shadow-xl backdrop-blur",children:[p.jsx("div",{className:"mb-1.5 px-1 text-[12px] leading-5 font-semibold uppercase tracking-wider text-muted-foreground/60",children:V("自动配图","Auto illustration","Tự động minh họa")}),["actors","moments","inventory"].map(he=>p.jsxs("label",{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[14px] leading-6 ${We?"cursor-pointer text-foreground hover:bg-secondary/50":"cursor-not-allowed text-muted-foreground/40"}`,title:We?void 0:V("先在「模型配置」里配好生图 API 才能开启","Configure an image API in Model Settings first","Cần cấu hình API tạo ảnh trong Cấu hình model trước"),children:[p.jsx("input",{type:"checkbox",disabled:!We,checked:We&&Ue[he],onChange:()=>void Fi(he),className:"h-4 w-4 accent-primary"}),he==="actors"?V("为角色配图","Characters","Minh họa nhân vật"):he==="moments"?V("为时刻配图","Moments","Minh họa khoảnh khắc"):V("为背包配图","Inventory","Minh họa vật phẩm")]},he)),We?null:p.jsx("p",{className:"mt-1 px-1 text-[12px] leading-5 text-muted-foreground/50",children:V("未检测到生图 API。","No image API configured.","Chưa cấu hình API tạo ảnh.")})]}):null]}):null]}),Fe?p.jsx("p",{className:"mt-2 text-right text-[13px] leading-5 text-destructive/80",children:V(`配图失败:${Fe}`,`Image failed: ${Fe}`,`Minh họa thất bại: ${Fe}`)}):null]})}),H==="play"&&l&&p.jsx(hYe,{sessionId:l,isStreaming:h,isZh:O,open:ye,onClose:()=>we(!1),imageSettings:Ue,sessionTitle:(o==null?void 0:o.title)??null}),p.jsx(KGe,{})]})}function SYe({groupedModels:e,selectedModel:t,selectedService:r,onSelect:n,onManage:i}){const[s,a]=_.useState(""),o=_.useMemo(()=>use(e,s),[e,s]);return p.jsxs(Aw,{side:"top",align:"start",className:"w-64 max-h-80 flex flex-col",children:[p.jsx("div",{className:"px-2 py-1.5 border-b border-border/30",children:p.jsx("input",{type:"text",value:s,onChange:l=>a(l.target.value),placeholder:V("搜索模型...","Search models...","Tìm model..."),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/40",onClick:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation()})}),p.jsxs("div",{className:"overflow-y-auto flex-1",children:[o.map(l=>p.jsxs("div",{children:[p.jsx("div",{className:"px-2 py-1.5 text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:l.label}),l.models.map(c=>{const h=t===c.id&&r===l.service;return p.jsx(Ef,{onClick:()=>n(c.id,l.service),className:h?"bg-muted/50":"",children:p.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[p.jsx("span",{className:"text-sm",children:c.name??c.id}),h&&p.jsx(ac,{size:14,className:"text-primary shrink-0"})]})},`${l.service}:${c.id}`)})]},l.service)),o.length===0&&p.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center italic",children:V("无匹配模型","No matching models","Không có model phù hợp")})]}),p.jsx("div",{className:"border-t border-border/30",children:p.jsx(Ef,{onClick:i,className:"text-primary",children:V("管理服务商","Manage providers","Quản lý nhà cung cấp")})})]})}function _Ye(e,t){var n;const r={"ready-for-review":()=>t("chapter.readyForReview"),approved:()=>t("chapter.approved"),drafted:()=>t("chapter.drafted"),"needs-revision":()=>t("chapter.needsRevision"),imported:()=>t("chapter.imported"),"audit-failed":()=>t("chapter.auditFailed")};return((n=r[e])==null?void 0:n.call(r))??e}const fF={"ready-for-review":{color:"text-amber-500 bg-amber-500/10",icon:p.jsx(Qv,{size:12})},approved:{color:"text-emerald-500 bg-emerald-500/10",icon:p.jsx(ac,{size:12})},drafted:{color:"text-muted-foreground bg-muted/20",icon:p.jsx(Uh,{size:12})},"needs-revision":{color:"text-destructive bg-destructive/10",icon:p.jsx(P0,{size:12})},imported:{color:"text-blue-500 bg-blue-500/10",icon:p.jsx(Zv,{size:12})}};function EYe({bookId:e,nav:t,theme:r,t:n,sse:i}){const{data:s,loading:a,error:o,refetch:l}=$r(`/books/${e}`),[c,h]=_.useState(!1),[f,g]=_.useState(!1),[m,x]=_.useState(!1),[v,C]=_.useState(!1),[k,T]=_.useState([]),[w,L]=_.useState([]),[N,A]=_.useState([]),[R,P]=_.useState(!1),[q,j]=_.useState(null),[U,W]=_.useState(null),[J,G]=_.useState(null),[O,D]=_.useState("txt"),[H,Y]=_.useState(!1),[ae,z]=_.useState(null),[K,se]=_.useState("auto");_.useEffect(()=>{ct(`/books/${encodeURIComponent(e)}/chapter-review-mode`).then(Se=>se(Se.mode==="manual"?"manual":"auto")).catch(()=>{})},[e]);const X=_.useMemo(()=>ise(i.messages,e),[e,i.messages]),ke=c||X.writing,ye=f||X.drafting,we=s?s.nextChapter-1:0;_.useEffect(()=>{const Se=i.messages.at(-1);if(!Se)return;const st=Se.data;if((st==null?void 0:st.bookId)===e){if(Se.event==="write:start"){h(!1);return}if(Se.event==="draft:start"){g(!1);return}sse(Se,e)&&(h(!1),g(!1),l())}},[e,l,i.messages]);const Fe=async()=>{h(!0);try{await di(`/books/${e}/write-next`)}catch(Se){h(!1),alert(Se instanceof Error?Se.message:"Failed")}},ue=async()=>{g(!0);try{await di(`/books/${e}/draft`)}catch(Se){g(!1),alert(Se instanceof Error?Se.message:"Failed")}},Ne=async()=>{const Se=K==="manual"?"auto":"manual";se(Se);try{await ct(`/books/${encodeURIComponent(e)}/chapter-review-mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:Se})})}catch{se(K)}},Te=async()=>{C(!1),x(!0);try{const Se=await fetch(`/api/v1/books/${e}`,{method:"DELETE"});if(!Se.ok){const st=await Se.json().catch(()=>({}));throw new Error(st.error??`${Se.status}`)}t.toDashboard()}catch(Se){alert(Se instanceof Error?Se.message:"Delete failed")}finally{x(!1)}},Ue=async Se=>{const st=window.prompt(V("可选:输入这次重写要遵循的补充想法。留空则沿用现有 focus。","Optional rewrite brief for this run only. Leave blank to use existing focus.","Tùy chọn: nhập ý tưởng bổ sung cần theo cho lần viết lại này. Để trống sẽ dùng focus hiện tại."),"");if(st!==null){T(jt=>[...jt,Se]);try{await ct(`/books/${e}/rewrite/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:st.trim()||void 0})}),l()}catch(jt){alert(jt instanceof Error?jt.message:"Rewrite failed")}finally{T(jt=>jt.filter(ft=>ft!==Se))}}},Qe=async(Se,st)=>{const jt=window.prompt(V("可选:输入这次修订要遵循的补充想法。留空则沿用现有 focus。","Optional revise brief for this run only. Leave blank to use existing focus.","Tùy chọn: nhập ý tưởng bổ sung cần theo cho lần chỉnh sửa này. Để trống sẽ dùng focus hiện tại."),"");if(jt!==null){L(ft=>[...ft,Se]);try{await ct(`/books/${e}/revise/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:st,brief:jt.trim()||void 0})}),l()}catch(ft){alert(ft instanceof Error?ft.message:"Revision failed")}finally{L(ft=>ft.filter(wt=>wt!==Se))}}},We=async Se=>{const st=window.prompt(V("可选:输入这次同步时要遵循的补充说明。留空则直接按正文同步。","Optional sync brief for interpreting the edited chapter body. Leave blank to sync directly from the text.","Tùy chọn: nhập ghi chú bổ sung cần theo khi đồng bộ lần này. Để trống sẽ đồng bộ trực tiếp theo nội dung chương."),"");if(st!==null){A(jt=>[...jt,Se]);try{await ct(`/books/${e}/resync/${Se}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:st.trim()||void 0})}),l()}catch(jt){alert(jt instanceof Error?jt.message:"Sync failed")}finally{A(jt=>jt.filter(ft=>ft!==Se))}}},de=async()=>{if(s){P(!0);try{const Se={};q!==null&&(Se.chapterWordCount=q),U!==null&&(Se.targetChapters=U),J!==null&&(Se.status=J),await ct(`/books/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Se)}),l()}catch(Se){alert(Se instanceof Error?Se.message:"Save failed")}finally{P(!1)}}},te=async()=>{if(!s)return;const Se=s.chapters.filter(jt=>jt.status==="ready-for-review");let st=0;for(const jt of Se)try{await di(`/books/${e}/chapters/${jt.number}/approve`)}catch{st+=1}st>0&&alert(`${st}/${Se.length} approve(s) failed`),l()},$e=async(Se,st)=>{z(Se);try{alert(await st()),l()}catch(jt){alert(jt instanceof Error?jt.message:"Action failed")}finally{z(null)}},Ie=async()=>{await $e("eval",async()=>{const Se=await ct(`/books/${e}/eval`);return[`${n("book.evaluate")}: ${Se.qualityScore}/100`,`${n("dash.chapters")}: ${Se.totalChapters}`,`${n("book.words")}: ${Se.totalWords.toLocaleString()}`,`Audit: ${Se.auditPassRate}%`,`AI tells: ${Se.avgAiTellDensity}/1k`,`Hooks: ${Se.hookResolveRate}%`].join(`
1405
1410
  `)})},Be=async()=>{await $e("consolidate",async()=>{const Se=await ct(`/books/${e}/consolidate`,{method:"POST"});return V(`已归并 ${Se.archivedVolumes??0} 个卷摘要,保留最近 ${Se.retainedChapters??0} 条章节摘要。`,`Consolidated ${Se.archivedVolumes??0} volume(s). Retained ${Se.retainedChapters??0} recent chapter summaries.`,`Đã gộp ${Se.archivedVolumes??0} tóm tắt quyển, giữ lại ${Se.retainedChapters??0} tóm tắt chương gần nhất.`)})},Ee=async()=>{const Se=window.prompt(V("输入重修基础设定的反馈。此操作会重写基础设定,不直接改正文。","Foundation revision feedback. This rewrites the book foundation, not chapter body.","Nhập phản hồi để chỉnh sửa lại thiết lập cơ bản. Thao tác này viết lại thiết lập cơ bản, không sửa trực tiếp nội dung chương."),"");Se!=null&&Se.trim()&&await $e("revise-foundation",async()=>(await ct(`/books/${e}/foundation/revise`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Se})}),V("基础设定已重修。","Foundation revised.","Đã chỉnh sửa lại thiết lập cơ bản.")))},je=async()=>{const Se=window.prompt(V("可选:下一章规划补充说明。","Optional planning context for the next chapter.","Tùy chọn: ghi chú bổ sung cho việc lên kế hoạch chương tiếp theo."),"");Se!==null&&await $e("plan",async()=>{const st=await ct(`/books/${e}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:Se.trim()||void 0})});return V(`已计划第 ${st.chapterNumber??"?"} 章:${st.title??""}`,`Planned chapter ${st.chapterNumber??"?"}: ${st.title??""}`,`Đã lên kế hoạch chương ${st.chapterNumber??"?"}: ${st.title??""}`)})},ge=async()=>{const Se=window.prompt(V("可选:下一章组装补充说明。","Optional compose context for the next chapter.","Tùy chọn: ghi chú bổ sung cho việc soạn chương tiếp theo."),"");Se!==null&&await $e("compose",async()=>{const st=await ct(`/books/${e}/compose`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:Se.trim()||void 0})});return V(`已组装第 ${st.chapterNumber??"?"} 章:${st.title??""}`,`Composed chapter ${st.chapterNumber??"?"}: ${st.title??""}`,`Đã soạn chương ${st.chapterNumber??"?"}: ${st.title??""}`)})},De=async Se=>{await $e(`repair-state-${Se}`,async()=>(await ct(`/books/${e}/repair-state/${Se}`,{method:"POST"}),V(`第 ${Se} 章状态已修复。`,`Chapter ${Se} state repaired.`,`Đã khôi phục trạng thái chương ${Se}.`)))};if(a)return p.jsxs("div",{className:"flex flex-col items-center justify-center py-32 space-y-4",children:[p.jsx("div",{className:"w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin"}),p.jsx("span",{className:"text-sm text-muted-foreground",children:n("common.loading")})]});if(o)return p.jsxs("div",{className:"text-destructive p-8 bg-destructive/5 rounded-xl border border-destructive/20",children:["Error: ",o]});if(!s)return null;const{book:xe,chapters:ut}=s,Ut=ut.reduce((Se,st)=>Se+(st.wordCount??0),0),Oe=ut.filter(Se=>Se.status==="ready-for-review").length,Ge=q??xe.chapterWordCount,pt=U??xe.targetChapters??0,mt=J??xe.status;return p.jsxs("div",{className:"space-y-8 fade-in",children:[p.jsxs("nav",{className:"flex items-center gap-2 text-[13px] font-medium text-muted-foreground",children:[p.jsxs("button",{onClick:t.toDashboard,className:"hover:text-primary transition-colors flex items-center gap-1",children:[p.jsx(p_,{size:14}),n("bread.books")]}),p.jsx("span",{className:"text-border",children:"/"}),p.jsx("span",{className:"text-foreground",children:xe.title})]}),p.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 border-b border-border/40 pb-8",children:[p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("h1",{className:"text-4xl font-serif font-medium",children:xe.title}),xe.language==="en"&&p.jsx("span",{className:"px-1.5 py-0.5 rounded border border-primary/20 text-primary text-[10px] font-bold",children:"EN"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground font-medium",children:[p.jsx("span",{className:"px-2 py-0.5 rounded bg-secondary/50 text-foreground/70 uppercase tracking-wider text-xs",children:xe.genre}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Uh,{size:14}),p.jsxs("span",{children:[ut.length," ",n("dash.chapters")]})]}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(qh,{size:14}),p.jsxs("span",{children:[Ut.toLocaleString()," ",n("book.words")]})]}),xe.fanficMode&&p.jsxs("span",{className:"flex items-center gap-1 text-purple-500",children:[p.jsx(l2,{size:12}),p.jsxs("span",{className:"italic",children:["fanfic:",xe.fanficMode]})]})]})]}),p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsxs("button",{onClick:Fe,disabled:ke||ye,className:"flex items-center gap-2 px-5 py-2.5 text-sm font-bold bg-primary text-primary-foreground rounded-xl hover:scale-105 active:scale-95 transition-all shadow-lg shadow-primary/20 disabled:opacity-50",children:[ke?p.jsx("div",{className:"w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin"}):p.jsx(qh,{size:16}),n(ke?"dash.writing":"book.writeNext")]}),p.jsxs("button",{onClick:ue,disabled:ke||ye,className:"flex items-center gap-2 px-5 py-2.5 text-sm font-bold bg-secondary text-foreground rounded-xl hover:bg-secondary/80 transition-all border border-border/50 disabled:opacity-50",children:[ye?p.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/20 border-t-muted-foreground rounded-full animate-spin"}):p.jsx(a0,{size:16}),n(ye?"book.drafting":"book.draftOnly")]}),p.jsxs("button",{onClick:Ne,title:K==="manual"?V("手动审查:写完即停,由你点 审稿/修订/通过(更快、更可控)。点此切回自动。","Manual review: stops after writing so you click review/revise/approve (faster, more control). Click to switch back to automatic.","Duyệt thủ công: dừng lại sau khi viết xong để bạn tự bấm duyệt/chỉnh sửa/thông qua (nhanh hơn, kiểm soát tốt hơn). Nhấn để chuyển lại tự động."):V("自动审查:写完自动审校并按需重写(更省心,但更慢)。点此切到手动·写完即停。","Automatic review: reviews and rewrites as needed right after writing (less hands-on, but slower). Click to switch to manual (stop after writing).","Duyệt tự động: tự động soát và viết lại khi cần ngay sau khi viết xong (đỡ phải làm thủ công, nhưng chậm hơn). Nhấn để chuyển sang thủ công (dừng sau khi viết)."),className:"flex items-center gap-2 px-4 py-2.5 text-sm font-medium bg-secondary/60 text-foreground rounded-xl border border-border/50 hover:bg-secondary transition-all",children:[K==="manual"?p.jsx(yoe,{size:16}):p.jsx(ow,{size:16}),K==="manual"?V("审查:手动·写完即停","Review: Manual · Stop after writing","Duyệt: Thủ công · Dừng sau khi viết"):V("审查:自动","Review: Automatic","Duyệt: Tự động")]}),p.jsxs("button",{onClick:()=>C(!0),disabled:m,className:"flex items-center gap-2 px-5 py-2.5 text-sm font-bold bg-destructive/10 text-destructive rounded-xl hover:bg-destructive hover:text-white transition-all border border-destructive/20 disabled:opacity-50",children:[m?p.jsx("div",{className:"w-4 h-4 border-2 border-destructive/20 border-t-destructive rounded-full animate-spin"}):p.jsx(qo,{size:16}),n(m?"common.loading":"book.deleteBook")]})]})]}),(ke||ye||X.lastError)&&p.jsx("div",{className:`rounded-2xl border px-4 py-3 text-sm ${X.lastError?"border-destructive/30 bg-destructive/5 text-destructive":"border-primary/20 bg-primary/[0.04] text-foreground"}`,children:X.lastError?p.jsxs("span",{children:[n("book.pipelineFailed"),": ",X.lastError]}):ke?p.jsx("span",{children:n("book.pipelineWriting")}):p.jsx("span",{children:n("book.pipelineDrafting")})}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[Oe>0&&p.jsxs("button",{onClick:te,className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-emerald-500/10 text-emerald-600 rounded-lg hover:bg-emerald-500/20 transition-all border border-emerald-500/20",children:[p.jsx(Bae,{size:14}),n("book.approveAll")," (",Oe,")"]}),p.jsxs("button",{onClick:()=>t.toTruth(e),className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50",children:[p.jsx(sR,{size:14}),n("book.truthFiles")]}),p.jsxs("button",{onClick:()=>t.toAnalytics(e),className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50",children:[p.jsx($F,{size:14}),n("book.analytics")]}),p.jsxs("button",{onClick:Ie,disabled:ae==="eval",className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50 disabled:opacity-50",children:[p.jsx(Jv,{size:14}),n(ae==="eval"?"common.loading":"book.evaluate")]}),p.jsxs("button",{onClick:Be,disabled:ae==="consolidate",className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50 disabled:opacity-50",children:[p.jsx(sR,{size:14}),n(ae==="consolidate"?"common.loading":"book.consolidate")]}),p.jsxs("button",{onClick:Ee,disabled:ae==="revise-foundation",className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50 disabled:opacity-50",children:[p.jsx(l2,{size:14}),n(ae==="revise-foundation"?"common.loading":"book.reviseFoundation")]}),p.jsxs("button",{onClick:je,disabled:ae==="plan",className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50 disabled:opacity-50",children:[p.jsx(Uh,{size:14}),n(ae==="plan"?"common.loading":"book.planNext")]}),p.jsxs("button",{onClick:ge,disabled:ae==="compose",className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50 disabled:opacity-50",children:[p.jsx(a0,{size:14}),n(ae==="compose"?"common.loading":"book.composeNext")]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("select",{value:O,onChange:Se=>D(Se.target.value),className:"px-2 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg border border-border/50 outline-none",children:[p.jsx("option",{value:"txt",children:"TXT"}),p.jsx("option",{value:"md",children:"MD"}),p.jsx("option",{value:"epub",children:"EPUB"})]}),p.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-bold text-muted-foreground cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:H,onChange:Se=>Y(Se.target.checked),className:"rounded border-border/50"}),n("book.approvedOnly")]}),p.jsxs("button",{onClick:async()=>{try{const Se=await ct(`/books/${e}/export-save`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:O,approvedOnly:H})});alert(`${n("common.exportSuccess")}
1406
1411
  ${Se.path}
1407
1412
  (${Se.chapters} ${n("dash.chapters")})`)}catch(Se){alert(Se instanceof Error?Se.message:"Export failed")}},className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-secondary/50 text-muted-foreground rounded-lg hover:text-foreground hover:bg-secondary transition-all border border-border/50",children:[p.jsx(Zv,{size:14}),n("book.export")]})]})]}),p.jsxs("div",{className:"paper-sheet rounded-2xl border border-border/40 shadow-sm p-6",children:[p.jsx("h2",{className:"text-sm font-bold uppercase tracking-widest text-muted-foreground mb-4",children:n("book.settings")}),p.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("label",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:n("create.wordsPerChapter")}),p.jsx("input",{type:"number",value:Ge,onChange:Se=>j(Number(Se.target.value)),className:"px-3 py-2 text-sm rounded-lg border border-border/50 bg-secondary/30 outline-none focus:border-primary/50 w-32"})]}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("label",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:n("create.targetChapters")}),p.jsx("input",{type:"number",value:pt,onChange:Se=>W(Number(Se.target.value)),className:"px-3 py-2 text-sm rounded-lg border border-border/50 bg-secondary/30 outline-none focus:border-primary/50 w-32"})]}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("label",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:n("book.status")}),p.jsxs("select",{value:mt,onChange:Se=>G(Se.target.value),className:"px-3 py-2 text-sm rounded-lg border border-border/50 bg-secondary/30 outline-none focus:border-primary/50",children:[p.jsx("option",{value:"active",children:n("book.statusActive")}),p.jsx("option",{value:"paused",children:n("book.statusPaused")}),p.jsx("option",{value:"outlining",children:n("book.statusOutlining")}),p.jsx("option",{value:"completed",children:n("book.statusCompleted")}),p.jsx("option",{value:"dropped",children:n("book.statusDropped")})]})]}),p.jsxs("button",{onClick:de,disabled:R,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold bg-primary text-primary-foreground rounded-lg hover:scale-105 active:scale-95 transition-all disabled:opacity-50",children:[R?p.jsx("div",{className:"w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin"}):p.jsx(j0,{size:14}),n(R?"book.saving":"book.save")]})]})]}),p.jsxs("div",{className:"paper-sheet rounded-2xl overflow-hidden border border-border/40 shadow-xl shadow-primary/5",children:[p.jsx("div",{className:"overflow-x-auto",children:p.jsxs("table",{className:"w-full text-sm border-collapse",children:[p.jsx("thead",{children:p.jsxs("tr",{className:"bg-muted/30 border-b border-border/50",children:[p.jsx("th",{className:"text-left px-6 py-4 font-bold text-[11px] uppercase tracking-widest text-muted-foreground w-16",children:"#"}),p.jsx("th",{className:"text-left px-6 py-4 font-bold text-[11px] uppercase tracking-widest text-muted-foreground",children:n("book.manuscriptTitle")}),p.jsx("th",{className:"text-left px-6 py-4 font-bold text-[11px] uppercase tracking-widest text-muted-foreground w-28",children:n("book.words")}),p.jsx("th",{className:"text-left px-6 py-4 font-bold text-[11px] uppercase tracking-widest text-muted-foreground w-36",children:n("book.status")}),p.jsx("th",{className:"text-right px-6 py-4 font-bold text-[11px] uppercase tracking-widest text-muted-foreground",children:n("book.curate")})]})}),p.jsx("tbody",{className:"divide-y divide-border/30",children:ut.map((Se,st)=>{var ft,wt;const jt=`stagger-${Math.min(st+1,5)}`;return p.jsxs("tr",{className:`group hover:bg-primary/[0.02] transition-colors fade-in ${jt}`,children:[p.jsx("td",{className:"px-6 py-4 text-muted-foreground/60 font-mono text-xs",children:Se.number.toString().padStart(2,"0")}),p.jsx("td",{className:"px-6 py-4",children:p.jsx("button",{onClick:()=>t.toChapter(e,Se.number),className:"font-serif text-lg font-medium hover:text-primary transition-colors text-left",children:Se.title||n("chapter.label").replace("{n}",String(Se.number))})}),p.jsx("td",{className:"px-6 py-4 text-muted-foreground font-medium tabular-nums text-xs",children:(Se.wordCount??0).toLocaleString()}),p.jsx("td",{className:"px-6 py-4",children:p.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-tight ${((ft=fF[Se.status])==null?void 0:ft.color)??"bg-muted text-muted-foreground"}`,children:[(wt=fF[Se.status])==null?void 0:wt.icon,_Ye(Se.status,n)]})}),p.jsx("td",{className:"px-6 py-4 text-right",children:p.jsxs("div",{className:"flex gap-1.5 justify-end opacity-0 group-hover:opacity-100 transition-opacity",children:[Se.status==="ready-for-review"&&p.jsxs(p.Fragment,{children:[p.jsx("button",{onClick:async()=>{try{await di(`/books/${e}/chapters/${Se.number}/approve`),l()}catch(Mt){alert(Mt instanceof Error?Mt.message:"Approve failed")}},className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-600 hover:bg-emerald-500 hover:text-white transition-all shadow-sm",title:n("book.approve"),children:p.jsx(ac,{size:14})}),p.jsx("button",{onClick:async()=>{try{await di(`/books/${e}/chapters/${Se.number}/reject`),l()}catch(Mt){alert(Mt instanceof Error?Mt.message:"Reject failed")}},className:"p-2 rounded-lg bg-destructive/10 text-destructive hover:bg-destructive hover:text-white transition-all shadow-sm",title:n("book.reject"),children:p.jsx(ho,{size:14})})]}),p.jsx("button",{onClick:async()=>{var Mt;try{const qt=await ct(`/books/${e}/audit/${Se.number}`,{method:"POST"});alert(qt.passed?"Audit passed":`Audit failed: ${((Mt=qt.issues)==null?void 0:Mt.length)??0} issues`),l()}catch(qt){alert(qt instanceof Error?qt.message:"Audit failed")}},className:"p-2 rounded-lg bg-secondary text-muted-foreground hover:text-primary hover:bg-primary/10 transition-all shadow-sm",title:n("book.audit"),children:p.jsx(KF,{size:14})}),p.jsx("button",{onClick:()=>Ue(Se.number),disabled:k.includes(Se.number),className:"p-2 rounded-lg bg-secondary text-muted-foreground hover:text-primary hover:bg-primary/10 transition-all shadow-sm disabled:opacity-50",title:n("book.rewrite"),children:k.includes(Se.number)?p.jsx("div",{className:"w-3.5 h-3.5 border-2 border-muted-foreground/20 border-t-muted-foreground rounded-full animate-spin"}):p.jsx(P0,{size:14})}),p.jsx("button",{onClick:()=>We(Se.number),disabled:N.includes(Se.number)||Se.number!==we,className:"p-2 rounded-lg bg-secondary text-muted-foreground hover:text-primary hover:bg-primary/10 transition-all shadow-sm disabled:opacity-50",title:V("根据已编辑章节同步 truth/state","Sync truth/state from edited chapter","Đồng bộ truth/state theo chương đã chỉnh sửa"),children:N.includes(Se.number)?p.jsx("div",{className:"w-3.5 h-3.5 border-2 border-muted-foreground/20 border-t-muted-foreground rounded-full animate-spin"}):p.jsx(Eg,{size:14})}),Se.status==="state-degraded"&&p.jsx("button",{onClick:()=>De(Se.number),disabled:ae===`repair-state-${Se.number}`,className:"p-2 rounded-lg bg-amber-500/10 text-amber-600 hover:bg-amber-500 hover:text-white transition-all shadow-sm disabled:opacity-50",title:n("book.repairState"),children:ae===`repair-state-${Se.number}`?p.jsx("div",{className:"w-3.5 h-3.5 border-2 border-amber-600/20 border-t-amber-600 rounded-full animate-spin"}):p.jsx(ow,{size:14})}),p.jsxs("select",{disabled:w.includes(Se.number),value:"",onChange:Mt=>{const qt=Mt.target.value;qt&&Qe(Se.number,qt)},className:"px-2 py-1.5 text-[11px] font-bold rounded-lg bg-secondary text-muted-foreground border border-border/50 outline-none hover:text-primary hover:bg-primary/10 transition-all disabled:opacity-50 cursor-pointer",title:"Revise with AI",children:[p.jsx("option",{value:"",disabled:!0,children:w.includes(Se.number)?n("common.loading"):n("book.curate")}),p.jsx("option",{value:"spot-fix",children:n("book.spotFix")}),p.jsx("option",{value:"polish",children:n("book.polish")}),p.jsx("option",{value:"rewrite",children:n("book.rewrite")}),p.jsx("option",{value:"rework",children:n("book.rework")}),p.jsx("option",{value:"anti-detect",children:n("book.antiDetect")})]})]})})]},Se.number)})})]})}),ut.length===0&&p.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[p.jsx("div",{className:"w-12 h-12 rounded-full bg-muted/20 flex items-center justify-center mb-4",children:p.jsx(Uh,{size:20,className:"text-muted-foreground/40"})}),p.jsx("p",{className:"text-sm italic font-serif text-muted-foreground",children:n("book.noChapters")})]})]}),p.jsx(eC,{open:v,title:n("book.deleteBook"),message:n("book.confirmDelete"),confirmLabel:n("common.delete"),cancelLabel:n("common.cancel"),variant:"danger",onConfirm:Te,onCancel:()=>C(!1)})]})}function AYe({bookId:e,chapterNumber:t,t:r,onChapterChanged:n,onChapterDeleted:i}){const s=`/books/${e}/chapters/${t}/workspace`,{data:a,loading:o,error:l,refetch:c}=$r(s),[h,f]=_.useState(""),[g,m]=_.useState(null),[x,v]=_.useState(""),[C,k]=_.useState(""),[T,w]=_.useState(""),[L,N]=_.useState(null);_.useEffect(()=>{a&&f(a.brief)},[a]);const A=async(G,O)=>{m(G),v(""),k("");try{await O()}catch(D){k(D instanceof Error?D.message:String(D))}finally{m(null)}},R=()=>A("save",async()=>{await ct(`${s}/brief`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:h})}),await c(),v(r("reader.saved"))}),P=()=>A("rewrite",async()=>{await ct(`/books/${e}/rewrite/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:h})}),await Promise.all([c(),Promise.resolve(n())]),v(r("reader.rewriteComplete"))}),q=()=>A("inspiration",async()=>{const G=await ct(`${s}/inspiration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brief:h})});w(G.card)}),j=async G=>{k("");try{const O=await ct(`/books/${e}/chapters/${t}/versions/${G}`);N({id:G,content:O.content})}catch(O){k(O instanceof Error?O.message:String(O))}},U=G=>{window.confirm(r("reader.restoreConfirm"))&&A("restore",async()=>{await ct(`/books/${e}/chapters/${t}/versions/${G}/restore`,{method:"POST"}),N(null),await Promise.all([c(),Promise.resolve(n())]),v(r("reader.restoreComplete"))})},W=()=>{window.confirm(r("reader.deleteChapterConfirm"))&&A("delete",async()=>{await ct(`/books/${e}/chapters/${t}`,{method:"DELETE"}),i()})},J=()=>{f(G=>[G.trim(),T.trim()].filter(Boolean).join(`
@@ -1421,4 +1426,4 @@ ${Se.path}
1421
1426
  `)[0]??"":/^0?3[_\s]|配角|supporting|cast/i.test(s)&&(i=s.replace(/^[^\n]+\n/,"").trim().split(`
1422
1427
 
1423
1428
  `)[0]??"");return{world:r,protagonist:n,cast:i}}function ZXe({bookId:e}){const[t,r]=_.useState(null),[n,i]=_.useState(""),[s,a]=_.useState(null),o=Ht(f=>f.openArtifact),l=Ht(f=>f.bookDataVersion);_.useEffect(()=>{let f=!1;return r(null),i(""),a(null),ct(`/books/${e}/truth/outline/story_frame.md`).then(async g=>{if(f)return;if(g.content){r(g.frontmatter??null),i(UXe(g.body??g.content));return}const m=await ct(`/books/${e}/truth/story_bible.md`).catch(()=>({content:null}));!f&&m.content&&a(KXe(m.content))}).catch(()=>{f||a(null)}),()=>{f=!0}},[e,l]);const c=dre(t);if(c.length===0&&!n&&!s)return null;if(s)return p.jsxs(p.Fragment,{children:[s.world&&p.jsx(fu,{title:V("世界观","World","Thế giới"),children:p.jsx(Ho,{className:mb,plugins:pb,children:s.world})}),(s.protagonist||s.cast)&&p.jsxs(fu,{title:V("角色","Characters","Nhân vật"),children:[s.protagonist&&p.jsx(Ho,{className:mb,plugins:pb,children:s.protagonist}),s.cast&&p.jsx("div",{className:s.protagonist?"mt-2":void 0,children:p.jsx(Ho,{className:mb,plugins:pb,children:s.cast})})]})]});const h=p.jsx("button",{onClick:()=>o("outline/story_frame.md"),className:"mt-2 text-[15px] leading-6 text-primary hover:underline font-['SimSun','Songti_SC','STSong',serif]",children:V("查看完整设定 →","View full foundation →","Xem toàn bộ nền tảng →")});return p.jsxs(p.Fragment,{children:[c.length>0&&p.jsxs(fu,{title:V("故事基石","Story Foundation","Nền tảng câu chuyện"),children:[p.jsx(gre,{cards:c}),!n&&h]}),n&&p.jsxs(fu,{title:V("世界观","World","Thế giới"),children:[p.jsx(Ho,{className:mb,plugins:pb,children:n}),h]})]})}const QXe={approved:{symbol:"✓",color:"text-emerald-500"},"ready-for-review":{symbol:"◆",color:"text-amber-500"},drafted:{symbol:"○",color:"text-muted-foreground"},"needs-revision":{symbol:"✕",color:"text-destructive"},imported:{symbol:"◇",color:"text-blue-500"}};function JXe({bookId:e}){const[t,r]=_.useState([]),n=Ht(i=>i.bookDataVersion);return _.useEffect(()=>{ct(`/books/${e}`).then(i=>r(i.chapters)).catch(()=>r([]))},[e,n]),p.jsx(fu,{title:V("章节","Chapters","Chương"),children:t.length===0?p.jsx("p",{className:"text-[15px] leading-6 text-muted-foreground/50 italic",children:V("暂无章节","No chapters","Chưa có chương nào")}):p.jsx("ul",{className:"space-y-1 max-h-52 overflow-y-auto overflow-x-hidden",children:t.map(i=>{const s=QXe[i.status]??{symbol:"○",color:"text-muted-foreground"};return p.jsxs("li",{onClick:()=>Ht.getState().openChapterArtifact(i.number),className:"flex items-center gap-2 py-1 text-[15px] leading-6 text-muted-foreground cursor-pointer hover:text-foreground transition-colors rounded px-1 -mx-1 hover:bg-secondary/50",children:[p.jsx("span",{className:kn("text-[13px] shrink-0",s.color),children:s.symbol}),p.jsxs("span",{className:"truncate flex-1",children:[String(i.number).padStart(2,"0")," ",i.title||V(`第${i.number}章`,`Chapter ${i.number}`,`Chương ${i.number}`)]}),p.jsx("span",{className:"tabular-nums text-[13px] text-muted-foreground/50 shrink-0",children:(i.wordCount??0).toLocaleString()})]},`${i.number}-${i.title??""}`)})})})}function eKe(e){const t=[],r=e.split(/^## /m).slice(1);for(const n of r){const i=n.split(`
1424
- `),s=i[0].trim();if(!s)continue;const a={};for(let o=1;o<i.length;o++){const l=i[o].match(/^-\s+\*\*(.+?)\*\*:\s*(.+)/);l&&(a[l[1]]=l[2].trim())}t.push({name:s,fields:a})}return t}const tKe={主角:"bg-amber-500/15 text-amber-600 dark:text-amber-400",反派:"bg-red-500/15 text-red-600 dark:text-red-400",盟友:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",配角:"bg-blue-500/15 text-blue-600 dark:text-blue-400",提及:"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400",protagonist:"bg-amber-500/15 text-amber-600 dark:text-amber-400",antagonist:"bg-red-500/15 text-red-600 dark:text-red-400",ally:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",minor:"bg-blue-500/15 text-blue-600 dark:text-blue-400",mentioned:"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"};function rKe(e){const t=e.toLowerCase().trim();for(const[r,n]of Object.entries(tKe))if(t.includes(r))return n;return"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"}const nKe={major:{zh:"主要",en:"Major",vi:"Chính",color:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},minor:{zh:"次要",en:"Minor",vi:"Phụ",color:"bg-blue-500/15 text-blue-600 dark:text-blue-400"}};function iKe({role:e}){const t=Ht(n=>n.openArtifact),r=nKe[e.tier];return p.jsxs("button",{onClick:()=>t(e.path),className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-lg bg-secondary/30 hover:bg-secondary/50 transition-colors text-left",children:[p.jsx(QF,{size:16,className:"shrink-0 text-muted-foreground/60"}),p.jsx("span",{className:"text-[15px] leading-6 font-medium text-foreground font-['SimSun','Songti_SC','STSong',serif] flex-1 truncate",children:e.name}),p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full shrink-0",r.color),children:V(r.zh,r.en,r.vi)})]})}function sKe({char:e}){const[t,r]=_.useState(!1),n=e.fields.定位??e.fields.Role??"",i=e.fields.标签??e.fields.Tags??"",s=e.fields.当前??e.fields.Current??"";return p.jsxs("div",{className:"rounded-lg bg-secondary/30 overflow-hidden",children:[p.jsxs("button",{onClick:()=>r(!t),className:"w-full flex items-center gap-2 px-2.5 py-2 text-left",children:[p.jsx(QF,{size:16,className:"shrink-0 text-muted-foreground/60"}),p.jsx("span",{className:"text-[15px] leading-6 font-medium text-foreground font-['SimSun','Songti_SC','STSong',serif] flex-1 truncate",children:e.name}),n&&p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full shrink-0",rKe(n)),children:n.split("/")[0].trim()}),p.jsx(Bu,{size:14,className:kn("text-muted-foreground/50 transition-transform shrink-0",t&&"rotate-180")})]}),t&&p.jsxs("div",{className:"px-2.5 pb-2.5 space-y-1",children:[i&&p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:V("标签","Tags","Nhãn")})," ",i]}),s&&p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:V("当前","Current","Hiện tại")})," ",s]}),Object.entries(e.fields).filter(([a])=>!["定位","Role","标签","Tags","当前","Current"].includes(a)).map(([a,o])=>p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:a})," ",o]},a))]})]})}function aKe({bookId:e}){const[t,r]=_.useState([]),[n,i]=_.useState([]),s=Ht(a=>a.bookDataVersion);return _.useEffect(()=>{let a=!1;return r([]),i([]),ct(`/books/${e}/truth`).then(async o=>{if(a)return;const l=o.files.map(h=>pre(h.name)).filter(h=>h!==null).sort((h,f)=>h.tier===f.tier?h.name.localeCompare(f.name):h.tier==="major"?-1:1);if(l.length>0){r(l);return}const c=await ct(`/books/${e}/truth/character_matrix.md`).catch(()=>({content:null}));!a&&c.content&&i(eKe(c.content))}).catch(()=>{a||(r([]),i([]))}),()=>{a=!0}},[e,s]),t.length===0&&n.length===0?null:p.jsx(fu,{title:V("角色","Characters","Nhân vật"),children:p.jsx("div",{className:"space-y-1.5",children:t.length>0?t.map(a=>p.jsx(iKe,{role:a},a.path)):n.map(a=>p.jsx(sKe,{char:a},a.name))})})}const oKe={主线伏笔:"bg-amber-500/15 text-amber-600 dark:text-amber-400",角色前置:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",情感线伏笔:"bg-pink-500/15 text-pink-600 dark:text-pink-400",次要伏笔:"bg-blue-500/15 text-blue-600 dark:text-blue-400"};function lKe(e){return oKe[e]??"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"}function cKe({content:e}){const t=GXe(e);return t.length===0?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有埋下伏笔。","No foreshadowing planted yet.","Chưa có cài cắm nào.")}):p.jsx("div",{className:"flex flex-col gap-2",children:t.map(r=>p.jsxs("div",{className:"rounded-lg bg-secondary/30 px-3 py-2.5",children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5 flex-wrap",children:[r.promoted===!1&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-zinc-500/10 text-muted-foreground",children:V("种子","Seed","Hạt giống")}),r.promoted===!0&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:V("活跃","Active","Đang hoạt động")}),r.type&&p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full",lKe(r.type)),children:r.type}),r.core&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400",children:V("核心","Core","Trọng tâm")}),r.payoff&&p.jsxs("span",{className:"text-[12px] text-muted-foreground/50 ml-auto",children:[V("回收","Payoff","Hoàn kết")," · ",r.payoff]})]}),p.jsx("p",{className:"text-[15px] text-foreground leading-7 font-['SimSun','Songti_SC','STSong',serif]",children:r.content})]},r.id))})}const EF={cjk:v1};function uKe(e){var t;return((t=pre(e))==null?void 0:t.name)??mre[e]??e}function hKe(e,t,r,n){if(e==="pending_hooks.md")return p.jsx(cKe,{content:t});if(e==="current_state.md"){const{isEmpty:i,body:s}=VXe(t);return i?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有运行状态。开始写作后,每写完一章这里会自动记录最新的故事进展。","No run state yet. Once you start writing, the latest story progress is recorded here after each chapter.","Chưa có trạng thái nào. Sau khi bắt đầu viết, diễn biến mới nhất sẽ được ghi lại ở đây sau mỗi chương.")}):p.jsx(Ho,{plugins:EF,mode:"static",children:s})}return e==="emotional_arcs.md"&&!WXe(t)?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有情感弧线记录。开始写作后,这里会记录角色在各章的情绪变化。","No emotional arcs recorded yet. Once you start writing, each character's emotional shifts per chapter appear here.","Chưa có ghi nhận cung cảm xúc. Sau khi bắt đầu viết, thay đổi cảm xúc của nhân vật qua từng chương sẽ hiện ở đây.")}):p.jsxs(p.Fragment,{children:[p.jsx(gre,{cards:dre(r)}),p.jsx(Ho,{plugins:EF,mode:"static",children:HXe(fre(n??t))})]})}function yre({bookId:e}){const t=Ht(A=>A.artifactFile),r=Ht(A=>A.artifactChapter),n=Ht(A=>A.closeArtifact),[i,s]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(null),[h,f]=_.useState(!0),[g,m]=_.useState(!1),[x,v]=_.useState(""),[C,k]=_.useState(!1),T=r!==null,w=T?V(`第 ${r} 章`,`Chapter ${r}`,`Chương ${r}`):t?uKe(t):"";_.useEffect(()=>{m(!1),f(!0),o(null),c(null),T?ct(`/books/${e}/chapters/${r}`).then(A=>s(A.content??"")).catch(()=>s(null)).finally(()=>f(!1)):t&&ct(`/books/${e}/truth/${t}`).then(A=>{s(A.content??""),o(A.frontmatter??null),c(A.body??null)}).catch(()=>s(null)).finally(()=>f(!1))},[e,t,r,T]);const L=_.useCallback(()=>{v(i??""),m(!0)},[i]),N=_.useCallback(async()=>{k(!0);try{T?await ct(`/books/${e}/chapters/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}):t&&await ct(`/books/${e}/truth/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}),s(x),m(!1)}catch{}finally{k(!1)}},[e,t,r,T,x]);return p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border/20 shrink-0",children:[p.jsx("button",{onClick:n,className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(jF,{size:14})}),p.jsx("span",{className:"text-[15px] leading-6 font-medium truncate flex-1",children:w}),!h&&i!==null&&!g&&p.jsx("button",{onClick:L,className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(Kh,{size:12})}),g&&p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{onClick:N,disabled:C,className:"w-6 h-6 rounded-md flex items-center justify-center text-emerald-500 hover:bg-emerald-500/10 transition-colors",children:C?p.jsx(qn,{size:12,className:"animate-spin"}):p.jsx(j0,{size:12})}),p.jsx("button",{onClick:()=>m(!1),className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(ho,{size:12})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:h?p.jsx("div",{className:"flex items-center justify-center py-8",children:p.jsx(qn,{size:16,className:"text-muted-foreground animate-spin"})}):i===null?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/50 italic px-4 py-3",children:V("文件不存在","File not found","Không tìm thấy tệp")}):g?p.jsx("textarea",{value:x,onChange:A=>v(A.target.value),className:"w-full h-full min-h-[300px] bg-transparent text-[15px] leading-7 px-4 py-3 resize-none outline-none border-0 font-mono"}):p.jsx("div",{className:"px-4 py-3 text-[15px] leading-7",children:hKe(T?null:t,i,a,l)})})]})}function xre({bookId:e,theme:t,t:r,sse:n}){const[i,s]=_.useState(null);_.useEffect(()=>{var c;const o=n.messages;if(o.length===0)return;const l=o[o.length-1];if(l.event==="write:start")s("write");else if(l.event==="tool:start"){const h=l.data;if((h==null?void 0:h.tool)==="sub_agent"){const f=(c=h.args)==null?void 0:c.agent;f==="writer"?s("write"):f==="auditor"?s("audit"):f==="reviser"&&s("revise")}}else(l.event==="write:complete"||l.event==="tool:end")&&s(null)},[n.messages]);const a={write:V("正在写作中...","Writing...","Đang viết..."),audit:V("正在审计中...","Auditing...","Đang kiểm tra..."),revise:V("正在修订中...","Revising...","Đang sửa...")};return p.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[i&&p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/5 border border-primary/10",children:[p.jsx(qn,{size:12,className:"text-primary animate-spin shrink-0"}),p.jsx("span",{className:"text-[14px] leading-5 text-primary font-medium",children:a[i]??i})]}),p.jsx(FXe,{sse:n}),p.jsx(JXe,{bookId:e}),p.jsx(aKe,{bookId:e}),p.jsx(XXe,{bookId:e}),p.jsx(ZXe,{bookId:e})]})}const dKe=.4,bre=280,vre=700;function fKe(){return Math.min(vre,Math.max(bre,Math.round(window.innerWidth*dKe)))}function pKe({bookId:e,theme:t,t:r,sse:n}){const i=Ht(c=>c.sidebarView),[s,a]=_.useState(fKe),o=_.useRef(!1),l=_.useCallback(c=>{c.preventDefault(),o.current=!0;const h=c.clientX,f=s,g=x=>{if(!o.current)return;const v=h-x.clientX;a(Math.min(vre,Math.max(bre,f+v)))},m=()=>{o.current=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",m)},[s]);return p.jsxs("aside",{className:"hidden lg:flex shrink-0 flex-col bg-background/30 backdrop-blur-sm overflow-y-auto relative",style:{width:s},children:[p.jsx("div",{onMouseDown:l,className:"absolute left-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/20 active:bg-primary/30 transition-colors z-10"}),i==="artifact"?p.jsx(yre,{bookId:e}):p.jsx(xre,{bookId:e,theme:t,t:r,sse:n})]})}function mKe({bookId:e,theme:t,t:r,sse:n}){const[i,s]=_.useState(!1),a=Ht(o=>o.sidebarView);return p.jsxs(p.Fragment,{children:[p.jsx("button",{onClick:()=>s(!0),className:"fixed right-3 top-[72px] z-20 lg:hidden w-8 h-8 rounded-lg bg-card border border-border/40 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",children:p.jsx(Poe,{size:14})}),i&&p.jsxs("div",{className:"fixed inset-0 z-40 lg:hidden",onClick:()=>s(!1),children:[p.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-sm"}),p.jsxs("aside",{className:"absolute right-0 top-0 h-full w-[420px] max-w-[85vw] bg-background border-l border-border/20 overflow-y-auto",onClick:o=>o.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/20",children:[p.jsx("span",{className:"text-[15px] leading-6 font-medium text-muted-foreground",children:V("书籍信息","Book info","Thông tin sách")}),p.jsx("button",{onClick:()=>s(!1),className:"text-muted-foreground hover:text-foreground",children:p.jsx(Boe,{size:14})})]}),a==="artifact"?p.jsx(yre,{bookId:e}):p.jsx(xre,{bookId:e,theme:t,t:r,sse:n})]})]})]})}const gKe=["book:creating","book:created","book:deleted","book:error","write:start","write:complete","write:error","draft:start","draft:complete","draft:error","daemon:chapter","daemon:started","daemon:stopped","daemon:error","agent:start","agent:complete","agent:error","session:title","audit:start","audit:complete","audit:error","revise:start","revise:complete","revise:error","rewrite:start","rewrite:complete","rewrite:error","style:start","style:complete","style:error","import:start","import:complete","import:error","fanfic:start","fanfic:complete","fanfic:error","fanfic:refresh:start","fanfic:refresh:complete","fanfic:refresh:error","draft:delta","radar:start","radar:complete","radar:error","log","llm:progress","ping"];function yKe(e,t){if(e.length===0)return{fresh:[],nextCursor:t};const r=e[e.length-1].seq;return t===null?{fresh:[],nextCursor:r}:r<=t?{fresh:[],nextCursor:t}:{fresh:e.filter(n=>n.seq>t),nextCursor:r}}function xKe(e,t){const r=_.useRef(null);_.useEffect(()=>{const{fresh:n,nextCursor:i}=yKe(e,r.current);r.current=i;for(const s of n)t(s)},[t,e])}function bKe(e="/api/v1/events"){const[t,r]=_.useState([]),[n,i]=_.useState(!1),s=_.useRef(null),a=_.useRef(0);_.useEffect(()=>{const l=new EventSource(e);s.current=l,l.onopen=()=>i(!0),l.onerror=()=>i(!1);const c=h=>{try{const f=h.data?JSON.parse(h.data):null;a.current+=1;const g={event:h.type,data:f,timestamp:Date.now(),seq:a.current};r(m=>[...m.slice(-99),g])}catch{}};for(const h of gKe)l.addEventListener(h,c);return()=>{l.close(),s.current=null}},[e]);const o=_.useCallback(()=>r([]),[]);return{messages:t,connected:n,clear:o}}function vKe(e,t,r){xKe(e.messages,n=>{if(n.event==="session:title"){const i=n.data;if(!(i!=null&&i.sessionId)||!i.title)return;const{sessionId:s,title:a}=i;Ht.setState(o=>o.sessions[s]?{sessions:Dr(o.sessions,s,()=>({title:a}))}:{});return}if(n.event==="book:created"){const i=n.data;if(!(i!=null&&i.sessionId)||!i.bookId)return;const{sessionId:s,bookId:a}=i;Ht.setState(o=>{const l=o.sessions[s];if(!l)return{};const c=Aa(l.bookId),h=Aa(a);return{sessions:Dr(o.sessions,s,()=>({bookId:a})),sessionIdsByBook:{...o.sessionIdsByBook,[c]:(o.sessionIdsByBook[c]??[]).filter(f=>f!==s),[h]:Im(o.sessionIdsByBook[h],[s])}}}),BF()===s&&(lse(),t.page==="book-create"&&r({page:"book",bookId:a}))}})}const Cre="inkos:studio:theme";function CKe(e){return e>=6&&e<18?"light":"dark"}function JT(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function AF(e){const t=e==null?void 0:e.getItem(Cre);return t==="light"||t==="dark"?t:null}function NF(e){return e.storedTheme??CKe(e.hour)}function kKe(){const[e,t]=_.useState(()=>NF({hour:new Date().getHours(),storedTheme:AF(JT())}));return _.useEffect(()=>{const n=setInterval(()=>{const i=AF(JT());t(NF({hour:new Date().getHours(),storedTheme:i}))},6e4);return()=>clearInterval(n)},[]),{theme:e,setTheme:n=>{const i=JT();try{i==null||i.setItem(Cre,n)}catch{}t(n)}}}const TKe=_.lazy(()=>re(()=>import("./FlowView-rMLtzFZK.js"),__vite__mapDeps([152,123,153]))),wKe=_.lazy(()=>re(()=>import("./FilmWizard-CuCB-1xV.js"),__vite__mapDeps([154,152,123,153])));function SKe(e){if("bookId"in e)return e.bookId}function _Ke(e){return e.page==="book-create"}function EKe(e){return e.ready?"ready":e.projectError?"error":"loading"}function AKe(){const{route:e,setRoute:t}=Yie(),r=bKe(),{theme:n,setTheme:i}=kKe(),{t:s,lang:a}=_3(),{data:o,error:l,refetch:c}=$r("/project"),[h,f]=_.useState(!1),g=n==="dark";YL(a),_.useEffect(()=>{YL(a)},[a]),_.useEffect(()=>{document.documentElement.classList.toggle("dark",g)},[g]),_.useEffect(()=>{o&&f(!0)},[o]),vKe(r,e,t);const m={toDashboard:()=>t({page:"dashboard"}),toChat:()=>t({page:"chat"}),toBook:k=>t({page:"book",bookId:k}),toBookSettings:k=>t({page:"book-settings",bookId:k}),toBookCreate:()=>t({page:"book-create"}),toChapter:(k,T)=>t({page:"chapter",bookId:k,chapterNumber:T}),toAnalytics:k=>t({page:"analytics",bookId:k}),toServices:()=>t({page:"services"}),toProjectSettings:()=>t({page:"project-settings"}),toServiceDetail:k=>t({page:"service-detail",serviceId:k}),toTruth:k=>t({page:"truth",bookId:k}),toDaemon:()=>t({page:"daemon"}),toLogs:()=>t({page:"logs"}),toGenres:()=>t({page:"genres"}),toStyle:()=>t({page:"style"}),toTranslation:()=>t({page:"translation"}),toImport:k=>t({page:"import",...k?{tab:k}:{}}),toRadar:()=>t({page:"radar"}),toDoctor:()=>t({page:"doctor"}),toPlay:k=>t({page:"play",projectId:k}),toFilm:k=>t({page:"film",projectId:k}),toFlow:k=>t({page:"flow",projectId:k}),toFilmAuthor:k=>t({page:"film-author",projectId:k}),toFilmStudio:k=>t({page:"film-studio",projectId:k})},x=SKe(e),v=x?`book:${x}`:e.page==="service-detail"?"services":e.page,C=EKe({ready:h,projectError:l});return C==="error"?p.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:p.jsxs("div",{className:"max-w-md w-full rounded-2xl border border-destructive/30 bg-destructive/5 p-6 space-y-4",children:[p.jsxs("div",{children:[p.jsx("h1",{className:"text-lg font-semibold text-destructive",children:"Không tải được cấu hình dự án / Failed to load project config"}),p.jsx("p",{className:"mt-2 text-sm text-muted-foreground break-all",children:l})]}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Kiểm tra xem inkos.json trong thư mục gốc của dự án có tồn tại và có phải JSON hợp lệ không, rồi thử lại.",p.jsx("br",{}),"Check that inkos.json in the project root exists and is valid JSON, then retry."]}),p.jsx("button",{type:"button",onClick:()=>c(),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Thử lại / Retry"})]})}):C==="loading"?p.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:p.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):p.jsxs("div",{className:"h-screen bg-background text-foreground flex overflow-hidden font-sans",children:[p.jsx(u0e,{nav:m,activePage:v,sse:r,t:s}),p.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background/30 backdrop-blur-sm",children:[p.jsxs("header",{className:"h-14 shrink-0 flex items-center justify-between px-8 border-b border-border/40",children:[p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs("button",{onClick:m.toDashboard,className:"inline-flex items-center gap-2 rounded-lg border border-border/50 bg-card/70 px-3.5 py-2 text-[17px] font-semibold text-foreground hover:bg-secondary/50 transition-colors",children:[p.jsx(Toe,{size:18}),p.jsx("span",{children:s("bread.home")}),p.jsx("span",{className:"text-muted-foreground/70",children:"/"}),p.jsx("span",{className:"font-serif",children:"InkOS Studio"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{className:"flex gap-0.5 bg-muted/50 rounded-lg p-0.5",children:[p.jsx("button",{onClick:async()=>{await Sh("/project",{language:"vi"}),c()},className:`px-2.5 py-1 text-[16px] font-medium rounded-md ${a==="vi"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"VI"}),p.jsx("button",{onClick:async()=>{await Sh("/project",{language:"en"}),c()},className:`px-2.5 py-1 text-[16px] font-medium rounded-md ${a==="en"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"EN"})]}),p.jsx("button",{onClick:()=>i(g?"light":"dark"),className:"text-muted-foreground hover:text-foreground transition-colors",children:g?p.jsx(sle,{size:18}):p.jsx(Roe,{size:18})})]})]}),p.jsxs("main",{className:"flex-1 relative overflow-y-auto scroll-smooth",children:[e.page==="dashboard"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(d0e,{nav:m,sse:r,theme:n,t:s})}),_Ke(e)&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{mode:"book-create",nav:m,theme:n,t:s,sse:r})}),e.page==="chat"&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{mode:"project-chat",nav:m,theme:n,t:s,sse:r})}),e.page==="book"&&p.jsxs("div",{className:"absolute inset-0 flex min-w-0",children:[p.jsx(ub,{activeBookId:e.bookId,mode:"book",nav:m,theme:n,t:s,sse:r}),p.jsx(pKe,{bookId:e.bookId,theme:n,t:s,sse:r}),p.jsx(mKe,{bookId:e.bookId,theme:n,t:s,sse:r})]}),e.page==="book-settings"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(EYe,{bookId:e.bookId,nav:m,theme:n,t:s,sse:r})}),e.page==="chapter"&&p.jsx("div",{className:"mx-auto w-full max-w-[1400px] px-4 py-12 sm:px-6 lg:px-10 lg:py-16 2xl:px-12 fade-in",children:p.jsx(NYe,{bookId:e.bookId,chapterNumber:e.chapterNumber,nav:m,theme:n,t:s})}),e.page==="analytics"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(LYe,{bookId:e.bookId,nav:m,theme:n,t:s})}),e.page==="services"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(zYe,{nav:m})}),e.page==="project-settings"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(eXe,{nav:m,theme:n,t:s})}),e.page==="service-detail"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(WYe,{serviceId:e.serviceId,nav:m})}),e.page==="truth"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(rXe,{bookId:e.bookId,nav:m,theme:n,t:s})}),e.page==="daemon"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(nXe,{nav:m,theme:n,t:s,sse:r})}),e.page==="logs"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(sXe,{nav:m,theme:n,t:s})}),e.page==="genres"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(hXe,{nav:m,theme:n,t:s})}),e.page==="style"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(fXe,{nav:m,theme:n,t:s})}),e.page==="translation"&&p.jsx("div",{className:"max-w-6xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(bXe,{nav:m,theme:n,t:s})}),e.page==="import"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(kXe,{nav:m,theme:n,t:s,initialTab:e.tab})}),e.page==="radar"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(TXe,{nav:m,theme:n,t:s})}),e.page==="doctor"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(wXe,{nav:m,theme:n,t:s})}),e.page==="play"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(NXe,{projectId:e.projectId,nav:m,theme:n,t:s})}),e.page==="film"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(PXe,{projectId:e.projectId,nav:m,theme:n,t:s})}),e.page==="film-author"&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{activeBookId:e.projectId,mode:"interactive-film-authoring",nav:m,theme:n,t:s,sse:r})}),e.page==="film-studio"&&p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"p-6 text-sm",children:V("加载创作向导…","Loading creation wizard…","Đang tải trình tạo…")}),children:p.jsx(wKe,{projectId:e.projectId,nav:m,theme:n,t:s,sse:r})}),e.page==="flow"&&p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"p-6 text-sm",children:V("加载流程图…","Loading flow view…","Đang tải sơ đồ…")}),children:p.jsx(TKe,{projectId:e.projectId,nav:m,theme:n,t:s})})]})]})]})}Uie.createRoot(document.getElementById("root")).render(p.jsx(_.StrictMode,{children:p.jsx(AKe,{})}));const NKe=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:HJ},Symbol.toStringTag,{value:"Module"}));export{GE as $,tze as A,QKe as B,y0 as C,ECe as D,zKe as E,yu as F,tl as G,nve as H,En as I,kTe as J,BCe as K,vZe as L,m8 as M,Vq as N,h6e as O,g5e as P,t5e as Q,ua as R,vO as S,bO as T,tr as U,XKe as V,qKe as W,GKe as X,WKe as Y,HKe as Z,B as _,NCe as a,WG as a$,YKe as a0,UKe as a1,uf as a2,ZKe as a3,KKe as a4,VKe as a5,Fve as a6,Hg as a7,jKe as a8,r3 as a9,mZe as aA,hZe as aB,Bt as aC,dZe as aD,LEe as aE,SEe as aF,wEe as aG,ja as aH,js as aI,$r as aJ,xKe as aK,V as aL,NXe as aM,ub as aN,PXe as aO,BXe as aP,A_e as aQ,Bq as aR,r5e as aS,UE as aT,Jc as aU,Vg as aV,fO as aW,B4e as aX,PKe as aY,t3 as aZ,dv as a_,r6e as aa,mCe as ab,eV as ac,eO as ad,s5e as ae,_S as af,u6e as ag,go as ah,qe as ai,ze as aj,TCe as ak,rV as al,J_e as am,nK as an,pZe as ao,wTe as ap,ys as aq,fc as ar,pm as as,g8 as at,QG as au,od as av,rY as aw,At as ax,t8e as ay,fZe as az,ACe as b,re as b$,d1 as b0,B1 as b1,__e as b2,S_e as b3,LSe as b4,qG as b5,PG as b6,Owe as b7,cv as b8,Bwe as b9,Ds as bA,A4e as bB,HE as bC,gV as bD,L1 as bE,bV as bF,$Ke as bG,rve as bH,Q0 as bI,DSe as bJ,w8e as bK,M1 as bL,hv as bM,Uu as bN,ZC as bO,BO as bP,c8 as bQ,FG as bR,UG as bS,Rwe as bT,o6 as bU,ZSe as bV,qSe as bW,JSe as bX,o8 as bY,t6e as bZ,RKe as b_,I1 as ba,Th as bb,SSe as bc,zO as bd,bd as be,Dwe as bf,l8 as bg,Iwe as bh,Fwe as bi,J0 as bj,NSe as bk,QSe as bl,qwe as bm,VSe as bn,a8 as bo,RB as bp,nV as bq,p5e as br,Nf as bs,G4e as bt,m5e as bu,MKe as bv,Mm as bw,ct as bx,Rt as by,nY as bz,jr as c,pr as d,tV as e,fi as f,RCe as g,ic as h,po as i,p as j,ETe as k,Ze as l,A1 as m,eY as n,E1 as o,FKe as p,yZe as q,_ as r,LCe as s,gZe as t,so as u,MCe as v,p6e as w,ICe as x,TTe as y,bEe as z};
1429
+ `),s=i[0].trim();if(!s)continue;const a={};for(let o=1;o<i.length;o++){const l=i[o].match(/^-\s+\*\*(.+?)\*\*:\s*(.+)/);l&&(a[l[1]]=l[2].trim())}t.push({name:s,fields:a})}return t}const tKe={主角:"bg-amber-500/15 text-amber-600 dark:text-amber-400",反派:"bg-red-500/15 text-red-600 dark:text-red-400",盟友:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",配角:"bg-blue-500/15 text-blue-600 dark:text-blue-400",提及:"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400",protagonist:"bg-amber-500/15 text-amber-600 dark:text-amber-400",antagonist:"bg-red-500/15 text-red-600 dark:text-red-400",ally:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",minor:"bg-blue-500/15 text-blue-600 dark:text-blue-400",mentioned:"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"};function rKe(e){const t=e.toLowerCase().trim();for(const[r,n]of Object.entries(tKe))if(t.includes(r))return n;return"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"}const nKe={major:{zh:"主要",en:"Major",vi:"Chính",color:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},minor:{zh:"次要",en:"Minor",vi:"Phụ",color:"bg-blue-500/15 text-blue-600 dark:text-blue-400"}};function iKe({role:e}){const t=Ht(n=>n.openArtifact),r=nKe[e.tier];return p.jsxs("button",{onClick:()=>t(e.path),className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-lg bg-secondary/30 hover:bg-secondary/50 transition-colors text-left",children:[p.jsx(QF,{size:16,className:"shrink-0 text-muted-foreground/60"}),p.jsx("span",{className:"text-[15px] leading-6 font-medium text-foreground font-['SimSun','Songti_SC','STSong',serif] flex-1 truncate",children:e.name}),p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full shrink-0",r.color),children:V(r.zh,r.en,r.vi)})]})}function sKe({char:e}){const[t,r]=_.useState(!1),n=e.fields.定位??e.fields.Role??"",i=e.fields.标签??e.fields.Tags??"",s=e.fields.当前??e.fields.Current??"";return p.jsxs("div",{className:"rounded-lg bg-secondary/30 overflow-hidden",children:[p.jsxs("button",{onClick:()=>r(!t),className:"w-full flex items-center gap-2 px-2.5 py-2 text-left",children:[p.jsx(QF,{size:16,className:"shrink-0 text-muted-foreground/60"}),p.jsx("span",{className:"text-[15px] leading-6 font-medium text-foreground font-['SimSun','Songti_SC','STSong',serif] flex-1 truncate",children:e.name}),n&&p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full shrink-0",rKe(n)),children:n.split("/")[0].trim()}),p.jsx(Bu,{size:14,className:kn("text-muted-foreground/50 transition-transform shrink-0",t&&"rotate-180")})]}),t&&p.jsxs("div",{className:"px-2.5 pb-2.5 space-y-1",children:[i&&p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:V("标签","Tags","Nhãn")})," ",i]}),s&&p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:V("当前","Current","Hiện tại")})," ",s]}),Object.entries(e.fields).filter(([a])=>!["定位","Role","标签","Tags","当前","Current"].includes(a)).map(([a,o])=>p.jsxs("p",{className:"text-[14px] leading-6 text-muted-foreground",children:[p.jsx("span",{className:"text-muted-foreground/60",children:a})," ",o]},a))]})]})}function aKe({bookId:e}){const[t,r]=_.useState([]),[n,i]=_.useState([]),s=Ht(a=>a.bookDataVersion);return _.useEffect(()=>{let a=!1;return r([]),i([]),ct(`/books/${e}/truth`).then(async o=>{if(a)return;const l=o.files.map(h=>pre(h.name)).filter(h=>h!==null).sort((h,f)=>h.tier===f.tier?h.name.localeCompare(f.name):h.tier==="major"?-1:1);if(l.length>0){r(l);return}const c=await ct(`/books/${e}/truth/character_matrix.md`).catch(()=>({content:null}));!a&&c.content&&i(eKe(c.content))}).catch(()=>{a||(r([]),i([]))}),()=>{a=!0}},[e,s]),t.length===0&&n.length===0?null:p.jsx(fu,{title:V("角色","Characters","Nhân vật"),children:p.jsx("div",{className:"space-y-1.5",children:t.length>0?t.map(a=>p.jsx(iKe,{role:a},a.path)):n.map(a=>p.jsx(sKe,{char:a},a.name))})})}const oKe={主线伏笔:"bg-amber-500/15 text-amber-600 dark:text-amber-400",角色前置:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",情感线伏笔:"bg-pink-500/15 text-pink-600 dark:text-pink-400",次要伏笔:"bg-blue-500/15 text-blue-600 dark:text-blue-400"};function lKe(e){return oKe[e]??"bg-zinc-500/15 text-zinc-600 dark:text-zinc-400"}function cKe({content:e}){const t=GXe(e);return t.length===0?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有埋下伏笔。","No foreshadowing planted yet.","Chưa có cài cắm nào.")}):p.jsx("div",{className:"flex flex-col gap-2",children:t.map(r=>p.jsxs("div",{className:"rounded-lg bg-secondary/30 px-3 py-2.5",children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5 flex-wrap",children:[r.promoted===!1&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-zinc-500/10 text-muted-foreground",children:V("种子","Seed","Hạt giống")}),r.promoted===!0&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:V("活跃","Active","Đang hoạt động")}),r.type&&p.jsx("span",{className:kn("text-[12px] px-1.5 py-0.5 rounded-full",lKe(r.type)),children:r.type}),r.core&&p.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400",children:V("核心","Core","Trọng tâm")}),r.payoff&&p.jsxs("span",{className:"text-[12px] text-muted-foreground/50 ml-auto",children:[V("回收","Payoff","Hoàn kết")," · ",r.payoff]})]}),p.jsx("p",{className:"text-[15px] text-foreground leading-7 font-['SimSun','Songti_SC','STSong',serif]",children:r.content})]},r.id))})}const EF={cjk:v1};function uKe(e){var t;return((t=pre(e))==null?void 0:t.name)??mre[e]??e}function hKe(e,t,r,n){if(e==="pending_hooks.md")return p.jsx(cKe,{content:t});if(e==="current_state.md"){const{isEmpty:i,body:s}=VXe(t);return i?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有运行状态。开始写作后,每写完一章这里会自动记录最新的故事进展。","No run state yet. Once you start writing, the latest story progress is recorded here after each chapter.","Chưa có trạng thái nào. Sau khi bắt đầu viết, diễn biến mới nhất sẽ được ghi lại ở đây sau mỗi chương.")}):p.jsx(Ho,{plugins:EF,mode:"static",children:s})}return e==="emotional_arcs.md"&&!WXe(t)?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/60 italic",children:V("还没有情感弧线记录。开始写作后,这里会记录角色在各章的情绪变化。","No emotional arcs recorded yet. Once you start writing, each character's emotional shifts per chapter appear here.","Chưa có ghi nhận cung cảm xúc. Sau khi bắt đầu viết, thay đổi cảm xúc của nhân vật qua từng chương sẽ hiện ở đây.")}):p.jsxs(p.Fragment,{children:[p.jsx(gre,{cards:dre(r)}),p.jsx(Ho,{plugins:EF,mode:"static",children:HXe(fre(n??t))})]})}function yre({bookId:e}){const t=Ht(A=>A.artifactFile),r=Ht(A=>A.artifactChapter),n=Ht(A=>A.closeArtifact),[i,s]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(null),[h,f]=_.useState(!0),[g,m]=_.useState(!1),[x,v]=_.useState(""),[C,k]=_.useState(!1),T=r!==null,w=T?V(`第 ${r} 章`,`Chapter ${r}`,`Chương ${r}`):t?uKe(t):"";_.useEffect(()=>{m(!1),f(!0),o(null),c(null),T?ct(`/books/${e}/chapters/${r}`).then(A=>s(A.content??"")).catch(()=>s(null)).finally(()=>f(!1)):t&&ct(`/books/${e}/truth/${t}`).then(A=>{s(A.content??""),o(A.frontmatter??null),c(A.body??null)}).catch(()=>s(null)).finally(()=>f(!1))},[e,t,r,T]);const L=_.useCallback(()=>{v(i??""),m(!0)},[i]),N=_.useCallback(async()=>{k(!0);try{T?await ct(`/books/${e}/chapters/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}):t&&await ct(`/books/${e}/truth/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}),s(x),m(!1)}catch{}finally{k(!1)}},[e,t,r,T,x]);return p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border/20 shrink-0",children:[p.jsx("button",{onClick:n,className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(jF,{size:14})}),p.jsx("span",{className:"text-[15px] leading-6 font-medium truncate flex-1",children:w}),!h&&i!==null&&!g&&p.jsx("button",{onClick:L,className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(Kh,{size:12})}),g&&p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{onClick:N,disabled:C,className:"w-6 h-6 rounded-md flex items-center justify-center text-emerald-500 hover:bg-emerald-500/10 transition-colors",children:C?p.jsx(qn,{size:12,className:"animate-spin"}):p.jsx(j0,{size:12})}),p.jsx("button",{onClick:()=>m(!1),className:"w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary/50 transition-colors",children:p.jsx(ho,{size:12})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:h?p.jsx("div",{className:"flex items-center justify-center py-8",children:p.jsx(qn,{size:16,className:"text-muted-foreground animate-spin"})}):i===null?p.jsx("p",{className:"text-[14px] leading-6 text-muted-foreground/50 italic px-4 py-3",children:V("文件不存在","File not found","Không tìm thấy tệp")}):g?p.jsx("textarea",{value:x,onChange:A=>v(A.target.value),className:"w-full h-full min-h-[300px] bg-transparent text-[15px] leading-7 px-4 py-3 resize-none outline-none border-0 font-mono"}):p.jsx("div",{className:"px-4 py-3 text-[15px] leading-7",children:hKe(T?null:t,i,a,l)})})]})}function xre({bookId:e,theme:t,t:r,sse:n}){const[i,s]=_.useState(null);_.useEffect(()=>{var c;const o=n.messages;if(o.length===0)return;const l=o[o.length-1];if(l.event==="write:start")s("write");else if(l.event==="tool:start"){const h=l.data;if((h==null?void 0:h.tool)==="sub_agent"){const f=(c=h.args)==null?void 0:c.agent;f==="writer"?s("write"):f==="auditor"?s("audit"):f==="reviser"&&s("revise")}}else(l.event==="write:complete"||l.event==="tool:end")&&s(null)},[n.messages]);const a={write:V("正在写作中...","Writing...","Đang viết..."),audit:V("正在审计中...","Auditing...","Đang kiểm tra..."),revise:V("正在修订中...","Revising...","Đang sửa...")};return p.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[i&&p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/5 border border-primary/10",children:[p.jsx(qn,{size:12,className:"text-primary animate-spin shrink-0"}),p.jsx("span",{className:"text-[14px] leading-5 text-primary font-medium",children:a[i]??i})]}),p.jsx(FXe,{sse:n}),p.jsx(JXe,{bookId:e}),p.jsx(aKe,{bookId:e}),p.jsx(XXe,{bookId:e}),p.jsx(ZXe,{bookId:e})]})}const dKe=.4,bre=280,vre=700;function fKe(){return Math.min(vre,Math.max(bre,Math.round(window.innerWidth*dKe)))}function pKe({bookId:e,theme:t,t:r,sse:n}){const i=Ht(c=>c.sidebarView),[s,a]=_.useState(fKe),o=_.useRef(!1),l=_.useCallback(c=>{c.preventDefault(),o.current=!0;const h=c.clientX,f=s,g=x=>{if(!o.current)return;const v=h-x.clientX;a(Math.min(vre,Math.max(bre,f+v)))},m=()=>{o.current=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",m)},[s]);return p.jsxs("aside",{className:"hidden lg:flex shrink-0 flex-col bg-background/30 backdrop-blur-sm overflow-y-auto relative",style:{width:s},children:[p.jsx("div",{onMouseDown:l,className:"absolute left-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/20 active:bg-primary/30 transition-colors z-10"}),i==="artifact"?p.jsx(yre,{bookId:e}):p.jsx(xre,{bookId:e,theme:t,t:r,sse:n})]})}function mKe({bookId:e,theme:t,t:r,sse:n}){const[i,s]=_.useState(!1),a=Ht(o=>o.sidebarView);return p.jsxs(p.Fragment,{children:[p.jsx("button",{onClick:()=>s(!0),className:"fixed right-3 top-[72px] z-20 lg:hidden w-8 h-8 rounded-lg bg-card border border-border/40 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",children:p.jsx(Poe,{size:14})}),i&&p.jsxs("div",{className:"fixed inset-0 z-40 lg:hidden",onClick:()=>s(!1),children:[p.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-sm"}),p.jsxs("aside",{className:"absolute right-0 top-0 h-full w-[420px] max-w-[85vw] bg-background border-l border-border/20 overflow-y-auto",onClick:o=>o.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/20",children:[p.jsx("span",{className:"text-[15px] leading-6 font-medium text-muted-foreground",children:V("书籍信息","Book info","Thông tin sách")}),p.jsx("button",{onClick:()=>s(!1),className:"text-muted-foreground hover:text-foreground",children:p.jsx(Boe,{size:14})})]}),a==="artifact"?p.jsx(yre,{bookId:e}):p.jsx(xre,{bookId:e,theme:t,t:r,sse:n})]})]})]})}const gKe=["book:creating","book:created","book:deleted","book:error","write:start","write:complete","write:error","draft:start","draft:complete","draft:error","daemon:chapter","daemon:started","daemon:stopped","daemon:error","agent:start","agent:complete","agent:error","session:title","audit:start","audit:complete","audit:error","revise:start","revise:complete","revise:error","rewrite:start","rewrite:complete","rewrite:error","style:start","style:complete","style:error","import:start","import:complete","import:error","fanfic:start","fanfic:complete","fanfic:error","fanfic:refresh:start","fanfic:refresh:complete","fanfic:refresh:error","draft:delta","radar:start","radar:complete","radar:error","log","llm:progress","ping"];function yKe(e,t){if(e.length===0)return{fresh:[],nextCursor:t};const r=e[e.length-1].seq;return t===null?{fresh:[],nextCursor:r}:r<=t?{fresh:[],nextCursor:t}:{fresh:e.filter(n=>n.seq>t),nextCursor:r}}function xKe(e,t){const r=_.useRef(null);_.useEffect(()=>{const{fresh:n,nextCursor:i}=yKe(e,r.current);r.current=i;for(const s of n)t(s)},[t,e])}function bKe(e="/api/v1/events"){const[t,r]=_.useState([]),[n,i]=_.useState(!1),s=_.useRef(null),a=_.useRef(0);_.useEffect(()=>{const l=new EventSource(e);s.current=l,l.onopen=()=>i(!0),l.onerror=()=>i(!1);const c=h=>{try{const f=h.data?JSON.parse(h.data):null;a.current+=1;const g={event:h.type,data:f,timestamp:Date.now(),seq:a.current};r(m=>[...m.slice(-99),g])}catch{}};for(const h of gKe)l.addEventListener(h,c);return()=>{l.close(),s.current=null}},[e]);const o=_.useCallback(()=>r([]),[]);return{messages:t,connected:n,clear:o}}function vKe(e,t,r){xKe(e.messages,n=>{if(n.event==="session:title"){const i=n.data;if(!(i!=null&&i.sessionId)||!i.title)return;const{sessionId:s,title:a}=i;Ht.setState(o=>o.sessions[s]?{sessions:Dr(o.sessions,s,()=>({title:a}))}:{});return}if(n.event==="book:created"){const i=n.data;if(!(i!=null&&i.sessionId)||!i.bookId)return;const{sessionId:s,bookId:a}=i;Ht.setState(o=>{const l=o.sessions[s];if(!l)return{};const c=Aa(l.bookId),h=Aa(a);return{sessions:Dr(o.sessions,s,()=>({bookId:a})),sessionIdsByBook:{...o.sessionIdsByBook,[c]:(o.sessionIdsByBook[c]??[]).filter(f=>f!==s),[h]:Im(o.sessionIdsByBook[h],[s])}}}),BF()===s&&(lse(),t.page==="book-create"&&r({page:"book",bookId:a}))}})}const Cre="inkos:studio:theme";function CKe(e){return e>=6&&e<18?"light":"dark"}function JT(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function AF(e){const t=e==null?void 0:e.getItem(Cre);return t==="light"||t==="dark"?t:null}function NF(e){return e.storedTheme??CKe(e.hour)}function kKe(){const[e,t]=_.useState(()=>NF({hour:new Date().getHours(),storedTheme:AF(JT())}));return _.useEffect(()=>{const n=setInterval(()=>{const i=AF(JT());t(NF({hour:new Date().getHours(),storedTheme:i}))},6e4);return()=>clearInterval(n)},[]),{theme:e,setTheme:n=>{const i=JT();try{i==null||i.setItem(Cre,n)}catch{}t(n)}}}const TKe=_.lazy(()=>re(()=>import("./FlowView-C6n6r8pJ.js"),__vite__mapDeps([152,123,153]))),wKe=_.lazy(()=>re(()=>import("./FilmWizard-BAeDX_rI.js"),__vite__mapDeps([154,152,123,153])));function SKe(e){if("bookId"in e)return e.bookId}function _Ke(e){return e.page==="book-create"}function EKe(e){return e.ready?"ready":e.projectError?"error":"loading"}function AKe(){const{route:e,setRoute:t}=Yie(),r=bKe(),{theme:n,setTheme:i}=kKe(),{t:s,lang:a}=_3(),{data:o,error:l,refetch:c}=$r("/project"),[h,f]=_.useState(!1),g=n==="dark";YL(a),_.useEffect(()=>{YL(a)},[a]),_.useEffect(()=>{document.documentElement.classList.toggle("dark",g)},[g]),_.useEffect(()=>{o&&f(!0)},[o]),vKe(r,e,t);const m={toDashboard:()=>t({page:"dashboard"}),toChat:()=>t({page:"chat"}),toBook:k=>t({page:"book",bookId:k}),toBookSettings:k=>t({page:"book-settings",bookId:k}),toBookCreate:()=>t({page:"book-create"}),toChapter:(k,T)=>t({page:"chapter",bookId:k,chapterNumber:T}),toAnalytics:k=>t({page:"analytics",bookId:k}),toServices:()=>t({page:"services"}),toProjectSettings:()=>t({page:"project-settings"}),toServiceDetail:k=>t({page:"service-detail",serviceId:k}),toTruth:k=>t({page:"truth",bookId:k}),toDaemon:()=>t({page:"daemon"}),toLogs:()=>t({page:"logs"}),toGenres:()=>t({page:"genres"}),toStyle:()=>t({page:"style"}),toTranslation:()=>t({page:"translation"}),toImport:k=>t({page:"import",...k?{tab:k}:{}}),toRadar:()=>t({page:"radar"}),toDoctor:()=>t({page:"doctor"}),toPlay:k=>t({page:"play",projectId:k}),toFilm:k=>t({page:"film",projectId:k}),toFlow:k=>t({page:"flow",projectId:k}),toFilmAuthor:k=>t({page:"film-author",projectId:k}),toFilmStudio:k=>t({page:"film-studio",projectId:k})},x=SKe(e),v=x?`book:${x}`:e.page==="service-detail"?"services":e.page,C=EKe({ready:h,projectError:l});return C==="error"?p.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:p.jsxs("div",{className:"max-w-md w-full rounded-2xl border border-destructive/30 bg-destructive/5 p-6 space-y-4",children:[p.jsxs("div",{children:[p.jsx("h1",{className:"text-lg font-semibold text-destructive",children:"Không tải được cấu hình dự án / Failed to load project config"}),p.jsx("p",{className:"mt-2 text-sm text-muted-foreground break-all",children:l})]}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Kiểm tra xem inkos.json trong thư mục gốc của dự án có tồn tại và có phải JSON hợp lệ không, rồi thử lại.",p.jsx("br",{}),"Check that inkos.json in the project root exists and is valid JSON, then retry."]}),p.jsx("button",{type:"button",onClick:()=>c(),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Thử lại / Retry"})]})}):C==="loading"?p.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:p.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):p.jsxs("div",{className:"h-screen bg-background text-foreground flex overflow-hidden font-sans",children:[p.jsx(u0e,{nav:m,activePage:v,sse:r,t:s}),p.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background/30 backdrop-blur-sm",children:[p.jsxs("header",{className:"h-14 shrink-0 flex items-center justify-between px-8 border-b border-border/40",children:[p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs("button",{onClick:m.toDashboard,className:"inline-flex items-center gap-2 rounded-lg border border-border/50 bg-card/70 px-3.5 py-2 text-[17px] font-semibold text-foreground hover:bg-secondary/50 transition-colors",children:[p.jsx(Toe,{size:18}),p.jsx("span",{children:s("bread.home")}),p.jsx("span",{className:"text-muted-foreground/70",children:"/"}),p.jsx("span",{className:"font-serif",children:"InkOS Studio"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{className:"flex gap-0.5 bg-muted/50 rounded-lg p-0.5",children:[p.jsx("button",{onClick:async()=>{await Sh("/project",{language:"vi"}),c()},className:`px-2.5 py-1 text-[16px] font-medium rounded-md ${a==="vi"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"VI"}),p.jsx("button",{onClick:async()=>{await Sh("/project",{language:"en"}),c()},className:`px-2.5 py-1 text-[16px] font-medium rounded-md ${a==="en"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"EN"})]}),p.jsx("button",{onClick:()=>i(g?"light":"dark"),className:"text-muted-foreground hover:text-foreground transition-colors",children:g?p.jsx(sle,{size:18}):p.jsx(Roe,{size:18})})]})]}),p.jsxs("main",{className:"flex-1 relative overflow-y-auto scroll-smooth",children:[e.page==="dashboard"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(d0e,{nav:m,sse:r,theme:n,t:s})}),_Ke(e)&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{mode:"book-create",nav:m,theme:n,t:s,sse:r})}),e.page==="chat"&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{mode:"project-chat",nav:m,theme:n,t:s,sse:r})}),e.page==="book"&&p.jsxs("div",{className:"absolute inset-0 flex min-w-0",children:[p.jsx(ub,{activeBookId:e.bookId,mode:"book",nav:m,theme:n,t:s,sse:r}),p.jsx(pKe,{bookId:e.bookId,theme:n,t:s,sse:r}),p.jsx(mKe,{bookId:e.bookId,theme:n,t:s,sse:r})]}),e.page==="book-settings"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(EYe,{bookId:e.bookId,nav:m,theme:n,t:s,sse:r})}),e.page==="chapter"&&p.jsx("div",{className:"mx-auto w-full max-w-[1400px] px-4 py-12 sm:px-6 lg:px-10 lg:py-16 2xl:px-12 fade-in",children:p.jsx(NYe,{bookId:e.bookId,chapterNumber:e.chapterNumber,nav:m,theme:n,t:s})}),e.page==="analytics"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(LYe,{bookId:e.bookId,nav:m,theme:n,t:s})}),e.page==="services"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(zYe,{nav:m})}),e.page==="project-settings"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(eXe,{nav:m,theme:n,t:s})}),e.page==="service-detail"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(WYe,{serviceId:e.serviceId,nav:m})}),e.page==="truth"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(rXe,{bookId:e.bookId,nav:m,theme:n,t:s})}),e.page==="daemon"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(nXe,{nav:m,theme:n,t:s,sse:r})}),e.page==="logs"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(sXe,{nav:m,theme:n,t:s})}),e.page==="genres"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(hXe,{nav:m,theme:n,t:s})}),e.page==="style"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(fXe,{nav:m,theme:n,t:s})}),e.page==="translation"&&p.jsx("div",{className:"max-w-6xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(bXe,{nav:m,theme:n,t:s})}),e.page==="import"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(kXe,{nav:m,theme:n,t:s,initialTab:e.tab})}),e.page==="radar"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(TXe,{nav:m,theme:n,t:s})}),e.page==="doctor"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(wXe,{nav:m,theme:n,t:s})}),e.page==="play"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(NXe,{projectId:e.projectId,nav:m,theme:n,t:s})}),e.page==="film"&&p.jsx("div",{className:"max-w-4xl mx-auto px-6 py-12 md:px-12 lg:py-16 fade-in",children:p.jsx(PXe,{projectId:e.projectId,nav:m,theme:n,t:s})}),e.page==="film-author"&&p.jsx("div",{className:"absolute inset-0 flex min-w-0",children:p.jsx(ub,{activeBookId:e.projectId,mode:"interactive-film-authoring",nav:m,theme:n,t:s,sse:r})}),e.page==="film-studio"&&p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"p-6 text-sm",children:V("加载创作向导…","Loading creation wizard…","Đang tải trình tạo…")}),children:p.jsx(wKe,{projectId:e.projectId,nav:m,theme:n,t:s,sse:r})}),e.page==="flow"&&p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"p-6 text-sm",children:V("加载流程图…","Loading flow view…","Đang tải sơ đồ…")}),children:p.jsx(TKe,{projectId:e.projectId,nav:m,theme:n,t:s})})]})]})]})}Uie.createRoot(document.getElementById("root")).render(p.jsx(_.StrictMode,{children:p.jsx(AKe,{})}));const NKe=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:HJ},Symbol.toStringTag,{value:"Module"}));export{GE as $,tze as A,QKe as B,y0 as C,ECe as D,zKe as E,yu as F,tl as G,nve as H,En as I,kTe as J,BCe as K,vZe as L,m8 as M,Vq as N,h6e as O,g5e as P,t5e as Q,ua as R,vO as S,bO as T,tr as U,XKe as V,qKe as W,GKe as X,WKe as Y,HKe as Z,B as _,NCe as a,WG as a$,YKe as a0,UKe as a1,uf as a2,ZKe as a3,KKe as a4,VKe as a5,Fve as a6,Hg as a7,jKe as a8,r3 as a9,mZe as aA,hZe as aB,Bt as aC,dZe as aD,LEe as aE,SEe as aF,wEe as aG,ja as aH,js as aI,$r as aJ,xKe as aK,V as aL,NXe as aM,ub as aN,PXe as aO,BXe as aP,A_e as aQ,Bq as aR,r5e as aS,UE as aT,Jc as aU,Vg as aV,fO as aW,B4e as aX,PKe as aY,t3 as aZ,dv as a_,r6e as aa,mCe as ab,eV as ac,eO as ad,s5e as ae,_S as af,u6e as ag,go as ah,qe as ai,ze as aj,TCe as ak,rV as al,J_e as am,nK as an,pZe as ao,wTe as ap,ys as aq,fc as ar,pm as as,g8 as at,QG as au,od as av,rY as aw,At as ax,t8e as ay,fZe as az,ACe as b,re as b$,d1 as b0,B1 as b1,__e as b2,S_e as b3,LSe as b4,qG as b5,PG as b6,Owe as b7,cv as b8,Bwe as b9,Ds as bA,A4e as bB,HE as bC,gV as bD,L1 as bE,bV as bF,$Ke as bG,rve as bH,Q0 as bI,DSe as bJ,w8e as bK,M1 as bL,hv as bM,Uu as bN,ZC as bO,BO as bP,c8 as bQ,FG as bR,UG as bS,Rwe as bT,o6 as bU,ZSe as bV,qSe as bW,JSe as bX,o8 as bY,t6e as bZ,RKe as b_,I1 as ba,Th as bb,SSe as bc,zO as bd,bd as be,Dwe as bf,l8 as bg,Iwe as bh,Fwe as bi,J0 as bj,NSe as bk,QSe as bl,qwe as bm,VSe as bn,a8 as bo,RB as bp,nV as bq,p5e as br,Nf as bs,G4e as bt,m5e as bu,MKe as bv,Mm as bw,ct as bx,Rt as by,nY as bz,jr as c,pr as d,tV as e,fi as f,RCe as g,ic as h,po as i,p as j,ETe as k,Ze as l,A1 as m,eY as n,E1 as o,FKe as p,yZe as q,_ as r,LCe as s,gZe as t,so as u,MCe as v,p6e as w,ICe as x,TTe as y,bEe as z};