@cmmd-center/forge 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BunHttpServer-Dc5XijQF.mjs → BunHttpServer-BgNCpQzV.mjs} +2 -2
- package/dist/{BunHttpServer-Cuya1Zon.cjs → BunHttpServer-DOAuw4Iq.cjs} +2 -2
- package/dist/{BunPTY-z9OKvyBo.cjs → BunPTY-2icf7sRj.cjs} +2 -2
- package/dist/{BunPTY-CfS5zDoQ.mjs → BunPTY-D-Klry5N.mjs} +2 -2
- package/dist/{BunServices-eq_c-3x1.mjs → BunServices-ChM4mYH9.mjs} +1 -1
- package/dist/{BunServices-khEuvPaA.cjs → BunServices-CiNXNzHD.cjs} +1 -1
- package/dist/Mime-BITO-E1U.mjs +1395 -0
- package/dist/Mime-CyHbecis.cjs +1400 -0
- package/dist/{Mime-B75_d9aw.mjs → NodeHttpServer-C_wePPV0.mjs} +614 -1456
- package/dist/{Mime-aSilaQX9.cjs → NodeHttpServer-D_ismXpd.cjs} +617 -1466
- package/dist/{NodePTY-ChjVFpUH.mjs → NodePTY-BMUFdM93.mjs} +2 -2
- package/dist/{NodePTY-BOaJi0JA.cjs → NodePTY-cb7HIasY.cjs} +2 -2
- package/dist/{NodeSqliteClient-GlgGqc8V.mjs → NodeSqliteClient-OdI1TawL.mjs} +1 -1
- package/dist/{NodeSqliteClient-Vunn3aFN.cjs → NodeSqliteClient-SsUCk9mA.cjs} +1 -1
- package/dist/{PTY-rn2kGjhB.mjs → PTY-CBkE5akF.mjs} +1 -1
- package/dist/{PTY-D5OpMK9s.cjs → PTY-U3JQnLXS.cjs} +1 -1
- package/dist/{SqliteClient-Bpkno4Ob.cjs → SqliteClient-CdAhI4lb.cjs} +1 -1
- package/dist/{SqliteClient-DYQAvreq.mjs → SqliteClient-aoOb51gB.mjs} +1 -1
- package/dist/bin.cjs +14484 -10871
- package/dist/bin.mjs +14667 -11052
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/apple-touch-icon.png.publish-bak +0 -0
- package/dist/client/assets/CanvasPanel-BIN3OTEQ.js +441 -0
- package/dist/client/assets/CompositeItem-UKxcvvWv.js +2 -0
- package/dist/client/assets/DiffPanel-CeuRaSj1.js +64 -0
- package/dist/client/assets/DiffPanel.logic-D5i9QswQ.js +21 -0
- package/dist/client/assets/DiffPanelShell-W5nEVL52.js +2531 -0
- package/dist/client/assets/DiffWorkerPoolProvider-D87CO5TY.js +73 -0
- package/dist/client/assets/PullRequestCodePanel-DAmHwtY9.js +5 -0
- package/dist/client/assets/Stream-CToP6xzI.js +15 -0
- package/dist/client/assets/Virtualizer-CnwVHiy3.js +2 -0
- package/dist/client/assets/__vite-browser-external-DkEyUtaV.js +2 -0
- package/dist/client/assets/abap-kWSt4ETq.js +2 -0
- package/dist/client/assets/actionscript-3-DUMfZd56.js +2 -0
- package/dist/client/assets/ada-B5ZVVI6u.js +2 -0
- package/dist/client/assets/andromeeda-DXFdNco6.js +2 -0
- package/dist/client/assets/andromeeda-DwmQuk--.js +2 -0
- package/dist/client/assets/angular-html-BHUTdQ2k.js +2 -0
- package/dist/client/assets/angular-ts-BSGCbJ0j.js +2 -0
- package/dist/client/assets/apache-Cu40O3Ol.js +2 -0
- package/dist/client/assets/apex-DMPEjfSG.js +2 -0
- package/dist/client/assets/apl-BoCi4WkG.js +2 -0
- package/dist/client/assets/applescript-mUd3mpyF.js +2 -0
- package/dist/client/assets/ara-LhQXZmm_.js +2 -0
- package/dist/client/assets/asciidoc-BhTPoeH5.js +2 -0
- package/dist/client/assets/asm-BGGwX2ZL.js +2 -0
- package/dist/client/assets/astro-BMi5lGMm.js +2 -0
- package/dist/client/assets/atomRegistry-Bq5Y4LP1.js +3 -0
- package/dist/client/assets/aurora-x-CLgz8jpO.js +2 -0
- package/dist/client/assets/aurora-x-DY4EgSB_.js +2 -0
- package/dist/client/assets/awk-emAjNmqG.js +2 -0
- package/dist/client/assets/ayu-dark-BOsBaLmt.js +2 -0
- package/dist/client/assets/ayu-dark-Dm87GVDE.js +2 -0
- package/dist/client/assets/ayu-light-CVzS2PQZ.js +2 -0
- package/dist/client/assets/ayu-light-nGNJ-WDB.js +2 -0
- package/dist/client/assets/ayu-mirage-CionIqJ2.js +2 -0
- package/dist/client/assets/ayu-mirage-wUDx3klU.js +2 -0
- package/dist/client/assets/ballerina-Zz4P1PCo.js +2 -0
- package/dist/client/assets/bat-CojohPr3.js +2 -0
- package/dist/client/assets/beancount-DIrDFIbZ.js +2 -0
- package/dist/client/assets/berry-BktKISqk.js +2 -0
- package/dist/client/assets/bibtex-QuZiL8vO.js +2 -0
- package/dist/client/assets/bicep-BBqBjbA3.js +2 -0
- package/dist/client/assets/bird2-FrGIamnO.js +2 -0
- package/dist/client/assets/blade-CUGHtpnt.js +2 -0
- package/dist/client/assets/bsl-Dwz0otKA.js +2 -0
- package/dist/client/assets/c-3r97XxSq.js +2 -0
- package/dist/client/assets/c3-D-fgrOzJ.js +2 -0
- package/dist/client/assets/cadence-53eYIqKQ.js +2 -0
- package/dist/client/assets/cairo-Cai_OBhL.js +2 -0
- package/dist/client/assets/canvasStateStore-D3R1Ldk1.js +2 -0
- package/dist/client/assets/catppuccin-frappe-B9ztfCCY.js +2 -0
- package/dist/client/assets/catppuccin-frappe-Dtq86Zt-.js +2 -0
- package/dist/client/assets/catppuccin-latte-D1lF_ULk.js +2 -0
- package/dist/client/assets/catppuccin-latte-jgmNlGoB.js +2 -0
- package/dist/client/assets/catppuccin-macchiato-CcX-f1yB.js +2 -0
- package/dist/client/assets/catppuccin-macchiato-DfuKQKcK.js +2 -0
- package/dist/client/assets/catppuccin-mocha-B3_lpdvM.js +2 -0
- package/dist/client/assets/catppuccin-mocha-DfNnOvvn.js +2 -0
- package/dist/client/assets/clarity-DCS2DMlE.js +2 -0
- package/dist/client/assets/clojure-XwHeeE37.js +2 -0
- package/dist/client/assets/cmake-VIYk9tbe.js +2 -0
- package/dist/client/assets/cmmdAuthRedirect-DLvl7JNi.js +2 -0
- package/dist/client/assets/cobol-IPhylbE9.js +2 -0
- package/dist/client/assets/codeowners-DiTXAskR.js +2 -0
- package/dist/client/assets/codeql-0208dEuz.js +2 -0
- package/dist/client/assets/coffee-BwGUpF4f.js +2 -0
- package/dist/client/assets/common-lisp-Bbk7xLRF.js +2 -0
- package/dist/client/assets/coq-CDDZdGGh.js +2 -0
- package/dist/client/assets/cpp-jFyTvZsm.js +2 -0
- package/dist/client/assets/crystal-DYkQl9zO.js +2 -0
- package/dist/client/assets/csharp-Dausz59m.js +2 -0
- package/dist/client/assets/css-jXIxCbs3.js +2 -0
- package/dist/client/assets/csv-e2HVQau9.js +2 -0
- package/dist/client/assets/cue-BMgE_xju.js +2 -0
- package/dist/client/assets/cypher-CA95tXqi.js +2 -0
- package/dist/client/assets/d-DeO2qMKQ.js +2 -0
- package/dist/client/assets/dark-plus-DaoBxEuI.js +2 -0
- package/dist/client/assets/dark-plus-hlEOAUn6.js +2 -0
- package/dist/client/assets/dart-_9gbW0uG.js +2 -0
- package/dist/client/assets/dax-BMSB_urL.js +2 -0
- package/dist/client/assets/desktop-CFWOIXtS.js +2 -0
- package/dist/client/assets/diff-K3NAzB5h.js +2 -0
- package/dist/client/assets/docker-BHQx5Ff2.js +2 -0
- package/dist/client/assets/dotenv-CkiqXLC8.js +2 -0
- package/dist/client/assets/dracula-C9rp4fWn.js +2 -0
- package/dist/client/assets/dracula-CIJxKfwh.js +2 -0
- package/dist/client/assets/dracula-soft-BN-taJLQ.js +2 -0
- package/dist/client/assets/dracula-soft-De1wWQ_v.js +2 -0
- package/dist/client/assets/dream-maker-BM-H3AID.js +2 -0
- package/dist/client/assets/edge-CVf1J8H7.js +2 -0
- package/dist/client/assets/elixir-DtWV_YYF.js +2 -0
- package/dist/client/assets/elm-BJC2NMzB.js +2 -0
- package/dist/client/assets/emacs-lisp-BBM_ORbk.js +2 -0
- package/dist/client/assets/erb-cwYn0k3w.js +2 -0
- package/dist/client/assets/erlang-QNS0KA0S.js +2 -0
- package/dist/client/assets/everforest-dark-BSYmfNnp.js +2 -0
- package/dist/client/assets/everforest-dark-DUW3cHBn.js +2 -0
- package/dist/client/assets/everforest-light-CXyS_8Pc.js +2 -0
- package/dist/client/assets/everforest-light-DR-OhbXr.js +2 -0
- package/dist/client/assets/fennel-CAUJGoSU.js +2 -0
- package/dist/client/assets/fish-Cgln2BIC.js +2 -0
- package/dist/client/assets/fluent-BFL910sE.js +2 -0
- package/dist/client/assets/fortran-fixed-form-GNS6k7js.js +2 -0
- package/dist/client/assets/fortran-free-form-DB-siuqX.js +2 -0
- package/dist/client/assets/fsharp-BEjSdIee.js +2 -0
- package/dist/client/assets/gdresource-D24f9BeL.js +2 -0
- package/dist/client/assets/gdscript-Bq5ZYHDh.js +2 -0
- package/dist/client/assets/gdshader-BWxXiThj.js +2 -0
- package/dist/client/assets/genie-BOcsPMcn.js +2 -0
- package/dist/client/assets/gherkin-pSvoetjt.js +2 -0
- package/dist/client/assets/git-commit-Ddcy2Rzd.js +2 -0
- package/dist/client/assets/git-rebase-95AHstHI.js +2 -0
- package/dist/client/assets/github-dark-BbHkogeI.js +2 -0
- package/dist/client/assets/github-dark-D1nTcH4E.js +2 -0
- package/dist/client/assets/github-dark-default-Cgu-j31c.js +2 -0
- package/dist/client/assets/github-dark-default-CwMUtNVn.js +2 -0
- package/dist/client/assets/github-dark-dimmed-BmSK4vhs.js +2 -0
- package/dist/client/assets/github-dark-dimmed-CQVfITf-.js +2 -0
- package/dist/client/assets/github-dark-high-contrast-8_9Rbsic.js +2 -0
- package/dist/client/assets/github-dark-high-contrast-BO-0858k.js +2 -0
- package/dist/client/assets/github-light-DWIA8Fx_.js +2 -0
- package/dist/client/assets/github-light-default-CR0FtjVb.js +2 -0
- package/dist/client/assets/github-light-default-LLPbqR-K.js +2 -0
- package/dist/client/assets/github-light-high-contrast-5o8qRjCb.js +2 -0
- package/dist/client/assets/github-light-high-contrast-C8BCDz6a.js +2 -0
- package/dist/client/assets/github-light-lCcn0xRl.js +2 -0
- package/dist/client/assets/gleam-DPm9Zc9U.js +2 -0
- package/dist/client/assets/glimmer-js-Cjwf-Ijv.js +2 -0
- package/dist/client/assets/glimmer-ts-DXnOWlZf.js +2 -0
- package/dist/client/assets/glsl-iXGbnqIU.js +2 -0
- package/dist/client/assets/gn-DEuV1her.js +2 -0
- package/dist/client/assets/gnuplot-CqGlKjK6.js +2 -0
- package/dist/client/assets/go-mptU-yl2.js +2 -0
- package/dist/client/assets/graphql-DJMVZQv3.js +2 -0
- package/dist/client/assets/groovy-CKg5KWq9.js +2 -0
- package/dist/client/assets/gruvbox-dark-hard-Df4rfbxN.js +2 -0
- package/dist/client/assets/gruvbox-dark-hard-DsK6pQOr.js +2 -0
- package/dist/client/assets/gruvbox-dark-medium-nlSbDtaA.js +2 -0
- package/dist/client/assets/gruvbox-dark-medium-zSmEeDKP.js +2 -0
- package/dist/client/assets/gruvbox-dark-soft-BSW4a3D0.js +2 -0
- package/dist/client/assets/gruvbox-dark-soft-DgI1MxVf.js +2 -0
- package/dist/client/assets/gruvbox-light-hard-D144A6HZ.js +2 -0
- package/dist/client/assets/gruvbox-light-hard-DMNoHzNU.js +2 -0
- package/dist/client/assets/gruvbox-light-medium-C0B0NCuj.js +2 -0
- package/dist/client/assets/gruvbox-light-medium-CY2MDbN0.js +2 -0
- package/dist/client/assets/gruvbox-light-soft-CWJ8aP9f.js +2 -0
- package/dist/client/assets/gruvbox-light-soft-CyPlqRD8.js +2 -0
- package/dist/client/assets/hack-CkGKtoya.js +2 -0
- package/dist/client/assets/haml-mV-E4efJ.js +2 -0
- package/dist/client/assets/handlebars-Da6i86YE.js +2 -0
- package/dist/client/assets/haskell-DFWkJmsd.js +2 -0
- package/dist/client/assets/haxe-DoXg9N2w.js +2 -0
- package/dist/client/assets/hcl-VbcvLW6X.js +2 -0
- package/dist/client/assets/hjson-dQ--SYg9.js +2 -0
- package/dist/client/assets/hlsl-DNh8NDKB.js +2 -0
- package/dist/client/assets/horizon-BeufL1QP.js +2 -0
- package/dist/client/assets/horizon-CnOil3H1.js +2 -0
- package/dist/client/assets/horizon-bright-BoFfNO4u.js +2 -0
- package/dist/client/assets/horizon-bright-CJCE-DcQ.js +2 -0
- package/dist/client/assets/houston-C5_OTP91.js +2 -0
- package/dist/client/assets/houston-jaZUvSzs.js +2 -0
- package/dist/client/assets/html-derivative-BOw7yS3Z.js +2 -0
- package/dist/client/assets/html-e1ppUAVa.js +2 -0
- package/dist/client/assets/html2canvas-C_LL7spC.js +6 -0
- package/dist/client/assets/http-DFrMFVWs.js +2 -0
- package/dist/client/assets/hurl-3N2UscjA.js +2 -0
- package/dist/client/assets/hxml-Ip0yb8dg.js +2 -0
- package/dist/client/assets/hy-Bg-RIaMc.js +2 -0
- package/dist/client/assets/imba-BjZ9NRcj.js +2 -0
- package/dist/client/assets/index-Dr7HwjTE.css +1 -0
- package/dist/client/assets/index-DyEYqQdf.js +151 -0
- package/dist/client/assets/index.es-piUKIQw4.js +6 -0
- package/dist/client/assets/ini-CXagdQO9.js +2 -0
- package/dist/client/assets/java-DY6ZSujp.js +2 -0
- package/dist/client/assets/javascript-BfTuFzbs.js +2 -0
- package/dist/client/assets/jinja-C4NVx4X-.js +2 -0
- package/dist/client/assets/jison-BaE4DrvM.js +2 -0
- package/dist/client/assets/json-LL0kLbs_.js +2 -0
- package/dist/client/assets/json5-B1LcXsA8.js +2 -0
- package/dist/client/assets/jsonc-CYSDka7c.js +2 -0
- package/dist/client/assets/jsonl-CwfwQmvE.js +2 -0
- package/dist/client/assets/jsonnet-DG_zYewp.js +2 -0
- package/dist/client/assets/jspdf.es.min-_OjqfV_L.js +80 -0
- package/dist/client/assets/jssm-IkACsEzj.js +2 -0
- package/dist/client/assets/jsx-BOBg7x46.js +2 -0
- package/dist/client/assets/julia-D5dobu9Y.js +2 -0
- package/dist/client/assets/just-D99ddsWv.js +2 -0
- package/dist/client/assets/kanagawa-dragon-BBUl63AF.js +2 -0
- package/dist/client/assets/kanagawa-dragon-CBGy-6ik.js +2 -0
- package/dist/client/assets/kanagawa-lotus-BKY9TlU3.js +2 -0
- package/dist/client/assets/kanagawa-lotus-D93oLQjR.js +2 -0
- package/dist/client/assets/kanagawa-wave-CWf0rFWt.js +2 -0
- package/dist/client/assets/kanagawa-wave-CZBJ3hQh.js +2 -0
- package/dist/client/assets/kdl-DuytcvNV.js +2 -0
- package/dist/client/assets/kotlin-DmtnKz6Z.js +2 -0
- package/dist/client/assets/kusto-DmrVjfae.js +2 -0
- package/dist/client/assets/laserwave-DTzUwFmi.js +2 -0
- package/dist/client/assets/laserwave-NRABVcaO.js +2 -0
- package/dist/client/assets/latex-0e5rhe9m.js +2 -0
- package/dist/client/assets/lean-Bhkhoed1.js +2 -0
- package/dist/client/assets/less-BgyohKqc.js +2 -0
- package/dist/client/assets/light-plus-Cbc9ZUH4.js +2 -0
- package/dist/client/assets/light-plus-SK-KfMAV.js +2 -0
- package/dist/client/assets/liquid-BR35Xk1k.js +2 -0
- package/dist/client/assets/llvm-BtFJuFOJ.js +2 -0
- package/dist/client/assets/log-Df3M8ERB.js +2 -0
- package/dist/client/assets/logo-VfSEjTs6.js +2 -0
- package/dist/client/assets/lua-BMt4EqAw.js +2 -0
- package/dist/client/assets/luau-DIHOVG2A.js +2 -0
- package/dist/client/assets/make-gTMDFaMm.js +2 -0
- package/dist/client/assets/markdown-B_5il8S2.js +2 -0
- package/dist/client/assets/marko-DN4rLggA.js +2 -0
- package/dist/client/assets/material-theme-Pm6m-Kzc.js +2 -0
- package/dist/client/assets/material-theme-darker-BxFgxa9U.js +2 -0
- package/dist/client/assets/material-theme-darker-pKUQPx9-.js +2 -0
- package/dist/client/assets/material-theme-lighter-BLqni5my.js +2 -0
- package/dist/client/assets/material-theme-lighter-D6-26WhM.js +2 -0
- package/dist/client/assets/material-theme-ocean-C2N-nFlu.js +2 -0
- package/dist/client/assets/material-theme-ocean-DCxzET3l.js +2 -0
- package/dist/client/assets/material-theme-palenight-DyQqRTLL.js +2 -0
- package/dist/client/assets/material-theme-palenight-Y14J3SJp.js +2 -0
- package/dist/client/assets/material-theme-zfTX2d95.js +2 -0
- package/dist/client/assets/matlab-B2zVSjQq.js +2 -0
- package/dist/client/assets/mdc-kokCuEO8.js +2 -0
- package/dist/client/assets/mdx-CL7pLDiG.js +2 -0
- package/dist/client/assets/mermaid-Cou83ohU.js +2 -0
- package/dist/client/assets/min-dark-Bg1kQHvJ.js +2 -0
- package/dist/client/assets/min-dark-BhN4iMRs.js +2 -0
- package/dist/client/assets/min-light-BjU80CRL.js +2 -0
- package/dist/client/assets/min-light-Bw9u-P_u.js +2 -0
- package/dist/client/assets/mipsasm-CNFOlV7Y.js +2 -0
- package/dist/client/assets/module-fAFg92om.js +4 -0
- package/dist/client/assets/mojo-DmJMpmxj.js +2 -0
- package/dist/client/assets/monokai-C4NNjw1j.js +2 -0
- package/dist/client/assets/monokai-DIfgn9Q6.js +2 -0
- package/dist/client/assets/moonbit-f-DlcHvh.js +2 -0
- package/dist/client/assets/move-3UEJ-86q.js +2 -0
- package/dist/client/assets/narrat-BSySVkso.js +2 -0
- package/dist/client/assets/nextflow-B6YiVxNF.js +2 -0
- package/dist/client/assets/nextflow-groovy-CJM1tnxB.js +2 -0
- package/dist/client/assets/nginx-yFGqgywB.js +2 -0
- package/dist/client/assets/night-owl-CVqrHJ7c.js +2 -0
- package/dist/client/assets/night-owl-M-9PEzO3.js +2 -0
- package/dist/client/assets/night-owl-light-BFLAfCgh.js +2 -0
- package/dist/client/assets/night-owl-light-CbICj08I.js +2 -0
- package/dist/client/assets/nim-H0r8m4Bj.js +2 -0
- package/dist/client/assets/nix-D01-yy0s.js +2 -0
- package/dist/client/assets/nord-DdQ2eXb7.js +2 -0
- package/dist/client/assets/nord-b31BpoFd.js +2 -0
- package/dist/client/assets/nushell-CHtjMTHK.js +2 -0
- package/dist/client/assets/objective-c-CpnACn2A.js +2 -0
- package/dist/client/assets/objective-cpp-CC37zF8s.js +2 -0
- package/dist/client/assets/ocaml-zEzf7VRa.js +2 -0
- package/dist/client/assets/odin-7LfNaizd.js +2 -0
- package/dist/client/assets/one-dark-pro-D7GXMkD_.js +2 -0
- package/dist/client/assets/one-dark-pro-DZNXQIff.js +2 -0
- package/dist/client/assets/one-light-D0m2woYU.js +2 -0
- package/dist/client/assets/one-light-vpvEwBNE.js +2 -0
- package/dist/client/assets/openscad-alCnkqb3.js +2 -0
- package/dist/client/assets/pascal-BzxE7FG0.js +2 -0
- package/dist/client/assets/perl-DMfQlGhS.js +2 -0
- package/dist/client/assets/php-eC0_nfgu.js +2 -0
- package/dist/client/assets/pierre-dark-C8scyjTE.js +2 -0
- package/dist/client/assets/pierre-dark-protanopia-deuteranopia-DjjI5tLG.js +2 -0
- package/dist/client/assets/pierre-dark-soft-U4k3hSAg.js +2 -0
- package/dist/client/assets/pierre-dark-tritanopia-CwldMLve.js +2 -0
- package/dist/client/assets/pierre-dark-vibrant-CbqW77RL.js +2 -0
- package/dist/client/assets/pierre-light-CRazXHrY.js +2 -0
- package/dist/client/assets/pierre-light-protanopia-deuteranopia-C-0-s32M.js +2 -0
- package/dist/client/assets/pierre-light-soft-CeMgeGD-.js +2 -0
- package/dist/client/assets/pierre-light-tritanopia-CwP7kaEp.js +2 -0
- package/dist/client/assets/pierre-light-vibrant-BRw7kdwa.js +2 -0
- package/dist/client/assets/pkl-B_4Y3aQj.js +2 -0
- package/dist/client/assets/plastic-7ebP7j7m.js +2 -0
- package/dist/client/assets/plastic-BxJ4wlPp.js +2 -0
- package/dist/client/assets/plsql-Vnj6O-p2.js +2 -0
- package/dist/client/assets/po-BDEiW-In.js +2 -0
- package/dist/client/assets/poimandres-CjxvpNV1.js +2 -0
- package/dist/client/assets/poimandres-DaajSABO.js +2 -0
- package/dist/client/assets/polar-DkeS43LD.js +2 -0
- package/dist/client/assets/postcss-BdW9ckpW.js +2 -0
- package/dist/client/assets/powerquery-Ck_tTsxM.js +2 -0
- package/dist/client/assets/powershell-CSE_7mny.js +2 -0
- package/dist/client/assets/preload-helper-2nxZ5jlD.js +1 -0
- package/dist/client/assets/prisma-Bo0mLS5-.js +2 -0
- package/dist/client/assets/prolog-BKKH5B6F.js +2 -0
- package/dist/client/assets/proto-CQGfqf21.js +2 -0
- package/dist/client/assets/pug-CdkPd3m5.js +2 -0
- package/dist/client/assets/puppet-CMQRMMTw.js +2 -0
- package/dist/client/assets/purescript-CCcyGQO2.js +2 -0
- package/dist/client/assets/purify.es-BOhOJYGt.js +3 -0
- package/dist/client/assets/python-DMPOlDIf.js +2 -0
- package/dist/client/assets/qml-CjgSvi7A.js +2 -0
- package/dist/client/assets/qmldir-WCdsq__X.js +2 -0
- package/dist/client/assets/qss-AtgwhOez.js +2 -0
- package/dist/client/assets/r-CyfaTtPo.js +2 -0
- package/dist/client/assets/racket-BChN0yKc.js +2 -0
- package/dist/client/assets/raku-y2whvo3i.js +2 -0
- package/dist/client/assets/razor-xg0jlt5d.js +2 -0
- package/dist/client/assets/red-4ASUbyQz.js +2 -0
- package/dist/client/assets/red-FUTSeuNn.js +2 -0
- package/dist/client/assets/reg-Vw5mc10D.js +2 -0
- package/dist/client/assets/regexp-DNjghFOM.js +2 -0
- package/dist/client/assets/rel-B7yBab0H.js +2 -0
- package/dist/client/assets/riscv-CoVA6mXv.js +2 -0
- package/dist/client/assets/rolldown-runtime-BeQ30c1w.js +1 -0
- package/dist/client/assets/ron-Dncoj8f2.js +2 -0
- package/dist/client/assets/rose-pine-BYqQazSr.js +2 -0
- package/dist/client/assets/rose-pine-DKVJldI6.js +2 -0
- package/dist/client/assets/rose-pine-dawn-BzAj1SA_.js +2 -0
- package/dist/client/assets/rose-pine-dawn-DpMWSJny.js +2 -0
- package/dist/client/assets/rose-pine-moon-BF7RtPma.js +2 -0
- package/dist/client/assets/rose-pine-moon-Buv_ZumG.js +2 -0
- package/dist/client/assets/rosmsg-DMM9gQ6F.js +2 -0
- package/dist/client/assets/rst-DUzGXO8S.js +2 -0
- package/dist/client/assets/ruby-rVw1KmtO.js +2 -0
- package/dist/client/assets/rust-Do9fnzCe.js +2 -0
- package/dist/client/assets/sas-DqCEPep6.js +2 -0
- package/dist/client/assets/sass-C-AYCcFv.js +2 -0
- package/dist/client/assets/scala-g1Tl2-Vx.js +2 -0
- package/dist/client/assets/scheme-DMNTmmtl.js +2 -0
- package/dist/client/assets/scss-DUVpCPFS.js +2 -0
- package/dist/client/assets/sdbl-DN-YwBSp.js +2 -0
- package/dist/client/assets/shaderlab-CU1ngQGv.js +2 -0
- package/dist/client/assets/shellscript-DhExEfAl.js +2 -0
- package/dist/client/assets/shellsession-BRLd459R.js +2 -0
- package/dist/client/assets/slack-dark-CHVebfsv.js +2 -0
- package/dist/client/assets/slack-dark-DsHK2SW9.js +2 -0
- package/dist/client/assets/slack-ochin-DLRnnjq1.js +2 -0
- package/dist/client/assets/slack-ochin-auUeui07.js +2 -0
- package/dist/client/assets/smalltalk-DfTqE6NI.js +2 -0
- package/dist/client/assets/snazzy-light-DYCniS15.js +2 -0
- package/dist/client/assets/snazzy-light-DcJ4c2TI.js +2 -0
- package/dist/client/assets/solarized-dark-C2M3A6iX.js +2 -0
- package/dist/client/assets/solarized-dark-f_BlEcC2.js +2 -0
- package/dist/client/assets/solarized-light-DGdaihLk.js +2 -0
- package/dist/client/assets/solarized-light-p0lk9NUw.js +2 -0
- package/dist/client/assets/solidity-UrsYApv4.js +2 -0
- package/dist/client/assets/soy-B2el7XDq.js +2 -0
- package/dist/client/assets/sparql-Ckg9aAAq.js +2 -0
- package/dist/client/assets/splunk-BbdNC7mF.js +2 -0
- package/dist/client/assets/sql-DiDaRjp9.js +2 -0
- package/dist/client/assets/src-pwcrD9wg.js +3 -0
- package/dist/client/assets/ssh-config-NaDpXiNE.js +2 -0
- package/dist/client/assets/stata-C71yNzqX.js +2 -0
- package/dist/client/assets/stylus-BmDWwNjA.js +2 -0
- package/dist/client/assets/surrealql-Cmypmwl2.js +2 -0
- package/dist/client/assets/svelte-VS6niI_T.js +2 -0
- package/dist/client/assets/swift-C69NyPuQ.js +2 -0
- package/dist/client/assets/synthwave-84-2NxBVDLO.js +2 -0
- package/dist/client/assets/synthwave-84-CVwMZOby.js +2 -0
- package/dist/client/assets/system-verilog-DJk0s1jv.js +2 -0
- package/dist/client/assets/systemd-CcQAXEZ9.js +2 -0
- package/dist/client/assets/talonscript-CUGr7vYM.js +2 -0
- package/dist/client/assets/tasl-BB-YNBB8.js +2 -0
- package/dist/client/assets/tcl-DR8-AcmN.js +2 -0
- package/dist/client/assets/templ-Cr4Do0uA.js +2 -0
- package/dist/client/assets/terraform-DS-GC2Bj.js +2 -0
- package/dist/client/assets/tex-CcZtvqzZ.js +2 -0
- package/dist/client/assets/toggle-BBEoD8mr.js +2 -0
- package/dist/client/assets/tokyo-night-9wJEO1G-.js +2 -0
- package/dist/client/assets/tokyo-night-ZUp4Hulo.js +2 -0
- package/dist/client/assets/toml-ByrHRc5Z.js +2 -0
- package/dist/client/assets/transport-B-82Ada5.js +2 -0
- package/dist/client/assets/ts-tags-Dhe4Ce_p.js +2 -0
- package/dist/client/assets/tsv-2A2hWH8i.js +2 -0
- package/dist/client/assets/tsx-rRP2I03K.js +2 -0
- package/dist/client/assets/turtle-BYbwzkhD.js +2 -0
- package/dist/client/assets/twig-DtN4j4nR.js +2 -0
- package/dist/client/assets/typeof-DOAxNSYQ.js +2 -0
- package/dist/client/assets/typescript-tv4fsI1Q.js +2 -0
- package/dist/client/assets/typespec-DoZVUoUi.js +2 -0
- package/dist/client/assets/typst-BmNF0lss.js +2 -0
- package/dist/client/assets/useTriggerFocusGuards-B2i3DSgR.js +2 -0
- package/dist/client/assets/v-CtCN4vLO.js +2 -0
- package/dist/client/assets/vala-DOsY6Y3z.js +2 -0
- package/dist/client/assets/vb-C1Ff9hOT.js +2 -0
- package/dist/client/assets/verilog-Dt4OfjHN.js +2 -0
- package/dist/client/assets/vesper-5ZmhmIun.js +2 -0
- package/dist/client/assets/vesper-J3W-7eep.js +2 -0
- package/dist/client/assets/vhdl-DkoQ3qnl.js +2 -0
- package/dist/client/assets/viml-C3b4aEDf.js +2 -0
- package/dist/client/assets/vitesse-black-CYOC7ssU.js +2 -0
- package/dist/client/assets/vitesse-black-DWaDDoI3.js +2 -0
- package/dist/client/assets/vitesse-dark-Bxewb9U5.js +2 -0
- package/dist/client/assets/vitesse-dark-CZotVzc8.js +2 -0
- package/dist/client/assets/vitesse-light-Bf_msd9a.js +2 -0
- package/dist/client/assets/vitesse-light-BfrRSjRx.js +2 -0
- package/dist/client/assets/vue-C0rWZC13.js +2 -0
- package/dist/client/assets/vue-html-bxw887C2.js +2 -0
- package/dist/client/assets/vue-vine-DUWGjTI5.js +2 -0
- package/dist/client/assets/vyper-BamdcTqV.js +2 -0
- package/dist/client/assets/wasm-C2MLrNQ1.js +2 -0
- package/dist/client/assets/wasm-CGd31VpO.js +2 -0
- package/dist/client/assets/wenyan-BPZ76iog.js +2 -0
- package/dist/client/assets/wgsl-sH_fVDG_.js +2 -0
- package/dist/client/assets/wikitext-BsPo9Czf.js +2 -0
- package/dist/client/assets/wit-BfBhtJwS.js +2 -0
- package/dist/client/assets/wolfram-GL7CPBRD.js +2 -0
- package/dist/client/assets/worker-Cvq2iJN1.js +162 -0
- package/dist/client/assets/workspaceReadinessAtom-DUP5NKsc.js +2 -0
- package/dist/client/assets/xml-C0zxRzgj.js +2 -0
- package/dist/client/assets/xsl-CC403A_G.js +2 -0
- package/dist/client/assets/yaml-BCnsJrvx.js +2 -0
- package/dist/client/assets/zenscript-CmwVE7RW.js +2 -0
- package/dist/client/assets/zig-GtQXM-vf.js +2 -0
- package/dist/client/favicon-16x16.png +0 -0
- package/dist/client/favicon-16x16.png.publish-bak +0 -0
- package/dist/client/favicon-32x32.png +0 -0
- package/dist/client/favicon-32x32.png.publish-bak +0 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.ico.publish-bak +0 -0
- package/dist/client/forge-mark.svg +5 -0
- package/dist/client/index.html +131 -0
- package/dist/client/mockServiceWorker.js +336 -0
- package/dist/client/sidebar/forge-ember-field.webp +0 -0
- package/dist/{esm-wLIF-u3N.mjs → esm-Ce1GqbVk.mjs} +1 -1
- package/dist/{esm-BZhXwX5p.cjs → esm-Do7HVhLA.cjs} +1 -1
- package/dist/{execAsync-DWZyWH-_.mjs → execAsync-BNNdR88o.mjs} +1 -1
- package/dist/{execAsync-jnYVB5RZ.cjs → execAsync-BUcaFQ1D.cjs} +1 -1
- package/dist/forge-provision-display.sh +316 -0
- package/dist/{getMachineId-bsd-BLtyMA4j.cjs → getMachineId-bsd-C_qi9crE.cjs} +3 -3
- package/dist/{getMachineId-bsd-CTjiY7jG.mjs → getMachineId-bsd-FI863wjR.mjs} +3 -3
- package/dist/{getMachineId-darwin-DaGS2zUd.cjs → getMachineId-darwin-BOoNuqXn.cjs} +3 -3
- package/dist/{getMachineId-darwin-BrPuyPOo.mjs → getMachineId-darwin-D9VhTaPM.mjs} +3 -3
- package/dist/{getMachineId-linux-BsP3wJaE.cjs → getMachineId-linux-C9L-vW7m.cjs} +2 -2
- package/dist/{getMachineId-linux-D9QEWWF-.mjs → getMachineId-linux-DE2x36Kt.mjs} +2 -2
- package/dist/{getMachineId-unsupported-Cm-2s4Sg.mjs → getMachineId-unsupported-9S6pcxXb.mjs} +2 -2
- package/dist/{getMachineId-unsupported-B_M-gck7.cjs → getMachineId-unsupported-CmbM8LYa.cjs} +2 -2
- package/dist/{getMachineId-win-qtEKaUYj.mjs → getMachineId-win-0EVRuBxU.mjs} +3 -3
- package/dist/{getMachineId-win-3zJ3HQLG.cjs → getMachineId-win-BPaemVew.cjs} +3 -3
- package/dist/{open-CGXZLos4.cjs → open-BAsPVCWX.cjs} +1 -1
- package/dist/{open-Cf0bgbyx.mjs → open-FIgTDosf.mjs} +1 -1
- package/dist/runtimeBootstrap.cjs +8 -0
- package/dist/runtimeBootstrap.mjs +4 -0
- package/dist/runtimeControlAuthority-L85w5RTn.mjs +535 -0
- package/dist/runtimeControlAuthority-SNBF5Mjy.cjs +601 -0
- package/package.json +28 -30
- package/dist/NodeHttpServer-C7YMYP5R.cjs +0 -616
- package/dist/NodeHttpServer-D5-EtRwc.mjs +0 -605
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-_OjqfV_L.js","assets/rolldown-runtime-BeQ30c1w.js","assets/preload-helper-2nxZ5jlD.js","assets/typeof-DOAxNSYQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.4`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`5c9469e4-5c32-47cc-8b77-3c393c909c74`,e._sentryDebugIdIdentifier=`sentry-dbid-5c9469e4-5c32-47cc-8b77-3c393c909c74`)}catch{}})();import{r as e}from"./rolldown-runtime-BeQ30c1w.js";import{La as t,Ra as n,za as r}from"./Stream-CToP6xzI.js";import{Ht as i,Vt as a,i as o,o as s,r as c}from"./useTriggerFocusGuards-B2i3DSgR.js";import{Pn as l,g as u}from"./CompositeItem-UKxcvvWv.js";import{t as d}from"./preload-helper-2nxZ5jlD.js";import{C as f,S as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,x as N,y as P}from"./canvasStateStore-D3R1Ldk1.js";import{t as F}from"./toggle-BBEoD8mr.js";var I=l(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ee=l(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),L=l(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),R=l(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),z=l(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),B=l(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),te=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),ne=l(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),re=l(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),ie=l(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),ae=l(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),oe=l(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),se=l(`wand`,[[`path`,{d:`M15 4V2`,key:`z1p9b7`}],[`path`,{d:`M15 16v-2`,key:`px0unx`}],[`path`,{d:`M8 9h2`,key:`1g203m`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M17.8 11.8 19 13`,key:`yihg8r`}],[`path`,{d:`M15 9h.01`,key:`x1ddxp`}],[`path`,{d:`M17.8 6.2 19 5`,key:`fd4us0`}],[`path`,{d:`m3 21 9-9`,key:`1jfql5`}],[`path`,{d:`M12.2 6.2 11 5`,key:`i3da3b`}]]),ce=l(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),le=l(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),V=e(r(),1),ue=[{id:`instagram-post`,label:`Instagram Post`,category:`Social Media`,width:1080,height:1080},{id:`instagram-story`,label:`Instagram Story`,category:`Social Media`,width:1080,height:1920},{id:`facebook-cover`,label:`Facebook Cover`,category:`Social Media`,width:820,height:312},{id:`linkedin-banner`,label:`LinkedIn Banner`,category:`Social Media`,width:1584,height:396},{id:`twitter-post`,label:`Twitter/X Post`,category:`Social Media`,width:1200,height:675},{id:`youtube-thumbnail`,label:`YouTube Thumbnail`,category:`Social Media`,width:1280,height:720},{id:`presentation`,label:`Presentation 16:9`,category:`Presentation`,width:1920,height:1080},{id:`a4`,label:`A4`,category:`Print`,width:2480,height:3508},{id:`us-letter`,label:`US Letter`,category:`Print`,width:2550,height:3300},{id:`business-card`,label:`Business Card`,category:`Print`,width:1050,height:600},{id:`invoice`,label:`Invoice`,category:`Documents`,width:2480,height:3508}],de=new Map(ue.map(e=>[e.id,e]));[...new Set(ue.map(e=>e.category))];function fe(){let e=new Map;for(let t of ue){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return e}function pe(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function me(e,t){let n=URL.createObjectURL(e);pe(n,t),URL.revokeObjectURL(n)}function he(e,t,n,r,i=40){let a=n-i*2,o=r-i*2,s=Math.min(a/e,o/t,1),c=e*s,l=t*s;return{scale:s,offsetX:(n-c)/2,offsetY:(r-l)/2}}function ge(e){return Math.min(e*1.25,5)}function _e(e){return Math.max(e/1.25,.1)}function ve(e,t){return{rect:`Rectangle`,circle:`Circle`,line:`Line`,polygon:`Polygon`,textbox:`Text`,"i-text":`Text`,image:`Image`,path:`Drawing`,group:`Group`}[e]??`Object ${t+1}`}var ye=Object.defineProperty,be=(e,t)=>{let n={};for(var r in e)ye(n,r,{get:e[r],enumerable:!0});return t||ye(n,Symbol.toStringTag,{value:`Module`}),n};function xe(e){return xe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xe(e)}function Se(e){var t=function(e,t){if(xe(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(xe(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return xe(t)==`symbol`?t:t+``}function H(e,t,n){return(t=Se(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ce=class{constructor(){H(this,`browserShadowBlurConstant`,1),H(this,`DPI`,96),H(this,`devicePixelRatio`,typeof window<`u`?window.devicePixelRatio:1),H(this,`perfLimitSizeTotal`,2097152),H(this,`maxCacheSideLimit`,4096),H(this,`minCacheSideLimit`,256),H(this,`disableStyleCopyPaste`,!1),H(this,`enableGLFiltering`,!0),H(this,`textureSize`,4096),H(this,`forceGLPutImageData`,!1),H(this,`cachesBoundsOfCurve`,!1),H(this,`fontPaths`,{}),H(this,`NUM_FRACTION_DIGITS`,4)}},U=new class extends Ce{constructor(e){super(),this.configure(e)}configure(e={}){Object.assign(this,e)}addFonts(e={}){this.fontPaths={...this.fontPaths,...e}}removeFonts(e=[]){e.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(e){let t=new Ce,n=e?.reduce((e,n)=>(e[n]=t[n],e),{})||t;this.configure(n)}},we=(e,...t)=>console[e](`fabric`,...t),Te=class extends Error{constructor(e,t){super(`fabric: ${e}`,t)}},Ee=class extends Te{constructor(e){super(`${e} 'options.signal' is in 'aborted' state`)}},De=class{},Oe=class extends De{testPrecision(e,t){let n=`precision ${t} float;\nvoid main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return!!r&&(e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS))}queryWebGL(e){let t=e.getContext(`webgl`);t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=[`highp`,`mediump`,`lowp`].find(e=>this.testPrecision(t,e)),t.getExtension(`WEBGL_lose_context`).loseContext(),we(`log`,`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}},ke={},Ae,je=()=>Ae||={document,window,isTouchSupported:`ontouchstart`in window||`ontouchstart`in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Oe,dispose(){},copyPasteData:ke},Me=()=>je().document,Ne=()=>je().window,Pe=()=>Math.max(U.devicePixelRatio??Ne().devicePixelRatio,1),Fe=new class{constructor(){H(this,`boundsOfCurveCache`,{}),this.charWidthsCache=new Map}getFontCache({fontFamily:e,fontStyle:t,fontWeight:n}){e=e.toLowerCase();let r=this.charWidthsCache;r.has(e)||r.set(e,new Map);let i=r.get(e),a=`${t.toLowerCase()}_${(n+``).toLowerCase()}`;return i.has(a)||i.set(a,new Map),i.get(a)}clearFontCache(e){e?this.charWidthsCache.delete((e||``).toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(e){let{perfLimitSizeTotal:t}=U,n=Math.sqrt(t*e);return[Math.floor(n),Math.floor(t/n)]}},Ie=`7.4.0`;function Le(){}var Re=Math.PI/2,ze=Math.PI/4,Be=2*Math.PI,Ve=Math.PI/180,He=Object.freeze([1,0,0,1,0,0]),W=`center`,G=`left`,Ue=`bottom`,We=`right`,Ge=`none`,Ke=/\r?\n/,qe=`moving`,Je=`scaling`,Ye=`rotating`,Xe=`rotate`,Ze=`skewing`,Qe=`resizing`,$e=`modifyPoly`,et=`changed`,tt=`scale`,nt=`scaleX`,rt=`scaleY`,it=`skewX`,at=`skewY`,ot=`fill`,st=`stroke`,ct=`modified`,lt=`normal`,ut=`json`,K=new class{constructor(){this[ut]=new Map,this.svg=new Map}has(e){return this[ut].has(e)}getClass(e){let t=this[ut].get(e);if(!t)throw new Te(`No class registered for ${e}`);return t}setClass(e,t){t?this[ut].set(t,e):(this[ut].set(e.type,e),this[ut].set(e.type.toLowerCase(),e))}getSVGClass(e){return this.svg.get(e)}setSVGClass(e,t){this.svg.set(t??e.type.toLowerCase(),e)}},dt=new class extends Array{remove(e){let t=this.indexOf(e);t>-1&&this.splice(t,1)}cancelAll(){let e=this.splice(0);return e.forEach(e=>e.abort()),e}cancelByCanvas(e){if(!e)return[];let t=this.filter(t=>t.target===e||typeof t.target==`object`&&t.target?.canvas===e);return t.forEach(e=>e.abort()),t}cancelByTarget(e){if(!e)return[];let t=this.filter(t=>t.target===e);return t.forEach(e=>e.abort()),t}},ft=class{constructor(){H(this,`__eventListeners`,{})}on(e,t){if(this.__eventListeners||={},typeof e==`object`)return Object.entries(e).forEach(([e,t])=>{this.on(e,t)}),()=>this.off(e);if(t){let n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}return()=>!1}once(e,t){if(typeof e==`object`){let t=[];return Object.entries(e).forEach(([e,n])=>{t.push(this.once(e,n))}),()=>t.forEach(e=>e())}if(t){let n=this.on(e,function(...e){t.call(this,...e),n()});return n}return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){let n=this.__eventListeners[e],r=n.indexOf(t);r>-1&&n.splice(r,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(let e in this.__eventListeners)this._removeEventListener(e);else typeof e==`object`?Object.entries(e).forEach(([e,t])=>{this._removeEventListener(e,t)}):this._removeEventListener(e,t)}fire(e,t){if(!this.__eventListeners)return;let n=this.__eventListeners[e]?.concat();if(n)for(let e=0;e<n.length;e++)n[e].call(this,t||{})}},pt=(e,t)=>{let n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},mt=e=>{if(e===0)return 1;switch(Math.abs(e)/Re){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},ht=e=>{if(e===0)return 0;let t=e/Re,n=Math.sign(e);switch(t){case 1:return n;case 2:return 0;case 3:return-n}return Math.sin(e)},q=class e{constructor(e=0,t=0){typeof e==`object`?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(t){return new e(this.x+t.x,this.y+t.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(t){return new e(this.x+t,this.y+t)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(t){return new e(this.x-t.x,this.y-t.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(t){return new e(this.x-t,this.y-t)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(t){return new e(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new e(this.x*t,this.y*t)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(t){return new e(this.x/t.x,this.y/t.y)}scalarDivide(t){return new e(this.x/t,this.y/t)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(t,n=.5){return n=Math.max(Math.min(1,n),0),new e(this.x+(t.x-this.x)*n,this.y+(t.y-this.y)*n)}distanceFrom(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new e(this.x,this.y)}rotate(t,n=gt){let r=ht(t),i=mt(t),a=this.subtract(n);return new e(a.x*i-a.y*r,a.x*r+a.y*i).add(n)}transform(t,n=!1){return new e(t[0]*this.x+t[2]*this.y+(n?0:t[4]),t[1]*this.x+t[3]*this.y+(n?0:t[5]))}},gt=new q(0,0),_t=e=>!!e&&Array.isArray(e._objects);function vt(e){class t extends e{constructor(...e){super(...e),H(this,`_objects`,[])}_onObjectAdded(e){}_onObjectRemoved(e){}_onStackOrderChanged(e){}add(...e){let t=this._objects.push(...e);return e.forEach(e=>this._onObjectAdded(e)),t}insertAt(e,...t){return this._objects.splice(e,0,...t),t.forEach(e=>this._onObjectAdded(e)),this._objects.length}remove(...e){let t=this._objects,n=[];return e.forEach(e=>{let r=t.indexOf(e);r!==-1&&(t.splice(r,1),n.push(e),this._onObjectRemoved(e))}),n}forEachObject(e){this.getObjects().forEach((t,n,r)=>e(t,n,r))}getObjects(...e){return e.length===0?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(e){return this._objects[e]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(e,n){return!!this._objects.includes(e)||!!n&&this._objects.some(n=>n instanceof t&&n.contains(e,!0))}complexity(){return this._objects.reduce((e,t)=>e+=t.complexity?t.complexity():0,0)}sendObjectToBack(e){return!(!e||e===this._objects[0])&&(pt(this._objects,e),this._objects.unshift(e),this._onStackOrderChanged(e),!0)}bringObjectToFront(e){return!(!e||e===this._objects[this._objects.length-1])&&(pt(this._objects,e),this._objects.push(e),this._onStackOrderChanged(e),!0)}sendObjectBackwards(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==0){let r=this.findNewLowerIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}bringObjectForward(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==this._objects.length-1){let r=this.findNewUpperIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}moveObjectTo(e,t){return e!==this._objects[t]&&(pt(this._objects,e),this._objects.splice(t,0,e),this._onStackOrderChanged(e),!0)}findNewLowerIndex(e,t,n){let r;if(n){r=t;for(let n=t-1;n>=0;--n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t-1;return r}findNewUpperIndex(e,t,n){let r;if(n){r=t;for(let n=t+1;n<this._objects.length;++n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t+1;return r}collectObjects({left:e,top:t,width:n,height:r},{includeIntersecting:i=!0}={}){let a=[],o=new q(e,t),s=o.add(new q(n,r));for(let e=this._objects.length-1;e>=0;e--){let t=this._objects[e];t.selectable&&t.visible&&(i&&t.intersectsWithRect(o,s)||t.isContainedWithinRect(o,s)||i&&t.containsPoint(o)||i&&t.containsPoint(s))&&a.push(t)}return a}}return t}var yt=class extends ft{_setOptions(e={}){for(let t in e)this.set(t,e[t])}_setObject(e){for(let t in e)this._set(t,e[t])}set(e,t){return typeof e==`object`?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){let t=this.get(e);return typeof t==`boolean`&&this.set(e,!t),this}get(e){return this[e]}};function bt(e){return Ne().requestAnimationFrame(e)}function xt(e){return Ne().cancelAnimationFrame(e)}var St=0,Ct=()=>St++,wt=()=>{let e=Me().createElement(`canvas`);if(!e||e.getContext===void 0)throw new Te("Failed to create `canvas` element");return e},Tt=()=>Me().createElement(`img`),Et=e=>{var t;let n=Dt(e);return(t=n.getContext(`2d`))==null||t.drawImage(e,0,0),n},Dt=e=>{let t=wt();return t.width=e.width,t.height=e.height,t},Ot=(e,t,n)=>e.toDataURL(`image/${t}`,n),kt=(e,t,n)=>new Promise((r,i)=>{e.toBlob(r,`image/${t}`,n)}),J=e=>e*Ve,At=e=>e/Ve,jt=e=>e.every((e,t)=>e===He[t]),Mt=(e,t,n)=>new q(e).transform(t,n),Nt=e=>{let t=1/(e[0]*e[3]-e[1]*e[2]),n=[t*e[3],-t*e[1],-t*e[2],t*e[0],0,0],{x:r,y:i}=new q(e[4],e[5]).transform(n,!0);return n[4]=-r,n[5]=-i,n},Y=(e,t,n)=>[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],n?0:e[0]*t[4]+e[2]*t[5]+e[4],n?0:e[1]*t[4]+e[3]*t[5]+e[5]],Pt=(e,t)=>e.reduceRight((e,n)=>n&&e?Y(n,e,t):n||e,void 0)||He.concat(),Ft=([e,t])=>Math.atan2(t,e),It=([e,t])=>Math.sqrt(e*e+t*t),Lt=([,,e,t])=>Math.sqrt(e*e+t*t),Rt=e=>{let t=Ft(e),n=e[0]**2+e[1]**2,r=Math.sqrt(n),i=(e[0]*e[3]-e[2]*e[1])/r,a=Math.atan2(e[0]*e[2]+e[1]*e[3],n);return{angle:At(t),scaleX:r,scaleY:i,skewX:At(a),skewY:0,translateX:e[4]||0,translateY:e[5]||0}},zt=(e,t=0)=>[1,0,0,1,e,t];function Bt({angle:e=0}={},{x:t=0,y:n=0}={}){let r=J(e),i=mt(r),a=ht(r);return[i,a,-a,i,t?t-(i*t-a*n):0,n?n-(a*t+i*n):0]}var Vt=(e,t=e)=>[e,0,0,t,0,0],Ht=e=>Math.tan(J(e)),Ut=e=>[1,0,Ht(e),1,0,0],Wt=e=>[1,Ht(e),0,1,0,0],Gt=({scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:r=!1,skewX:i=0,skewY:a=0})=>{let o=Vt(n?-e:e,r?-t:t);return i&&(o=Y(o,Ut(i),!0)),a&&(o=Y(o,Wt(a),!0)),o},Kt=e=>{let{translateX:t=0,translateY:n=0,angle:r=0}=e,i=zt(t,n);r&&(i=Y(i,Bt({angle:r})));let a=Gt(e);return jt(a)||(i=Y(i,a)),i},qt=(e,{signal:t,crossOrigin:n=null}={})=>new Promise(function(r,i){if(t&&t.aborted)return i(new Ee(`loadImage`));let a=Tt(),o;t&&(o=function(e){a.src=``,i(e)},t.addEventListener(`abort`,o,{once:!0}));let s=function(){a.onload=a.onerror=null,o&&t?.removeEventListener(`abort`,o),r(a)};e?(a.onload=s,a.onerror=function(){o&&t?.removeEventListener(`abort`,o),i(new Te(`Error loading ${a.src}`))},n&&(a.crossOrigin=n),a.src=e):s()}),Jt=(e,{signal:t,reviver:n=Le}={})=>new Promise((r,i)=>{let a=[];t&&t.addEventListener(`abort`,i,{once:!0}),Promise.allSettled(e.map(e=>K.getClass(e.type).fromObject(e,{signal:t}))).then(async t=>{for(let[r,i]of t.entries())if(i.status===`fulfilled`&&(await n(e[r],i.value),a.push(i.value)),i.status===`rejected`){let t=await n(e[r],void 0,i.reason);t&&a.push(t)}r(a)}).catch(e=>{a.forEach(e=>{e.dispose&&e.dispose()}),i(e)}).finally(()=>{t&&t.removeEventListener(`abort`,i)})}),Yt=(e,{signal:t}={})=>new Promise((n,r)=>{let i=[];t&&t.addEventListener(`abort`,r,{once:!0});let a=Object.values(e).map(e=>e&&e.type&&K.has(e.type)?Jt([e],{signal:t}).then(([e])=>(i.push(e),e)):e),o=Object.keys(e);Promise.all(a).then(e=>e.reduce((e,t,n)=>(e[o[n]]=t,e),{})).then(n).catch(e=>{i.forEach(e=>{e.dispose&&e.dispose()}),r(e)}).finally(()=>{t&&t.removeEventListener(`abort`,r)})}),Xt=(e,t=[])=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),Zt=(e,t)=>Object.keys(e).reduce((n,r)=>(t(e[r],r,e)&&(n[r]=e[r]),n),{}),X=(e,t)=>parseFloat(Number(e).toFixed(t)),Qt=e=>`matrix(`+e.map(e=>X(e,U.NUM_FRACTION_DIGITS)).join(` `)+`)`,$t=e=>!!e&&e.toLive!==void 0,en=e=>!!e&&typeof e.toObject==`function`,tn=e=>!!e&&e.offsetX!==void 0&&`source`in e,nn=e=>!!e&&`multiSelectionStacking`in e;function rn(e){let t=e&&an(e),n=0,r=0;if(!e||!t)return{left:n,top:r};let i=e,a=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(n=o.scrollLeft||a.scrollLeft||0,r=o.scrollTop||a.scrollTop||0):(n+=i.scrollLeft||0,r+=i.scrollTop||0),i.nodeType!==1||i.style.position!==`fixed`););return{left:n,top:r}}var an=e=>e.ownerDocument||null,on=e=>e.ownerDocument?.defaultView||null,sn=(e,t,{width:n,height:r},i=1)=>{e.width=n,e.height=r,i>1&&(e.setAttribute(`width`,(n*i).toString()),e.setAttribute(`height`,(r*i).toString()),t.scale(i,i))},cn=(e,{width:t,height:n})=>{t&&(e.style.width=typeof t==`number`?`${t}px`:t),n&&(e.style.height=typeof n==`number`?`${n}px`:n)};function ln(e){return e.onselectstart!==void 0&&(e.onselectstart=()=>!1),e.style.userSelect=Ge,e}var un=class{constructor(e){H(this,`_originalCanvasStyle`,void 0),H(this,`lower`,void 0);let t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext(`2d`)}}createLowerCanvas(e){let t=(n=e)&&n.getContext!==void 0?e:e&&Me().getElementById(e)||wt();var n;if(t.hasAttribute(`data-fabric`))throw new Te(`Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?`);return this._originalCanvasStyle=t.style.cssText,t.setAttribute(`data-fabric`,`main`),t.classList.add(`lower-canvas`),t}cleanupDOM({width:e,height:t}){let{el:n}=this.lower;n.classList.remove(`lower-canvas`),n.removeAttribute(`data-fabric`),n.setAttribute(`width`,`${e}`),n.setAttribute(`height`,`${t}`),n.style.cssText=this._originalCanvasStyle||``,this._originalCanvasStyle=void 0}setDimensions(e,t){let{el:n,ctx:r}=this.lower;sn(n,r,e,t)}setCSSDimensions(e){cn(this.lower.el,e)}calcOffset(){return function(e){let t=e&&an(e),n={left:0,top:0};if(!t)return n;let r=on(e)?.getComputedStyle(e,null)||{};n.left+=parseInt(r.borderLeftWidth,10)||0,n.top+=parseInt(r.borderTopWidth,10)||0,n.left+=parseInt(r.paddingLeft,10)||0,n.top+=parseInt(r.paddingTop,10)||0;let i={left:0,top:0},a=t.documentElement;e.getBoundingClientRect!==void 0&&(i=e.getBoundingClientRect());let o=rn(e);return{left:i.left+o.left-(a.clientLeft||0)+n.left,top:i.top+o.top-(a.clientTop||0)+n.top}}(this.lower.el)}dispose(){je().dispose(this.lower.el),delete this.lower}},dn={backgroundVpt:!0,backgroundColor:``,overlayVpt:!0,overlayColor:``,includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...He],patternQuality:`best`},fn=be({capitalize:()=>pn,escapeXml:()=>Z,graphemeSplit:()=>hn}),pn=(e,t=!1)=>`${e.charAt(0).toUpperCase()}${t?e.slice(1):e.slice(1).toLowerCase()}`,Z=e=>e.toString().replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`),mn,hn=e=>{if(mn||mn||(mn=`Intl`in Ne()&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`})),mn){let t=mn.segment(e);return Array.from(t).map(({segment:e})=>e)}return gn(e)},gn=e=>{let t=[];for(let n,r=0;r<e.length;r++)!1!==(n=_n(e,r))&&t.push(n);return t},_n=(e,t)=>{let n=e.charCodeAt(t);if(isNaN(n))return``;if(n<55296||n>57343)return e.charAt(t);if(55296<=n&&n<=56319){if(e.length<=t+1)throw`High surrogate without following low surrogate`;let n=e.charCodeAt(t+1);if(56320>n||n>57343)throw`High surrogate without following low surrogate`;return e.charAt(t)+e.charAt(t+1)}if(t===0)throw`Low surrogate without preceding high surrogate`;let r=e.charCodeAt(t-1);if(55296>r||r>56319)throw`Low surrogate without preceding high surrogate`;return!1},vn=class e extends vt(yt){get lowerCanvasEl(){return this.elements.lower?.el}get contextContainer(){return this.elements.lower?.ctx}static getDefaults(){return e.ownDefaults}constructor(e,t={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new un(e)}add(...e){let t=super.add(...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(e,...t){let n=super.insertAt(e,...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(...e){let t=super.remove(...e);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(we(`warn`,`Canvas is trying to add an object that belongs to a different canvas.
|
|
3
|
+
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set(`canvas`,this),e.setCoords(),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e){e._set(`canvas`,void 0),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?Pe():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(e,{cssOnly:t=!1,backstoreOnly:n=!1}={}){if(!t){let t={width:this.width,height:this.height,...e};this.elements.setDimensions(t,this.getRetinaScaling()),this.hasLostContext=!0,this.width=t.width,this.height=t.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return It(this.viewportTransform)}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){let n=e,r=[...this.viewportTransform],i=Mt(e,Nt(r));r[0]=t,r[3]=t;let a=Mt(i,r);r[4]+=n.x-a.x,r[5]+=n.y-a.y,this.setViewportTransform(r)}setZoom(e){this.zoomToPoint(new q(0,0),e)}absolutePan(e){let t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new q(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor=``,this.overlayColor=``,this.clearContext(this.getContext()),this.fire(`canvas:cleared`),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=bt(()=>this.renderAndReset()))}calcViewportBoundaries(){let e=this.width,t=this.height,n=Nt(this.viewportTransform),r=Mt({x:0,y:0},n),i=Mt({x:e,y:t},n),a=r.min(i),o=r.max(i);return this.vptCoords={tl:a,tr:new q(o.x,a.y),bl:new q(a.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&=(xt(this.nextRenderHandle),0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;let n=this.viewportTransform,r=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality=this.patternQuality,this.fire(`before:render`,{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),r&&(r._set(`canvas`,this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,r)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire(`after:render`,{ctx:e}),this.__cleanupTask&&=(this.__cleanupTask(),void 0)}drawClipPathOnCanvas(e,t){let n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation=`destination-in`,t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,r=t.length;n<r;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){let n=this[`${t}Color`],r=this[`${t}Image`],i=this.viewportTransform,a=this[`${t}Vpt`];if(!n&&!r)return;let o=$t(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=o?n.toLive(e):n,a&&e.transform(...i),o){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);let t=n.gradientTransform||n.patternTransform;t&&e.transform(...t)}e.fill(),e.restore()}if(r){e.save();let{skipOffscreen:t}=this;this.skipOffscreen=a,a&&e.transform(...i),r.render(e),this.skipOffscreen=t,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,`background`)}_renderOverlay(e){this._renderBackgroundOrOverlay(e,`overlay`)}getCenterPoint(){return new q(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new q(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new q(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new q(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new q(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Mt(this.getCenterPoint(),Nt(this.viewportTransform))}_centerObject(e,t){e.setXY(t,W,W),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod(`toObject`,e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod(`toDatalessObject`,e)}_toObjectMethod(e,t){let n=this.clipPath,r=n&&!n.excludeFromExport?this._toObject(n,e,t):null;return{version:Ie,...Xt(this,t),objects:this._objects.filter(e=>!e.excludeFromExport).map(n=>this._toObject(n,e,t)),...this.__serializeBgOverlay(e,t),...r?{clipPath:r}:null}}_toObject(e,t,n){let r;this.includeDefaultValues||(r=e.includeDefaultValues,e.includeDefaultValues=!1);let i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=!!r),i}__serializeBgOverlay(e,t){let n={},r=this.backgroundImage,i=this.overlayImage,a=this.backgroundColor,o=this.overlayColor;return $t(a)?a.excludeFromExport||(n.background=a.toObject(t)):a&&(n.background=a),$t(o)?o.excludeFromExport||(n.overlay=o.toObject(t)):o&&(n.overlay=o),r&&!r.excludeFromExport&&(n.backgroundImage=this._toObject(r,e,t)),i&&!i.excludeFromExport&&(n.overlayImage=this._toObject(i,e,t)),n}toSVG(e={},t){e.reviver=t;let n=[];return this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this.clipPath&&n.push(`<g clip-path="url(#${Z(this.clipPath.clipPathId??``)})" >\n`),this._setSVGBgOverlayColor(n,`background`),this._setSVGBgOverlayImage(n,`backgroundImage`,t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
|
|
4
|
+
`),this._setSVGBgOverlayColor(n,`overlay`),this._setSVGBgOverlayImage(n,`overlayImage`,t),n.push(`</svg>`),n.join(``)}_setSVGPreamble(e,t){t.suppressPreamble||e.push(`<?xml version="1.0" encoding="`,t.encoding||`UTF-8`,`" standalone="no" ?>
|
|
5
|
+
`,`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" `,`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
6
|
+
`)}_setSVGHeader(e,t){let n=t.width||`${this.width}`,r=t.height||`${this.height}`,i=U.NUM_FRACTION_DIGITS,a=t.viewBox,o;if(a)o=`viewBox="${a.x} ${a.y} ${a.width} ${a.height}" `;else if(this.svgViewportTransformation){let e=this.viewportTransform;o=`viewBox="${X(-e[4]/e[0],i)} ${X(-e[5]/e[3],i)} ${X(this.width/e[0],i)} ${X(this.height/e[3],i)}" `}else o=`viewBox="0 0 ${this.width} ${this.height}" `;e.push(`<svg `,`xmlns="http://www.w3.org/2000/svg" `,`xmlns:xlink="http://www.w3.org/1999/xlink" `,`version="1.1" `,`width="`,n,`" `,`height="`,r,`" `,o,`xml:space="preserve">
|
|
7
|
+
`,`<desc>Created with Fabric.js `,Ie,`</desc>
|
|
8
|
+
`,`<defs>
|
|
9
|
+
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
|
|
10
|
+
`)}createSVGClipPathMarkup(e){let t=this.clipPath;return t?(t.clipPathId=`CLIPPATH_${Ct()}`,`<clipPath id="${t.clipPathId}" >\n${t.toClipPathSVG(e.reviver)}</clipPath>\n`):``}createSVGRefElementsMarkup(){return[`background`,`overlay`].map(e=>{let t=this[`${e}Color`];if($t(t)){let n=this[`${e}Vpt`],r=this.viewportTransform,i={isType:()=>!1,width:this.width/(n?r[0]:1),height:this.height/(n?r[3]:1)};return t.toSVG(i,{additionalTransform:n?Qt(r):``})}}).join(``)}createSVGFontFacesMarkup(){let e=[],t={},n=U.fontPaths;this._objects.forEach(function t(n){e.push(n),_t(n)&&n._objects.forEach(t)}),e.forEach(e=>{if(!(r=e)||typeof r._renderText!=`function`)return;var r;let{styles:i,fontFamily:a}=e;!t[a]&&n[a]&&(t[a]=!0,i&&Object.values(i).forEach(e=>{Object.values(e).forEach(({fontFamily:e=``})=>{!t[e]&&n[e]&&(t[e]=!0)})}))});let r=Object.keys(t).map(e=>`\t\t@font-face {\n\t\t\tfont-family: '${e}';\n\t\t\tsrc: url('${n[e]}');\n\t\t}\n`).join(``);return r?`\t<style type="text/css"><![CDATA[\n${r}]]></style>\n`:``}_setSVGObjects(e,t){this.forEachObject(n=>{n.excludeFromExport||this._setSVGObject(e,n,t)})}_setSVGObject(e,t,n){e.push(t.toSVG(n))}_setSVGBgOverlayImage(e,t,n){let r=this[t];r&&!r.excludeFromExport&&r.toSVG&&e.push(r.toSVG(n))}_setSVGBgOverlayColor(e,t){let n=this[`${t}Color`];if(n)if($t(n)){let r=n.repeat||``,i=this.width,a=this.height,o=this[`${t}Vpt`]?Qt(Nt(this.viewportTransform)):``;e.push(`<rect transform="${o} translate(${i/2},${a/2})" x="${n.offsetX-i/2}" y="${n.offsetY-a/2}" width="${r!==`repeat-y`&&r!==`no-repeat`||!tn(n)?i:n.source.width}" height="${r!==`repeat-x`&&r!==`no-repeat`||!tn(n)?a:n.source.height}" fill="url(#SVGID_${n.id})"></rect>\n`)}else e.push(`<rect x="0" y="0" width="100%" height="100%" `,`fill="`,n,`"`,`></rect>
|
|
11
|
+
`)}loadFromJSON(e,t,{signal:n}={}){if(!e)return Promise.reject(new Te("`json` is undefined"));let{objects:r=[],...i}=typeof e==`string`?JSON.parse(e):e,{backgroundImage:a,background:o,overlayImage:s,overlay:c,clipPath:l}=i,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Jt(r,{reviver:t,signal:n}),Yt({backgroundImage:a,backgroundColor:o,overlayImage:s,overlayColor:c,clipPath:l},{signal:n})]).then(([e,t])=>(this.clear(),this.add(...e),this.set(i),this.set(t),this.renderOnAddRemove=u,this))}clone(e){let t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){let e=Dt(this);return new this.constructor(e)}toDataURL(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return Ot(this.toCanvasElement(a,e),t,n)}toBlob(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return kt(this.toCanvasElement(a,e),t,n)}toCanvasElement(e=1,{width:t,height:n,left:r,top:i,filter:a}={}){let o=(t||this.width)*e,s=(n||this.height)*e,c=this.getZoom(),l=this.width,u=this.height,d=this.skipControlsDrawing,f=c*e,p=this.viewportTransform,m=[f,0,0,f,(p[4]-(r||0))*e,(p[5]-(i||0))*e],h=this.enableRetinaScaling,g=Dt({width:o,height:s}),_=a?this._objects.filter(e=>a(e)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=o,this.height=s,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(g.getContext(`2d`),_),this.viewportTransform=p,this.width=l,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=h,this.skipControlsDrawing=d,g}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),dt.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{let n=()=>{this.destroy(),e(!0)};n.kill=t,this.__cleanupTask&&this.__cleanupTask.kill(`aborted`),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=n:n()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return`#<Canvas (${this.complexity()}): { objects: ${this._objects.length} }>`}};H(vn,`ownDefaults`,dn);var yn=[`touchstart`,`touchmove`,`touchend`],bn=e=>{let t=rn(e.target),n=function(e){let t=e.changedTouches;return t&&t[0]?t[0]:e}(e);return new q(n.clientX+t.left,n.clientY+t.top)},xn=e=>yn.includes(e.type)||e.pointerType===`touch`,Sn=e=>{e.preventDefault(),e.stopPropagation()},Cn=e=>{let t=0,n=0,r=0,i=0;for(let a=0,o=e.length;a<o;a++){let{x:o,y:s}=e[a];(o>r||!a)&&(r=o),(o<t||!a)&&(t=o),(s>i||!a)&&(i=s),(s<n||!a)&&(n=s)}return{left:t,top:n,width:r-t,height:i-n}},wn=(e,t)=>{En(e,Y(Nt(t),e.calcOwnMatrix()))},Tn=(e,t)=>En(e,Y(t,e.calcOwnMatrix())),En=(e,t)=>{let{translateX:n,translateY:r,scaleX:i,scaleY:a,...o}=Rt(t),s=new q(n,r);e.flipX=!1,e.flipY=!1,Object.assign(e,o),e.set({scaleX:i,scaleY:a}),e.setPositionByOrigin(s,W,W)},Dn=e=>{e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},On=e=>({scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,angle:e.angle,left:e.left,flipX:e.flipX,flipY:e.flipY,top:e.top}),kn=(e,t,n)=>{let r=e/2,i=t/2,a=Cn([new q(-r,-i),new q(r,-i),new q(-r,i),new q(r,i)].map(e=>e.transform(n)));return new q(a.width,a.height)},An=(e=He,t=He)=>Y(Nt(t),e),jn=(e,t=He,n=He)=>e.transform(An(t,n)),Mn=(e,t=He,n=He)=>e.transform(An(t,n),!0),Nn=(e,t,n)=>{let r=An(t,n);return En(e,Y(r,e.calcOwnMatrix())),r},Pn={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Fn=e=>typeof e==`string`?Pn[e]:e-.5,In=new q(1,0),Ln=new q,Rn=(e,t)=>e.rotate(t),zn=(e,t)=>new q(t).subtract(e),Bn=e=>e.distanceFrom(Ln),Vn=(e,t)=>Math.atan2(Gn(e,t),Kn(e,t)),Hn=e=>Vn(In,e),Un=e=>e.eq(Ln)?e:e.scalarDivide(Bn(e)),Wn=(e,t=!0)=>Un(new q(-e.y,e.x).scalarMultiply(t?1:-1)),Gn=(e,t)=>e.x*t.y-e.y*t.x,Kn=(e,t)=>e.x*t.x+e.y*t.y,qn=(e,t,n)=>{if(e.eq(t)||e.eq(n))return!0;let r=Gn(t,n),i=Gn(t,e),a=Gn(n,e);return r>=0?i>=0&&a<=0:!(i<=0&&a>=0)},Jn=`not-allowed`;function Yn(e){return Fn(e.originX)===Fn(`center`)&&Fn(e.originY)===Fn(`center`)}function Xn(e){return .5-Fn(e)}var Zn=(e,t)=>e[t],Qn=(e,t,n,r)=>({e,transform:t,pointer:new q(n,r)});function $n(e,t,n){let r=n,i=Hn(zn(jn(e.getCenterPoint(),e.canvas.viewportTransform,void 0),r))+Be;return Math.round(i%Be/ze)}function er({target:e,corner:t},n,r,i,a){let o=e.controls[t],s=e.canvas?.getZoom()||1,c=e.padding/s,l=function(e,t,n,r){let i=e.getRelativeCenterPoint(),a=n!==void 0&&r!==void 0?e.translateToGivenOrigin(i,W,W,n,r):new q(e.left,e.top);return(e.angle?t.rotate(-J(e.angle),i):t).subtract(a)}(e,new q(i,a),n,r);return l.x>=c&&(l.x-=c),l.x<=-c&&(l.x+=c),l.y>=c&&(l.y-=c),l.y<=c&&(l.y+=c),l.x-=o.offsetX,l.y-=o.offsetY,l}var tr=new RegExp(String.raw`[\0-\x1F\x7F;<>\\]|\/\*|\*\/|url\s*\(|expression\s*\(|(?:java|vb)script\s*:|data\s*:|@import\b`,`iu`),nr=e=>typeof e==`string`&&e.trim().length>0&&!tr.test(e),rr=(e,t=``)=>{let n=Number(e);return Number.isFinite(n)?`${n}`:t},ir=(e,t=``)=>typeof e==`string`&&nr(e)?e:t,ar=e=>e.replace(/\s+/g,` `),or={aliceblue:`#F0F8FF`,antiquewhite:`#FAEBD7`,aqua:`#0FF`,aquamarine:`#7FFFD4`,azure:`#F0FFFF`,beige:`#F5F5DC`,bisque:`#FFE4C4`,black:`#000`,blanchedalmond:`#FFEBCD`,blue:`#00F`,blueviolet:`#8A2BE2`,brown:`#A52A2A`,burlywood:`#DEB887`,cadetblue:`#5F9EA0`,chartreuse:`#7FFF00`,chocolate:`#D2691E`,coral:`#FF7F50`,cornflowerblue:`#6495ED`,cornsilk:`#FFF8DC`,crimson:`#DC143C`,cyan:`#0FF`,darkblue:`#00008B`,darkcyan:`#008B8B`,darkgoldenrod:`#B8860B`,darkgray:`#A9A9A9`,darkgrey:`#A9A9A9`,darkgreen:`#006400`,darkkhaki:`#BDB76B`,darkmagenta:`#8B008B`,darkolivegreen:`#556B2F`,darkorange:`#FF8C00`,darkorchid:`#9932CC`,darkred:`#8B0000`,darksalmon:`#E9967A`,darkseagreen:`#8FBC8F`,darkslateblue:`#483D8B`,darkslategray:`#2F4F4F`,darkslategrey:`#2F4F4F`,darkturquoise:`#00CED1`,darkviolet:`#9400D3`,deeppink:`#FF1493`,deepskyblue:`#00BFFF`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1E90FF`,firebrick:`#B22222`,floralwhite:`#FFFAF0`,forestgreen:`#228B22`,fuchsia:`#F0F`,gainsboro:`#DCDCDC`,ghostwhite:`#F8F8FF`,gold:`#FFD700`,goldenrod:`#DAA520`,gray:`#808080`,grey:`#808080`,green:`#008000`,greenyellow:`#ADFF2F`,honeydew:`#F0FFF0`,hotpink:`#FF69B4`,indianred:`#CD5C5C`,indigo:`#4B0082`,ivory:`#FFFFF0`,khaki:`#F0E68C`,lavender:`#E6E6FA`,lavenderblush:`#FFF0F5`,lawngreen:`#7CFC00`,lemonchiffon:`#FFFACD`,lightblue:`#ADD8E6`,lightcoral:`#F08080`,lightcyan:`#E0FFFF`,lightgoldenrodyellow:`#FAFAD2`,lightgray:`#D3D3D3`,lightgrey:`#D3D3D3`,lightgreen:`#90EE90`,lightpink:`#FFB6C1`,lightsalmon:`#FFA07A`,lightseagreen:`#20B2AA`,lightskyblue:`#87CEFA`,lightslategray:`#789`,lightslategrey:`#789`,lightsteelblue:`#B0C4DE`,lightyellow:`#FFFFE0`,lime:`#0F0`,limegreen:`#32CD32`,linen:`#FAF0E6`,magenta:`#F0F`,maroon:`#800000`,mediumaquamarine:`#66CDAA`,mediumblue:`#0000CD`,mediumorchid:`#BA55D3`,mediumpurple:`#9370DB`,mediumseagreen:`#3CB371`,mediumslateblue:`#7B68EE`,mediumspringgreen:`#00FA9A`,mediumturquoise:`#48D1CC`,mediumvioletred:`#C71585`,midnightblue:`#191970`,mintcream:`#F5FFFA`,mistyrose:`#FFE4E1`,moccasin:`#FFE4B5`,navajowhite:`#FFDEAD`,navy:`#000080`,oldlace:`#FDF5E6`,olive:`#808000`,olivedrab:`#6B8E23`,orange:`#FFA500`,orangered:`#FF4500`,orchid:`#DA70D6`,palegoldenrod:`#EEE8AA`,palegreen:`#98FB98`,paleturquoise:`#AFEEEE`,palevioletred:`#DB7093`,papayawhip:`#FFEFD5`,peachpuff:`#FFDAB9`,peru:`#CD853F`,pink:`#FFC0CB`,plum:`#DDA0DD`,powderblue:`#B0E0E6`,purple:`#800080`,rebeccapurple:`#639`,red:`#F00`,rosybrown:`#BC8F8F`,royalblue:`#4169E1`,saddlebrown:`#8B4513`,salmon:`#FA8072`,sandybrown:`#F4A460`,seagreen:`#2E8B57`,seashell:`#FFF5EE`,sienna:`#A0522D`,silver:`#C0C0C0`,skyblue:`#87CEEB`,slateblue:`#6A5ACD`,slategray:`#708090`,slategrey:`#708090`,snow:`#FFFAFA`,springgreen:`#00FF7F`,steelblue:`#4682B4`,tan:`#D2B48C`,teal:`#008080`,thistle:`#D8BFD8`,tomato:`#FF6347`,turquoise:`#40E0D0`,violet:`#EE82EE`,wheat:`#F5DEB3`,white:`#FFF`,whitesmoke:`#F5F5F5`,yellow:`#FF0`,yellowgreen:`#9ACD32`},sr=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e),cr=(e,t,n,r)=>{e/=255,t/=255,n/=255;let i=Math.max(e,t,n),a=Math.min(e,t,n),o,s,c=(i+a)/2;if(i===a)o=s=0;else{let r=i-a;switch(s=c>.5?r/(2-i-a):r/(i+a),i){case e:o=(t-n)/r+(t<n?6:0);break;case t:o=(n-e)/r+2;break;case n:o=(e-t)/r+4}o/=6}return[Math.round(360*o),Math.round(100*s),Math.round(100*c),r]},lr=(e=`1`)=>parseFloat(e)/(e.endsWith(`%`)?100:1),ur=e=>Math.min(Math.round(e),255).toString(16).toUpperCase().padStart(2,`0`),dr=([e,t,n,r=1])=>{let i=Math.round(.3*e+.59*t+.11*n);return[i,i,i,r]},fr=class e{constructor(t){if(H(this,`isUnrecognised`,!1),t)if(t instanceof e)this.setSource([...t._source]);else if(Array.isArray(t)){let[e,n,r,i=1]=t;this.setSource([e,n,r,i])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in or&&(t=or[t]),t===`transparent`?[255,255,255,0]:e.sourceFromHex(t)||e.sourceFromRgb(t)||e.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(e){this._source=e}toRgb(){let[e,t,n]=this.getSource();return`rgb(${e},${t},${n})`}toRgba(){return`rgba(${this.getSource().join(`,`)})`}toHsl(){let[e,t,n]=cr(...this.getSource());return`hsl(${e},${t}%,${n}%)`}toHsla(){let[e,t,n,r]=cr(...this.getSource());return`hsla(${e},${t}%,${n}%,${r})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){let[e,t,n,r]=this.getSource();return`${ur(e)}${ur(t)}${ur(n)}${ur(Math.round(255*r))}`}getAlpha(){return this.getSource()[3]}setAlpha(e){return this._source[3]=e,this}toGrayscale(){return this.setSource(dr(this.getSource())),this}toBlackWhite(e){let[t,,,n]=dr(this.getSource()),r=t<(e||127)?0:255;return this.setSource([r,r,r,n]),this}overlayWith(t){t instanceof e||(t=new e(t));let n=this.getSource(),r=t.getSource(),[i,a,o]=n.map((e,t)=>Math.round(.5*e+.5*r[t]));return this.setSource([i,a,o,n[3]]),this}static fromRgb(t){return e.fromRgba(t)}static fromRgba(t){return new e(e.sourceFromRgb(t))}static sourceFromRgb(e){let t=ar(e).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(t){let[e,n,r]=t.slice(1,4).map(e=>{let t=parseFloat(e);return e.endsWith(`%`)?Math.round(2.55*t):t});return[e,n,r,lr(t[4])]}}static fromHsl(t){return e.fromHsla(t)}static fromHsla(t){return new e(e.sourceFromHsl(t))}static sourceFromHsl(t){let n=ar(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!n)return;let r=(e.parseAngletoDegrees(n[1])%360+360)%360/360,i=parseFloat(n[2])/100,a=parseFloat(n[3])/100,o,s,c;if(i===0)o=s=c=a;else{let e=a<=.5?a*(i+1):a+i-a*i,t=2*a-e;o=sr(t,e,r+1/3),s=sr(t,e,r),c=sr(t,e,r-1/3)}return[Math.round(255*o),Math.round(255*s),Math.round(255*c),lr(n[4])]}static fromHex(t){return new e(e.sourceFromHex(t))}static sourceFromHex(e){if(e.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){let t=e.slice(e.indexOf(`#`)+1),n;n=t.length<=4?t.split(``).map(e=>e+e):t.match(/.{2}/g);let[r,i,a,o=255]=n.map(e=>parseInt(e,16));return[r,i,a,o/255]}}static parseAngletoDegrees(e){let t=e.toLowerCase(),n=parseFloat(t);return t.includes(`rad`)?At(n):t.includes(`turn`)?360*n:n}},pr=e=>{let t=[`instantiated_by_use`,`style`,`id`,`class`];switch(e){case`linearGradient`:return t.concat([`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`]);case`radialGradient`:return t.concat([`gradientUnits`,`gradientTransform`,`cx`,`cy`,`r`,`fx`,`fy`,`fr`]);case`stop`:return t.concat([`offset`,`stop-color`,`stop-opacity`])}return t},mr=(e,t=16)=>{let n=/\D{0,2}$/.exec(e),r=parseFloat(e),i=U.DPI;switch(n?.[0]){case`mm`:return r*i/25.4;case`cm`:return r*i/2.54;case`in`:return r*i;case`pt`:return r*i/72;case`pc`:return r*i/72*12;case`em`:return r*t;default:return r}},hr=e=>{let[t,n]=e.trim().split(` `),[r,i]=(a=t)&&a!==`none`?[a.slice(1,4),a.slice(5,8)]:a===`none`?[a,a]:[`Mid`,`Mid`];var a;return{meetOrSlice:n||`meet`,alignX:r,alignY:i}},gr=(e,t,n=!0)=>{let r,i;if(t)if(t.toLive)r=`url(#SVGID_${Z(t.id)})`;else{let e=String(t);if(nr(e)){let t=new fr(e),n=t.getAlpha();r=t.toRgb(),n!==1&&(i=n.toString())}else r=new fr(`black`).toRgb()}else r=`none`;return n?`${e}: ${r}; ${i?`${e}-opacity: ${i}; `:``}`:`${e}="${r}" ${i?`${e}-opacity="${i}" `:``}`},_r=class{getSvgStyles(e){let t=this.fillRule==null?`nonzero`:ir(this.fillRule),n=this.strokeWidth==null?`0`:rr(this.strokeWidth),r=this.strokeDashArray==null?Ge:this.strokeDashArray.every(e=>Number.isFinite(Number(e)))?this.strokeDashArray.join(` `):``,i=this.strokeDashOffset==null?`0`:rr(this.strokeDashOffset),a=this.strokeLineCap==null?`butt`:ir(this.strokeLineCap),o=this.strokeLineJoin==null?`miter`:ir(this.strokeLineJoin),s=this.strokeMiterLimit==null?`4`:rr(this.strokeMiterLimit),c=this.opacity==null?`1`:rr(this.opacity),l=this.visible?``:` visibility: hidden;`,u=e?``:this.getSvgFilter(),d=gr(ot,this.fill);return[gr(st,this.stroke),n?`stroke-width: ${n}; `:``,r?`stroke-dasharray: ${r}; `:``,a?`stroke-linecap: ${a}; `:``,i?`stroke-dashoffset: ${i}; `:``,o?`stroke-linejoin: ${o}; `:``,s?`stroke-miterlimit: ${s}; `:``,d,t?`fill-rule: ${t}; `:``,c?`opacity: ${c};`:``,u,l].map(e=>Z(e)).join(``)}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${Z(this.shadow.id)});`:``}getSvgCommons(){return[this.id?`id="${Z(String(this.id))}" `:``,this.clipPath?`clip-path="url(#${Z(this.clipPath.clipPathId)})" `:``].join(``)}getSvgTransform(e,t=``){return`transform="${Qt(e?this.calcTransformMatrix():this.calcOwnMatrix())}${t}" `}_toSVG(e){return[``]}toSVG(e){return this._createBaseSVGMarkup(this._toSVG(e),{reviver:e})}toClipPathSVG(e){return` `+this._createBaseClipPathSVGMarkup(this._toSVG(e),{reviver:e})}_createBaseClipPathSVGMarkup(e,{reviver:t,additionalTransform:n=``}={}){let r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(``),i=e.indexOf(`COMMON_PARTS`);return e[i]=r,t?t(e.join(``)):e.join(``)}_createBaseSVGMarkup(e,{noStyle:t,reviver:n,withShadow:r,additionalTransform:i}={}){let a=t?``:`style="${this.getSvgStyles()}" `,o=r?`style="${this.getSvgFilter()}" `:``,s=this.clipPath,c=this.strokeUniform?`vector-effect="non-scaling-stroke" `:``,l=s&&s.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,p=[],m=e.indexOf(`COMMON_PARTS`),h;return s&&(s.clipPathId=`CLIPPATH_${Ct()}`,h=`<clipPath id="${s.clipPathId}" >\n${s.toClipPathSVG(n)}</clipPath>\n`),l&&p.push(`<g `,o,this.getSvgCommons(),` >
|
|
12
|
+
`),p.push(`<g `,this.getSvgTransform(!1),l?``:o+this.getSvgCommons(),` >
|
|
13
|
+
`),e[m]=[a,c,t?``:this.addPaintOrder(),` `,i?`transform="${i}" `:``].join(``),$t(d)&&p.push(d.toSVG(this)),$t(u)&&p.push(u.toSVG(this)),f&&p.push(f.toSVG(this)),s&&p.push(h),p.push(e.join(``)),p.push(`</g>
|
|
14
|
+
`),l&&p.push(`</g>
|
|
15
|
+
`),n?n(p.join(``)):p.join(``)}addPaintOrder(){return this.paintFirst===`fill`?``:` paint-order="${Z(this.paintFirst)}" `}};function vr(e){return RegExp(`^(`+e.join(`|`)+`)\\b`,`i`)}var yr=`textDecorationThickness`,br=`textDecorationColor`,xr=[`fontSize`,`fontWeight`,`fontFamily`,`fontStyle`],Sr=[`underline`,`overline`,`linethrough`],Cr=[...xr,`lineHeight`,`text`,`charSpacing`,`textAlign`,`styles`,`path`,`pathStartOffset`,`pathSide`,`pathAlign`],wr=[...Cr,...Sr,`textBackgroundColor`,`direction`,yr,br],Tr=[...xr,...Sr,st,`strokeWidth`,ot,`deltaY`,`textBackgroundColor`,yr,br],Er={_reNewline:Ke,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:lt,fontFamily:`Times New Roman`,underline:!1,overline:!1,linethrough:!1,textAlign:G,fontStyle:lt,lineHeight:1.16,textBackgroundColor:``,stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:G,pathAlign:`baseline`,charSpacing:0,deltaY:0,direction:`ltr`,CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[yr]:66.667},Dr=`justify`,Or=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,kr=String.raw`(?:\s*,?\s+|\s*,\s*)`,Ar=RegExp(`(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(`+Or+`(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|`+Or+`))?\\s+(.*)`),jr={cx:G,x:G,r:`radius`,cy:`top`,y:`top`,display:`visible`,visibility:`visible`,transform:`transformMatrix`,"fill-opacity":`fillOpacity`,"fill-rule":`fillRule`,"font-family":`fontFamily`,"font-size":`fontSize`,"font-style":`fontStyle`,"font-weight":`fontWeight`,"letter-spacing":`charSpacing`,"paint-order":`paintFirst`,"stroke-dasharray":`strokeDashArray`,"stroke-dashoffset":`strokeDashOffset`,"stroke-linecap":`strokeLineCap`,"stroke-linejoin":`strokeLineJoin`,"stroke-miterlimit":`strokeMiterLimit`,"stroke-opacity":`strokeOpacity`,"stroke-width":`strokeWidth`,"text-decoration":`textDecoration`,"text-anchor":`textAnchor`,opacity:`opacity`,"clip-path":`clipPath`,"clip-rule":`clipRule`,"vector-effect":`strokeUniform`,"image-rendering":`imageSmoothing`,"text-decoration-thickness":yr,"text-decoration-color":br},Mr=`font-size`,Nr=`clip-path`;vr([`path`,`circle`,`polygon`,`polyline`,`ellipse`,`rect`,`line`,`image`,`text`]),vr([`symbol`,`image`,`marker`,`pattern`,`view`,`svg`]);var Pr=vr([`symbol`,`g`,`a`,`svg`,`clipPath`,`defs`]);new RegExp(String.raw`^\s*(${Or})${kr}(${Or})${kr}(${Or})${kr}(${Or})\s*$`);var Fr=`(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?`,Ir=RegExp(`(?:\\s|^)`+Fr+Fr+`(`+Or+`?(?:px)?)?(?:\\s?|$)(?:$|\\s)`),Lr=class e{constructor(t={}){let n=typeof t==`string`?e.parseShadow(t):t;Object.assign(this,e.ownDefaults,n),this.id=Ct()}static parseShadow(e){let t=e.trim(),[,n=0,r=0,i=0]=(Ir.exec(t)||[]).map(e=>parseFloat(e)||0);return{color:(t.replace(Ir,``)||`rgb(0,0,0)`).trim(),offsetX:n,offsetY:r,blur:i}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join(`px `)}toSVG(e){let t=Rn(new q(this.offsetX,this.offsetY),J(-e.angle)),n=U.NUM_FRACTION_DIGITS,r=new fr(this.color),i=40,a=40;return e.width&&e.height&&(i=100*X((Math.abs(t.x)+this.blur)/e.width,n)+20,a=100*X((Math.abs(t.y)+this.blur)/e.height,n)+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),`<filter id="SVGID_${Z(this.id)}" y="-${a}%" height="${100+2*a}%" x="-${i}%" width="${100+2*i}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${X(this.blur?this.blur/2:0,n)}"></feGaussianBlur>\n\t<feOffset dx="${X(t.x,n)}" dy="${X(t.y,n)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${r.toRgb()}" flood-opacity="${r.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`}toObject(){let t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},n=e.ownDefaults;return this.includeDefaultValues?t:Zt(t,(e,t)=>e!==n[t])}static async fromObject(e){return new this(e)}};H(Lr,`ownDefaults`,{color:`rgb(0,0,0)`,blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),H(Lr,`type`,`shadow`),K.setClass(Lr,`shadow`);var Rr=(e,t,n)=>Math.max(e,Math.min(t,n)),zr=[`top`,G,nt,rt,`flipX`,`flipY`,`originX`,`originY`,`angle`,`opacity`,`globalCompositeOperation`,`shadow`,`visible`,it,at],Br=[ot,st,`strokeWidth`,`strokeDashArray`,`width`,`height`,`paintFirst`,`strokeUniform`,`strokeLineCap`,`strokeDashOffset`,`strokeLineJoin`,`strokeMiterLimit`,`backgroundColor`,`clipPath`],Vr={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:W,originY:W,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:ot,fill:`rgb(0,0,0)`,fillRule:`nonzero`,stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:`butt`,strokeLineJoin:`miter`,strokeMiterLimit:4,globalCompositeOperation:`source-over`,backgroundColor:``,shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},Hr=be({defaultEasing:()=>Gr,easeInBack:()=>pi,easeInBounce:()=>_i,easeInCirc:()=>si,easeInCubic:()=>Kr,easeInElastic:()=>ui,easeInExpo:()=>ii,easeInOutBack:()=>hi,easeInOutBounce:()=>vi,easeInOutCirc:()=>li,easeInOutCubic:()=>Jr,easeInOutElastic:()=>fi,easeInOutExpo:()=>oi,easeInOutQuad:()=>xi,easeInOutQuart:()=>Zr,easeInOutQuint:()=>ei,easeInOutSine:()=>ri,easeInQuad:()=>yi,easeInQuart:()=>Yr,easeInQuint:()=>Qr,easeInSine:()=>ti,easeOutBack:()=>mi,easeOutBounce:()=>gi,easeOutCirc:()=>ci,easeOutCubic:()=>qr,easeOutElastic:()=>di,easeOutExpo:()=>ai,easeOutQuad:()=>bi,easeOutQuart:()=>Xr,easeOutQuint:()=>$r,easeOutSine:()=>ni}),Ur=(e,t,n,r)=>(e<Math.abs(t)?(e=t,r=n/4):r=t===0&&e===0?n/Be*Math.asin(1):n/Be*Math.asin(t/e),{a:e,c:t,p:n,s:r}),Wr=(e,t,n,r,i)=>e*2**(10*--r)*Math.sin((r*i-t)*Be/n),Gr=(e,t,n,r)=>-n*Math.cos(e/r*Re)+n+t,Kr=(e,t,n,r)=>n*(e/r)**3+t,qr=(e,t,n,r)=>n*((e/r-1)**3+1)+t,Jr=(e,t,n,r)=>(e/=r/2)<1?n/2*e**3+t:n/2*((e-2)**3+2)+t,Yr=(e,t,n,r)=>n*(e/=r)*e**3+t,Xr=(e,t,n,r)=>-n*((e=e/r-1)*e**3-1)+t,Zr=(e,t,n,r)=>(e/=r/2)<1?n/2*e**4+t:-n/2*((e-=2)*e**3-2)+t,Qr=(e,t,n,r)=>n*(e/r)**5+t,$r=(e,t,n,r)=>n*((e/r-1)**5+1)+t,ei=(e,t,n,r)=>(e/=r/2)<1?n/2*e**5+t:n/2*((e-2)**5+2)+t,ti=(e,t,n,r)=>-n*Math.cos(e/r*Re)+n+t,ni=(e,t,n,r)=>n*Math.sin(e/r*Re)+t,ri=(e,t,n,r)=>-n/2*(Math.cos(Math.PI*e/r)-1)+t,ii=(e,t,n,r)=>e===0?t:n*2**(10*(e/r-1))+t,ai=(e,t,n,r)=>e===r?t+n:n*-(2**(-10*e/r)+1)+t,oi=(e,t,n,r)=>e===0?t:e===r?t+n:(e/=r/2)<1?n/2*2**(10*(e-1))+t:n/2*-(2**(-10*(e-1))+2)+t,si=(e,t,n,r)=>-n*(Math.sqrt(1-(e/=r)*e)-1)+t,ci=(e,t,n,r)=>n*Math.sqrt(1-(e=e/r-1)*e)+t,li=(e,t,n,r)=>(e/=r/2)<1?-n/2*(Math.sqrt(1-e**2)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t,ui=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if((e/=r)===1)return t+n;a||=.3*r;let{a:o,s,p:c}=Ur(i,n,a,1.70158);return-Wr(o,s,c,e,r)+t},di=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if((e/=r)===1)return t+n;a||=.3*r;let{a:o,s,p:c,c:l}=Ur(i,n,a,1.70158);return o*2**(-10*e)*Math.sin((e*r-s)*Be/c)+l+t},fi=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if((e/=r/2)==2)return t+n;a||=.3*1.5*r;let{a:o,s,p:c,c:l}=Ur(i,n,a,1.70158);return e<1?-.5*Wr(o,s,c,e,r)+t:o*2**(-10*--e)*Math.sin((e*r-s)*Be/c)*.5+l+t},pi=(e,t,n,r,i=1.70158)=>n*(e/=r)*e*((i+1)*e-i)+t,mi=(e,t,n,r,i=1.70158)=>n*((e=e/r-1)*e*((i+1)*e+i)+1)+t,hi=(e,t,n,r,i=1.70158)=>(e/=r/2)<1?n/2*(e*e*((1+(i*=1.525))*e-i))+t:n/2*((e-=2)*e*((1+(i*=1.525))*e+i)+2)+t,gi=(e,t,n,r)=>(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,_i=(e,t,n,r)=>n-gi(r-e,0,n,r)+t,vi=(e,t,n,r)=>e<r/2?.5*_i(2*e,0,n,r)+t:.5*gi(2*e-r,0,n,r)+.5*n+t,yi=(e,t,n,r)=>n*(e/=r)*e+t,bi=(e,t,n,r)=>-n*(e/=r)*(e-2)+t,xi=(e,t,n,r)=>(e/=r/2)<1?n/2*e**2+t:-n/2*(--e*(e-2)-1)+t,Si=()=>!1,Ci=class{constructor({startValue:e,byValue:t,duration:n=500,delay:r=0,easing:i=Gr,onStart:a=Le,onChange:o=Le,onComplete:s=Le,abort:c=Si,target:l}){H(this,`_state`,`pending`),H(this,`durationProgress`,0),H(this,`valueProgress`,0),this.tick=this.tick.bind(this),this.duration=n,this.delay=r,this.easing=i,this._onStart=a,this._onChange=o,this._onComplete=s,this._abort=c,this.target=l,this.startValue=e,this.byValue=t,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state===`aborted`||this._state===`completed`}start(){let e=e=>{this._state===`pending`&&(this.startTime=e||+new Date,this._state=`running`,this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?this.timeout=Ne().setTimeout(()=>bt(e),this.delay):bt(e)}tick(e){let t=(e||+new Date)-this.startTime,n=Math.min(t,this.duration);this.durationProgress=n/this.duration;let{value:r,valueProgress:i}=this.calculate(n);this.value=Object.freeze(r),this.valueProgress=i,this._state!==`aborted`&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state=`aborted`,this.unregister()):t>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state=`completed`,this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister(),this.timeout=null):(this._onChange(this.value,this.valueProgress,this.durationProgress),bt(this.tick)))}register(){dt.push(this)}unregister(){dt.remove(this)}abort(){this._state=`aborted`,this.unregister(),this.timeout&&Ne().clearTimeout(this.timeout)}},wi=class extends Ci{constructor({startValue:e=0,endValue:t=100,...n}){super({...n,startValue:e,byValue:t-e})}calculate(e){let t=this.easing(e,this.startValue,this.byValue,this.duration);return{value:t,valueProgress:Math.abs((t-this.startValue)/this.byValue)}}},Ti=class extends Ci{constructor({startValue:e=[0],endValue:t=[100],...n}){super({...n,startValue:e,byValue:t.map((t,n)=>t-e[n])})}calculate(e){let t=this.startValue.map((t,n)=>this.easing(e,t,this.byValue[n],this.duration,n));return{value:t,valueProgress:Math.abs((t[0]-this.startValue[0])/this.byValue[0])}}},Ei=(e,t,n,r)=>t+n*(1-Math.cos(e/r*Re)),Di=e=>e&&((t,n,r)=>e(new fr(t).toRgba(),n,r)),Oi=class extends Ci{constructor({startValue:e,endValue:t,easing:n=Ei,onChange:r,onComplete:i,abort:a,...o}){let s=new fr(e).getSource(),c=new fr(t).getSource();super({...o,startValue:s,byValue:c.map((e,t)=>e-s[t]),easing:n,onChange:Di(r),onComplete:Di(i),abort:Di(a)})}calculate(e){let[t,n,r,i]=this.startValue.map((t,n)=>this.easing(e,t,this.byValue[n],this.duration,n)),a=[...[t,n,r].map(Math.round),Rr(0,i,1)];return{value:a,valueProgress:a.map((e,t)=>this.byValue[t]===0?0:Math.abs((e-this.startValue[t])/this.byValue[t])).find(e=>e!==0)||0}}};function ki(e){let t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(e)?new Ti(e):new wi(e);return t.start(),t}function Ai(e){let t=new Oi(e);return t.start(),t}var ji=class e{constructor(e){this.status=e,this.points=[]}includes(e){return this.points.some(t=>t.eq(e))}append(...e){return this.points=this.points.concat(e.filter(e=>!this.includes(e))),this}static isPointContained(e,t,n,r=!1){if(t.eq(n))return e.eq(t);if(t.x===n.x)return e.x===t.x&&(r||e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y));if(t.y===n.y)return e.y===t.y&&(r||e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x));{let i=zn(t,n),a=zn(t,e).divide(i);return r?Math.abs(a.x)===Math.abs(a.y):a.x===a.y&&a.x>=0&&a.x<=1}}static isPointInPolygon(e,t){let n=new q(e).setX(Math.min(e.x-1,...t.map(e=>e.x))),r=0;for(let i=0;i<t.length;i++){let a=this.intersectSegmentSegment(t[i],t[(i+1)%t.length],e,n);if(a.includes(e))return!0;r+=Number(a.status===`Intersection`)}return r%2==1}static intersectLineLine(t,n,r,i,a=!0,o=!0){let s=n.x-t.x,c=n.y-t.y,l=i.x-r.x,u=i.y-r.y,d=t.x-r.x,f=t.y-r.y,p=l*f-u*d,m=s*f-c*d,h=u*s-l*c;if(h!==0){let n=p/h,r=m/h;return(a||0<=n&&n<=1)&&(o||0<=r&&r<=1)?new e(`Intersection`).append(new q(t.x+n*s,t.y+n*c)):new e}return new e(p===0||m===0?a||o||e.isPointContained(t,r,i)||e.isPointContained(n,r,i)||e.isPointContained(r,t,n)||e.isPointContained(i,t,n)?`Coincident`:void 0:`Parallel`)}static intersectSegmentLine(t,n,r,i){return e.intersectLineLine(t,n,r,i,!1,!0)}static intersectSegmentSegment(t,n,r,i){return e.intersectLineLine(t,n,r,i,!1,!1)}static intersectLinePolygon(t,n,r,i=!0){let a=new e,o=r.length;for(let s,c,l,u=0;u<o;u++){if(s=r[u],c=r[(u+1)%o],l=e.intersectLineLine(t,n,s,c,i,!1),l.status===`Coincident`)return l;a.append(...l.points)}return a.points.length>0&&(a.status=`Intersection`),a}static intersectSegmentPolygon(t,n,r){return e.intersectLinePolygon(t,n,r,!1)}static intersectPolygonPolygon(t,n){let r=new e,i=t.length,a=[];for(let o=0;o<i;o++){let s=t[o],c=t[(o+1)%i],l=e.intersectSegmentPolygon(s,c,n);l.status===`Coincident`?(a.push(l),r.append(s,c)):r.append(...l.points)}return a.length>0&&a.length===t.length?new e(`Coincident`):(r.points.length>0&&(r.status=`Intersection`),r)}static intersectPolygonRectangle(t,n,r){let i=n.min(r),a=n.max(r),o=new q(a.x,i.y),s=new q(i.x,a.y);return e.intersectPolygonPolygon(t,[i,o,a,s])}},Mi=class extends yt{getX(){return this.getXY().x}setX(e){this.setXY(this.getXY().setX(e))}getY(){return this.getXY().y}setY(e){this.setXY(this.getXY().setY(e))}getRelativeX(){return this.left}setRelativeX(e){this.left=e}getRelativeY(){return this.top}setRelativeY(e){this.top=e}getXY(){let e=this.getRelativeXY();return this.group?Mt(e,this.group.calcTransformMatrix()):e}setXY(e,t,n){this.group&&(e=Mt(e,Nt(this.group.calcTransformMatrix()))),this.setRelativeXY(e,t,n)}getRelativeXY(){return new q(this.left,this.top)}setRelativeXY(e,t=this.originX,n=this.originY){this.setPositionByOrigin(e,t,n)}isStrokeAccountedForInDimensions(){return!1}getCoords(){let{tl:e,tr:t,br:n,bl:r}=this.aCoords||=this.calcACoords(),i=[e,t,n,r];if(this.group){let e=this.group.calcTransformMatrix();return i.map(t=>Mt(t,e))}return i}intersectsWithRect(e,t){return ji.intersectPolygonRectangle(this.getCoords(),e,t).status===`Intersection`}intersectsWithObject(e){let t=ji.intersectPolygonPolygon(this.getCoords(),e.getCoords());return t.status===`Intersection`||t.status===`Coincident`||e.isContainedWithinObject(this)||this.isContainedWithinObject(e)}isContainedWithinObject(e){return this.getCoords().every(t=>e.containsPoint(t))}isContainedWithinRect(e,t){let{left:n,top:r,width:i,height:a}=this.getBoundingRect();return n>=e.x&&n+i<=t.x&&r>=e.y&&r+a<=t.y}isOverlapping(e){return this.intersectsWithObject(e)||this.isContainedWithinObject(e)||e.isContainedWithinObject(this)}containsPoint(e){return ji.isPointInPolygon(e,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;let{tl:e,br:t}=this.canvas.vptCoords;return!!this.getCoords().some(n=>n.x<=t.x&&n.x>=e.x&&n.y<=t.y&&n.y>=e.y)||!!this.intersectsWithRect(e,t)||this.containsPoint(e.midPointFrom(t))}isPartiallyOnScreen(){if(!this.canvas)return!1;let{tl:e,br:t}=this.canvas.vptCoords;return!!this.intersectsWithRect(e,t)||this.getCoords().every(n=>(n.x>=t.x||n.x<=e.x)&&(n.y>=t.y||n.y<=e.y))&&this.containsPoint(e.midPointFrom(t))}getBoundingRect(){return Cn(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(e){this._set(nt,e),this._set(rt,e),this.setCoords()}scaleToWidth(e){let t=this.getBoundingRect().width/this.getScaledWidth();return this.scale(e/this.width/t)}scaleToHeight(e){let t=this.getBoundingRect().height/this.getScaledHeight();return this.scale(e/this.height/t)}getCanvasRetinaScaling(){return this.canvas?.getRetinaScaling()||1}getTotalAngle(){return this.group?At(Ft(this.calcTransformMatrix())):this.angle}getViewportTransform(){return this.canvas?.viewportTransform||He.concat()}calcACoords(){let e=Bt({angle:this.angle}),{x:t,y:n}=this.getRelativeCenterPoint(),r=Y(zt(t,n),e),i=this._getTransformedDimensions(),a=i.x/2,o=i.y/2;return{tl:Mt({x:-a,y:-o},r),tr:Mt({x:a,y:-o},r),bl:Mt({x:-a,y:o},r),br:Mt({x:a,y:o},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(e=!1){let t=[];return!e&&this.group&&(t=this.group.transformMatrixKey(e)),t.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Fn(this.originX),Fn(this.originY)),t}calcTransformMatrix(e=!1){let t=this.calcOwnMatrix();if(e||!this.group)return t;let n=this.transformMatrixKey(e),r=this.matrixCache;return r&&r.key.every((e,t)=>e===n[t])?r.value:(this.group&&(t=Y(this.group.calcTransformMatrix(!1),t)),this.matrixCache={key:n,value:t},t)}calcOwnMatrix(){let e=this.transformMatrixKey(!0),t=this.ownMatrixCache;if(t&&t.key.every((t,n)=>t===e[n]))return t.value;let n=this.getRelativeCenterPoint(),r=Kt({angle:this.angle,translateX:n.x,translateY:n.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY});return this.ownMatrixCache={key:e,value:r},r}_getNonTransformedDimensions(){return new q(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(e){let t=this.canvas?.viewportTransform,n=this._getTransformedDimensions(e);return t?n.multiply(new q(It(t),Lt(t))).scalarAdd(2*this.padding):n.scalarAdd(2*this.padding)}_getTransformedDimensions(e={}){let t={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...e},n=t.strokeWidth,r=n,i=0;this.strokeUniform&&(r=0,i=n);let a=t.width+r,o=t.height+r,s;return s=t.skewX===0&&t.skewY===0?new q(a*t.scaleX,o*t.scaleY):kn(a,o,Gt(t)),s.scalarAdd(i)}translateToGivenOrigin(e,t,n,r,i){let a=e.x,o=e.y,s=Fn(r)-Fn(t),c=Fn(i)-Fn(n);if(s||c){let e=this._getTransformedDimensions();a+=s*e.x,o+=c*e.y}return new q(a,o)}translateToCenterPoint(e,t,n){if(t===`center`&&n===`center`)return e;let r=this.translateToGivenOrigin(e,t,n,W,W);return this.angle?r.rotate(J(this.angle),e):r}translateToOriginPoint(e,t,n){let r=this.translateToGivenOrigin(e,W,W,t,n);return this.angle?r.rotate(J(this.angle),e):r}getCenterPoint(){let e=this.getRelativeCenterPoint();return this.group?Mt(e,this.group.calcTransformMatrix()):e}getRelativeCenterPoint(){return this.translateToCenterPoint(new q(this.left,this.top),this.originX,this.originY)}getPointByOrigin(e,t){return this.getPositionByOrigin(e,t)}getPositionByOrigin(e,t){return this.translateToOriginPoint(this.getRelativeCenterPoint(),e,t)}setPositionByOrigin(e,t,n){let r=this.translateToCenterPoint(e,t,n),i=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:i.x,top:i.y})}_getLeftTopCoords(){return this.getPositionByOrigin(G,`top`)}positionByLeftTop(e){return this.setPositionByOrigin(e,G,`top`)}},Ni=class e extends Mi{static getDefaults(){return e.ownDefaults}get type(){let e=this.constructor.type;return e===`FabricObject`?`object`:e.toLowerCase()}set type(e){we(`warn`,`Setting type has no effect`,e)}constructor(t){super(),H(this,`_cacheContext`,null),Object.assign(this,e.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=wt(),this._cacheContext=this._cacheCanvas.getContext(`2d`),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(e){let t=e.width,n=e.height,r=U.maxCacheSideLimit,i=U.minCacheSideLimit;if(t<=r&&n<=r&&t*n<=U.perfLimitSizeTotal)return t<i&&(e.width=i),n<i&&(e.height=i),e;let a=t/n,[o,s]=Fe.limitDimsByArea(a),c=Rr(i,o,r),l=Rr(i,s,r);return t>c&&(e.zoomX/=t/c,e.width=c,e.capped=!0),n>l&&(e.zoomY/=n/l,e.height=l,e.capped=!0),e}_getCacheCanvasDimensions(){let e=this.getTotalObjectScaling(),t=this._getTransformedDimensions({skewX:0,skewY:0}),n=t.x*e.x/this.scaleX,r=t.y*e.y/this.scaleY;return{width:Math.ceil(n+2),height:Math.ceil(r+2),zoomX:e.x,zoomY:e.y,x:n,y:r}}_updateCacheCanvas(){let e=this._cacheCanvas,t=this._cacheContext,{width:n,height:r,zoomX:i,zoomY:a,x:o,y:s}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=n!==e.width||r!==e.height,l=this.zoomX!==i||this.zoomY!==a;if(!e||!t)return!1;if(c||l){n!==e.width||r!==e.height?(e.width=n,e.height=r):(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height));let c=o/2,l=s/2;return this.cacheTranslationX=Math.round(e.width/2-c)+c,this.cacheTranslationY=Math.round(e.height/2-l)+l,t.translate(this.cacheTranslationX,this.cacheTranslationY),t.scale(i,a),this.zoomX=i,this.zoomY=a,!0}return!1}setOptions(e={}){this._setOptions(e)}transform(e){let t=this.group&&!this.group._transformDone||this.group&&this.canvas&&e===this.canvas.contextTop,n=this.calcTransformMatrix(!t);e.transform(n[0],n[1],n[2],n[3],n[4],n[5])}getObjectScaling(){if(!this.group)return new q(Math.abs(this.scaleX),Math.abs(this.scaleY));let e=Rt(this.calcTransformMatrix());return new q(Math.abs(e.scaleX),Math.abs(e.scaleY))}getTotalObjectScaling(){let e=this.getObjectScaling();if(this.canvas){let t=this.canvas.getZoom(),n=this.getCanvasRetinaScaling();return e.scalarMultiply(t*n)}return e}getObjectOpacity(){let e=this.opacity;return this.group&&(e*=this.group.getObjectOpacity()),e}_constrainScale(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e===0?1e-4:e}_set(e,t){e!==`scaleX`&&e!==`scaleY`||(t=this._constrainScale(t)),e===`scaleX`&&t<0?(this.flipX=!this.flipX,t*=-1):e===`scaleY`&&t<0?(this.flipY=!this.flipY,t*=-1):e!==`shadow`||!t||t instanceof Lr||(t=new Lr(t));let n=this[e]!==t;return this[e]=t,n&&this.constructor.cacheProperties.includes(e)&&(this.dirty=!0),this.parent&&(this.dirty||n&&this.constructor.stateProperties.includes(e))&&this.parent._set(`dirty`,!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(e){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(e.save(),this._setupCompositeOperation(e),this.drawSelectionBackground(e),this.transform(e),this._setOpacity(e),this._setShadow(e),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(e)):(this._removeCacheCanvas(),this.drawObject(e,!1,{}),this.dirty=!1),e.restore())}drawSelectionBackground(e){}renderCache(e){if(e||={},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){let{zoomX:t,zoomY:n,cacheTranslationX:r,cacheTranslationY:i}=this,{width:a,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,e.forClipping,{zoomX:t,zoomY:n,cacheTranslationX:r,cacheTranslationY:i,width:a,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return!!this.stroke&&this.stroke!==`transparent`&&this.strokeWidth!==0}hasFill(){return!!this.fill&&this.fill!==`transparent`}needsItsOwnCache(){return!!(this.paintFirst===`stroke`&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(e,t,n){e.save(),e.globalCompositeOperation=t.inverted?`destination-out`:`destination-in`,e.setTransform(1,0,0,1,0,0),e.drawImage(n,0,0),e.restore()}drawObject(e,t,n){let r=this.fill,i=this.stroke;t?(this.fill=`black`,this.stroke=``,this._setClippingProperties(e)):this._renderBackground(e),this.fire(`before:render`,{ctx:e}),this._render(e),this._drawClipPath(e,this.clipPath,n),this.fill=r,this.stroke=i}createClipPathLayer(e,t){let n=Dt(t),r=n.getContext(`2d`);if(r.translate(t.cacheTranslationX,t.cacheTranslationY),r.scale(t.zoomX,t.zoomY),e._cacheCanvas=n,t.parentClipPaths.forEach(e=>{e.transform(r)}),t.parentClipPaths.push(e),e.absolutePositioned){let e=Nt(this.calcTransformMatrix());r.transform(e[0],e[1],e[2],e[3],e[4],e[5])}return e.transform(r),e.drawObject(r,!0,t),n}_drawClipPath(e,t,n){if(!t)return;t._transformDone=!0;let r=this.createClipPathLayer(t,n);this.drawClipPathOnCache(e,t,r)}drawCacheOnCanvas(e){e.scale(1/this.zoomX,1/this.zoomY),e.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(e=!1){if(this.isNotVisible())return!1;let t=this._cacheCanvas,n=this._cacheContext;return!(!t||!n||e||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(t&&n&&!e&&(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()),!0)}_renderBackground(e){if(!this.backgroundColor)return;let t=this._getNonTransformedDimensions();e.fillStyle=this.backgroundColor,e.fillRect(-t.x/2,-t.y/2,t.x,t.y),this._removeShadow(e)}_setOpacity(e){this.group&&!this.group._transformDone?e.globalAlpha=this.getObjectOpacity():e.globalAlpha*=this.opacity}_setStrokeStyles(e,t){let n=t.stroke;n&&(e.lineWidth=t.strokeWidth,e.lineCap=t.strokeLineCap,e.lineDashOffset=t.strokeDashOffset,e.lineJoin=t.strokeLineJoin,e.miterLimit=t.strokeMiterLimit,$t(n)?n.gradientUnits===`percentage`||n.gradientTransform||n.patternTransform?this._applyPatternForTransformedGradient(e,n):(e.strokeStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.strokeStyle=t.stroke)}_setFillStyles(e,{fill:t}){t&&($t(t)?(e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t)):e.fillStyle=t)}_setClippingProperties(e){e.globalAlpha=1,e.strokeStyle=`transparent`,e.fillStyle=`#000000`}_setLineDash(e,t){t&&t.length!==0&&e.setLineDash(t)}_setShadow(e){if(!this.shadow)return;let t=this.shadow,n=this.canvas,r=this.getCanvasRetinaScaling(),[i,,,a]=n?.viewportTransform||He,o=i*r,s=a*r,c=t.nonScaling?new q(1,1):this.getObjectScaling();e.shadowColor=t.color,e.shadowBlur=t.blur*U.browserShadowBlurConstant*(o+s)*(c.x+c.y)/4,e.shadowOffsetX=t.offsetX*o*c.x,e.shadowOffsetY=t.offsetY*s*c.y}_removeShadow(e){this.shadow&&(e.shadowColor=``,e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0)}_applyPatternGradientTransform(e,t){if(!$t(t))return{offsetX:0,offsetY:0};let n=t.gradientTransform||t.patternTransform,r=-this.width/2+t.offsetX||0,i=-this.height/2+t.offsetY||0;return t.gradientUnits===`percentage`?e.transform(this.width,0,0,this.height,r,i):e.transform(1,0,0,1,r,i),n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),{offsetX:r,offsetY:i}}_renderPaintInOrder(e){this.paintFirst===`stroke`?(this._renderStroke(e),this._renderFill(e)):(this._renderFill(e),this._renderStroke(e))}_render(e){}_renderFill(e){this.fill&&(e.save(),this._setFillStyles(e,this),this.fillRule===`evenodd`?e.fill(`evenodd`):e.fill(),e.restore())}_renderStroke(e){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this.strokeUniform){let t=this.getObjectScaling();e.scale(1/t.x,1/t.y)}this._setLineDash(e,this.strokeDashArray),this._setStrokeStyles(e,this),e.stroke(),e.restore()}}_applyPatternForTransformedGradient(e,t){let n=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),i=n.x/this.scaleX/r,a=n.y/this.scaleY/r,o=Dt({width:Math.ceil(i),height:Math.ceil(a)}),s=o.getContext(`2d`);s&&(s.beginPath(),s.moveTo(0,0),s.lineTo(i,0),s.lineTo(i,a),s.lineTo(0,a),s.closePath(),s.translate(i/2,a/2),s.scale(n.zoomX/this.scaleX/r,n.zoomY/this.scaleY/r),this._applyPatternGradientTransform(s,t),s.fillStyle=t.toLive(e),s.fill(),e.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),e.scale(r*this.scaleX/n.zoomX,r*this.scaleY/n.zoomY),e.strokeStyle=s.createPattern(o,`no-repeat`)??``)}_findCenterFromElement(){return new q(this.left+this.width/2,this.top+this.height/2)}clone(e){let t=this.toObject(e);return this.constructor.fromObject(t)}cloneAsImage(e){let t=this.toCanvasElement(e);return new(K.getClass(`image`))(t)}toCanvasElement(e={}){let t=On(this),n=this.group,r=this.shadow,i=Math.abs,a=e.enableRetinaScaling?Pe():1,o=(e.multiplier||1)*a,s=e.canvasProvider||(e=>new vn(e,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,e.withoutTransform&&Dn(this),e.withoutShadow&&(this.shadow=null),e.viewportTransform&&Nn(this,this.getViewportTransform()),this.setCoords();let c=wt(),l=this.getBoundingRect(),u=this.shadow,d=new q;if(u){let e=u.blur,t=u.nonScaling?new q(1,1):this.getObjectScaling();d.x=2*Math.round(i(u.offsetX)+e)*i(t.x),d.y=2*Math.round(i(u.offsetY)+e)*i(t.y)}let f=l.width+d.x,p=l.height+d.y;c.width=Math.ceil(f),c.height=Math.ceil(p);let m=s(c);e.format===`jpeg`&&(m.backgroundColor=`#fff`),this.setPositionByOrigin(new q(m.width/2,m.height/2),W,W);let h=this.canvas;m._objects=[this],this.set(`canvas`,m),this.setCoords();let g=m.toCanvasElement(o||1,e);return this.set(`canvas`,h),this.shadow=r,n&&(this.group=n),this.set(t),this.setCoords(),m._objects=[],m.destroy(),g}toDataURL(e={}){return Ot(this.toCanvasElement(e),e.format||`png`,e.quality||1)}toBlob(e={}){return kt(this.toCanvasElement(e),e.format||`png`,e.quality||1)}isType(...e){return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(e){let{centeredRotation:t,originX:n,originY:r}=this;if(t){let{x:e,y:t}=this.getRelativeCenterPoint();this.originX=W,this.originY=W,this.left=e,this.top=t}if(this.set(`angle`,e),t){let{x:e,y:t}=this.getPositionByOrigin(n,r);this.left=e,this.top=t,this.originX=n,this.originY=r}}setOnGroup(){}_setupCompositeOperation(e){this.globalCompositeOperation&&(e.globalCompositeOperation=this.globalCompositeOperation)}dispose(){dt.cancelByTarget(this),this.off(),this._set(`canvas`,void 0),this._cacheCanvas&&je().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(e,t){return Object.entries(e).reduce((e,[n,r])=>(e[n]=this._animate(n,r,t),e),{})}_animate(e,t,n={}){let r=e.split(`.`),i=this.constructor.colorProperties.includes(r[r.length-1]),{abort:a,startValue:o,onChange:s,onComplete:c}=n,l={...n,target:this,startValue:o??r.reduce((e,t)=>e[t],this),endValue:t,abort:a?.bind(this),onChange:(e,t,n)=>{r.reduce((t,n,i)=>(i===r.length-1&&(t[n]=e),t[n]),this),s&&s(e,t,n)},onComplete:(e,t,n)=>{this.setCoords(),c&&c(e,t,n)}};return i?Ai(l):ki(l)}isDescendantOf(e){let{parent:t,group:n}=this;return t===e||n===e||!!t&&t.isDescendantOf(e)||!!n&&n!==t&&n.isDescendantOf(e)}getAncestors(){let e=[],t=this;do t=t.parent,t&&e.push(t);while(t);return e}findCommonAncestors(e){if(this===e)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};let t=this.getAncestors(),n=e.getAncestors();if(t.length===0&&n.length>0&&this===n[n.length-1])return{fork:[],otherFork:[e,...n.slice(0,n.length-1)],common:[this]};for(let r,i=0;i<t.length;i++){if(r=t[i],r===e)return{fork:[this,...t.slice(0,i)],otherFork:[],common:t.slice(i)};for(let a=0;a<n.length;a++){if(this===n[a])return{fork:[],otherFork:[e,...n.slice(0,a)],common:[this,...t]};if(r===n[a])return{fork:[this,...t.slice(0,i)],otherFork:[e,...n.slice(0,a)],common:t.slice(i)}}}return{fork:[this,...t],otherFork:[e,...n],common:[]}}hasCommonAncestors(e){let t=this.findCommonAncestors(e);return t&&!!t.common.length}isInFrontOf(e){if(this===e)return;let t=this.findCommonAncestors(e);if(t.fork.includes(e))return!0;if(t.otherFork.includes(this))return!1;let n=t.common[0]||this.canvas;if(!n)return;let r=t.fork.pop(),i=t.otherFork.pop(),a=n._objects.indexOf(r),o=n._objects.indexOf(i);return a>-1&&a>o}toObject(t=[]){let n=t.concat(e.customProperties,this.constructor.customProperties||[]),r,i=U.NUM_FRACTION_DIGITS,{clipPath:a,fill:o,stroke:s,shadow:c,strokeDashArray:l,left:u,top:d,originX:f,originY:p,width:m,height:h,strokeWidth:g,strokeLineCap:_,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:b,strokeMiterLimit:x,scaleX:S,scaleY:C,angle:w,flipX:T,flipY:E,opacity:D,visible:O,backgroundColor:k,fillRule:A,paintFirst:j,globalCompositeOperation:M,skewX:N,skewY:P}=this;a&&!a.excludeFromExport&&(r=a.toObject(n.concat(`inverted`,`absolutePositioned`)));let F=e=>X(e,i),I={...Xt(this,n),type:this.constructor.type,version:Ie,originX:f,originY:p,left:F(u),top:F(d),width:F(m),height:F(h),fill:en(o)?o.toObject():o,stroke:en(s)?s.toObject():s,strokeWidth:F(g),strokeDashArray:l&&l.concat(),strokeLineCap:_,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:b,strokeMiterLimit:F(x),scaleX:F(S),scaleY:F(C),angle:F(w),flipX:T,flipY:E,opacity:F(D),shadow:c&&c.toObject(),visible:O,backgroundColor:k,fillRule:A,paintFirst:j,globalCompositeOperation:M,skewX:F(N),skewY:F(P),...r?{clipPath:r}:null};return this.includeDefaultValues?I:this._removeDefaultValues(I)}toDatalessObject(e){return this.toObject(e)}_removeDefaultValues(e){let t=this.constructor.getDefaults(),n=Object.keys(t).length>0?t:Object.getPrototypeOf(this);return Zt(e,(e,t)=>{if(t===`left`||t===`top`||t===`type`)return!0;let r=n[t];return e!==r&&!(Array.isArray(e)&&Array.isArray(r)&&e.length===0&&r.length===0)})}toString(){return`#<${this.constructor.type}>`}static _fromObject({type:e,...t},{extraParam:n,...r}={}){return Yt(t,r).then(e=>n?(delete e[n],new this(t[n],e)):new this(e))}static fromObject(e,t){return this._fromObject(e,t)}};H(Ni,`stateProperties`,zr),H(Ni,`cacheProperties`,Br),H(Ni,`ownDefaults`,Vr),H(Ni,`type`,`FabricObject`),H(Ni,`colorProperties`,[ot,st,`backgroundColor`]),H(Ni,`customProperties`,[]),K.setClass(Ni),K.setClass(Ni,`object`);var Pi=(e,t)=>{var n;let{transform:{target:r}}=t;(n=r.canvas)==null||n.fire(`object:${e}`,{...t,target:r}),r.fire(e,t)},Fi=(e,t,n)=>(r,i,a,o)=>{let s=t(r,i,a,o);return s&&Pi(e,{...Qn(r,i,a,o),...n}),s};function Ii(e){return(t,n,r,i)=>{let{target:a,originX:o,originY:s}=n,c=a.getPositionByOrigin(o,s),l=e(t,n,r,i);return a.setPositionByOrigin(c,n.originX,n.originY),l}}var Li=(e,t,n,r)=>(i,a,o,s)=>{let c=er(a,a.originX,a.originY,o,s)[n],l=Fn(a[t]);if(l===0||l>0&&c<0||l<0&&c>0){let{target:t}=a,n=t.strokeWidth/(t.strokeUniform?t[r]:1),i=Yn(a)?2:1,o=t[e],s=Math.abs(c*i/t[r])-n;return t.set(e,Math.max(s,1)),o!==t[e]}return!1},Ri=Li(`width`,`originX`,`x`,`scaleX`),zi=Li(`height`,`originY`,`y`,`scaleY`),Bi=Fi(Qe,Ii(Ri)),Vi=Fi(Qe,Ii(zi));function Hi(e,t,n,r,i){e.save();let{stroke:a,xSize:o,ySize:s,opName:c}=this.commonRenderProps(e,t,n,i,r),l=o;o>s?e.scale(1,s/o):s>o&&(l=s,e.scale(o/s,1)),e.beginPath(),e.arc(0,0,l/2,0,Be,!1),e[c](),a&&e.stroke(),e.restore()}function Ui(e,t,n,r,i){e.save();let{stroke:a,xSize:o,ySize:s,opName:c}=this.commonRenderProps(e,t,n,i,r),l=o/2,u=s/2;e[`${c}Rect`](-l,-u,o,s),a&&e.strokeRect(-l,-u,o,s),e.restore()}var Wi=class{constructor(e){H(this,`visible`,!0),H(this,`actionName`,tt),H(this,`angle`,0),H(this,`x`,0),H(this,`y`,0),H(this,`offsetX`,0),H(this,`offsetY`,0),H(this,`sizeX`,0),H(this,`sizeY`,0),H(this,`touchSizeX`,0),H(this,`touchSizeY`,0),H(this,`cursorStyle`,`crosshair`),H(this,`withConnection`,!1),Object.assign(this,e)}getTransformAnchorPoint(){return this.transformAnchorPoint??new q(.5-this.x,.5-this.y)}shouldActivate(e,t,n,{tl:r,tr:i,br:a,bl:o}){return t.canvas?.getActiveObject()===t&&t.isControlVisible(e)&&ji.isPointInPolygon(n,[r,i,a,o])}getActionHandler(e,t,n){return this.actionHandler}getMouseDownHandler(e,t,n){return this.mouseDownHandler}getMouseUpHandler(e,t,n){return this.mouseUpHandler}cursorStyleHandler(e,t,n,r){return t.cursorStyle}getActionName(e,t,n){return t.actionName}getVisibility(e,t){return e._controlsVisibility?.[t]??this.visible}setVisibility(e,t,n){this.visible=e}positionHandler(e,t,n,r){return new q(this.x*e.x+this.offsetX,this.y*e.y+this.offsetY).transform(t)}calcCornerCoords(e,t,n,r,i,a){let o=Pt([zt(n,r),Bt({angle:e}),Vt((i?this.touchSizeX:this.sizeX)||t,(i?this.touchSizeY:this.sizeY)||t)]);return{tl:new q(-.5,-.5).transform(o),tr:new q(.5,-.5).transform(o),br:new q(.5,.5).transform(o),bl:new q(-.5,.5).transform(o)}}commonRenderProps(e,t,n,r,i={}){let{cornerSize:a,cornerColor:o,transparentCorners:s,cornerStrokeColor:c}=i,l=a||r.cornerSize,u=this.sizeX||l,d=this.sizeY||l,f=s===void 0?r.transparentCorners:s,p=f?st:ot,m=c||r.cornerStrokeColor,h=!f&&!!m;return e.fillStyle=o||r.cornerColor||``,e.strokeStyle=m||``,e.translate(t,n),e.rotate(J(r.getTotalAngle())),{stroke:h,xSize:u,ySize:d,transparentCorners:f,opName:p}}render(e,t,n,r,i){((r||={}).cornerStyle||i.cornerStyle)===`circle`?Hi.call(this,e,t,n,r,i):Ui.call(this,e,t,n,r,i)}},Gi=(e,t,n)=>n.lockRotation?Jn:t.cursorStyle,Ki=Fi(Ye,Ii((e,{target:t,ex:n,ey:r,theta:i,originX:a,originY:o},s,c)=>{let l=t.getPositionByOrigin(a,o);if(Zn(t,`lockRotation`))return!1;let u=Math.atan2(r-l.y,n-l.x),d=At(Math.atan2(c-l.y,s-l.x)-u+i);if(t.snapAngle&&t.snapAngle>0){let e=t.snapAngle,n=t.snapThreshold||e,r=Math.ceil(d/e)*e,i=Math.floor(d/e)*e;Math.abs(d-i)<n?d=i:Math.abs(d-r)<n&&(d=r)}d<0&&(d=360+d),d%=360;let f=t.angle!==d;return t.angle=d,f}));function qi(e,t){let n=t.canvas,r=e[n.uniScaleKey];return n.uniformScaling&&!r||!n.uniformScaling&&r}function Ji(e,t,n){let r=Zn(e,`lockScalingX`),i=Zn(e,`lockScalingY`);if(r&&i||!t&&(r||i)&&n||r&&t===`x`||i&&t===`y`)return!0;let{width:a,height:o,strokeWidth:s}=e;return a===0&&s===0&&t!==`y`||o===0&&s===0&&t!==`x`}var Yi=[`e`,`se`,`s`,`sw`,`w`,`nw`,`n`,`ne`,`e`],Xi=(e,t,n,r)=>{let i=qi(e,n);return Ji(n,t.x!==0&&t.y===0?`x`:t.x===0&&t.y!==0?`y`:``,i)?Jn:`${Yi[$n(n,0,r)]}-resize`};function Zi(e,t,n,r,i={}){let a=t.target,o=i.by,s=qi(e,a),c,l,u,d,f,p;if(Ji(a,o,s))return!1;if(t.gestureScale)l=t.scaleX*t.gestureScale,u=t.scaleY*t.gestureScale;else{if(c=er(t,t.originX,t.originY,n,r),f=o===`y`?1:Math.sign(c.x||t.signX||1),p=o===`x`?1:Math.sign(c.y||t.signY||1),t.signX||=f,t.signY||=p,Zn(a,`lockScalingFlip`)&&(t.signX!==f||t.signY!==p))return!1;if(d=a._getTransformedDimensions(),s&&!o){let e=Math.abs(c.x)+Math.abs(c.y),{original:n}=t,r=e/(Math.abs(d.x*n.scaleX/a.scaleX)+Math.abs(d.y*n.scaleY/a.scaleY));l=n.scaleX*r,u=n.scaleY*r}else l=Math.abs(c.x*a.scaleX/d.x),u=Math.abs(c.y*a.scaleY/d.y);Yn(t)&&(l*=2,u*=2),t.signX!==f&&o!==`y`&&(t.originX=Xn(t.originX),l*=-1,t.signX=f),t.signY!==p&&o!==`x`&&(t.originY=Xn(t.originY),u*=-1,t.signY=p)}let m=a.scaleX,h=a.scaleY;return o?(o===`x`&&a.set(`scaleX`,l),o===`y`&&a.set(`scaleY`,u)):(!Zn(a,`lockScalingX`)&&a.set(`scaleX`,l),!Zn(a,`lockScalingY`)&&a.set(`scaleY`,u)),m!==a.scaleX||h!==a.scaleY}var Qi=Fi(Je,Ii((e,t,n,r)=>Zi(e,t,n,r))),$i=Fi(Je,Ii((e,t,n,r)=>Zi(e,t,n,r,{by:`x`}))),ea=Fi(Je,Ii((e,t,n,r)=>Zi(e,t,n,r,{by:`y`}))),ta={x:{counterAxis:`y`,scale:nt,skew:it,lockSkewing:`lockSkewingX`,origin:`originX`,flip:`flipX`},y:{counterAxis:`x`,scale:rt,skew:at,lockSkewing:`lockSkewingY`,origin:`originY`,flip:`flipY`}},na=[`ns`,`nesw`,`ew`,`nwse`],ra=(e,t,n,r)=>t.x!==0&&Zn(n,`lockSkewingY`)||t.y!==0&&Zn(n,`lockSkewingX`)?Jn:`${na[$n(n,0,r)%4]}-resize`;function ia(e,t,n,r,i){let{target:a}=n,{counterAxis:o,origin:s,lockSkewing:c,skew:l,flip:u}=ta[e];if(Zn(a,c))return!1;let{origin:d,flip:f}=ta[o],p=Fn(n[d])*(a[f]?-1:1),m=-Math.sign(p)*(a[u]?-1:1),h=-(a[l]===0&&er(n,`center`,`center`,r,i)[e]>0||a[l]>0?1:-1)*m*.5+.5;return Fi(Ze,Ii((t,n,r,i)=>function(e,{target:t,ex:n,ey:r,skewingSide:i,...a},o){let{skew:s}=ta[e],c=o.subtract(new q(n,r)).divide(new q(t.scaleX,t.scaleY))[e],l=t[s],u=a[s],d=Math.tan(J(u)),f=e===`y`?t._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:t._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*c*i/Math.max(f,1)+d,m=At(Math.atan(p));t.set(s,m);let h=l!==t[s];if(h&&e===`y`){let{skewX:e,scaleX:n}=t,r=t._getTransformedDimensions({skewY:l}),i=t._getTransformedDimensions(),a=e===0?1:r.x/i.x;a!==1&&t.set(`scaleX`,a*n)}return h}(e,n,new q(r,i))))(t,{...n,[s]:h,skewingSide:m},r,i)}var aa=(e,t,n,r)=>ia(`x`,e,t,n,r),oa=(e,t,n,r)=>ia(`y`,e,t,n,r);function sa(e,t){return e[t.canvas.altActionKey]}var ca=(e,t,n)=>{let r=sa(e,n);return t.x===0?r?it:rt:t.y===0?r?at:nt:``},la=(e,t,n,r)=>sa(e,n)?ra(0,t,n,r):Xi(e,t,n,r),ua=(e,t,n,r)=>sa(e,t.target)?oa(e,t,n,r):$i(e,t,n,r),da=(e,t,n,r)=>sa(e,t.target)?aa(e,t,n,r):ea(e,t,n,r),fa=()=>({ml:new Wi({x:-.5,y:0,cursorStyleHandler:la,actionHandler:ua,getActionName:ca}),mr:new Wi({x:.5,y:0,cursorStyleHandler:la,actionHandler:ua,getActionName:ca}),mb:new Wi({x:0,y:.5,cursorStyleHandler:la,actionHandler:da,getActionName:ca}),mt:new Wi({x:0,y:-.5,cursorStyleHandler:la,actionHandler:da,getActionName:ca}),tl:new Wi({x:-.5,y:-.5,cursorStyleHandler:Xi,actionHandler:Qi}),tr:new Wi({x:.5,y:-.5,cursorStyleHandler:Xi,actionHandler:Qi}),bl:new Wi({x:-.5,y:.5,cursorStyleHandler:Xi,actionHandler:Qi}),br:new Wi({x:.5,y:.5,cursorStyleHandler:Xi,actionHandler:Qi}),mtr:new Wi({x:0,y:-.5,actionHandler:Ki,cursorStyleHandler:Gi,offsetY:-40,withConnection:!0,actionName:Xe})}),pa=()=>({mr:new Wi({x:.5,y:0,actionHandler:Bi,cursorStyleHandler:la,actionName:Qe}),ml:new Wi({x:-.5,y:0,actionHandler:Bi,cursorStyleHandler:la,actionName:Qe})}),ma=()=>({...fa(),...pa()}),ha=class e extends Ni{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),e.ownDefaults),this.setOptions(t)}static createControls(){return{controls:fa()}}_updateCacheCanvas(){let e=this.canvas;if(this.noScaleCache&&e&&e._currentTransform){let t=e._currentTransform,n=t.target,r=t.action;if(this===n&&r&&r.startsWith(`scale`))return!1}return super._updateCacheCanvas()}getActiveControl(){let e=this.__corner;return e?{key:e,control:this.controls[e],coord:this.oCoords[e]}:void 0}findControl(e,t=!1){if(!this.hasControls||!this.canvas)return;this.__corner=void 0;let n=Object.entries(this.oCoords);for(let r=n.length-1;r>=0;r--){let[i,a]=n[r],o=this.controls[i];if(o.shouldActivate(i,this,e,t?a.touchCorner:a.corner))return this.__corner=i,{key:i,control:o,coord:this.oCoords[i]}}}calcOCoords(){let e=this.getViewportTransform(),t=It(e),n=Lt(e),r=this.getCenterPoint(),i=Y(Y(e,Y(zt(r.x,r.y),Bt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}))),[1/t,0,0,1/n,0,0]),a=this.group?Rt(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));let o=this._calculateCurrentDimensions(a),s={};return this.forEachControl((e,t)=>{let n=e.positionHandler(o,i,this,e);s[t]=Object.assign(n,this._calcCornerCoords(e,n))}),s}_calcCornerCoords(e,t){let n=this.getTotalAngle();return{corner:e.calcCornerCoords(n,this.cornerSize,t.x,t.y,!1,this),touchCorner:e.calcCornerCoords(n,this.touchCornerSize,t.x,t.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(e){for(let t in this.controls)e(this.controls[t],t,this)}drawSelectionBackground(e){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;e.save();let t=this.getRelativeCenterPoint(),n=this._calculateCurrentDimensions(),r=this.getViewportTransform();e.translate(t.x,t.y),e.scale(1/r[0],1/r[3]),e.rotate(J(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore()}strokeBorders(e,t){e.strokeRect(-t.x/2,-t.y/2,t.x,t.y)}_drawBorders(e,t,n={}){let r={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...n};e.save(),e.strokeStyle=r.borderColor,this._setLineDash(e,r.borderDashArray),this.strokeBorders(e,t),r.hasControls&&this.drawControlsConnectingLines(e,t),e.restore()}_renderControls(e,t={}){let{hasBorders:n,hasControls:r}=this,i={hasBorders:n,hasControls:r,...t},a=this.getViewportTransform(),o=i.hasBorders,s=i.hasControls,c=Rt(Y(a,this.calcTransformMatrix()));e.save(),e.translate(c.translateX,c.translateY),e.lineWidth=this.borderScaleFactor,this.group===this.parent&&(e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180);let l=Ft(a);e.rotate(this.group?J(c.angle):J(this.angle)+l),o&&this.drawBorders(e,c,t),s&&this.drawControls(e,t),e.restore()}drawBorders(e,t,n){let r;if(n&&n.forActiveSelection||this.group){let e=kn(this.width,this.height,Gt(t)),n=this.isStrokeAccountedForInDimensions()?gt:(this.strokeUniform?new q().scalarAdd(this.canvas?this.canvas.getZoom():1):new q(t.scaleX,t.scaleY)).scalarMultiply(this.strokeWidth);r=e.add(n).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(e,r,n)}drawControlsConnectingLines(e,t){let n=!1;e.beginPath(),this.forEachControl((r,i)=>{r.withConnection&&r.getVisibility(this,i)&&(n=!0,e.moveTo(r.x*t.x,r.y*t.y),e.lineTo(r.x*t.x+r.offsetX,r.y*t.y+r.offsetY))}),n&&e.stroke()}drawControls(e,t={}){e.save();let n=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:i,cornerColor:a}=this,o={cornerStrokeColor:r,cornerDashArray:i,cornerColor:a,...t};e.setTransform(n,0,0,n,0,0),e.strokeStyle=e.fillStyle=o.cornerColor,this.transparentCorners||(e.strokeStyle=o.cornerStrokeColor),this._setLineDash(e,o.cornerDashArray),this.forEachControl((t,n)=>{if(t.getVisibility(this,n)){let r=this.oCoords[n];t.render(e,r.x,r.y,o,this)}}),e.restore()}isControlVisible(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)}setControlVisible(e,t){this._controlsVisibility||={},this._controlsVisibility[e]=t}setControlsVisibility(e={}){Object.entries(e).forEach(([e,t])=>this.setControlVisible(e,t))}clearContextTop(e){if(!this.canvas)return;let t=this.canvas.contextTop;if(!t)return;let n=this.canvas.viewportTransform;t.save(),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this.transform(t);let r=this.width+4,i=this.height+4;return t.clearRect(-r/2,-i/2,r,i),e||t.restore(),t}onDeselect(e){return!1}onSelect(e){return!1}shouldStartDragging(e){return!1}onDragStart(e){return!1}canDrop(e){return!1}renderDragSourceEffect(e){}renderDropTargetEffect(e){}};function ga(e,t){return t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!==`constructor`&&Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}),e}H(ha,`ownDefaults`,{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:`rgb(178,204,255)`,cornerStrokeColor:``,cornerStyle:`rect`,cornerDashArray:null,hasControls:!0,borderColor:`rgb(178,204,255)`,borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:``,selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:`down`,hoverCursor:null,moveCursor:null});var _a=class extends ha{};ga(_a,[_r]),K.setClass(_a),K.setClass(_a,`object`);var va=(e,t,n,r)=>{let i=2*(r=Math.round(r))+1,{data:a}=e.getImageData(t-r,n-r,i,i);for(let e=3;e<a.length;e+=4)if(a[e]>0)return!1;return!0},ya=class{constructor(e){this.options=e,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new q(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new q(1/this.options.scaleX,1/this.options.scaleY):new q(1,1)}createSideVector(e,t){let n=zn(e,t);return this.options.strokeUniform?n.multiply(this.scale):n}projectOrthogonally(e,t,n){return this.applySkew(e.add(this.calcOrthogonalProjection(e,t,n)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(e){let t=new q(e);return t.y+=t.x*Math.tan(J(this.options.skewY)),t.x+=t.y*Math.tan(J(this.options.skewX)),t}scaleUnitVector(e,t){return e.multiply(this.strokeUniformScalar).scalarMultiply(t)}},ba=new q,xa=class e extends ya{static getOrthogonalRotationFactor(e,t){let n=t?Vn(e,t):Hn(e);return Math.abs(n)<Re?-1:1}constructor(e,t,n,r){super(r),H(this,`AB`,void 0),H(this,`AC`,void 0),H(this,`alpha`,void 0),H(this,`bisector`,void 0),this.A=new q(e),this.B=new q(t),this.C=new q(n),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Vn(this.AB,this.AC),this.bisector=Un(Rn(this.AB.eq(ba)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,n,r=this.strokeProjectionMagnitude){let i=Wn(this.createSideVector(t,n)),a=e.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,r*a)}projectBevel(){let e=[];return(this.alpha%Be===0?[this.B]:[this.B,this.C]).forEach(t=>{e.push(this.projectOrthogonally(this.A,t)),e.push(this.projectOrthogonally(this.A,t,-this.strokeProjectionMagnitude))}),e}projectMiter(){let e=[],t=Math.abs(this.alpha),n=1/Math.sin(t/2),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*n),i=this.options.strokeUniform?Bn(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Bn(r)/this.strokeProjectionMagnitude<=i&&e.push(this.applySkew(this.A.add(r))),e.push(...this.projectBevel()),e}projectRoundNoSkew(t,n){let r=[],i=new q(e.getOrthogonalRotationFactor(this.bisector),e.getOrthogonalRotationFactor(new q(this.bisector.y,this.bisector.x)));return[new q(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new q(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(e=>{qn(e,t,n)&&r.push(this.A.add(e))}),r}projectRoundWithSkew(e,t){let n=[],{skewX:r,skewY:i,scaleX:a,scaleY:o,strokeUniform:s}=this.options,c=new q(Math.tan(J(r)),Math.tan(J(i))),l=this.strokeProjectionMagnitude,u=s?l/o/Math.sqrt(1/o**2+1/a**2*c.y**2):l/Math.sqrt(1+c.y**2),d=new q(Math.sqrt(Math.max(l**2-u**2,0)),u),f=s?l/Math.sqrt(1+c.x**2*(1/o)**2/(1/a+1/a*c.x*c.y)**2):l/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),p=new q(f,Math.sqrt(Math.max(l**2-f**2,0)));return[p,p.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(e=>this.applySkew(s?e.multiply(this.strokeUniformScalar):e)).forEach(r=>{qn(r,e,t)&&n.push(this.applySkew(this.A).add(r))}),n}projectRound(){let e=[];e.push(...this.projectBevel());let t=this.alpha%Be===0,n=this.applySkew(this.A),r=e[t?0:2].subtract(n),i=e[+!!t].subtract(n),a=Gn(r,t?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,o=a?r:i,s=a?i:r;return this.isSkewed()?e.push(...this.projectRoundWithSkew(o,s)):e.push(...this.projectRoundNoSkew(o,s)),e}projectPoints(){switch(this.options.strokeLineJoin){case`miter`:return this.projectMiter();case`round`:return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e,angle:this.alpha,bisector:this.bisector}))}},Sa=class extends ya{constructor(e,t,n){super(n),this.A=new q(e),this.T=new q(t)}calcOrthogonalProjection(e,t,n=this.strokeProjectionMagnitude){let r=this.createSideVector(e,t);return this.scaleUnitVector(Wn(r),n)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){let e=[];if(!this.isSkewed()&&this.A.eq(this.T)){let t=new q(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.applySkew(this.A.add(t)),this.applySkew(this.A.subtract(t)))}else e.push(...new xa(this.A,this.T,this.T,this.options).projectRound());return e}projectSquare(){let e=[];if(this.A.eq(this.T)){let t=new q(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.A.add(t),this.A.subtract(t))}else{let t=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),n=this.scaleUnitVector(Un(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(n);e.push(r.add(t),r.subtract(t))}return e.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case`round`:return this.projectRound();case`square`:return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e}))}},Ca=(e,t,n=!1)=>{let r=[];if(e.length===0)return r;let i=e.reduce((e,t)=>(e[e.length-1].eq(t)||e.push(new q(t)),e),[new q(e[0])]);if(i.length===1)n=!0;else if(!n){let e=i[0],t=((e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1})(i,t=>!t.eq(e));i.splice(t+1)}return i.forEach((e,i,a)=>{let o,s;i===0?(s=a[1],o=n?e:a[a.length-1]):i===a.length-1?(o=a[i-1],s=n?e:a[0]):(o=a[i-1],s=a[i+1]),n&&a.length===1?r.push(...new Sa(e,e,t).project()):!n||i!==0&&i!==a.length-1?r.push(...new xa(e,o,s,t).project()):r.push(...new Sa(e,i===0?s:o,t).project())}),r},wa=e=>{let t={};return Object.keys(e).forEach(n=>{t[n]={},Object.keys(e[n]).forEach(r=>{t[n][r]={...e[n][r]}})}),t},Ta=(e,t,n=!1)=>e.fill!==t.fill||e.stroke!==t.stroke||e.strokeWidth!==t.strokeWidth||e.fontSize!==t.fontSize||e.fontFamily!==t.fontFamily||e.fontWeight!==t.fontWeight||e.fontStyle!==t.fontStyle||e.textDecorationThickness!==t.textDecorationThickness||e.textDecorationColor!==t.textDecorationColor||e.textBackgroundColor!==t.textBackgroundColor||e.deltaY!==t.deltaY||n&&(e.overline!==t.overline||e.underline!==t.underline||e.linethrough!==t.linethrough),Ea=(e,t)=>{let n=t.split(`
|
|
16
|
+
`),r=[],i=-1,a={};e=wa(e);for(let t=0;t<n.length;t++){let o=hn(n[t]);if(e[t])for(let n=0;n<o.length;n++){i++;let o=e[t][n];o&&Object.keys(o).length>0&&(Ta(a,o,!0)?r.push({start:i,end:i+1,style:o}):r[r.length-1].end++),a=o||{}}else i+=o.length,a={}}return r},Da=(e,t)=>{if(!Array.isArray(e))return wa(e);let n=t.split(Ke),r={},i=-1,a=0;for(let t=0;t<n.length;t++){let o=hn(n[t]);for(let n=0;n<o.length;n++)i++,e[a]&&e[a].start<=i&&i<e[a].end&&(r[t]=r[t]||{},r[t][n]={...e[a].style},i===e[a].end-1&&a++)}return r},Oa=[`display`,`transform`,ot,`fill-opacity`,`fill-rule`,`opacity`,st,`stroke-dasharray`,`stroke-linecap`,`stroke-dashoffset`,`stroke-linejoin`,`stroke-miterlimit`,`stroke-opacity`,`stroke-width`,`id`,`paint-order`,`vector-effect`,`instantiated_by_use`,`clip-path`];function ka(e,t){let n=e.nodeName,r=e.getAttribute(`class`),i=e.getAttribute(`id`),a=`(?![a-zA-Z\\-]+)`,o;if(o=RegExp(`^`+n,`i`),t=t.replace(o,``),i&&t.length&&(o=RegExp(`#`+i+a,`i`),t=t.replace(o,``)),r&&t.length){let e=r.split(` `);for(let n=e.length;n--;)o=RegExp(`\\.`+e[n]+a,`i`),t=t.replace(o,``)}return t.length===0}function Aa(e,t){let n=!0,r=ka(e,t.pop());return r&&t.length&&(n=function(e,t){let n,r=!0;for(;e.parentElement&&e.parentElement.nodeType===1&&t.length;)r&&(n=t.pop()),r=ka(e=e.parentElement,n);return t.length===0}(e,t)),r&&n&&t.length===0}function ja(e,t={}){let n={};for(let r in t)Aa(e,r.split(` `))&&(n={...n,...t[r]});return n}var Ma=e=>jr[e]??e,Na=RegExp(`(${Or})`,`gi`),Pa=`(${Or})`,Fa=String.raw`(skewX)\(${Pa}\)`,Ia=String.raw`(skewY)\(${Pa}\)`,La=String.raw`(rotate)\(${Pa}(?: ${Pa} ${Pa})?\)`,Ra=String.raw`(scale)\(${Pa}(?: ${Pa})?\)`,za=String.raw`(translate)\(${Pa}(?: ${Pa})?\)`,Ba=`(?:${String.raw`(matrix)\(${Pa} ${Pa} ${Pa} ${Pa} ${Pa} ${Pa}\)`}|${za}|${La}|${Ra}|${Fa}|${Ia})`,Va=`(?:${Ba}*)`,Ha=String.raw`^\s*(?:${Va}?)\s*$`,Ua=new RegExp(Ha),Wa=new RegExp(Ba),Ga=new RegExp(Ba,`g`);function Ka(e){let t=[];if(!(e=(e=>ar(e.replace(Na,` $1 `).replace(/,/gi,` `)))(e).replace(/\s*([()])\s*/gi,`$1`))||e&&!Ua.test(e))return[...He];for(let n of e.matchAll(Ga)){let e=Wa.exec(n[0]);if(!e)continue;let r=He,[,i,...a]=e.filter(e=>!!e),[o,s,c,l,u,d]=a.map(e=>parseFloat(e));switch(i){case`translate`:r=zt(o,s);break;case Xe:r=Bt({angle:o},{x:s,y:c});break;case tt:r=Vt(o,s);break;case it:r=Ut(o);break;case at:r=Wt(o);break;case`matrix`:r=[o,s,c,l,u,d]}t.push(r)}return Pt(t)}function qa(e,t,n,r){let i=Array.isArray(t),a,o=t;if(e!==`fill`&&e!==`stroke`||t!==`none`){if(e===`strokeUniform`)return t===`non-scaling-stroke`;if(e===`strokeDashArray`)o=t===`none`?null:t.replace(/,/g,` `).split(/\s+/).map(parseFloat);else if(e===`transformMatrix`)o=n&&n.transformMatrix?Y(n.transformMatrix,Ka(t)):Ka(t);else if(e===`visible`)o=t!==`none`&&t!==`hidden`,n&&!1===n.visible&&(o=!1);else if(e===`opacity`)o=parseFloat(t),n&&n.opacity!==void 0&&(o*=n.opacity);else if(e===`textAnchor`)o=t===`start`?G:t===`end`?We:W;else if(e===`charSpacing`||e===`textDecorationThickness`)a=mr(t,r)/r*1e3;else if(e===`paintFirst`){let e=t.indexOf(ot),n=t.indexOf(st);o=ot,(e>-1&&n>-1&&n<e||e===-1&&n>-1)&&(o=st)}else{if(e===`href`||e===`xlink:href`||e===`font`||e===`id`)return t;if(e===`imageSmoothing`)return t===`optimizeQuality`;a=i?t.map(mr):mr(t,r)}}else o=``;return!i&&isNaN(a)?o:a}function Ja(e,t){e.replace(/;\s*$/,``).split(`;`).forEach(e=>{if(!e)return;let[n,r]=e.split(`:`);t[n.trim().toLowerCase()]=r.trim()})}function Ya(e){let t={},n=e.getAttribute(`style`);return n&&(typeof n==`string`?Ja(n,t):function(e,t){Object.entries(e).forEach(([e,n])=>{n!==void 0&&(t[e.toLowerCase()]=n)})}(n,t)),t}var Xa={stroke:`strokeOpacity`,fill:`fillOpacity`};function Za(e,t,n){if(!e)return{};let r,i={},a=16;e.parentNode&&Pr.test(e.parentNode.nodeName)&&(i=Za(e.parentElement,t,n),i.fontSize&&(r=a=mr(i.fontSize)));let o={...t.reduce((t,n)=>{let r=e.getAttribute(n);return r&&(t[n]=r),t},{}),...ja(e,n),...Ya(e)};o[`clip-path`]&&e.setAttribute(Nr,o[Nr]),o[`font-size`]&&(r=mr(o[Mr],a),o[Mr]=`${r}`);let s={};for(let e in o){let t=Ma(e);s[t]=qa(t,o[e],i,r)}s&&s.font&&function(e,t){let n=e.match(Ar);if(!n)return;let r=n[1],i=n[3],a=n[4],o=n[5],s=n[6];r&&(t.fontStyle=r),i&&(t.fontWeight=isNaN(parseFloat(i))?i:parseFloat(i)),a&&(t.fontSize=mr(a)),s&&(t.fontFamily=s),o&&(t.lineHeight=o===`normal`?1:o)}(s.font,s);let c={...i,...s};return Pr.test(e.nodeName)?c:function(e){let t=_a.getDefaults();return Object.entries(Xa).forEach(([n,r])=>{if(e[r]===void 0||e[n]===``)return;if(e[n]===void 0){if(!t[n])return;e[n]=t[n]}if(e[n].indexOf(`url(`)===0)return;let i=new fr(e[n]);e[n]=i.setAlpha(X(i.getAlpha()*e[r],2)).toRgba()}),e}(c)}var Qa=[`rx`,`ry`],$a=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){let{rx:e,ry:t}=this;e&&!t?this.ry=e:t&&!e&&(this.rx=t)}_render(e){let{width:t,height:n}=this,r=-t/2,i=-n/2,a=this.rx?Math.min(this.rx,t/2):0,o=this.ry?Math.min(this.ry,n/2):0,s=a!==0||o!==0;e.beginPath(),e.moveTo(r+a,i),e.lineTo(r+t-a,i),s&&e.bezierCurveTo(r+t-.4477152502*a,i,r+t,i+.4477152502*o,r+t,i+o),e.lineTo(r+t,i+n-o),s&&e.bezierCurveTo(r+t,i+n-.4477152502*o,r+t-.4477152502*a,i+n,r+t-a,i+n),e.lineTo(r+a,i+n),s&&e.bezierCurveTo(r+.4477152502*a,i+n,r,i+n-.4477152502*o,r,i+n-o),e.lineTo(r,i+o),s&&e.bezierCurveTo(r,i+.4477152502*o,r+.4477152502*a,i,r+a,i),e.closePath(),this._renderPaintInOrder(e)}toObject(e=[]){return super.toObject([...Qa,...e])}_toSVG(){let{width:e,height:t,rx:n,ry:r}=this;return[`<rect `,`COMMON_PARTS`,`x="${-e/2}" y="${-t/2}" rx="${Z(n)}" ry="${Z(r)}" width="${Z(e)}" height="${Z(t)}" />\n`]}static async fromElement(e,t,n){let{left:r=0,top:i=0,width:a=0,height:o=0,visible:s=!0,...c}=Za(e,this.ATTRIBUTE_NAMES,n);return new this({...t,...c,left:r,top:i,width:a,height:o,visible:!!(s&&a&&o)})}};H($a,`type`,`Rect`),H($a,`cacheProperties`,[...Br,...Qa]),H($a,`ownDefaults`,{rx:0,ry:0}),H($a,`ATTRIBUTE_NAMES`,[...Oa,`x`,`y`,`rx`,`ry`,`width`,`height`]),K.setClass($a),K.setSVGClass($a);var eo=`initialization`,to=`added`,no=(e,t)=>{let{strokeUniform:n,strokeWidth:r,width:i,height:a,group:o}=t,s=o&&o!==e?An(o.calcTransformMatrix(),e.calcTransformMatrix()):null,c=s?t.getRelativeCenterPoint().transform(s):t.getRelativeCenterPoint(),l=!t.isStrokeAccountedForInDimensions(),u=n&&l?Mn(new q(r,r),void 0,e.calcTransformMatrix()):gt,d=!n&&l?r:0,f=kn(i+d,a+d,Pt([s,t.calcOwnMatrix()],!0)).add(u).scalarDivide(2);return[c.subtract(f),c.add(f)]},ro=class{calcLayoutResult(e,t){if(this.shouldPerformLayout(e))return this.calcBoundingBox(t,e)}shouldPerformLayout({type:e,prevStrategy:t,strategy:n}){return e===`initialization`||e===`imperative`||!!t&&n!==t}shouldLayoutClipPath({type:e,target:{clipPath:t}}){return e!==`initialization`&&t&&!t.absolutePositioned}getInitialSize(e,t){return t.size}calcBoundingBox(e,t){let{type:n,target:r}=t;if(n===`imperative`&&t.overrides)return t.overrides;if(e.length===0)return;let{left:i,top:a,width:o,height:s}=Cn(e.map(e=>no(r,e)).reduce((e,t)=>e.concat(t),[])),c=new q(o,s),l=new q(i,a).add(c.scalarDivide(2));if(n===`initialization`){let e=this.getInitialSize(t,{size:c,center:l});return{center:l,relativeCorrection:new q(0,0),size:e}}return{center:l.transform(r.calcOwnMatrix()),size:c}}};H(ro,`type`,`strategy`);var io=class extends ro{shouldPerformLayout(e){return!0}};H(io,`type`,`fit-content`),K.setClass(io);var ao=`layoutManager`,oo=class{constructor(e=new io){H(this,`strategy`,void 0),this.strategy=e,this._subscriptions=new Map}performLayout(e){let t={bubbles:!0,strategy:this.strategy,...e,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(t);let n=this.getLayoutResult(t);n&&this.commitLayout(t,n),this.onAfterLayout(t,n),this._prevLayoutStrategy=t.strategy}attachHandlers(e,t){let{target:n}=t;return[ct,qe,Qe,Ye,Je,Ze,et,$e,`modifyPath`].map(t=>e.on(t,e=>this.performLayout(t===`modified`?{type:`object_modified`,trigger:t,e,target:n}:{type:`object_modifying`,trigger:t,e,target:n})))}subscribe(e,t){this.unsubscribe(e,t);let n=this.attachHandlers(e,t);this._subscriptions.set(e,n)}unsubscribe(e,t){(this._subscriptions.get(e)||[]).forEach(e=>e()),this._subscriptions.delete(e)}unsubscribeTargets(e){e.targets.forEach(t=>this.unsubscribe(t,e))}subscribeTargets(e){e.targets.forEach(t=>this.subscribe(t,e))}onBeforeLayout(e){let{target:t,type:n}=e,{canvas:r}=t;if(n===`initialization`||n===`added`?this.subscribeTargets(e):n===`removed`&&this.unsubscribeTargets(e),t.fire(`layout:before`,{context:e}),r&&r.fire(`object:layout:before`,{target:t,context:e}),n===`imperative`&&e.deep){let{strategy:n,...r}=e;t.forEachObject(e=>e.layoutManager&&e.layoutManager.performLayout({...r,bubbles:!1,target:e}))}}getLayoutResult(e){let{target:t,strategy:n,type:r}=e,i=n.calcLayoutResult(e,t.getObjects());if(!i)return;let a=r===`initialization`?new q:t.getRelativeCenterPoint(),{center:o,correction:s=new q,relativeCorrection:c=new q}=i;return{result:i,prevCenter:a,nextCenter:o,offset:a.subtract(o).add(s).transform(r===`initialization`?He:Nt(t.calcOwnMatrix()),!0).add(c)}}commitLayout(e,t){let{target:n}=e,{result:{size:r},nextCenter:i}=t;n.set({width:r.x,height:r.y}),this.layoutObjects(e,t),e.type===`initialization`?n.set({left:e.x??i.x+r.x*Fn(n.originX),top:e.y??i.y+r.y*Fn(n.originY)}):(n.setPositionByOrigin(i,W,W),n.setCoords(),n.set(`dirty`,!0))}layoutObjects(e,t){let{target:n}=e;n.forEachObject(r=>{r.group===n&&this.layoutObject(e,t,r)}),e.strategy.shouldLayoutClipPath(e)&&this.layoutObject(e,t,n.clipPath)}layoutObject(e,{offset:t},n){n.set({left:n.left+t.x,top:n.top+t.y})}onAfterLayout(e,t){let{target:n,strategy:r,bubbles:i,prevStrategy:a,...o}=e,{canvas:s}=n;n.fire(`layout:after`,{context:e,result:t}),s&&s.fire(`object:layout:after`,{context:e,result:t,target:n});let c=n.parent;i&&c!=null&&c.layoutManager&&((o.path||=[]).push(n),c.layoutManager.performLayout({...o,target:c})),n.set(`dirty`,!0)}dispose(){let{_subscriptions:e}=this;e.forEach(e=>e.forEach(e=>e())),e.clear()}toObject(){return{type:ao,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}};K.setClass(oo,ao);var so=class extends oo{performLayout(){}},co=class e extends vt(_a){static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),H(this,`_activeObjects`,[]),H(this,`__objectSelectionTracker`,void 0),H(this,`__objectSelectionDisposer`,void 0),Object.assign(this,e.ownDefaults),this.setOptions(n),this.groupInit(t,n)}groupInit(e,t){this._objects=[...e],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(e=>{this.enterGroup(e,!1)}),this.layoutManager=t.layoutManager??new oo,this.layoutManager.performLayout({type:eo,target:this,targets:[...e],x:t.left,y:t.top})}canEnterGroup(e){return e===this||this.isDescendantOf(e)?(we(`error`,`Group: circular object trees are not supported, this call has no effect`),!1):this._objects.indexOf(e)===-1||(we(`error`,`Group: duplicate objects are not supported inside group, this call has no effect`),!1)}_filterObjectsBeforeEnteringGroup(e){return e.filter((e,t,n)=>this.canEnterGroup(e)&&n.indexOf(e)===t)}add(...e){let t=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...t);return this._onAfterObjectsChange(to,t),n}insertAt(e,...t){let n=this._filterObjectsBeforeEnteringGroup(t),r=super.insertAt(e,...n);return this._onAfterObjectsChange(to,n),r}remove(...e){let t=super.remove(...e);return this._onAfterObjectsChange(`removed`,t),t}_onObjectAdded(e){this.enterGroup(e,!0),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e,t){this.exitGroup(e,t),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onAfterObjectsChange(e,t){this.layoutManager.performLayout({type:e,targets:t,target:this})}_onStackOrderChanged(){this._set(`dirty`,!0)}_set(e,t){let n=this[e];return super._set(e,t),e===`canvas`&&n!==t&&(this._objects||[]).forEach(n=>{n._set(e,t)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(e,{target:t}){let n=this._activeObjects;if(e)n.push(t),this._set(`dirty`,!0);else if(n.length>0){let e=n.indexOf(t);e>-1&&(n.splice(e,1),this._set(`dirty`,!0))}}_watchObject(e,t){e&&this._watchObject(!1,t),e?(t.on(`selected`,this.__objectSelectionTracker),t.on(`deselected`,this.__objectSelectionDisposer)):(t.off(`selected`,this.__objectSelectionTracker),t.off(`deselected`,this.__objectSelectionDisposer))}enterGroup(e,t){e.group&&e.group.remove(e),e._set(`parent`,this),this._enterGroup(e,t)}_enterGroup(e,t){t&&En(e,Y(Nt(this.calcTransformMatrix()),e.calcTransformMatrix())),this._shouldSetNestedCoords()&&e.setCoords(),e._set(`group`,this),e._set(`canvas`,this.canvas),this._watchObject(!0,e);let n=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();n&&(n===e||e.isDescendantOf(n))&&this._activeObjects.push(e)}exitGroup(e,t){this._exitGroup(e,t),e._set(`parent`,void 0),e._set(`canvas`,void 0)}_exitGroup(e,t){e._set(`group`,void 0),t||(En(e,Y(this.calcTransformMatrix(),e.calcTransformMatrix())),e.setCoords()),this._watchObject(!1,e);let n=this._activeObjects.length>0?this._activeObjects.indexOf(e):-1;n>-1&&this._activeObjects.splice(n,1)}shouldCache(){let e=_a.prototype.shouldCache.call(this);if(e){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return e}willDrawShadow(){if(super.willDrawShadow())return!0;for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(e,t,n){this._renderBackground(e);for(let t=0;t<this._objects.length;t++){var r;let n=this._objects[t];(r=this.canvas)!=null&&r.preserveObjectStacking&&n.group!==this?(e.save(),e.transform(...Nt(this.calcTransformMatrix())),n.render(e),e.restore()):n.group===this&&n.render(e)}this._drawClipPath(e,this.clipPath,n)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(e=>e.setCoords())}triggerLayout(e={}){this.layoutManager.performLayout({target:this,type:`imperative`,...e})}render(e){this._transformDone=!0,super.render(e),this._transformDone=!1}__serializeObjects(e,t){let n=this.includeDefaultValues;return this._objects.filter(function(e){return!e.excludeFromExport}).map(function(r){let i=r.includeDefaultValues;r.includeDefaultValues=n;let a=r[e||`toObject`](t);return r.includeDefaultValues=i,a})}toObject(e=[]){let t=this.layoutManager.toObject();return{...super.toObject([`subTargetCheck`,`interactive`,...e]),...t.strategy!==`fit-content`||this.includeDefaultValues?{layoutManager:t}:{},objects:this.__serializeObjects(`toObject`,e)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(e=>{this._watchObject(!1,e),e.dispose()}),super.dispose()}_createSVGBgRect(e){if(!this.backgroundColor)return``;let t=$a.prototype._toSVG.call(this),n=t.indexOf(`COMMON_PARTS`);t[n]=`for="group" `;let r=t.join(``);return e?e(r):r}_toSVG(e){let t=[`<g `,`COMMON_PARTS`,` >
|
|
17
|
+
`],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toSVG(e));return t.push(`</g>
|
|
18
|
+
`),t}getSvgStyles(){let e=this.opacity!==void 0&&this.opacity!==1?`opacity: ${Z(this.opacity)};`:``,t=this.visible?``:` visibility: hidden;`;return[e,this.getSvgFilter(),t].join(``)}toClipPathSVG(e){let t=[],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject({type:e,objects:t=[],layoutManager:n,...r},i){return Promise.all([Jt(t,i),Yt(r,i)]).then(([e,t])=>{let i=new this(e,{...r,...t,layoutManager:new so});return i.layoutManager=n?new(K.getClass(n.type))(new(K.getClass(n.strategy))):new oo,i.layoutManager.subscribeTargets({type:eo,target:i,targets:i.getObjects()}),i.setCoords(),i})}};H(co,`type`,`Group`),H(co,`ownDefaults`,{strokeWidth:0,subTargetCheck:!1,interactive:!1}),K.setClass(co);var lo=(e,t)=>e&&e.length===1?e[0]:new co(e,t),uo=(e,t)=>Math.min(t.width/e.width,t.height/e.height),fo=(e,t)=>Math.max(t.width/e.width,t.height/e.height),po=`\\s*,?\\s*`,mo=`${po}(${Or})`,ho=`${mo}${mo}${mo}${po}([01])${po}([01])${mo}${mo}`,go={m:`l`,M:`L`},_o=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=mt(e),f=ht(e),p=mt(t),m=ht(t),h=n*i*p-r*a*m+o,g=r*i*p+n*a*m+s;return[`C`,l+c*(-n*i*f-r*a*d),u+c*(-r*i*f+n*a*d),h+c*(n*i*m+r*a*p),g+c*(r*i*m-n*a*p),h,g]},vo=(e,t,n,r)=>{let i=Math.atan2(t,e),a=Math.atan2(r,n);return a>=i?a-i:2*Math.PI-(i-a)};function yo(e,t,n,r,i,a,o,s){let c;if(U.cachesBoundsOfCurve&&(c=[...arguments].join(),Fe.boundsOfCurveCache[c]))return Fe.boundsOfCurveCache[c];let l=Math.sqrt,u=Math.abs,d=[],f=[[0,0],[0,0]],p=6*e-12*n+6*i,m=-3*e+9*n-9*i+3*o,h=3*n-3*e;for(let e=0;e<2;++e){if(e>0&&(p=6*t-12*r+6*a,m=-3*t+9*r-9*a+3*s,h=3*r-3*t),u(m)<1e-12){if(u(p)<1e-12)continue;let e=-h/p;0<e&&e<1&&d.push(e);continue}let n=p*p-4*h*m;if(n<0)continue;let i=l(n),o=(-p+i)/(2*m);0<o&&o<1&&d.push(o);let c=(-p-i)/(2*m);0<c&&c<1&&d.push(c)}let g=d.length,_=g,v=Co(e,t,n,r,i,a,o,s);for(;g--;){let{x:e,y:t}=v(d[g]);f[0][g]=e,f[1][g]=t}f[0][_]=e,f[1][_]=t,f[0][_+1]=o,f[1][_+1]=s;let y=[new q(Math.min(...f[0]),Math.min(...f[1])),new q(Math.max(...f[0]),Math.max(...f[1]))];return U.cachesBoundsOfCurve&&(Fe.boundsOfCurveCache[c]=y),y}var bo=(e,t,[n,r,i,a,o,s,c,l])=>{let u=((e,t,n,r,i,a,o)=>{if(n===0||r===0)return[];let s=0,c=0,l=0,u=Math.PI,d=o*Ve,f=ht(d),p=mt(d),m=.5*(-p*e-f*t),h=.5*(-p*t+f*e),g=n**2,_=r**2,v=h**2,y=m**2,b=g*_-g*v-_*y,x=Math.abs(n),S=Math.abs(r);if(b<0){let e=Math.sqrt(1-b/(g*_));x*=e,S*=e}else l=(i===a?-1:1)*Math.sqrt(b/(g*v+_*y));let C=l*x*h/S,w=-l*S*m/x,T=p*C-f*w+.5*e,E=f*C+p*w+.5*t,D=vo(1,0,(m-C)/x,(h-w)/S),O=vo((m-C)/x,(h-w)/S,(-m-C)/x,(-h-w)/S);a===0&&O>0?O-=2*u:a===1&&O<0&&(O+=2*u);let k=Math.ceil(Math.abs(O/u*2)),A=[],j=O/k,M=8/3*Math.sin(j/4)*Math.sin(j/4)/Math.sin(j/2),N=D+j;for(let e=0;e<k;e++)A[e]=_o(D,N,p,f,x,S,T,E,M,s,c),s=A[e][5],c=A[e][6],D=N,N+=j;return A})(c-e,l-t,r,i,o,s,a);for(let n=0,r=u.length;n<r;n++)u[n][1]+=e,u[n][2]+=t,u[n][3]+=e,u[n][4]+=t,u[n][5]+=e,u[n][6]+=t;return u},xo=e=>{let t=0,n=0,r=0,i=0,a=[],o,s=0,c=0;for(let l of e){let e=[...l],u;switch(e[0]){case`l`:e[1]+=t,e[2]+=n;case`L`:t=e[1],n=e[2],u=[`L`,t,n];break;case`h`:e[1]+=t;case`H`:t=e[1],u=[`L`,t,n];break;case`v`:e[1]+=n;case`V`:n=e[1],u=[`L`,t,n];break;case`m`:e[1]+=t,e[2]+=n;case`M`:t=e[1],n=e[2],r=e[1],i=e[2],u=[`M`,t,n];break;case`c`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n,e[5]+=t,e[6]+=n;case`C`:s=e[3],c=e[4],t=e[5],n=e[6],u=[`C`,e[1],e[2],s,c,t,n];break;case`s`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`S`:o===`C`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[3],n=e[4],u=[`C`,s,c,e[1],e[2],t,n],s=u[3],c=u[4];break;case`q`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`Q`:s=e[1],c=e[2],t=e[3],n=e[4],u=[`Q`,s,c,t,n];break;case`t`:e[1]+=t,e[2]+=n;case`T`:o===`Q`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[1],n=e[2],u=[`Q`,s,c,t,n];break;case`a`:e[6]+=t,e[7]+=n;case`A`:bo(t,n,e).forEach(e=>a.push(e)),t=e[6],n=e[7];break;case`z`:case`Z`:t=r,n=i,u=[`Z`]}u?(a.push(u),o=u[0]):o=``}return a},So=(e,t,n,r)=>Math.sqrt((n-e)**2+(r-t)**2),Co=(e,t,n,r,i,a,o,s)=>c=>{let l=c**3,u=(e=>3*e**2*(1-e))(c),d=(e=>3*e*(1-e)**2)(c),f=(e=>(1-e)**3)(c);return new q(o*l+i*u+n*d+e*f,s*l+a*u+r*d+t*f)},wo=e=>e**2,To=e=>2*e*(1-e),Eo=e=>(1-e)**2,Do=(e,t,n,r,i,a,o,s)=>c=>{let l=wo(c),u=To(c),d=Eo(c),f=3*(d*(n-e)+u*(i-n)+l*(o-i)),p=3*(d*(r-t)+u*(a-r)+l*(s-a));return Math.atan2(p,f)},Oo=(e,t,n,r,i,a)=>o=>{let s=wo(o),c=To(o),l=Eo(o);return new q(i*s+n*c+e*l,a*s+r*c+t*l)},ko=(e,t,n,r,i,a)=>o=>{let s=1-o,c=2*(s*(n-e)+o*(i-n)),l=2*(s*(r-t)+o*(a-r));return Math.atan2(l,c)},Ao=(e,t,n)=>{let r=new q(t,n),i=0;for(let t=1;t<=100;t+=1){let n=e(t/100);i+=So(r.x,r.y,n.x,n.y),r=n}return i},jo=(e,t)=>{let n,r=0,i=0,a={x:e.x,y:e.y},o={...a},s=.01,c=0,l=e.iterator,u=e.angleFinder;for(;i<t&&s>1e-4;)o=l(r),c=r,n=So(a.x,a.y,o.x,o.y),n+i>t?(r-=s,s/=2):(a=o,r+=s,i+=n);return{...o,angle:u(c)}},Mo=e=>{let t,n,r=0,i=0,a=0,o=0,s=0,c=[];for(let l of e){let e={x:i,y:a,command:l[0],length:0};switch(l[0]){case`M`:n=e,n.x=o=i=l[1],n.y=s=a=l[2];break;case`L`:n=e,n.length=So(i,a,l[1],l[2]),i=l[1],a=l[2];break;case`C`:t=Co(i,a,l[1],l[2],l[3],l[4],l[5],l[6]),n=e,n.iterator=t,n.angleFinder=Do(i,a,l[1],l[2],l[3],l[4],l[5],l[6]),n.length=Ao(t,i,a),i=l[5],a=l[6];break;case`Q`:t=Oo(i,a,l[1],l[2],l[3],l[4]),n=e,n.iterator=t,n.angleFinder=ko(i,a,l[1],l[2],l[3],l[4]),n.length=Ao(t,i,a),i=l[3],a=l[4];break;case`Z`:n=e,n.destX=o,n.destY=s,n.length=So(i,a,o,s),i=o,a=s}r+=n.length,c.push(n)}return c.push({length:r,x:i,y:a}),c},No=(e,t,n=Mo(e))=>{let r=0;for(;t-n[r].length>0&&r<n.length-2;)t-=n[r].length,r++;let i=n[r],a=t/i.length,o=e[r];switch(i.command){case`M`:return{x:i.x,y:i.y,angle:0};case`Z`:return{...new q(i.x,i.y).lerp(new q(i.destX,i.destY),a),angle:Math.atan2(i.destY-i.y,i.destX-i.x)};case`L`:return{...new q(i.x,i.y).lerp(new q(o[1],o[2]),a),angle:Math.atan2(o[2]-i.y,o[1]-i.x)};case`C`:case`Q`:return jo(i,t)}},Po=RegExp(`[mzlhvcsqta][^mzlhvcsqta]*`,`gi`),Fo=new RegExp(ho,`g`),Io=new RegExp(Or,`gi`),Lo={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Ro=e=>{let t=[],n=e.match(Po)??[];for(let e of n){let n=e[0];if(n===`z`||n===`Z`){t.push([n]);continue}let r=Lo[n.toLowerCase()],i=[];if(n===`a`||n===`A`){let t;for(Fo.lastIndex=0;t=Fo.exec(e);)i.push(...t.slice(1))}else i=e.match(Io)||[];for(let e=0;e<i.length;e+=r){let a=Array(r),o=go[n];a[0]=e>0&&o?o:n;for(let t=0;t<r;t++)a[t+1]=parseFloat(i[e+t]);t.push(a)}}return t},zo=(e,t=0)=>{let n=new q(e[0]),r=new q(e[1]),i=1,a=0,o=[],s=e.length,c=s>2,l;for(c&&(i=e[2].x<r.x?-1:e[2].x===r.x?0:1,a=e[2].y<r.y?-1:e[2].y===r.y?0:1),o.push([`M`,n.x-i*t,n.y-a*t]),l=1;l<s;l++){if(!n.eq(r)){let e=n.midPointFrom(r);o.push([`Q`,n.x,n.y,e.x,e.y])}n=e[l],l+1<e.length&&(r=e[l+1])}return c&&(i=n.x>e[l-2].x?1:n.x===e[l-2].x?0:-1,a=n.y>e[l-2].y?1:n.y===e[l-2].y?0:-1),o.push([`L`,n.x+i*t,n.y+a*t]),o},Bo=(e,t,n)=>(n&&(t=Y(t,[1,0,0,1,-n.x,-n.y])),e.map(e=>{let n=[...e];for(let r=1;r<e.length-1;r+=2){let{x:i,y:a}=Mt({x:e[r],y:e[r+1]},t);n[r]=i,n[r+1]=a}return n})),Vo=(e,t)=>{let n=2*Math.PI/e,r=-Re;e%2==0&&(r+=n/2);let i=Array(e+1);for(let a=0;a<e;a++){let e=a*n+r,{x:o,y:s}=new q(mt(e),ht(e)).scalarMultiply(t);i[a]=[a===0?`M`:`L`,o,s]}return i[e]=[`Z`],i},Ho=(e,t)=>e.map(e=>e.map((e,n)=>n===0||t===void 0?e:X(e,t)).join(` `)).join(` `),Uo=(e,t)=>{let n=e,r=t;n.inverted&&!r.inverted&&(n=t,r=e),Nn(r,r.group?.calcTransformMatrix(),n.calcTransformMatrix());let i=n.inverted&&r.inverted;return i&&(n.inverted=r.inverted=!1),new co([n],{clipPath:r,inverted:i})},Wo=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,Go=(e,t)=>{let n=e._findCenterFromElement();e.transformMatrix&&((e=>{if(e.transformMatrix){let{scaleX:t,scaleY:n,angle:r,skewX:i}=Rt(e.transformMatrix);e.flipX=!1,e.flipY=!1,e.set(nt,t),e.set(rt,n),e.angle=r,e.skewX=i,e.skewY=0}})(e),n=n.transform(e.transformMatrix)),delete e.transformMatrix,t&&(e.scaleX*=t.scaleX,e.scaleY*=t.scaleY,e.cropX=t.cropX,e.cropY=t.cropY,n.x+=t.offsetLeft,n.y+=t.offsetTop,e.width=t.width,e.height=t.height),e.setPositionByOrigin(n,W,W)};be({addTransformToObject:()=>Tn,animate:()=>ki,animateColor:()=>Ai,applyTransformToObject:()=>En,calcAngleBetweenVectors:()=>Vn,calcDimensionsMatrix:()=>Gt,calcPlaneChangeMatrix:()=>An,calcVectorRotation:()=>Hn,cancelAnimFrame:()=>xt,capValue:()=>Rr,composeMatrix:()=>Kt,copyCanvasElement:()=>Et,cos:()=>mt,createCanvasElement:()=>wt,createImage:()=>Tt,createRotateMatrix:()=>Bt,createScaleMatrix:()=>Vt,createSkewXMatrix:()=>Ut,createSkewYMatrix:()=>Wt,createTranslateMatrix:()=>zt,createVector:()=>zn,crossProduct:()=>Gn,degreesToRadians:()=>J,dotProduct:()=>Kn,ease:()=>Hr,enlivenObjectEnlivables:()=>Yt,enlivenObjects:()=>Jt,findScaleToCover:()=>fo,findScaleToFit:()=>uo,getBoundsOfCurve:()=>yo,getOrthonormalVector:()=>Wn,getPathSegmentsInfo:()=>Mo,getPointOnPath:()=>No,getPointer:()=>bn,getRandomInt:()=>Wo,getRegularPolygonPath:()=>Vo,getSmoothPathFromPoints:()=>zo,getSvgAttributes:()=>pr,getUnitVector:()=>Un,groupSVGElements:()=>lo,hasStyleChanged:()=>Ta,invertTransform:()=>Nt,isBetweenVectors:()=>qn,isIdentityMatrix:()=>jt,isTouchEvent:()=>xn,isTransparent:()=>va,joinPath:()=>Ho,loadImage:()=>qt,magnitude:()=>Bn,makeBoundingBoxFromPoints:()=>Cn,makePathSimpler:()=>xo,matrixToSVG:()=>Qt,mergeClipPaths:()=>Uo,multiplyTransformMatrices:()=>Y,multiplyTransformMatrixArray:()=>Pt,parsePath:()=>Ro,parsePreserveAspectRatioAttribute:()=>hr,parseUnit:()=>mr,pick:()=>Xt,projectStrokeOnPoints:()=>Ca,qrDecompose:()=>Rt,radiansToDegrees:()=>At,removeFromArray:()=>pt,removeTransformFromObject:()=>wn,removeTransformMatrixForSvgParsing:()=>Go,requestAnimFrame:()=>bt,resetObjectTransform:()=>Dn,rotateVector:()=>Rn,saveObjectTransform:()=>On,sendObjectToPlane:()=>Nn,sendPointToPlane:()=>jn,sendVectorToPlane:()=>Mn,sin:()=>ht,sizeAfterTransform:()=>kn,string:()=>fn,stylesFromArray:()=>Da,stylesToArray:()=>Ea,toBlob:()=>kt,toDataURL:()=>Ot,toFixed:()=>X,transformPath:()=>Bo,transformPoint:()=>Mt});function Ko(e,t){let n=e.style;n&&Object.entries(t).forEach(([e,t])=>n.setProperty(e,t))}var qo=class extends un{constructor(e,{allowTouchScrolling:t=!1,containerClass:n=``}={}){super(e),H(this,`upper`,void 0),H(this,`container`,void 0);let{el:r}=this.lower,i=this.createUpperCanvas();this.upper={el:i,ctx:i.getContext(`2d`)},this.applyCanvasStyle(r,{allowTouchScrolling:t}),this.applyCanvasStyle(i,{allowTouchScrolling:t,styles:{position:`absolute`,left:`0`,top:`0`}});let a=this.createContainerElement();a.classList.add(n),r.parentNode&&r.parentNode.replaceChild(a,r),a.append(r,i),this.container=a}createUpperCanvas(){let{el:e}=this.lower,t=wt();return t.className=e.className,t.classList.remove(`lower-canvas`),t.classList.add(`upper-canvas`),t.setAttribute(`data-fabric`,`top`),t.style.cssText=e.style.cssText,t.setAttribute(`draggable`,`true`),t}createContainerElement(){let e=Me().createElement(`div`);return e.setAttribute(`data-fabric`,`wrapper`),Ko(e,{position:`relative`}),ln(e),e}applyCanvasStyle(e,t){let{styles:n,allowTouchScrolling:r}=t;Ko(e,{...n,"touch-action":r?`manipulation`:Ge}),ln(e)}setDimensions(e,t){super.setDimensions(e,t);let{el:n,ctx:r}=this.upper;sn(n,r,e,t)}setCSSDimensions(e){super.setCSSDimensions(e),cn(this.upper.el,e),cn(this.container,e)}cleanupDOM(e){let t=this.container,{el:n}=this.lower,{el:r}=this.upper;super.cleanupDOM(e),t.removeChild(r),t.removeChild(n),t.parentNode&&t.parentNode.replaceChild(n,t)}dispose(){super.dispose(),je().dispose(this.upper.el),delete this.upper,delete this.container}},Jo=(e,t,n,r)=>{let{target:i,offsetX:a,offsetY:o}=t,s=n-a,c=r-o,l=!Zn(i,`lockMovementX`)&&i.left!==s,u=!Zn(i,`lockMovementY`)&&i.top!==c;return l&&i.set(`left`,s),u&&i.set(`top`,c),(l||u)&&Pi(qe,Qn(e,t,n,r)),l||u},Yo=$e,Xo=e=>function(t,n,r){let{points:i,pathOffset:a}=r;return new q(i[e]).subtract(a).transform(Y(r.getViewportTransform(),r.calcTransformMatrix()))},Zo=(e,t,n,r)=>{let{target:i,pointIndex:a}=t,o=i,s=jn(new q(n,r),void 0,o.calcOwnMatrix());return o.points[a]=s.add(o.pathOffset),o.setDimensions(),o.set(`dirty`,!0),!0},Qo=(e,t)=>function(n,r,i,a){let o=r.target,s=new q(o.points[(e>0?e:o.points.length)-1]),c=s.subtract(o.pathOffset).transform(o.calcOwnMatrix()),l=t(n,{...r,pointIndex:e},i,a),u=s.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(c);return o.left-=u.x,o.top-=u.y,l},$o=e=>Fi(Yo,Qo(e,Zo));function es(e,t={}){let n={};for(let r=0;r<(typeof e==`number`?e:e.points.length);r++)n[`p${r}`]=new Wi({actionName:Yo,positionHandler:Xo(r),actionHandler:$o(r),...t});return n}var ts=(e,t,n)=>{let{path:r,pathOffset:i}=e,a=r[t];return new q(a[n]-i.x,a[n+1]-i.y).transform(Y(e.getViewportTransform(),e.calcTransformMatrix()))};function ns(e,t,n){let{commandIndex:r,pointIndex:i}=this;return ts(n,r,i)}function rs(e,t,n,r){let{target:i}=t,{commandIndex:a,pointIndex:o}=this,s=((e,t,n,r,i)=>{let{path:a,pathOffset:o}=e,s=a[(r>0?r:a.length)-1],c=new q(s[i],s[i+1]),l=c.subtract(o).transform(e.calcOwnMatrix()),u=jn(new q(t,n),void 0,e.calcOwnMatrix());a[r][i]=u.x+o.x,a[r][i+1]=u.y+o.y,e.setDimensions();let d=c.subtract(e.pathOffset).transform(e.calcOwnMatrix()).subtract(l);return e.left-=d.x,e.top-=d.y,e.set(`dirty`,!0),!0})(i,n,r,a,o);return s&&Pi(this.actionName,{...Qn(e,t,n,r),commandIndex:a,pointIndex:o}),s}var is=class extends Wi{constructor(e){super(e)}render(e,t,n,r,i){let a={...r,cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill};super.render(e,t,n,a,i)}},as=class extends is{constructor(e){super(e)}render(e,t,n,r,i){let{path:a}=i,{commandIndex:o,pointIndex:s,connectToCommandIndex:c,connectToPointIndex:l}=this;e.save(),e.strokeStyle=this.controlStroke,this.connectionDashArray&&e.setLineDash(this.connectionDashArray);let[u]=a[o],d=ts(i,c,l);if(u===`Q`){let r=ts(i,o,s+2);e.moveTo(r.x,r.y),e.lineTo(t,n)}else e.moveTo(t,n);e.lineTo(d.x,d.y),e.stroke(),e.restore(),super.render(e,t,n,r,i)}},os=(e,t,n,r,i,a)=>new(n?as:is)({commandIndex:e,pointIndex:t,actionName:`modifyPath`,positionHandler:ns,actionHandler:rs,connectToCommandIndex:i,connectToPointIndex:a,...r,...n?r.controlPointStyle:r.pointStyle});function ss(e,t={}){let n={},r=`M`;return e.path.forEach((e,i)=>{let a=e[0];switch(a!==`Z`&&(n[`c_${i}_${a}`]=os(i,e.length-2,!1,t)),a){case`C`:n[`c_${i}_C_CP_1`]=os(i,1,!0,t,i-1,(e=>e===`C`?5:e===`Q`?3:1)(r)),n[`c_${i}_C_CP_2`]=os(i,3,!0,t,i,5);break;case`Q`:n[`c_${i}_Q_CP_1`]=os(i,1,!0,t,i,3)}r=a}),n}be({changeHeight:()=>Vi,changeObjectHeight:()=>zi,changeObjectWidth:()=>Ri,changeWidth:()=>Bi,createObjectDefaultControls:()=>fa,createPathControls:()=>ss,createPolyActionHandler:()=>$o,createPolyControls:()=>es,createPolyPositionHandler:()=>Xo,createResizeControls:()=>pa,createTextboxDefaultControls:()=>ma,dragHandler:()=>Jo,factoryPolyActionHandler:()=>Qo,getLocalPoint:()=>er,polyActionHandler:()=>Zo,renderCircleControl:()=>Hi,renderSquareControl:()=>Ui,rotationStyleHandler:()=>Gi,rotationWithSnapping:()=>Ki,scaleCursorStyleHandler:()=>Xi,scaleOrSkewActionName:()=>ca,scaleSkewCursorStyleHandler:()=>la,scalingEqually:()=>Qi,scalingX:()=>$i,scalingXOrSkewingY:()=>ua,scalingY:()=>ea,scalingYOrSkewingX:()=>da,skewCursorStyleHandler:()=>ra,skewHandlerX:()=>aa,skewHandlerY:()=>oa,wrapWithFireEvent:()=>Fi,wrapWithFixedAnchor:()=>Ii});var cs=class e extends vn{constructor(...e){super(...e),H(this,`_hoveredTargets`,[]),H(this,`_currentTransform`,null),H(this,`_groupSelector`,null),H(this,`contextTopDirty`,!1)}static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}get upperCanvasEl(){return this.elements.upper?.el}get contextTop(){return this.elements.upper?.ctx}get wrapperEl(){return this.elements.container}initElements(e){this.elements=new qo(e,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(e){this._objectsToRender=void 0,super._onObjectAdded(e)}_onObjectRemoved(e){this._objectsToRender=void 0,e===this._activeObject&&(this.fire(`before:selection:cleared`,{deselected:[e]}),this._discardActiveObject(),this.fire(`selection:cleared`,{deselected:[e]}),e.fire(`deselected`,{target:e})),e===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(e)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){let e=this._activeObject;return!this.preserveObjectStacking&&e?this._objects.filter(t=>!t.group&&t!==e).concat(e):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&=(this.renderTopLayer(this.contextTop),!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(e){e.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(e),this.contextTopDirty=!0),e.restore()}renderTop(){let e=this.contextTop;this.clearContext(e),this.renderTopLayer(e),this.fire(`after:render`,{ctx:e})}setTargetFindTolerance(e){e=Math.round(e),this.targetFindTolerance=e;let t=this.getRetinaScaling(),n=Math.ceil((2*e+1)*t);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=n,this.pixelFindContext.scale(t,t)}isTargetTransparent(e,t,n){let r=this.targetFindTolerance,i=this.pixelFindContext;this.clearContext(i),i.save(),i.translate(-t+r,-n+r),i.transform(...this.viewportTransform);let a=e.selectionBackgroundColor;e.selectionBackgroundColor=``,e.render(i),e.selectionBackgroundColor=a,i.restore();let o=Math.round(r*this.getRetinaScaling());return va(i,o,o,o)}_isSelectionKeyPressed(e){let t=this.selectionKey;return!!t&&(Array.isArray(t)?!!t.find(t=>!!t&&!0===e[t]):e[t])}_shouldClearSelection(e,t){let n=this.getActiveObjects(),r=this._activeObject;return!!(!t||t&&r&&n.length>1&&n.indexOf(t)===-1&&r!==t&&!this._isSelectionKeyPressed(e)||t&&!t.evented||t&&!t.selectable&&r&&r!==t)}_shouldCenterTransform(e,t,n){if(!e)return;let r;return t===`scale`||t===`scaleX`||t===`scaleY`||t===`resizing`?r=this.centeredScaling||e.centeredScaling:t===`rotate`&&(r=this.centeredRotation||e.centeredRotation),r?!n:n}_getOriginFromCorner(e,t){let n=t?e.controls[t].getTransformAnchorPoint():{x:e.originX,y:e.originY};return t?([`ml`,`tl`,`bl`].includes(t)?n.x=We:[`mr`,`tr`,`br`].includes(t)&&(n.x=G),[`tl`,`mt`,`tr`].includes(t)?n.y=Ue:[`bl`,`mb`,`br`].includes(t)&&(n.y=`top`),n):n}_setupCurrentTransform(e,t,n){let r=t.group?jn(this.getScenePoint(e),void 0,t.group.calcTransformMatrix()):this.getScenePoint(e),{key:i=``,control:a}=t.getActiveControl()||{},o=n&&a?a.getActionHandler(e,t,a)?.bind(a):Jo,s=((e,t,n,r)=>{if(!t||!e)return`drag`;let i=r.controls[t];return i.getActionName(n,i,r)})(n,i,e,t),c=e[this.centeredKey],l=this._shouldCenterTransform(t,s,c)?{x:W,y:W}:this._getOriginFromCorner(t,i),{scaleX:u,scaleY:d,skewX:f,skewY:p,left:m,top:h,angle:g,width:_,height:v,cropX:y,cropY:b}=t,x={target:t,action:s,actionHandler:o,actionPerformed:!1,corner:i,scaleX:u,scaleY:d,skewX:f,skewY:p,offsetX:r.x-m,offsetY:r.y-h,originX:l.x,originY:l.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:J(g),width:_,height:v,shiftKey:e.shiftKey,altKey:c,original:{...On(t),originX:l.x,originY:l.y,cropX:y,cropY:b}};this._currentTransform=x,this.fire(`before:transform`,{e,transform:x})}setCursor(e){this.upperCanvasEl.style.cursor=e}_drawSelection(e){let{x:t,y:n,deltaX:r,deltaY:i}=this._groupSelector,a=new q(t,n).transform(this.viewportTransform),o=new q(t+r,n+i).transform(this.viewportTransform),s=this.selectionLineWidth/2,c=Math.min(a.x,o.x),l=Math.min(a.y,o.y),u=Math.max(a.x,o.x),d=Math.max(a.y,o.y);this.selectionColor&&(e.fillStyle=this.selectionColor,e.fillRect(c,l,u-c,d-l)),this.selectionLineWidth&&this.selectionBorderColor&&(e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor,c+=s,l+=s,u-=s,d-=s,_a.prototype._setLineDash.call(this,e,this.selectionDashArray),e.strokeRect(c,l,u-c,d-l))}findTarget(e){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};let t=this.getScenePoint(e),n=this._activeObject,r=this.getActiveObjects(),i=this.searchPossibleTargets(this._objects,t),{subTargets:a,container:o,target:s}=i,c={...i,currentSubTargets:a,currentContainer:o,currentTarget:s};if(!n)return c;let l={...this.searchPossibleTargets([n],t),currentSubTargets:a,currentContainer:o,currentTarget:s};return n.findControl(this.getViewportPoint(e),xn(e))?{...l,target:n}:l.target&&(r.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&e[this.altSelectionKey])?l:c}_pointIsInObjectSelectionArea(e,t){let n=e.getCoords(),r=this.getZoom(),i=e.padding/r;if(i){let[e,t,r,a]=n,o=Math.atan2(t.y-e.y,t.x-e.x),s=mt(o)*i,c=ht(o)*i,l=s+c,u=s-c;n=[new q(e.x-u,e.y-l),new q(t.x+l,t.y-u),new q(r.x+u,r.y+l),new q(a.x-l,a.y+u)]}return ji.isPointInPolygon(t,n)}_checkTarget(e,t){if(e&&e.visible&&e.evented&&this._pointIsInObjectSelectionArea(e,t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;{let n=t.transform(this.viewportTransform);if(!this.isTargetTransparent(e,n.x,n.y))return!0}}return!1}_searchPossibleTargets(e,t,n){let r=e.length;for(;r--;){let i=e[r];if(this._checkTarget(i,t)){if(_t(i)&&i.subTargetCheck){let{target:e}=this._searchPossibleTargets(i._objects,t,n);e&&n.push(e)}return{target:i,subTargets:n}}}return{subTargets:[]}}searchPossibleTargets(e,t){let n=this._searchPossibleTargets(e,t,[]);n.container=n.target;let{container:r,subTargets:i}=n;if(r&&_t(r)&&r.interactive&&i[0]){for(let e=i.length-1;e>0;e--){let t=i[e];if(!_t(t)||!t.interactive)return n.target=t,n}return n.target=i[0],n}return n}getViewportPoint(e){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(e,!0)}getScenePoint(e){return this._scenePoint?this._scenePoint:this._getPointerImpl(e)}_getPointerImpl(e,t=!1){let n=this.upperCanvasEl,r=n.getBoundingClientRect(),i=bn(e),a=r.width||0,o=r.height||0;a&&o||(`top`in r&&`bottom`in r&&(o=Math.abs(r.top-r.bottom)),`right`in r&&`left`in r&&(a=Math.abs(r.right-r.left))),this.calcOffset(),i.x-=this._offset.left,i.y-=this._offset.top,t||(i=jn(i,void 0,this.viewportTransform));let s=this.getRetinaScaling();s!==1&&(i.x/=s,i.y/=s);let c=a===0||o===0?new q(1,1):new q(n.width/a,n.height/o);return i.multiply(c)}_setDimensionsImpl(e,t){this._resetTransformEventData(),super._setDimensionsImpl(e,t),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=wt(),this.pixelFindContext=this.pixelFindCanvasEl.getContext(`2d`,{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){let e=this._activeObject;return nn(e)?e.getObjects():e?[e]:[]}_fireSelectionEvents(e,t){let n=!1,r=!1,i=this.getActiveObjects(),a=[],o=[];e.forEach(e=>{i.includes(e)||(n=!0,e.fire(`deselected`,{e:t,target:e}),o.push(e))}),i.forEach(r=>{e.includes(r)||(n=!0,r.fire(`selected`,{e:t,target:r}),a.push(r))}),e.length>0&&i.length>0?(r=!0,n&&this.fire(`selection:updated`,{e:t,selected:a,deselected:o})):i.length>0?(r=!0,this.fire(`selection:created`,{e:t,selected:a})):e.length>0&&(r=!0,this.fire(`selection:cleared`,{e:t,deselected:o})),r&&(this._objectsToRender=void 0)}setActiveObject(e,t){let n=this.getActiveObjects(),r=this._setActiveObject(e,t);return this._fireSelectionEvents(n,t),r}_setActiveObject(e,t){let n=this._activeObject;return n!==e&&!(!this._discardActiveObject(t,e)&&this._activeObject)&&!e.onSelect({e:t})&&(this._activeObject=e,nn(e)&&n!==e&&e.set(`canvas`,this),e.setCoords(),!0)}_discardActiveObject(e,t){let n=this._activeObject;return!!n&&!n.onDeselect({e,object:t})&&(this._currentTransform&&this._currentTransform.target===n&&this.endCurrentTransform(e),nn(n)&&n===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(e){let t=this.getActiveObjects(),n=this.getActiveObject();t.length&&this.fire(`before:selection:cleared`,{e,deselected:[n]});let r=this._discardActiveObject(e);return this._fireSelectionEvents(t,e),r}endCurrentTransform(e){let t=this._currentTransform;this._finalizeCurrentTransform(e),t&&t.target&&(t.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(e){let t=this._currentTransform,n=t.target,r={e,target:n,transform:t,action:t.action};n._scaling&&=!1,n.setCoords(),t.actionPerformed&&(this.fire(`object:modified`,r),n.fire(ct,r))}setViewportTransform(e){super.setViewportTransform(e);let t=this._activeObject;t&&t.setCoords()}destroy(){let e=this._activeObject;nn(e)&&(e.removeAll(),e.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(e){let t=this._activeObject;t&&t._renderControls(e)}_toObject(e,t,n){let r=this._realizeGroupTransformOnObject(e),i=super._toObject(e,t,n);return e.set(r),i}_realizeGroupTransformOnObject(e){let{group:t}=e;if(t&&nn(t)&&this._activeObject===t){let n=Xt(e,[`angle`,`flipX`,`flipY`,G,nt,rt,it,at,`top`]);return Tn(e,t.calcOwnMatrix()),n}return{}}_setSVGObject(e,t,n){let r=this._realizeGroupTransformOnObject(t);super._setSVGObject(e,t,n),t.set(r)}};H(cs,`ownDefaults`,{uniformScaling:!0,uniScaleKey:`shiftKey`,centeredScaling:!1,centeredRotation:!1,centeredKey:`altKey`,altActionKey:`shiftKey`,selection:!0,selectionKey:`shiftKey`,selectionColor:`rgba(100, 100, 255, 0.3)`,selectionDashArray:[],selectionBorderColor:`rgba(255, 255, 255, 0.3)`,selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:`move`,moveCursor:`move`,defaultCursor:`default`,freeDrawingCursor:`crosshair`,notAllowedCursor:`not-allowed`,perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:`canvas-container`,preserveObjectStacking:!0});var ls=class{constructor(e){H(this,`targets`,[]),H(this,`__disposer`,void 0);let t=()=>{let{hiddenTextarea:t}=e.getActiveObject()||{};t&&t.focus()},n=e.upperCanvasEl;n.addEventListener(`click`,t),this.__disposer=()=>n.removeEventListener(`click`,t)}exitTextEditing(){this.target=void 0,this.targets.forEach(e=>{e.isEditing&&e.exitEditing()})}add(e){this.targets.push(e)}remove(e){this.unregister(e),pt(this.targets,e)}register(e){this.target=e}unregister(e){e===this.target&&(this.target=void 0)}onMouseMove(e){var t;(t=this.target)!=null&&t.isEditing&&this.target.updateSelectionOnMouseMove(e)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}},us={passive:!1},ds=(e,t)=>({viewportPoint:e.getViewportPoint(t),scenePoint:e.getScenePoint(t)}),fs=(e,...t)=>e.addEventListener(...t),ps=(e,...t)=>e.removeEventListener(...t),ms={mouse:{in:`over`,out:`out`,targetIn:`mouseover`,targetOut:`mouseout`,canvasIn:`mouse:over`,canvasOut:`mouse:out`},drag:{in:`enter`,out:`leave`,targetIn:`dragenter`,targetOut:`dragleave`,canvasIn:`drag:enter`,canvasOut:`drag:leave`}},hs=class extends cs{constructor(e,t={}){super(e,t),H(this,`_isClick`,void 0),H(this,`textEditingManager`,new ls(this)),[`_onMouseDown`,`_onTouchStart`,`_onMouseMove`,`_onMouseUp`,`_onTouchEnd`,`_onResize`,`_onMouseWheel`,`_onMouseOut`,`_onMouseEnter`,`_onContextMenu`,`_onClick`,`_onDragStart`,`_onDragEnd`,`_onDragProgress`,`_onDragOver`,`_onDragEnter`,`_onDragLeave`,`_onDrop`].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(fs)}_getEventPrefix(){return this.enablePointerEvents?`pointer`:`mouse`}addOrRemove(e,t=!1){let n=this.upperCanvasEl,r=this._getEventPrefix();e(on(n),`resize`,this._onResize),e(n,r+`down`,this._onMouseDown),e(n,`${r}move`,this._onMouseMove,us),e(n,`${r}out`,this._onMouseOut),e(n,`${r}enter`,this._onMouseEnter),e(n,`wheel`,this._onMouseWheel,{passive:!1}),e(n,`contextmenu`,this._onContextMenu),t||(e(n,`click`,this._onClick),e(n,`dblclick`,this._onClick)),e(n,`dragstart`,this._onDragStart),e(n,`dragend`,this._onDragEnd),e(n,`dragover`,this._onDragOver),e(n,`dragenter`,this._onDragEnter),e(n,`dragleave`,this._onDragLeave),e(n,`drop`,this._onDrop),this.enablePointerEvents||e(n,`touchstart`,this._onTouchStart,us)}removeListeners(){this.addOrRemove(ps);let e=this._getEventPrefix(),t=an(this.upperCanvasEl);ps(t,`${e}up`,this._onMouseUp),ps(t,`touchend`,this._onTouchEnd,us),ps(t,`${e}move`,this._onMouseMove,us),ps(t,`touchmove`,this._onMouseMove,us),clearTimeout(this._willAddMouseDown)}_onMouseWheel(e){this._cacheTransformEventData(e),this._handleEvent(e,`wheel`),this._resetTransformEventData()}_onMouseOut(e){let t=this._hoveredTarget,n={e,...ds(this,e)};this.fire(`mouse:out`,{...n,target:t}),this._hoveredTarget=void 0,t&&t.fire(`mouseout`,{...n}),this._hoveredTargets.forEach(e=>{this.fire(`mouse:out`,{...n,target:e}),e&&e.fire(`mouseout`,{...n})}),this._hoveredTargets=[]}_onMouseEnter(e){let{target:t}=this.findTarget(e);this._currentTransform||t||(this.fire(`mouse:over`,{e,...ds(this,e)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(e){this._isClick=!1;let t=this.getActiveObject();if(t&&t.onDragStart(e)){this._dragSource=t;let n={e,target:t};this.fire(`dragstart`,n),t.fire(`dragstart`,n),fs(this.upperCanvasEl,`drag`,this._onDragProgress);return}Sn(e)}_renderDragEffects(e,t,n){let r=!1,i=this._dropTarget;i&&i!==t&&i!==n&&(i.clearContextTop(),r=!0),t?.clearContextTop(),n!==t&&n?.clearContextTop();let a=this.contextTop;a.save(),a.transform(...this.viewportTransform),t&&(a.save(),t.transform(a),t.renderDragSourceEffect(e),a.restore(),r=!0),n&&(a.save(),n.transform(a),n.renderDropTargetEffect(e),a.restore(),r=!0),a.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(e){let{currentSubTargets:t}=this.findTarget(e),n=!!e.dataTransfer&&e.dataTransfer.dropEffect!==`none`,r=n?this._activeObject:void 0,i={e,target:this._dragSource,subTargets:t,dragSource:this._dragSource,didDrop:n,dropTarget:r};ps(this.upperCanvasEl,`drag`,this._onDragProgress),this.fire(`dragend`,i),this._dragSource&&this._dragSource.fire(`dragend`,i),delete this._dragSource,this._onMouseUp(e)}_onDragProgress(e){let t={e,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire(`drag`,t),this._dragSource&&this._dragSource.fire(`drag`,t)}_onDragOver(e){let t=`dragover`,{currentContainer:n,currentSubTargets:r}=this.findTarget(e),i=this._dragSource,a={e,target:n,subTargets:r,dragSource:i,canDrop:!1,dropTarget:void 0},o;this.fire(t,a),this._fireEnterLeaveEvents(e,n,a),n&&(n.canDrop(e)&&(o=n),n.fire(t,a));for(let n=0;n<r.length;n++){let i=r[n];i.canDrop(e)&&(o=i),i.fire(t,a)}this._renderDragEffects(e,i,o),this._dropTarget=o}_onDragEnter(e){let{currentContainer:t,currentSubTargets:n}=this.findTarget(e),r={e,target:t,subTargets:n,dragSource:this._dragSource};this.fire(`dragenter`,r),this._fireEnterLeaveEvents(e,t,r)}_onDragLeave(e){let{currentSubTargets:t}=this.findTarget(e),n={e,target:this._draggedoverTarget,subTargets:t,dragSource:this._dragSource};this.fire(`dragleave`,n),this._fireEnterLeaveEvents(e,void 0,n),this._renderDragEffects(e,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(e){let{currentContainer:t,currentSubTargets:n}=this.findTarget(e),r=this._basicEventHandler(`drop:before`,{e,target:t,subTargets:n,dragSource:this._dragSource,...ds(this,e)});r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler(`drop`,r),this.fire(`drop:after`,r)}_onContextMenu(e){let{target:t,subTargets:n}=this.findTarget(e),r=this._basicEventHandler(`contextmenu:before`,{e,target:t,subTargets:n});return this.stopContextMenu&&Sn(e),this._basicEventHandler(`contextmenu`,r),!1}_onClick(e){let t=e.detail;t>3||t<2||(this._cacheTransformEventData(e),t==2&&e.type===`dblclick`&&this._handleEvent(e,`dblclick`),t==3&&this._handleEvent(e,`tripleclick`),this._resetTransformEventData())}fireEventFromPointerEvent(e,t,n,r={}){this._cacheTransformEventData(e);let{target:i,subTargets:a}=this.findTarget(e),o={e,target:i,subTargets:a,...ds(this,e),transform:this._currentTransform,...r};this.fire(t,o),i&&i.fire(n,o);for(let e=0;e<a.length;e++)a[e]!==i&&a[e].fire(n,o);this._resetTransformEventData()}getPointerId(e){let t=e.changedTouches;return t?t[0]&&t[0].identifier:this.enablePointerEvents?e.pointerId:-1}_isMainEvent(e){return!0===e.isPrimary||!1!==e.isPrimary&&(e.type===`touchend`&&e.touches.length===0||!e.changedTouches||e.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(e){this._cacheTransformEventData(e);let t=!this.allowTouchScrolling,n=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(e)),this.__onMouseDown(e);let{target:r}=this.findTarget(e);(this.isDrawingMode||n&&r===n)&&(t=!0),t&&e.preventDefault();let i=this.upperCanvasEl,a=this._getEventPrefix(),o=an(i);fs(o,`touchend`,this._onTouchEnd,us),t&&fs(o,`touchmove`,this._onMouseMove,us),ps(i,`${a}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(e){this._cacheTransformEventData(e),this.__onMouseDown(e);let t=this.upperCanvasEl,n=this._getEventPrefix();ps(t,`${n}move`,this._onMouseMove,us);let r=an(t);fs(r,`${n}up`,this._onMouseUp),fs(r,`${n}move`,this._onMouseMove,us),this._resetTransformEventData()}_onTouchEnd(e){if(e.touches.length>0)return;this._cacheTransformEventData(e),this.__onMouseUp(e),this._resetTransformEventData(),delete this.mainTouchId;let t=this._getEventPrefix(),n=an(this.upperCanvasEl);ps(n,`touchend`,this._onTouchEnd,us),ps(n,`touchmove`,this._onMouseMove,us),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{fs(this.upperCanvasEl,`${t}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(e){this._cacheTransformEventData(e),this.__onMouseUp(e);let t=this.upperCanvasEl,n=this._getEventPrefix();if(this._isMainEvent(e)){let e=an(this.upperCanvasEl);ps(e,`${n}up`,this._onMouseUp),ps(e,`${n}move`,this._onMouseMove,us),fs(t,`${n}move`,this._onMouseMove,us)}this._resetTransformEventData()}_onMouseMove(e){this._cacheTransformEventData(e);let t=this.getActiveObject();!this.allowTouchScrolling&&(!t||!t.shouldStartDragging(e))&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(e){let t=this.getActiveObject();return!!t!=!!e||t&&e&&t!==e}__onMouseUp(e){var t;this._handleEvent(e,`up:before`);let n=this._currentTransform,r=this._isClick,{target:i}=this.findTarget(e),{button:a}=e;if(a)return void((this.fireMiddleClick&&a===1||this.fireRightClick&&a===2)&&this._handleEvent(e,`up`));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(e);if(!this._isMainEvent(e))return;let o,s,c=!1;if(n&&(this._finalizeCurrentTransform(e),c=n.actionPerformed),!r){let t=i===this._activeObject;this.handleSelection(e),c||=this._shouldRender(i)||!t&&i===this._activeObject}if(i){let{key:t,control:r}=i.findControl(this.getViewportPoint(e),xn(e))||{};if(s=t,i.selectable&&i!==this._activeObject&&i.activeOn===`up`)this.setActiveObject(i,e),c=!0;else if(r){let t=r.getMouseUpHandler(e,i,r);t&&(o=this.getScenePoint(e),t.call(r,e,n,o.x,o.y))}i.isMoving=!1}if(n&&(n.target!==i||n.corner!==s)){let t=n.target&&n.target.controls[n.corner],r=t&&t.getMouseUpHandler(e,n.target,t);o||=this.getScenePoint(e),r&&r.call(t,e,n,o.x,o.y)}this._setCursorFromEvent(e,i),this._handleEvent(e,`up`),this._groupSelector=null,this._currentTransform=null,i&&(i.__corner=void 0),c?this.requestRenderAll():r||(t=this._activeObject)!=null&&t.isEditing||this.renderTop()}_basicEventHandler(e,t){let{target:n,subTargets:r=[]}=t;this.fire(e,t),n&&n.fire(e,t);for(let i=0;i<r.length;i++)r[i]!==n&&r[i].fire(e,t);return t}_handleEvent(e,t,n){let{target:r,subTargets:i}=this.findTarget(e),a={e,target:r,subTargets:i,...ds(this,e),transform:this._currentTransform,...t===`down:before`||t===`down`?n:{}};t!==`up:before`&&t!==`up`||(a.isClick=this._isClick),this.fire(`mouse:${t}`,a),r&&r.fire(`mouse${t}`,a);for(let e=0;e<i.length;e++)i[e]!==r&&i[e].fire(`mouse${t}`,a)}_onMouseDownInDrawingMode(e){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(e),this.requestRenderAll());let t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(t,{e,pointer:t}),this._handleEvent(e,`down`,{alreadySelected:!1})}_onMouseMoveInDrawingMode(e){if(this._isCurrentlyDrawing){let t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(t,{e,pointer:t})}this.setCursor(this.freeDrawingCursor),this._handleEvent(e,`move`)}_onMouseUpInDrawingMode(e){let t=this.getScenePoint(e);this._isCurrentlyDrawing=this.freeDrawingBrush?!!this.freeDrawingBrush.onMouseUp({e,pointer:t}):!1,this._handleEvent(e,`up`)}__onMouseDown(e){this._isClick=!0,this._handleEvent(e,`down:before`);let{target:t}=this.findTarget(e),n=!!t&&t===this._activeObject,{button:r}=e;if(r)return void((this.fireMiddleClick&&r===1||this.fireRightClick&&r===2)&&this._handleEvent(e,`down`,{alreadySelected:n}));if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(e);if(!this._isMainEvent(e)||this._currentTransform)return;let i=this._shouldRender(t),a=!1;if(this.handleMultiSelection(e,t)?(t=this._activeObject,a=!0,i=!0):this._shouldClearSelection(e,t)&&this.discardActiveObject(e),this.selection&&(!t||!t.selectable&&!t.isEditing&&t!==this._activeObject)){let t=this.getScenePoint(e);this._groupSelector={x:t.x,y:t.y,deltaY:0,deltaX:0}}if(n=!!t&&t===this._activeObject,t){t.selectable&&t.activeOn===`down`&&this.setActiveObject(t,e);let r=t.findControl(this.getViewportPoint(e),xn(e));if(t===this._activeObject&&(r||!a)){this._setupCurrentTransform(e,t,n);let i=r?r.control:void 0,a=this.getScenePoint(e),o=i&&i.getMouseDownHandler(e,t,i);o&&o.call(i,e,this._currentTransform,a.x,a.y)}}i&&(this._objectsToRender=void 0),this._handleEvent(e,`down`,{alreadySelected:n}),i&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(e){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(e),this._scenePoint=jn(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(e),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(e){if(this._isClick=!1,this._handleEvent(e,`move:before`),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(e);if(!this._isMainEvent(e))return;let t=this._groupSelector;if(t){let n=this.getScenePoint(e);t.deltaX=n.x-t.x,t.deltaY=n.y-t.y,this.renderTop()}else if(this._currentTransform)this._transformObject(e);else{let{target:t}=this.findTarget(e);this._setCursorFromEvent(e,t),this._fireOverOutEvents(e,t)}this.textEditingManager.onMouseMove(e),this._handleEvent(e,`move`)}_fireOverOutEvents(e,t){let{_hoveredTarget:n,_hoveredTargets:r}=this,{subTargets:i,currentTarget:a}=this.findTarget(e),o=Math.max(r.length,i.length);this.fireSyntheticInOutEvents(`mouse`,{e,target:t,oldTarget:n,actualTarget:a,oldActualTarget:this._hoveredActualTarget,fireCanvas:!0});for(let a=0;a<o;a++)i[a]===t||r[a]&&r[a]===n||this.fireSyntheticInOutEvents(`mouse`,{e,target:i[a],oldTarget:r[a]});this._hoveredActualTarget=a,this._hoveredTarget=t,this._hoveredTargets=i}_fireEnterLeaveEvents(e,t,n){let r=this._draggedoverTarget,i=this._hoveredTargets,{subTargets:a}=this.findTarget(e),o=Math.max(i.length,a.length);this.fireSyntheticInOutEvents(`drag`,{...n,target:t,oldTarget:r,fireCanvas:!0});for(let e=0;e<o;e++)this.fireSyntheticInOutEvents(`drag`,{...n,target:a[e],oldTarget:i[e]});this._draggedoverTarget=t}fireSyntheticInOutEvents(e,{target:t,oldTarget:n,actualTarget:r,oldActualTarget:i,fireCanvas:a,e:o,...s}){let{targetIn:c,targetOut:l,canvasIn:u,canvasOut:d}=ms[e],f=n!==t,p=i!==r,m=t&&f,h=r&&p,g=n&&f,_=i&&p,v={...s,e:o,...ds(this,o)},y={...v,target:n,nextTarget:t,actualTarget:i,nextActualTarget:r};(g||_)&&a&&this.fire(d,y),g&&n.fire(l,y),_&&n!==i&&i.fire(l,y);let b={...v,target:t,previousTarget:n,actualTarget:r,previousActualTarget:i};(m||h)&&a&&this.fire(u,b),m&&t.fire(c,b),h&&r!==t&&r.fire(c,b)}_transformObject(e){let t=this.getScenePoint(e),n=this._currentTransform,r=n.target,i=r.group?jn(t,void 0,r.group.calcTransformMatrix()):t;n.shiftKey=e.shiftKey,n.altKey=!!this.centeredKey&&e[this.centeredKey],this._performTransformAction(e,n,i),n.actionPerformed&&this.requestRenderAll()}_performTransformAction(e,t,n){let{action:r,actionHandler:i,target:a}=t,o=!!i&&i(e,t,n.x,n.y);o&&a.setCoords(),r===`drag`&&o&&(t.target.isMoving=!0,this.setCursor(t.target.moveCursor||this.moveCursor)),t.actionPerformed=t.actionPerformed||o}_setCursorFromEvent(e,t){if(!t)return void this.setCursor(this.defaultCursor);let n=t.hoverCursor||this.hoverCursor,r=nn(this._activeObject)?this._activeObject:null,i=(!r||t.group!==r)&&t.findControl(this.getViewportPoint(e));if(i){let{control:n,coord:r}=i;this.setCursor(n.cursorStyleHandler(e,n,t,r))}else{if(t.subTargetCheck){let{subTargets:t}=this.findTarget(e);t.concat().reverse().forEach(e=>{n=e.hoverCursor||n})}this.setCursor(n)}}handleMultiSelection(e,t){let n=this._activeObject,r=nn(n);if(n&&this._isSelectionKeyPressed(e)&&this.selection&&t&&t.selectable&&(n!==t||r)&&(r||!t.isDescendantOf(n)&&!n.isDescendantOf(t))&&!t.onSelect({e})&&!n.getActiveControl()){if(r){let r=n.getObjects(),i=[];if(t===n){let n=this.getScenePoint(e),a=this.searchPossibleTargets(r,n);if(a.target?(t=a.target,i=a.subTargets):(a=this.searchPossibleTargets(this._objects,n),t=a.target,i=a.subTargets),!t||!t.selectable)return!1}t.group===n?(n.remove(t),this._hoveredTarget=t,this._hoveredTargets=i,n.size()===1&&this._setActiveObject(n.item(0),e)):(n.multiSelectAdd(t),this._hoveredTarget=n,this._hoveredTargets=i),this._fireSelectionEvents(r,e)}else{n.isEditing&&n.exitEditing();let r=new(K.getClass(`ActiveSelection`))([],{canvas:this});r.multiSelectAdd(n,t),this._hoveredTarget=r,this._setActiveObject(r,e),this._fireSelectionEvents([n],e)}return!0}return!1}handleSelection(e){if(!this.selection||!this._groupSelector)return!1;let{x:t,y:n,deltaX:r,deltaY:i}=this._groupSelector,a=new q(t,n),o=a.add(new q(r,i)),s=a.min(o),c=a.max(o).subtract(s),l=this.collectObjects({left:s.x,top:s.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=a.eq(o)?l[0]?[l[0]]:[]:l.length>1?l.filter(t=>!t.onSelect({e})).reverse():l;if(u.length===1)this.setActiveObject(u[0],e);else if(u.length>1){let t=K.getClass(`ActiveSelection`);this.setActiveObject(new t(u,{canvas:this}),e)}return this._groupSelector=null,!0}toCanvasElement(e=1,t){let{upper:n}=this.elements;n.ctx=void 0;let r=super.toCanvasElement(e,t);return n.ctx=n.el.getContext(`2d`),r}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}},gs={x1:0,y1:0,x2:0,y2:0},_s={...gs,r1:0,r2:0},vs=(e,t)=>isNaN(e)&&typeof t==`number`?t:e;function ys(e){return e&&/%$/.test(e)&&Number.isFinite(parseFloat(e))}function bs(e,t){return Rr(0,vs(typeof e==`number`?e:typeof e==`string`?parseFloat(e)/(ys(e)?100:1):NaN,t),1)}var xs=/\s*;\s*/,Ss=/\s*:\s*/;function Cs(e,t){let n,r,i=e.getAttribute(`style`);if(i){let e=i.split(xs);e[e.length-1]===``&&e.pop();for(let t=e.length;t--;){let[i,a]=e[t].split(Ss).map(e=>e.trim());i===`stop-color`?n=a:i===`stop-opacity`&&(r=a)}}n=n||e.getAttribute(`stop-color`)||`rgb(0,0,0)`,r=vs(parseFloat(r||e.getAttribute(`stop-opacity`)||``),1);let a=new fr(n);return a.setAlpha(a.getAlpha()*r*t),{offset:bs(e.getAttribute(`offset`),0),color:a.toRgba()}}function ws(e,t){let n=[],r=e.getElementsByTagName(`stop`),i=bs(t,1);for(let e=r.length;e--;)n.push(Cs(r[e],i));return n}function Ts(e){return e.nodeName===`linearGradient`||e.nodeName===`LINEARGRADIENT`?`linear`:`radial`}function Es(e){return e.getAttribute(`gradientUnits`)===`userSpaceOnUse`?`pixels`:`percentage`}function Ds(e,t){return e.getAttribute(t)}function Os(e,t){return function(e,{width:t,height:n,gradientUnits:r}){let i;return Object.entries(e).reduce((e,[a,o])=>{if(o===`Infinity`)i=1;else if(o===`-Infinity`)i=0;else{let e=typeof o==`string`;i=e?parseFloat(o):o,e&&ys(o)&&(i*=.01,r===`pixels`&&(a!==`x1`&&a!==`x2`&&a!==`r2`||(i*=t),a!==`y1`&&a!==`y2`||(i*=n)))}return e[a]=i,e},{})}(Ts(e)===`linear`?function(e){return{x1:Ds(e,`x1`)||0,y1:Ds(e,`y1`)||0,x2:Ds(e,`x2`)||`100%`,y2:Ds(e,`y2`)||0}}(e):function(e){return{x1:Ds(e,`fx`)||Ds(e,`cx`)||`50%`,y1:Ds(e,`fy`)||Ds(e,`cy`)||`50%`,r1:0,x2:Ds(e,`cx`)||`50%`,y2:Ds(e,`cy`)||`50%`,r2:Ds(e,`r`)||`50%`}}(e),{...t,gradientUnits:Es(e)})}var ks=class{constructor(e){let{type:t=`linear`,gradientUnits:n=`pixels`,coords:r={},colorStops:i=[],offsetX:a=0,offsetY:o=0,gradientTransform:s,id:c}=e||{};Object.assign(this,{type:t,gradientUnits:n,coords:{...t===`radial`?_s:gs,...r},colorStops:i,offsetX:a,offsetY:o,gradientTransform:s,id:c?`${c}_${Ct()}`:Ct()})}addColorStop(e){for(let t in e)this.colorStops.push({offset:parseFloat(t),color:e[t]});return this}toObject(e){return{...Xt(this,e),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(e=>({...e})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(e,{additionalTransform:t}={}){let n=[],r=this.gradientTransform?this.gradientTransform.concat():He.concat(),i=this.gradientUnits===`pixels`?`userSpaceOnUse`:`objectBoundingBox`,a=this.colorStops.map(e=>({...e})).sort((e,t)=>e.offset-t.offset),o=-this.offsetX,s=-this.offsetY;var c;i===`objectBoundingBox`?(o/=e.width,s/=e.height):(o+=e.width/2,s+=e.height/2),(c=e)&&typeof c._renderPathCommands==`function`&&this.gradientUnits!==`percentage`&&(o-=e.pathOffset.x,s-=e.pathOffset.y),r[4]-=o,r[5]-=s;let l=[`id="SVGID_${Z(String(this.id))}"`,`gradientUnits="${i}"`,`gradientTransform="${t?t+` `:``}${Qt(r)}"`,``].join(` `),u=e=>parseFloat(String(e));if(this.type===`linear`){let{x1:e,y1:t,x2:r,y2:i}=this.coords,a=u(e),o=u(t),s=u(r),c=u(i);n.push(`<linearGradient `,l,` x1="`,a,`" y1="`,o,`" x2="`,s,`" y2="`,c,`">
|
|
19
|
+
`)}else if(this.type===`radial`){let{x1:e,y1:t,x2:r,y2:i,r1:o,r2:s}=this.coords,c=u(e),d=u(t),f=u(r),p=u(i),m=u(o),h=u(s),g=m>h;n.push(`<radialGradient `,l,` cx="`,g?c:f,`" cy="`,g?d:p,`" r="`,g?m:h,`" fx="`,g?f:c,`" fy="`,g?p:d,`">
|
|
20
|
+
`),g&&(a.reverse(),a.forEach(e=>{e.offset=1-e.offset}));let _=Math.min(m,h);if(_>0){let e=_/Math.max(m,h);a.forEach(t=>{t.offset+=e*(1-t.offset)})}}return a.forEach(({color:e,offset:t})=>{let r=String(e),i=nr(r)?r:new fr(r).toRgba();n.push(`<stop offset="${100*t}%" style="stop-color:${Z(i)};"/>\n`)}),n.push(this.type===`linear`?`</linearGradient>`:`</radialGradient>`,`
|
|
21
|
+
`),n.join(``)}toLive(e){let{x1:t,y1:n,x2:r,y2:i,r1:a,r2:o}=this.coords,s=this.type===`linear`?e.createLinearGradient(t,n,r,i):e.createRadialGradient(t,n,a,r,i,o);return this.colorStops.forEach(({color:e,offset:t})=>{s.addColorStop(t,e)}),s}static async fromObject(e){let{colorStops:t,gradientTransform:n}=e;return new this({...e,colorStops:t?t.map(e=>({...e})):void 0,gradientTransform:n?[...n]:void 0})}static fromElement(e,t,n){let r=Es(e),i=t._findCenterFromElement();return new this({id:e.getAttribute(`id`)||void 0,type:Ts(e),coords:Os(e,{width:n.viewBoxWidth||n.width,height:n.viewBoxHeight||n.height}),colorStops:ws(e,n.opacity),gradientUnits:r,gradientTransform:Ka(e.getAttribute(`gradientTransform`)||``),...r===`pixels`?{offsetX:t.width/2-i.x,offsetY:t.height/2-i.y}:{offsetX:0,offsetY:0}})}};H(ks,`type`,`Gradient`),K.setClass(ks,`gradient`),K.setClass(ks,`linear`),K.setClass(ks,`radial`);var As=class{get type(){return`pattern`}set type(e){we(`warn`,`Setting type has no effect`,e)}constructor(e){H(this,`repeat`,`repeat`),H(this,`offsetX`,0),H(this,`offsetY`,0),H(this,`crossOrigin`,``),this.id=Ct(),Object.assign(this,e)}isImageSource(){return!!this.source&&typeof this.source.src==`string`}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():``}toLive(e){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?e.createPattern(this.source,this.repeat):null}toObject(e=[]){let{repeat:t,crossOrigin:n}=this;return{...Xt(this,e),type:`pattern`,source:this.sourceToString(),repeat:t,crossOrigin:n,offsetX:X(this.offsetX,U.NUM_FRACTION_DIGITS),offsetY:X(this.offsetY,U.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG({width:e,height:t}){let{source:n,repeat:r,id:i}=this,a=vs(this.offsetX/e,0),o=vs(this.offsetY/t,0),s=r===`repeat-y`||r===`no-repeat`?1+Math.abs(a||0):vs(n.width/e,0),c=r===`repeat-x`||r===`no-repeat`?1+Math.abs(o||0):vs(n.height/t,0);return[`<pattern id="SVGID_${Z(i)}" x="${a}" y="${o}" width="${s}" height="${c}">`,`<image x="0" y="0" width="${n.width}" height="${n.height}" xlink:href="${Z(this.sourceToString())}"></image>`,`</pattern>`,``].join(`
|
|
22
|
+
`)}static async fromObject({type:e,source:t,patternTransform:n,...r},i){let a=await qt(t,{...i,crossOrigin:r.crossOrigin});return new this({...r,patternTransform:n&&n.slice(0),source:a})}};H(As,`type`,`Pattern`),K.setClass(As),K.setClass(As,`pattern`);var js=class{constructor(e){H(this,`color`,`rgb(0, 0, 0)`),H(this,`width`,1),H(this,`shadow`,null),H(this,`strokeLineCap`,`round`),H(this,`strokeLineJoin`,`round`),H(this,`strokeMiterLimit`,10),H(this,`strokeDashArray`,null),H(this,`limitedToCanvasSize`,!1),this.canvas=e}_setBrushStyles(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeDashArray||[])}_saveAndTransform(e){let t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new fr(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;let e=this.canvas,t=this.shadow,n=e.contextTop,r=e.getZoom()*e.getRetinaScaling();n.shadowColor=t.color,n.shadowBlur=t.blur*r,n.shadowOffsetX=t.offsetX*r,n.shadowOffsetY=t.offsetY*r}_resetShadow(){let e=this.canvas.contextTop;e.shadowColor=``,e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}_isOutSideCanvas(e){return e.x<0||e.x>this.canvas.getWidth()||e.y<0||e.y>this.canvas.getHeight()}},Ms=class e extends _a{constructor(t,{path:n,left:r,top:i,...a}={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(a),this._setPath(t||[],!0),typeof r==`number`&&this.set(`left`,r),typeof i==`number`&&this.set(`top`,i)}_setPath(e,t){this.path=xo(Array.isArray(e)?e:Ro(e)),this.setBoundingBox(t)}_findCenterFromElement(){let e=this._calcBoundsFromPath();return new q(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){let t=-this.pathOffset.x,n=-this.pathOffset.y;e.beginPath();for(let r of this.path)switch(r[0]){case`L`:e.lineTo(r[1]+t,r[2]+n);break;case`M`:e.moveTo(r[1]+t,r[2]+n);break;case`C`:e.bezierCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n,r[5]+t,r[6]+n);break;case`Q`:e.quadraticCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n);break;case`Z`:e.closePath()}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(e=[]){return{...super.toObject(e),path:this.path.map(e=>e.slice())}}toDatalessObject(e=[]){let t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){return[`<path `,`COMMON_PARTS`,`d="${Ho(this.path,U.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />\n`]}_getOffsetTransform(){let e=U.NUM_FRACTION_DIGITS;return` translate(${X(-this.pathOffset.x,e)}, ${X(-this.pathOffset.y,e)})`}toClipPathSVG(e){let t=this._getOffsetTransform();return` `+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){let t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{width:t,height:n,pathOffset:r}=this._calcDimensions();this.set({width:t,height:n,pathOffset:r}),e&&this.setPositionByOrigin(r,`center`,`center`)}_calcBoundsFromPath(){let e=[],t=0,n=0,r=0,i=0;for(let a of this.path)switch(a[0]){case`L`:r=a[1],i=a[2],e.push({x:t,y:n},{x:r,y:i});break;case`M`:r=a[1],i=a[2],t=r,n=i;break;case`C`:e.push(...yo(r,i,a[1],a[2],a[3],a[4],a[5],a[6])),r=a[5],i=a[6];break;case`Q`:e.push(...yo(r,i,a[1],a[2],a[1],a[2],a[3],a[4])),r=a[3],i=a[4];break;case`Z`:r=t,i=n}return Cn(e)}_calcDimensions(){let e=this._calcBoundsFromPath();return{...e,pathOffset:new q(e.left+e.width/2,e.top+e.height/2)}}static fromObject(e){return this._fromObject(e,{extraParam:`path`})}static async fromElement(e,t,n){let{d:r,...i}=Za(e,this.ATTRIBUTE_NAMES,n);return new this(r,{...i,...t,left:void 0,top:void 0})}};H(Ms,`type`,`Path`),H(Ms,`cacheProperties`,[...Br,`path`,`fillRule`]),H(Ms,`ATTRIBUTE_NAMES`,[...Oa,`d`]),K.setClass(Ms),K.setSVGClass(Ms);var Ns=class e extends js{constructor(e){super(e),H(this,`decimate`,.4),H(this,`drawStraightLine`,!1),H(this,`straightLineKey`,`shiftKey`),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(e,t,n){let r=t.midPointFrom(n);return e.quadraticCurveTo(t.x,t.y,r.x,r.y),r}onMouseDown(e,{e:t}){this.canvas._isMainEvent(t)&&(this.drawStraightLine=!!this.straightLineKey&&t[this.straightLineKey],this._prepareForDrawing(e),this._addPoint(e),this._render())}onMouseMove(t,{e:n}){if(this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{let t=this._points,n=t.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=e.drawSegment(r,t[n-2],t[n-1]),r.stroke(),r.restore()}}onMouseUp({e}){return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(e){this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)}_addPoint(e){return!(this._points.length>1&&e.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(e),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(t=this.canvas.contextTop){let n=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&n.x===r.x&&n.y===r.y){let e=this.width/1e3;n.x-=e,r.x+=e}t.moveTo(n.x,n.y);for(let i=1;i<this._points.length;i++)e.drawSegment(t,n,r),n=this._points[i],r=this._points[i+1];t.lineTo(n.x,n.y),t.stroke(),t.restore()}convertPointsToSVGPath(e){return zo(e,this.width/1e3)}createPath(e){let t=new Ms(e,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,t.shadow=new Lr(this.shadow)),t}decimatePoints(e,t){if(e.length<=2)return e;let n,r=e[0],i=(t/this.canvas.getZoom())**2,a=e.length-1,o=[r];for(let t=1;t<a-1;t++)n=(r.x-e[t].x)**2+(r.y-e[t].y)**2,n>=i&&(r=e[t],o.push(r));return o.push(e[a]),o}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));let e=this.convertPointsToSVGPath(this._points);if(function(e){return Ho(e)===`M 0 0 Q 0 0 0 0 L 0 0`}(e))return void this.canvas.requestRenderAll();let t=this.createPath(e);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire(`before:path:created`,{path:t}),this.canvas.add(t),this.canvas.requestRenderAll(),t.setCoords(),this._resetShadow(),this.canvas.fire(`path:created`,{path:t})}},Ps=[`radius`,`startAngle`,`endAngle`,`counterClockwise`],Fs=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_set(e,t){return super._set(e,t),e===`radius`&&this.setRadius(t),this}_render(e){e.beginPath(),e.arc(0,0,this.radius,J(this.startAngle),J(this.endAngle),this.counterClockwise),this._renderPaintInOrder(e)}getRadiusX(){return this.get(`radius`)*this.get(nt)}getRadiusY(){return this.get(`radius`)*this.get(rt)}setRadius(e){this.radius=e,this.set({width:2*e,height:2*e})}toObject(e=[]){return super.toObject([...Ps,...e])}_toSVG(){let{radius:e,startAngle:t,endAngle:n}=this,r=(n-t)%360;if(r===0)return[`<circle `,`COMMON_PARTS`,`cx="0" cy="0" `,`r="`,`${Z(e)}`,`" />
|
|
23
|
+
`];{let i=J(t),a=J(n),o=mt(i)*e,s=ht(i)*e,c=mt(a)*e,l=ht(a)*e;return[`<path d="M ${o} ${s} A ${e} ${e} 0 ${+(r>180)} ${+!this.counterClockwise} ${c} ${l}" `,`COMMON_PARTS`,` />
|
|
24
|
+
`]}}static async fromElement(e,t,n){let{left:r=0,top:i=0,radius:a=0,...o}=Za(e,this.ATTRIBUTE_NAMES,n);return new this({...o,radius:a,left:r-a,top:i-a})}static fromObject(e){return super._fromObject(e)}};H(Fs,`type`,`Circle`),H(Fs,`cacheProperties`,[...Br,...Ps]),H(Fs,`ownDefaults`,{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),H(Fs,`ATTRIBUTE_NAMES`,[`cx`,`cy`,`r`,...Oa]),K.setClass(Fs),K.setSVGClass(Fs);var Is=[`x1`,`x2`,`y1`,`y2`],Ls=class e extends _a{constructor([t,n,r,i]=[0,0,0,0],a={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(a),this.x1=t,this.x2=r,this.y1=n,this.y2=i,this._setWidthHeight();let{left:o,top:s}=a;typeof o==`number`&&this.set(`left`,o),typeof s==`number`&&this.set(`top`,s)}_setWidthHeight(){let{x1:e,y1:t,x2:n,y2:r}=this;this.width=Math.abs(n-e),this.height=Math.abs(r-t);let{left:i,top:a,width:o,height:s}=Cn([{x:e,y:t},{x:n,y:r}]),c=new q(i+o/2,a+s/2);this.setPositionByOrigin(c,W,W)}_set(e,t){return super._set(e,t),Is.includes(e)&&this._setWidthHeight(),this}_render(e){e.beginPath();let t=this.calcLinePoints();e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.lineWidth=this.strokeWidth;let n=e.strokeStyle;e.strokeStyle=$t(this.stroke)?this.stroke.toLive(e):this.stroke??e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=n}_findCenterFromElement(){return new q((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(e=[]){return{...super.toObject(e),...this.calcLinePoints()}}_getNonTransformedDimensions(){let e=super._getNonTransformedDimensions();return this.strokeLineCap===`butt`&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e}calcLinePoints(){let{x1:e,x2:t,y1:n,y2:r,width:i,height:a}=this,o=e<=t?-.5:.5,s=n<=r?-.5:.5;return{x1:o*i,x2:o*-i,y1:s*a,y2:s*-a}}_toSVG(){let{x1:e,x2:t,y1:n,y2:r}=this.calcLinePoints();return[`<line `,`COMMON_PARTS`,`x1="${e}" y1="${n}" x2="${t}" y2="${r}" />\n`]}static async fromElement(e,t,n){let{x1:r=0,y1:i=0,x2:a=0,y2:o=0,...s}=Za(e,this.ATTRIBUTE_NAMES,n);return new this([r,i,a,o],s)}static fromObject({x1:e,y1:t,x2:n,y2:r,...i}){return this._fromObject({...i,points:[e,t,n,r]},{extraParam:`points`})}};H(Ls,`type`,`Line`),H(Ls,`cacheProperties`,[...Br,...Is]),H(Ls,`ATTRIBUTE_NAMES`,Oa.concat(Is)),K.setClass(Ls),K.setSVGClass(Ls);var Rs=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_render(e){let t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderPaintInOrder(e)}_toSVG(){let e=this.width/2,t=this.height/2;return[`<polygon `,`COMMON_PARTS`,`points="`,`${-e} ${t},0 ${-t},${e} ${t}`,`" />`]}};H(Rs,`type`,`Triangle`),H(Rs,`ownDefaults`,{width:100,height:100}),K.setClass(Rs),K.setSVGClass(Rs);var zs=[`rx`,`ry`],Bs=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_set(e,t){switch(super._set(e,t),e){case`rx`:this.rx=t,this.set(`width`,2*t);break;case`ry`:this.ry=t,this.set(`height`,2*t)}return this}getRx(){return this.get(`rx`)*this.get(nt)}getRy(){return this.get(`ry`)*this.get(rt)}toObject(e=[]){return super.toObject([...zs,...e])}_toSVG(){return[`<ellipse `,`COMMON_PARTS`,`cx="0" cy="0" rx="${Z(this.rx)}" ry="${Z(this.ry)}" />\n`]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,Be,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,n){let r=Za(e,this.ATTRIBUTE_NAMES,n);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}};H(Bs,`type`,`Ellipse`),H(Bs,`cacheProperties`,[...Br,...zs]),H(Bs,`ownDefaults`,{rx:0,ry:0}),H(Bs,`ATTRIBUTE_NAMES`,[...Oa,`cx`,`cy`,`rx`,`ry`]),K.setClass(Bs),K.setSVGClass(Bs);var Vs={exactBoundingBox:!1},Hs=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),H(this,`strokeDiff`,void 0),Object.assign(this,e.ownDefaults),this.setOptions(n),this.points=t;let{left:r,top:i}=n;this.initialized=!0,this.setBoundingBox(!0),typeof r==`number`&&this.set(`left`,r),typeof i==`number`&&this.set(`top`,i)}isOpen(){return!0}_projectStrokeOnPoints(e){return Ca(this.points,e,this.isOpen())}_calcDimensions(e){e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth,...e||{}};let t=this.exactBoundingBox?this._projectStrokeOnPoints(e).map(e=>e.projectedPoint):this.points;if(t.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new q,strokeOffset:new q,strokeDiff:new q};let n=Cn(t),r=Gt({...e,scaleX:1,scaleY:1}),i=Cn(this.points.map(e=>Mt(e,r,!0))),a=new q(this.scaleX,this.scaleY),o=n.left+n.width/2,s=n.top+n.height/2;return this.exactBoundingBox&&(o-=s*Math.tan(J(this.skewX)),s-=o*Math.tan(J(this.skewY))),{...n,pathOffset:new q(o,s),strokeOffset:new q(i.left,i.top).subtract(new q(n.left,n.top)).multiply(a),strokeDiff:new q(n.width,n.height).subtract(new q(i.width,i.height)).multiply(a)}}_findCenterFromElement(){let e=Cn(this.points);return new q(e.left+e.width/2,e.top+e.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{left:t,top:n,width:r,height:i,pathOffset:a,strokeOffset:o,strokeDiff:s}=this._calcDimensions();this.set({width:r,height:i,pathOffset:a,strokeOffset:o,strokeDiff:s}),e&&this.setPositionByOrigin(new q(t+r/2,n+i/2),`center`,`center`)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new q(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(e={}){if(this.exactBoundingBox){let t;if(Object.keys(e).some(e=>this.strokeUniform||this.constructor.layoutProperties.includes(e))){let{width:n,height:r}=this._calcDimensions(e);t=new q(e.width??n,e.height??r)}else t=new q(e.width??this.width,e.height??this.height);return t.multiply(new q(e.scaleX||this.scaleX,e.scaleY||this.scaleY))}return super._getTransformedDimensions(e)}_set(e,t){let n=this.initialized&&this[e]!==t,r=super._set(e,t);return this.exactBoundingBox&&n&&((e===`scaleX`||e===`scaleY`)&&this.strokeUniform&&this.constructor.layoutProperties.includes(`strokeUniform`)||this.constructor.layoutProperties.includes(e))&&this.setDimensions(),r}toObject(e=[]){return{...super.toObject(e),points:this.points.map(({x:e,y:t})=>({x:e,y:t}))}}_toSVG(){let e=this.pathOffset.x,t=this.pathOffset.y,n=U.NUM_FRACTION_DIGITS,r=this.points.map(({x:r,y:i})=>`${X(r-e,n)},${X(i-t,n)}`).join(` `);return[`<${Z(this.constructor.type).toLowerCase()} `,`COMMON_PARTS`,`points="${r}" />\n`]}_render(e){let t=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(t&&!isNaN(this.points[t-1].y)){e.beginPath(),e.moveTo(this.points[0].x-n,this.points[0].y-r);for(let i=0;i<t;i++){let t=this.points[i];e.lineTo(t.x-n,t.y-r)}!this.isOpen()&&e.closePath(),this._renderPaintInOrder(e)}}complexity(){return this.points.length}static async fromElement(e,t,n){let r=function(e){if(!e)return[];let t=e.replace(/,/g,` `).trim().split(/\s+/),n=[];for(let e=0;e<t.length;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n}(e.getAttribute(`points`)),{left:i,top:a,...o}=Za(e,this.ATTRIBUTE_NAMES,n);return new this(r,{...o,...t})}static fromObject(e){return this._fromObject(e,{extraParam:`points`})}};H(Hs,`ownDefaults`,Vs),H(Hs,`type`,`Polyline`),H(Hs,`layoutProperties`,[it,at,`strokeLineCap`,`strokeLineJoin`,`strokeMiterLimit`,`strokeWidth`,`strokeUniform`,`points`]),H(Hs,`cacheProperties`,[...Br,`points`]),H(Hs,`ATTRIBUTE_NAMES`,[...Oa]),K.setClass(Hs),K.setSVGClass(Hs);var Us=class extends Hs{isOpen(){return!1}};H(Us,`ownDefaults`,Vs),H(Us,`type`,`Polygon`),K.setClass(Us),K.setSVGClass(Us);var Ws=class extends _a{isEmptyStyles(e){if(!this.styles||e!==void 0&&!this.styles[e])return!0;let t=e===void 0?this.styles:{line:this.styles[e]};for(let e in t)for(let n in t[e])for(let r in t[e][n])return!1;return!0}styleHas(e,t){if(!this.styles||t!==void 0&&!this.styles[t])return!1;let n=t===void 0?this.styles:{0:this.styles[t]};for(let t in n)for(let r in n[t])if(n[t][r][e]!==void 0)return!0;return!1}cleanStyle(e){if(!this.styles)return!1;let t=this.styles,n,r,i=0,a=!0,o=0;for(let o in t){n=0;for(let s in t[o]){let c=t[o][s]||{};i++,c[e]===void 0?a=!1:(r?c[e]!==r&&(a=!1):r=c[e],c[e]===this[e]&&delete c[e]),Object.keys(c).length===0?delete t[o][s]:n++}n===0&&delete t[o]}for(let e=0;e<this._textLines.length;e++)o+=this._textLines[e].length;a&&i===o&&(this[e]=r,this.removeStyle(e))}removeStyle(e){if(!this.styles)return;let t=this.styles,n,r,i;for(r in t){for(i in n=t[r],n)delete n[i][e],Object.keys(n[i]).length===0&&delete n[i];Object.keys(n).length===0&&delete t[r]}}_extendStyles(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e);this._getLineStyle(n)||this._setLineStyle(n);let i=Zt({...this._getStyleDeclaration(n,r),...t},e=>e!==void 0);this._setStyleDeclaration(n,r,i)}getSelectionStyles(e,t,n){let r=[];for(let i=e;i<(t||e);i++)r.push(this.getStyleAtPosition(i,n));return r}getStyleAtPosition(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e);return t?this.getCompleteStyleDeclaration(n,r):this._getStyleDeclaration(n,r)}setSelectionStyles(e,t,n){for(let r=t;r<(n||t);r++)this._extendStyles(r,e);this._forceClearCache=!0}_getStyleDeclaration(e,t){var n;let r=this.styles&&this.styles[e];return r&&(n=r[t])!=null?n:{}}getCompleteStyleDeclaration(e,t){return{...Xt(this,this.constructor._styleProperties),...this._getStyleDeclaration(e,t)}}_setStyleDeclaration(e,t,n){this.styles[e][t]=n}_deleteStyleDeclaration(e,t){delete this.styles[e][t]}_getLineStyle(e){return!!this.styles[e]}_setLineStyle(e){this.styles[e]={}}_deleteLineStyle(e){delete this.styles[e]}};H(Ws,`_styleProperties`,Tr);var Gs=/ +/g,Ks=/"/g;function qs(e,t,n,r,i){return`\t\t${((e,{left:t,top:n,width:r,height:i},a=U.NUM_FRACTION_DIGITS)=>{let o=gr(ot,e,!1),[s,c,l,u]=[t,n,r,i].map(e=>X(e,a));return`<rect ${o} x="${s}" y="${c}" width="${l}" height="${u}"></rect>`})(e,{left:t,top:n,width:r,height:i})}\n`}var Js,Ys=class e extends Ws{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(),H(this,`__charBounds`,[]),Object.assign(this,e.ownDefaults),this.setOptions(n),this.styles||={},this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){let e=this.path;e&&(e.segmentsInfo=Mo(e.path))}_splitText(){let e=this._splitTextIntoLines(this.text);return this.textLines=e.lines,this._textLines=e.graphemeLines,this._unwrappedTextLines=e._unwrappedLines,this._text=e.graphemeText,e}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(`justify`)&&this.enlargeSpaces()}enlargeSpaces(){let e,t,n,r,i,a,o;for(let s=0,c=this._textLines.length;s<c;s++)if((this.textAlign===`justify`||s!==c-1&&!this.isEndOfWrapping(s))&&(r=0,i=this._textLines[s],t=this.getLineWidth(s),t<this.width&&(o=this.textLines[s].match(this._reSpacesAndTabs)))){n=o.length,e=(this.width-t)/n;for(let t=0;t<=i.length;t++)a=this.__charBounds[s][t],this._reSpaceAndTab.test(i[t])?(a.width+=e,a.kernedWidth+=e,a.left+=r,r+=e):a.left+=r}}isEndOfWrapping(e){return e===this._textLines.length-1}missingNewlineOffset(e){return 1}get2DCursorLocation(e,t){let n=t?this._unwrappedTextLines:this._textLines,r;for(r=0;r<n.length;r++){if(e<=n[r].length)return{lineIndex:r,charIndex:e};e-=n[r].length+this.missingNewlineOffset(r,t)}return{lineIndex:r-1,charIndex:n[r-1].length<e?n[r-1].length:e}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){let e=super._getCacheCanvasDimensions(),t=this.fontSize;return e.width+=t*e.zoomX,e.height+=t*e.zoomY,e}_render(e){let t=this.path;t&&!t.isNotVisible()&&t._render(e),this._setTextStyles(e),this._renderTextLinesBackground(e),this._renderTextDecoration(e,`underline`),this._renderText(e),this._renderTextDecoration(e,`overline`),this._renderTextDecoration(e,`linethrough`)}_renderText(e){this.paintFirst===`stroke`?(this._renderTextStroke(e),this._renderTextFill(e)):(this._renderTextFill(e),this._renderTextStroke(e))}_setTextStyles(e,t,n){if(e.textBaseline=`alphabetic`,this.path)switch(this.pathAlign){case W:e.textBaseline=`middle`;break;case`ascender`:e.textBaseline=`top`;break;case`descender`:e.textBaseline=Ue}e.font=this._getFontDeclaration(t,n)}calcTextWidth(){let e=this.getLineWidth(0);for(let t=1,n=this._textLines.length;t<n;t++){let n=this.getLineWidth(t);n>e&&(e=n)}return e}_renderTextLine(e,t,n,r,i,a){this._renderChars(e,t,n,r,i,a)}_renderTextLinesBackground(e){if(!this.textBackgroundColor&&!this.styleHas(`textBackgroundColor`))return;let t=e.fillStyle,n=this._getLeftOffset(),r=this._getTopOffset();for(let t=0,i=this._textLines.length;t<i;t++){let i=this.getHeightOfLine(t);if(!this.textBackgroundColor&&!this.styleHas(`textBackgroundColor`,t)){r+=i;continue}let a=this._textLines[t].length,o=this._getLineLeftOffset(t),s,c,l=0,u=0,d=this.getValueOfPropertyAt(t,0,`textBackgroundColor`),f=this.getHeightOfLineImpl(t);for(let i=0;i<a;i++){let a=this.__charBounds[t][i];c=this.getValueOfPropertyAt(t,i,`textBackgroundColor`),this.path?(e.save(),e.translate(a.renderLeft,a.renderTop),e.rotate(a.angle),e.fillStyle=c,c&&e.fillRect(-a.width/2,-f*(1-this._fontSizeFraction),a.width,f),e.restore()):c===d?l+=a.kernedWidth:(s=n+o+u,this.direction===`rtl`&&(s=this.width-s-l),e.fillStyle=d,d&&e.fillRect(s,r,l,f),u=a.left,l=a.width,d=c)}c&&!this.path&&(s=n+o+u,this.direction===`rtl`&&(s=this.width-s-l),e.fillStyle=c,e.fillRect(s,r,l,f)),r+=i}e.fillStyle=t,this._removeShadow(e)}_measureChar(e,t,n,r){let i=Fe.getFontCache(t),a=this._getFontDeclaration(t),o=n?n+e:e,s=n&&a===this._getFontDeclaration(r),c=t.fontSize/this.CACHE_FONT_SIZE,l,u,d,f;if(n&&i.has(n)&&(d=i.get(n)),i.has(e)&&(f=l=i.get(e)),s&&i.has(o)&&(u=i.get(o),f=u-d),l===void 0||d===void 0||u===void 0){let r=(Js||=Dt({width:0,height:0}).getContext(`2d`),Js);this._setTextStyles(r,t,!0),l===void 0&&(f=l=r.measureText(e).width,i.set(e,l)),d===void 0&&s&&n&&(d=r.measureText(n).width,i.set(n,d)),s&&u===void 0&&(u=r.measureText(o).width,i.set(o,u),f=u-d)}return{width:l*c,kernedWidth:f*c}}getHeightOfChar(e,t){return this.getValueOfPropertyAt(e,t,`fontSize`)}measureLine(e){let t=this._measureLine(e);return this.charSpacing!==0&&(t.width-=this._getWidthOfCharSpacing()),t.width<0&&(t.width=0),t}_measureLine(e){let t,n,r=0,i=this.pathSide===We,a=this.path,o=this._textLines[e],s=o.length,c=Array(s);this.__charBounds[e]=c;for(let i=0;i<s;i++){let a=o[i];n=this._getGraphemeBox(a,e,i,t),c[i]=n,r+=n.kernedWidth,t=a}if(c[s]={left:n?n.left+n.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},a&&a.segmentsInfo){let e=0,t=a.segmentsInfo[a.segmentsInfo.length-1].length;switch(this.textAlign){case G:e=i?t-r:0;break;case W:e=(t-r)/2;break;case We:e=i?0:t-r}e+=this.pathStartOffset*(i?-1:1);for(let r=i?s-1:0;i?r>=0:r<s;i?r--:r++)n=c[r],e>t?e%=t:e<0&&(e+=t),this._setGraphemeOnPath(e,n),e+=n.kernedWidth}return{width:r,numOfSpaces:0}}_setGraphemeOnPath(e,t){let n=e+t.kernedWidth/2,r=this.path,i=No(r.path,n,r.segmentsInfo);t.renderLeft=i.x-r.pathOffset.x,t.renderTop=i.y-r.pathOffset.y,t.angle=i.angle+(this.pathSide===`right`?Math.PI:0)}_getGraphemeBox(e,t,n,r,i){let a=this.getCompleteStyleDeclaration(t,n),o=r?this.getCompleteStyleDeclaration(t,n-1):{},s=this._measureChar(e,a,r,o),c,l=s.kernedWidth,u=s.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,l+=c);let d={width:u,left:0,height:a.fontSize,kernedWidth:l,deltaY:a.deltaY};if(n>0&&!i){let e=this.__charBounds[t][n-1];d.left=e.left+e.width+s.kernedWidth-s.width}return d}getHeightOfLineImpl(e){let t=this.__lineHeights;if(t[e])return t[e];let n=this.getHeightOfChar(e,0);for(let t=1,r=this._textLines[e].length;t<r;t++)n=Math.max(this.getHeightOfChar(e,t),n);return t[e]=n*this._fontSizeMult}getHeightOfLine(e){return this.getHeightOfLineImpl(e)*this.lineHeight}calcTextHeight(){let e=0;for(let t=0,n=this._textLines.length;t<n;t++)e+=t===n-1?this.getHeightOfLineImpl(t):this.getHeightOfLine(t);return e}_getLeftOffset(){return this.direction===`ltr`?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(e,t){e.save();let n=0,r=this._getLeftOffset(),i=this._getTopOffset();for(let a=0,o=this._textLines.length;a<o;a++)this._renderTextLine(t,e,this._textLines[a],r+this._getLineLeftOffset(a),i+n+this.getHeightOfLineImpl(a),a),n+=this.getHeightOfLine(a);e.restore()}_renderTextFill(e){(this.fill||this.styleHas(`fill`))&&this._renderTextCommon(e,`fillText`)}_renderTextStroke(e){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this._setLineDash(e,this.strokeDashArray),e.beginPath(),this._renderTextCommon(e,`strokeText`),e.closePath(),e.restore())}_renderChars(e,t,n,r,i,a){let o=this.textAlign.includes(Dr),s=this.path,c=!o&&this.charSpacing===0&&this.isEmptyStyles(a)&&!s,l=this.direction===`ltr`,u=this.direction===`ltr`?1:-1,d=t.direction,f,p,m,h,g,_=``,v=0;if(t.save(),d!==this.direction&&(t.canvas.setAttribute(`dir`,l?`ltr`:`rtl`),t.direction=l?`ltr`:`rtl`,t.textAlign=l?G:We),i-=this.getHeightOfLineImpl(a)*this._fontSizeFraction,c)return this._renderChar(e,t,a,0,n.join(``),r,i),void t.restore();for(let c=0,l=n.length-1;c<=l;c++)h=c===l||this.charSpacing||s,_+=n[c],m=this.__charBounds[a][c],v===0?(r+=u*(m.kernedWidth-m.width),v+=m.width):v+=m.kernedWidth,o&&!h&&this._reSpaceAndTab.test(n[c])&&(h=!0),h||=(f||=this.getCompleteStyleDeclaration(a,c),p=this.getCompleteStyleDeclaration(a,c+1),Ta(f,p,!1)),h&&(s?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),this._renderChar(e,t,a,c,_,-v/2,0),t.restore()):(g=r,this._renderChar(e,t,a,c,_,g,i)),_=``,f=p,r+=u*v,v=0);t.restore()}_applyPatternGradientTransformText(e){let t=this.width+this.strokeWidth,n=this.height+this.strokeWidth,r=Dt({width:t,height:n}),i=r.getContext(`2d`);return r.width=t,r.height=n,i.beginPath(),i.moveTo(0,0),i.lineTo(t,0),i.lineTo(t,n),i.lineTo(0,n),i.closePath(),i.translate(t/2,n/2),i.fillStyle=e.toLive(i),this._applyPatternGradientTransform(i,e),i.fill(),i.createPattern(r,`no-repeat`)}handleFiller(e,t,n){let r,i;return $t(n)?n.gradientUnits===`percentage`||n.gradientTransform||n.patternTransform?(r=-this.width/2,i=-this.height/2,e.translate(r,i),e[t]=this._applyPatternGradientTransformText(n),{offsetX:r,offsetY:i}):(e[t]=n.toLive(e),this._applyPatternGradientTransform(e,n)):(e[t]=n,{offsetX:0,offsetY:0})}_setStrokeStyles(e,{stroke:t,strokeWidth:n}){return e.lineWidth=n,e.lineCap=this.strokeLineCap,e.lineDashOffset=this.strokeDashOffset,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,this.handleFiller(e,`strokeStyle`,t)}_setFillStyles(e,{fill:t}){return this.handleFiller(e,`fillStyle`,t)}_renderChar(e,t,n,r,i,a,o){let s=this._getStyleDeclaration(n,r),c=this.getCompleteStyleDeclaration(n,r),l=e===`fillText`&&c.fill,u=e===`strokeText`&&c.stroke&&c.strokeWidth;if(u||l){if(t.save(),t.font=this._getFontDeclaration(c),s.textBackgroundColor&&this._removeShadow(t),s.deltaY&&(o+=s.deltaY),l){let e=this._setFillStyles(t,c);t.fillText(i,a-e.offsetX,o-e.offsetY)}if(u){let e=this._setStrokeStyles(t,c);t.strokeText(i,a-e.offsetX,o-e.offsetY)}t.restore()}}setSuperscript(e,t){this._setScript(e,t,this.superscript)}setSubscript(e,t){this._setScript(e,t,this.subscript)}_setScript(e,t,n){let r=this.get2DCursorLocation(e,!0),i=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,`fontSize`),a=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,`deltaY`),o={fontSize:i*n.size,deltaY:a+i*n.baseline};this.setSelectionStyles(o,e,t)}_getLineLeftOffset(e){let t=this.getLineWidth(e),n=this.width-t,r=this.textAlign,i=this.direction,a=this.isEndOfWrapping(e),o=0;return r===`justify`||r===`justify-center`&&!a||r===`justify-right`&&!a||r===`justify-left`&&!a?0:(r===`center`&&(o=n/2),r===`right`&&(o=n),r===`justify-center`&&(o=n/2),r===`justify-right`&&(o=n),i===`rtl`&&(r===`right`||r===`justify-right`?o=0:r===`left`||r===`justify-left`?o=-n:r!==`center`&&r!==`justify-center`||(o=-n/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(e){if(this.__lineWidths[e]!==void 0)return this.__lineWidths[e];let{width:t}=this.measureLine(e);return this.__lineWidths[e]=t,t}_getWidthOfCharSpacing(){return this.charSpacing===0?0:this.fontSize*this.charSpacing/1e3}getValueOfPropertyAt(e,t,n){return this._getStyleDeclaration(e,t)[n]??this[n]}_renderTextDecoration(e,t){if(!this[t]&&!this.styleHas(t))return;let n=this._getTopOffset(),r=this._getLeftOffset(),i=this.path,a=this._getWidthOfCharSpacing(),o=t===`linethrough`?.5:+(t===`overline`),s=this.offsets[t];for(let c=0,l=this._textLines.length;c<l;c++){let l=this.getHeightOfLine(c);if(!this[t]&&!this.styleHas(t,c)){n+=l;continue}let u=this._textLines[c],d=l/this.lineHeight,f=this._getLineLeftOffset(c),p,m=0,h=0,g=this.getValueOfPropertyAt(c,0,t),_=this.getValueOfPropertyAt(c,0,ot),v=this.getValueOfPropertyAt(c,0,`textDecorationColor`)||_,y=this.getValueOfPropertyAt(c,0,yr),b=g,x=v,S=y,C=n+d*(1-this._fontSizeFraction),w=this.getHeightOfChar(c,0),T=this.getValueOfPropertyAt(c,0,`deltaY`);for(let n=0,a=u.length;n<a;n++){let a=this.__charBounds[c][n];b=this.getValueOfPropertyAt(c,n,t),p=this.getValueOfPropertyAt(c,n,ot),x=this.getValueOfPropertyAt(c,n,`textDecorationColor`)||p,S=this.getValueOfPropertyAt(c,n,yr);let l=this.getHeightOfChar(c,n),u=this.getValueOfPropertyAt(c,n,`deltaY`);if(i&&b&&p){let t=this.fontSize*S/1e3;e.save(),e.fillStyle=x,e.translate(a.renderLeft,a.renderTop),e.rotate(a.angle),e.fillRect(-a.kernedWidth/2,s*l+u-o*t,a.kernedWidth,t),e.restore()}else if((b!==g||p!==_||x!==v||l!==w||S!==y||u!==T)&&h>0){let t=this.fontSize*y/1e3,n=r+f+m;this.direction===`rtl`&&(n=this.width-n-h),g&&v&&y&&(e.fillStyle=v,e.fillRect(n,C+s*w+T-o*t,h,t)),m=a.left,h=a.width,g=b,v=x,y=S,_=p,w=l,T=u}else h+=a.kernedWidth}let E=r+f+m;this.direction===`rtl`&&(E=this.width-E-h),e.fillStyle=x;let D=this.fontSize*S/1e3;b&&x&&S&&e.fillRect(E,C+s*w+T-o*D,h-a,D),n+=l}this._removeShadow(e)}_getFontDeclaration({fontFamily:t=this.fontFamily,fontStyle:n=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}={},a){let o=t.includes(`'`)||t.includes(`"`)||t.includes(`,`)||e.genericFonts.includes(t.toLowerCase())?t:`"${t}"`;return[n,r,`${a?this.CACHE_FONT_SIZE:i}px`,o].join(` `)}render(e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(e)))}graphemeSplit(e){return hn(e)}_splitTextIntoLines(e){let t=e.split(this._reNewline),n=Array(t.length),r=[`
|
|
25
|
+
`],i=[];for(let e=0;e<t.length;e++)n[e]=this.graphemeSplit(t[e]),i=i.concat(n[e],r);return i.pop(),{_unwrappedLines:n,lines:t,graphemeText:i,graphemeLines:n}}toObject(e=[]){return{...super.toObject([...wr,...e]),styles:Ea(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(e,t){let{textLayoutProperties:n}=this.constructor;super.set(e,t);let r=!1,i=!1;if(typeof e==`object`)for(let t in e)t===`path`&&this.setPathInfo(),r||=n.includes(t),i||=t===`path`;else r=n.includes(e),i=e===`path`;return i&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,n,r){let i=Za(t,e.ATTRIBUTE_NAMES,r),{textAnchor:a=G,textDecoration:o=``,dx:s=0,dy:c=0,top:l=0,left:u=0,fontSize:d=16,strokeWidth:f=1,...p}={...n,...i},m=new this(ar(t.textContent||``).trim(),{left:u+s,top:l+c,underline:o.includes(`underline`),overline:o.includes(`overline`),linethrough:o.includes(`line-through`),strokeWidth:0,fontSize:d,...p}),h=m.getScaledHeight()/m.height,g=((m.height+m.strokeWidth)*m.lineHeight-m.height)*h,_=m.getScaledHeight()+g,v=0;return a===`center`&&(v=m.getScaledWidth()/2),a===`right`&&(v=m.getScaledWidth()),m.set({left:m.left-v,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(e){return this._fromObject({...e,styles:Da(e.styles||{},e.text)},{extraParam:`text`})}};H(Ys,`textLayoutProperties`,Cr),H(Ys,`cacheProperties`,[...Br,...wr]),H(Ys,`ownDefaults`,Er),H(Ys,`type`,`Text`),H(Ys,`genericFonts`,[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`math`,`emoji`,`fangsong`]),H(Ys,`ATTRIBUTE_NAMES`,Oa.concat(`x`,`y`,`dx`,`dy`,`font-family`,`font-style`,`font-weight`,`font-size`,`letter-spacing`,`text-decoration`,`text-decoration-thickness`,`text-decoration-color`,`text-anchor`)),ga(Ys,[class extends _r{_toSVG(){let e=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(e.textTop,e.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(e){let t=this._createBaseSVGMarkup(this._toSVG(),{reviver:e,noStyle:!0,withShadow:!0}),n=this.path;return n?t+n._createBaseSVGMarkup(n._toSVG(),{reviver:e,withShadow:!0,additionalTransform:Qt(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg({textBgRects:e,textSpans:t}){let n=this.getSvgTextDecoration(this);return[e.join(``),` <text xml:space="preserve" `,`font-family="${Z(this.fontFamily.replace(Ks,`'`))}" `,`font-size="${Z(this.fontSize)}" `,this.fontStyle?`font-style="${Z(this.fontStyle)}" `:``,this.fontWeight?`font-weight="${Z(this.fontWeight)}" `:``,n?`text-decoration="${n}" `:``,this.direction===`rtl`?`direction="rtl" `:``,`style="`,this.getSvgStyles(!0),`"`,this.addPaintOrder(),` >`,t.join(``),`</text>
|
|
26
|
+
`]}_getSVGTextAndBg(e,t){let n=[],r=[],i,a=e;this.backgroundColor&&r.push(qs(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let e=0,o=this._textLines.length;e<o;e++)i=this._getLineLeftOffset(e),this.direction===`rtl`&&(i+=this.width),(this.textBackgroundColor||this.styleHas(`textBackgroundColor`,e))&&this._setSVGTextLineBg(r,e,t+i,a),this._setSVGTextLineText(n,e,t+i,a),a+=this.getHeightOfLine(e);return{textSpans:n,textBgRects:r}}_createTextCharSpan(e,t,n,r,i){let a=U.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,e!==e.trim()||!!e.match(Gs)),s=o?`style="${o}"`:``,c=t.deltaY,l=c?` dy="${X(c,a)}" `:``,{angle:u,renderLeft:d,renderTop:f,width:p}=i,m=``;if(d!==void 0){let e=p/2;u&&(m=` rotate="${X(At(u),a)}"`);let t=Bt({angle:At(u)});t[4]=d,t[5]=f;let i=new q(-e,0).transform(t);n=i.x,r=i.y}return`<tspan x="${X(n,a)}" y="${X(r,a)}" ${l}${m}${s}>${Z(e)}</tspan>`}_setSVGTextLineText(e,t,n,r){let i=this.getHeightOfLine(t),a=this.textAlign.includes(Dr),o=this._textLines[t],s,c,l,u,d,f=``,p=0;r+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let i=0,m=o.length-1;i<=m;i++)d=i===m||this.charSpacing||this.path,f+=o[i],l=this.__charBounds[t][i],p===0?(n+=l.kernedWidth-l.width,p+=l.width):p+=l.kernedWidth,a&&!d&&this._reSpaceAndTab.test(o[i])&&(d=!0),d||=(s||=this.getCompleteStyleDeclaration(t,i),c=this.getCompleteStyleDeclaration(t,i+1),Ta(s,c,!0)),d&&(u=this._getStyleDeclaration(t,i),e.push(this._createTextCharSpan(f,u,n,r,l)),f=``,s=c,this.direction===`rtl`?n-=p:n+=p,p=0)}_setSVGTextLineBg(e,t,n,r){let i=this._textLines[t],a=this.getHeightOfLine(t)/this.lineHeight,o,s=0,c=0,l=this.getValueOfPropertyAt(t,0,`textBackgroundColor`);for(let u=0;u<i.length;u++){let{left:i,width:d,kernedWidth:f}=this.__charBounds[t][u];o=this.getValueOfPropertyAt(t,u,`textBackgroundColor`),o===l?s+=f:(l&&e.push(qs(l,n+c,r,s,a)),c=i,s=d,l=o)}o&&e.push(qs(l,n+c,r,s,a))}getSvgStyles(e){let t=nr(this.textDecorationColor)?` text-decoration-color: ${Z(this[br])};`:``;return`${super.getSvgStyles(e)} text-decoration-thickness: ${X(this.textDecorationThickness*this.getObjectScaling().y/10,U.NUM_FRACTION_DIGITS)}%;${t} white-space: pre;`}getSvgSpanStyles(e,t){let{fontFamily:n,strokeWidth:r,stroke:i,fill:a,fontSize:o,fontStyle:s,fontWeight:c,textDecorationThickness:l,textDecorationColor:u,linethrough:d,overline:f,underline:p}=e,m=this.getSvgTextDecoration({underline:p??this.underline,overline:f??this.overline,linethrough:d??this.linethrough}),h=l||this.textDecorationThickness,g=u||this.textDecorationColor,_=rr(r),v=ir(n),y=rr(o),b=ir(s),x=rr(c)||ir(c),S=ir(g);return[i?gr(st,i):``,_?`stroke-width: ${Z(_)}; `:``,v?`font-family: ${v.includes(`'`)||v.includes(`"`)?Z(v):`'${Z(v)}'`}; `:``,y?`font-size: ${Z(y)}px; `:``,b?`font-style: ${Z(b)}; `:``,x?`font-weight: ${Z(x)}; `:``,m?`text-decoration: ${m}; text-decoration-thickness: ${X(h*this.getObjectScaling().y/10,U.NUM_FRACTION_DIGITS)}%;${S?` text-decoration-color: ${Z(S)};`:``} `:``,a?gr(ot,a):``,t?`white-space: pre; `:``].join(``)}getSvgTextDecoration(e){return[`overline`,`underline`,`line-through`].filter(t=>e[t.replace(`-`,``)]).join(` `)}}]),K.setClass(Ys),K.setSVGClass(Ys);var Xs=class{constructor(e){H(this,`target`,void 0),H(this,`__mouseDownInPlace`,!1),H(this,`__dragStartFired`,!1),H(this,`__isDraggingOver`,!1),H(this,`__dragStartSelection`,void 0),H(this,`__dragImageDisposer`,void 0),H(this,`_dispose`,void 0),this.target=e;let t=[this.target.on(`dragenter`,this.dragEnterHandler.bind(this)),this.target.on(`dragover`,this.dragOverHandler.bind(this)),this.target.on(`dragleave`,this.dragLeaveHandler.bind(this)),this.target.on(`dragend`,this.dragEndHandler.bind(this)),this.target.on(`drop`,this.dropHandler.bind(this))];this._dispose=()=>{t.forEach(e=>e()),this._dispose=void 0}}isPointerOverSelection(e){let t=this.target,n=t.getSelectionStartFromPointer(e);return t.isEditing&&n>=t.selectionStart&&n<=t.selectionEnd&&t.selectionStart<t.selectionEnd}start(e){return this.__mouseDownInPlace=this.isPointerOverSelection(e)}isActive(){return this.__mouseDownInPlace}end(e){let t=this.isActive();return t&&!this.__dragStartFired&&(this.target.setCursorByClick(e),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,t}getDragStartSelection(){return this.__dragStartSelection}setDragImage(e,{selectionStart:t,selectionEnd:n}){var r;let i=this.target,a=i.canvas,o=new q(i.flipX?-1:1,i.flipY?-1:1),s=i._getCursorBoundaries(t),c=new q(s.left+s.leftOffset,s.top+s.topOffset).multiply(o).transform(i.calcTransformMatrix()),l=a.getScenePoint(e).subtract(c),u=i.getCanvasRetinaScaling(),d=i.getBoundingRect(),f=c.subtract(new q(d.left,d.top)),p=a.viewportTransform,m=f.add(l).transform(p,!0),h=i.backgroundColor,g=wa(i.styles);i.backgroundColor=``;let _={stroke:`transparent`,fill:`transparent`,textBackgroundColor:`transparent`};i.setSelectionStyles(_,0,t),i.setSelectionStyles(_,n,i.text.length),i.dirty=!0;let v=i.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});i.backgroundColor=h,i.styles=g,i.dirty=!0,Ko(v,{position:`fixed`,left:-v.width+`px`,border:Ge,width:v.width/u+`px`,height:v.height/u+`px`}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{v.remove()},an(e.target||this.target.hiddenTextarea).body.appendChild(v),(r=e.dataTransfer)==null||r.setDragImage(v,m.x,m.y)}onDragStart(e){this.__dragStartFired=!0;let t=this.target,n=this.isActive();if(n&&e.dataTransfer){let n=this.__dragStartSelection={selectionStart:t.selectionStart,selectionEnd:t.selectionEnd},r=t._text.slice(n.selectionStart,n.selectionEnd).join(``),i={text:t.text,value:r,...n};e.dataTransfer.setData(`text/plain`,r),e.dataTransfer.setData(`application/fabric`,JSON.stringify({value:r,styles:t.getSelectionStyles(n.selectionStart,n.selectionEnd,!0)})),e.dataTransfer.effectAllowed=`copyMove`,this.setDragImage(e,i)}return t.abortCursorAnimation(),n}canDrop(e){if(this.target.editable&&!this.target.getActiveControl()&&!e.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){let t=this.target.getSelectionStartFromPointer(e),n=this.__dragStartSelection;return t<n.selectionStart||t>n.selectionEnd}return!0}return!1}targetCanDrop(e){return this.target.canDrop(e)}dragEnterHandler({e}){let t=this.targetCanDrop(e);!this.__isDraggingOver&&t&&(this.__isDraggingOver=!0)}dragOverHandler(e){let{e:t}=e,n=this.targetCanDrop(t);!this.__isDraggingOver&&n?this.__isDraggingOver=!0:this.__isDraggingOver&&!n&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(t.preventDefault(),e.canDrop=!0,e.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(e){let{e:t}=e,n=t.defaultPrevented;this.__isDraggingOver=!1,t.preventDefault();let r=t.dataTransfer?.getData(`text/plain`);if(r&&!n){let n=this.target,i=n.canvas,a=n.getSelectionStartFromPointer(t),{styles:o}=t.dataTransfer.types.includes(`application/fabric`)?JSON.parse(t.dataTransfer.getData(`application/fabric`)):{},s=r[Math.max(0,r.length-1)];if(this.__dragStartSelection){let e=this.__dragStartSelection.selectionStart,t=this.__dragStartSelection.selectionEnd;a>e&&a<=t?a=e:a>t&&(a-=t-e),n.removeChars(e,t),delete this.__dragStartSelection}n._reNewline.test(s)&&(n._reNewline.test(n._text[a])||a===n._text.length)&&(r=r.trimEnd()),e.didDrop=!0,e.dropTarget=n,n.insertChars(r,o,a),i.setActiveObject(n),n.enterEditing(t),n.selectionStart=Math.min(a+0,n._text.length),n.selectionEnd=Math.min(n.selectionStart+r.length,n._text.length),n.hiddenTextarea.value=n.text,n._updateTextarea(),n.hiddenTextarea.focus(),n.fire(et,{index:a+0,action:`drop`}),i.fire(`text:changed`,{target:n}),i.contextTopDirty=!0,i.requestRenderAll()}}dragEndHandler({e}){if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){let t=this.target,n=this.target.canvas,{selectionStart:r,selectionEnd:i}=this.__dragStartSelection,a=e.dataTransfer?.dropEffect||`none`;a===`none`?(t.selectionStart=r,t.selectionEnd=i,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),a===`move`&&(t.removeChars(r,i),t.selectionStart=t.selectionEnd=r,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(et,{index:r,action:`dragend`}),n.fire(`text:changed`,{target:t}),n.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}},Zs=/[ \n\.,;!\?\-]/,Qs=class extends Ys{constructor(...e){super(...e),H(this,`_currentCursorOpacity`,1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(e){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(e)}_animateCursor({toValue:e,duration:t,delay:n,onComplete:r}){return ki({startValue:this._currentCursorOpacity,endValue:e,duration:t,delay:n,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:e=>{this._currentCursorOpacity=e,this.renderCursorOrSelection()}})}_tick(e){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(e||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var e;(e=this._currentTickCompleteState)==null||e.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(e){this.abortCursorAnimation(),this._tick(e?0:this.cursorDelay)}abortCursorAnimation(){let e=!1;[this._currentTickState,this._currentTickCompleteState].forEach(t=>{t&&!t.isDone()&&(e=!0,t.abort())}),this._currentCursorOpacity=1,e&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(e=>!e||e.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join(``)}findWordBoundaryLeft(e){let t=0,n=e-1;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n--;for(;/\S/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findWordBoundaryRight(e){let t=0,n=e;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n++;for(;/\S/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}findLineBoundaryLeft(e){let t=0,n=e-1;for(;!/\n/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findLineBoundaryRight(e){let t=0,n=e;for(;!/\n/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}searchWordBoundary(e,t){let n=this._text,r=e>0&&this._reSpace.test(n[e])&&(t===-1||!Ke.test(n[e-1]))?e-1:e,i=n[r];for(;r>0&&r<n.length&&!Zs.test(i);)r+=t,i=n[r];return t===-1&&Zs.test(i)&&r++,r}selectWord(e){e??=this.selectionStart;let t=this.searchWordBoundary(e,-1),n=Math.max(t,this.searchWordBoundary(e,1));this.selectionStart=t,this.selectionEnd=n,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(e){e??=this.selectionStart;let t=this.findLineBoundaryLeft(e),n=this.findLineBoundaryRight(e);this.selectionStart=t,this.selectionEnd=n,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(e){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire(`editing:entered`,e?{e}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire(`text:editing:entered`,{target:this,e}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(e){if(this.getActiveControl())return;let t=this.hiddenTextarea;an(t).activeElement!==t&&t.focus();let n=this.getSelectionStartFromPointer(e),r=this.selectionStart,i=this.selectionEnd;(n===this.__selectionStartOnMouseDown&&r!==i||r!==n&&i!==n)&&(n>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=n):(this.selectionStart=n,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===r&&this.selectionEnd===i||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor=`text`,this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor=`text`),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(e,t,n){let r=n.slice(0,e),i=this.graphemeSplit(r).length;if(e===t)return{selectionStart:i,selectionEnd:i};let a=n.slice(e,t);return{selectionStart:i,selectionEnd:i+this.graphemeSplit(a).length}}fromGraphemeToStringSelection(e,t,n){let r=n.slice(0,e).join(``).length;return e===t?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+n.slice(e,t).join(``).length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){let e=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=e.selectionStart,this.hiddenTextarea.selectionEnd=e.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){let{hiddenTextarea:e,direction:t,textAlign:n,inCompositionMode:r}=this;if(!e)return;let i=n===`justify`?t===`ltr`?G:We:n.replace(`justify-`,``),a=this.getPositionByOrigin(i,`top`);this.cursorOffsetCache={},this.text=e.value,this.set(`dirty`,!0),this.initDimensions(),this.setPositionByOrigin(a,i,`top`),this.setCoords();let o=this.fromStringToGraphemeSelection(e.selectionStart,e.selectionEnd,e.value);this.selectionEnd=this.selectionStart=o.selectionEnd,r||(this.selectionStart=o.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){let e=this._calcTextareaPosition();this.hiddenTextarea.style.left=e.left,this.hiddenTextarea.style.top=e.top}}_calcTextareaPosition(){if(!this.canvas)return{left:`1px`,top:`1px`};let e=this.inCompositionMode?this.compositionStart:this.selectionStart,t=this._getCursorBoundaries(e),n=this.get2DCursorLocation(e),r=n.lineIndex,i=n.charIndex,a=this.getValueOfPropertyAt(r,i,`fontSize`)*this.lineHeight,o=t.leftOffset,s=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,l=c.width/s,u=c.height/s,d=l-a,f=u-a,p=new q(t.left+o,t.top+t.topOffset+a).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new q(c.clientWidth/l,c.clientHeight/u));return p.x<0&&(p.x=0),p.x>d&&(p.x=d),p.y<0&&(p.y=0),p.y>f&&(p.y=f),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:`${p.x}px`,top:`${p.y}px`,fontSize:`${a}px`,charHeight:a}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}exitEditingImpl(){let e=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){let e=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire(`editing:exited`),e&&this.fire(`modified`),this.canvas&&(this.canvas.fire(`text:editing:exited`,{target:this}),e&&this.canvas.fire(`object:modified`,{target:this})),this}_removeExtraneousStyles(){for(let e in this.styles)this._textLines[e]||delete this.styles[e]}removeStyleFromTo(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e,!0),{lineIndex:i,charIndex:a}=this.get2DCursorLocation(t,!0);if(n!==i){if(this.styles[n])for(let e=r;e<this._unwrappedTextLines[n].length;e++)delete this.styles[n][e];if(this.styles[i])for(let e=a;e<this._unwrappedTextLines[i].length;e++){let t=this.styles[i][e];t&&(this.styles[n]||(this.styles[n]={}),this.styles[n][r+e-a]=t)}for(let e=n+1;e<=i;e++)delete this.styles[e];this.shiftLineStyles(i,n-i)}else if(this.styles[n]){let e=this.styles[n],t=a-r;for(let t=r;t<a;t++)delete e[t];for(let r in this.styles[n]){let n=parseInt(r,10);n>=a&&(e[n-t]=e[r],delete e[r])}}}shiftLineStyles(e,t){let n=Object.assign({},this.styles);for(let r in this.styles){let i=parseInt(r,10);i>e&&(this.styles[i+t]=n[i],n[i-t]||delete this.styles[i])}}insertNewlineStyleObject(e,t,n,r){let i={},a=this._unwrappedTextLines[e].length,o=a===t,s=!1;n||=1,this.shiftLineStyles(e,n);let c=this.styles[e]?this.styles[e][t===0?t:t-1]:void 0;for(let n in this.styles[e]){let r=parseInt(n,10);r>=t&&(s=!0,i[r-t]=this.styles[e][n],o&&t===0||delete this.styles[e][n])}let l=!1;for(s&&!o&&(this.styles[e+n]=i,l=!0),(l||a>t)&&n--;n>0;)r&&r[n-1]?this.styles[e+n]={0:{...r[n-1]}}:c?this.styles[e+n]={0:{...c}}:delete this.styles[e+n],n--;this._forceClearCache=!0}insertCharStyleObject(e,t,n,r){this.styles||={};let i=this.styles[e],a=i?{...i}:{};n||=1;for(let e in a){let r=parseInt(e,10);r>=t&&(i[r+n]=a[r],a[r-n]||delete i[r])}if(this._forceClearCache=!0,r){for(;n--;)Object.keys(r[n]).length&&(this.styles[e]||(this.styles[e]={}),this.styles[e][t+n]={...r[n]});return}if(!i)return;let o=i[t?t-1:1];for(;o&&n--;)this.styles[e][t+n]={...o}}insertNewStyleBlock(e,t,n){let r=this.get2DCursorLocation(t,!0),i=[0],a,o=0;for(let t=0;t<e.length;t++)e[t]===`
|
|
27
|
+
`?(o++,i[o]=0):i[o]++;for(i[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,i[0],n),n&&=n.slice(i[0]+1)),o&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+i[0],o),a=1;a<o;a++)i[a]>0?this.insertCharStyleObject(r.lineIndex+a,0,i[a],n):n&&this.styles[r.lineIndex+a]&&n[0]&&(this.styles[r.lineIndex+a][0]=n[0]),n&&=n.slice(i[a]+1);i[a]>0&&this.insertCharStyleObject(r.lineIndex+a,0,i[a],n)}removeChars(e,t=e+1){this.removeStyleFromTo(e,t),this._text.splice(e,t-e),this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(e,t,n,r=n){r>n&&this.removeStyleFromTo(n,r);let i=this.graphemeSplit(e);this.insertNewStyleBlock(i,n,t),this._text=[...this._text.slice(0,n),...i,...this._text.slice(r)],this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(e,t,n){n<=e?(t===e?this._selectionDirection=G:this._selectionDirection===`right`&&(this._selectionDirection=G,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===`right`?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=We:this._selectionDirection===`left`&&(this._selectionDirection=We,this.selectionStart=t),this.selectionEnd=n)}},$s=class extends Qs{initHiddenTextarea(){let e=this.canvas&&an(this.canvas.getElement())||Me(),t=e.createElement(`textarea`);Object.entries({autocapitalize:`off`,autocorrect:`off`,autocomplete:`off`,spellcheck:`false`,"data-fabric":`textarea`,wrap:`off`,name:`fabricTextarea`}).map(([e,n])=>t.setAttribute(e,n));let{top:n,left:r,fontSize:i}=this._calcTextareaPosition();t.style.cssText=`position: absolute; top: ${n}; left: ${r}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${i};`,(this.hiddenTextareaContainer||e.body).appendChild(t),Object.entries({blur:`blur`,keydown:`onKeyDown`,keyup:`onKeyUp`,input:`onInput`,copy:`copy`,cut:`copy`,paste:`paste`,compositionstart:`onCompositionStart`,compositionupdate:`onCompositionUpdate`,compositionend:`onCompositionEnd`}).map(([e,n])=>t.addEventListener(e,this[n].bind(this))),this.hiddenTextarea=t}blur(){this.abortCursorAnimation()}onKeyDown(e){if(!this.isEditing)return;let t=this.direction===`rtl`?this.keysMapRtl:this.keysMap;if(e.keyCode in t)this[t[e.keyCode]](e);else{if(!(e.keyCode in this.ctrlKeysMapDown)||!e.ctrlKey&&!e.metaKey)return;this[this.ctrlKeysMapDown[e.keyCode]](e)}e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(e){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey)&&(this[this.ctrlKeysMapUp[e.keyCode]](e),e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(e){let t=this.fromPaste,{value:n,selectionStart:r,selectionEnd:i}=this.hiddenTextarea;if(this.fromPaste=!1,e&&e.stopPropagation(),!this.isEditing)return;let a=()=>{this.updateFromTextArea(),this.fire(et),this.canvas&&(this.canvas.fire(`text:changed`,{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value===``)return this.styles={},void a();let o=this._splitTextIntoLines(n).graphemeText,s=this._text.length,c=o.length,l=this.selectionStart,u=this.selectionEnd,d=l!==u,f,p,m,h,g=c-s,_=this.fromStringToGraphemeSelection(r,i,n),v=l>_.selectionStart;d?(p=this._text.slice(l,u),g+=u-l):c<s&&(p=v?this._text.slice(u+g,u):this._text.slice(l,l-g));let y=o.slice(_.selectionEnd-g,_.selectionEnd);if(p&&p.length&&(y.length&&(f=this.getSelectionStyles(l,l+1,!1),f=y.map(()=>f[0])),d?(m=l,h=u):v?(m=u-p.length,h=u):(m=u,h=u+p.length),this.removeStyleFromTo(m,h)),y.length){let{copyPasteData:e}=je();t&&y.join(``)===e.copiedText&&!U.disableStyleCopyPaste&&(f=e.copiedTextStyle),this.insertNewStyleBlock(y,l,f)}a()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate({target:e}){let{selectionStart:t,selectionEnd:n}=e;this.compositionStart=t,this.compositionEnd=n,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;let{copyPasteData:e}=je();e.copiedText=this.getSelectedText(),e.copiedTextStyle=U.disableStyleCopyPaste?void 0:this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(e,t){let n,r=this._getLineLeftOffset(e);return t>0&&(n=this.__charBounds[e][t-1],r+=n.left+n.width),r}getDownCursorOffset(e,t){let n=this._getSelectionForOffset(e,t),r=this.get2DCursorLocation(n),i=r.lineIndex;if(i===this._textLines.length-1||e.metaKey||e.keyCode===34)return this._text.length-n;let a=r.charIndex,o=this._getWidthBeforeCursor(i,a),s=this._getIndexOnLine(i+1,o);return this._textLines[i].slice(a).length+s+1+this.missingNewlineOffset(i)}_getSelectionForOffset(e,t){return e.shiftKey&&this.selectionStart!==this.selectionEnd&&t?this.selectionEnd:this.selectionStart}getUpCursorOffset(e,t){let n=this._getSelectionForOffset(e,t),r=this.get2DCursorLocation(n),i=r.lineIndex;if(i===0||e.metaKey||e.keyCode===33)return-n;let a=r.charIndex,o=this._getWidthBeforeCursor(i,a),s=this._getIndexOnLine(i-1,o),c=this._textLines[i].slice(0,a),l=this.missingNewlineOffset(i-1);return-this._textLines[i-1].length+s-c.length+(1-l)}_getIndexOnLine(e,t){let n=this._textLines[e],r,i,a=this._getLineLeftOffset(e),o=0;for(let s=0,c=n.length;s<c;s++)if(r=this.__charBounds[e][s].width,a+=r,a>t){i=!0;let e=a-r,n=a,c=Math.abs(e-t);o=Math.abs(n-t)<c?s:s-1;break}return i||(o=n.length-1),o}moveCursorDown(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown(`Down`,e)}moveCursorUp(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown(`Up`,e)}_moveCursorUpOrDown(e,t){let n=this[`get${e}CursorOffset`](t,this._selectionDirection===We);if(t.shiftKey?this.moveCursorWithShift(n):this.moveCursorWithoutShift(n),n!==0){let e=this.text.length;this.selectionStart=Rr(0,this.selectionStart,e),this.selectionEnd=Rr(0,this.selectionEnd,e),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(e){let t=this._selectionDirection===`left`?this.selectionStart+e:this.selectionEnd+e;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,t),e!==0}moveCursorWithoutShift(e){return e<0?(this.selectionStart+=e,this.selectionEnd=this.selectionStart):(this.selectionEnd+=e,this.selectionStart=this.selectionEnd),e!==0}moveCursorLeft(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight(`Left`,e)}_move(e,t,n){let r;if(e.altKey)r=this[`findWordBoundary${n}`](this[t]);else{if(!e.metaKey&&e.keyCode!==35&&e.keyCode!==36)return this[t]+=n===`Left`?-1:1,!0;r=this[`findLineBoundary${n}`](this[t])}return r!==void 0&&this[t]!==r&&(this[t]=r,!0)}_moveLeft(e,t){return this._move(e,t,`Left`)}_moveRight(e,t){return this._move(e,t,`Right`)}moveCursorLeftWithoutShift(e){let t=!0;return this._selectionDirection=G,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(t=this._moveLeft(e,`selectionStart`)),this.selectionEnd=this.selectionStart,t}moveCursorLeftWithShift(e){return this._selectionDirection===`right`&&this.selectionStart!==this.selectionEnd?this._moveLeft(e,`selectionEnd`):this.selectionStart===0?void 0:(this._selectionDirection=G,this._moveLeft(e,`selectionStart`))}moveCursorRight(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight(`Right`,e)}_moveCursorLeftOrRight(e,t){let n=`moveCursor${e}${t.shiftKey?`WithShift`:`WithoutShift`}`;this._currentCursorOpacity=1,this[n](t)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(e){return this._selectionDirection===`left`&&this.selectionStart!==this.selectionEnd?this._moveRight(e,`selectionStart`):this.selectionEnd===this._text.length?void 0:(this._selectionDirection=We,this._moveRight(e,`selectionEnd`))}moveCursorRightWithoutShift(e){let t=!0;return this._selectionDirection=We,this.selectionStart===this.selectionEnd?(t=this._moveRight(e,`selectionStart`),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,t}},ec=e=>!!e.button,tc=class extends $s{constructor(...e){super(...e),H(this,`draggableTextDelegate`,void 0)}initBehavior(){this.on(`mousedown`,this._mouseDownHandler),this.on(`mouseup`,this.mouseUpHandler),this.on(`mousedblclick`,this.doubleClickHandler),this.on(`mousetripleclick`,this.tripleClickHandler),this.draggableTextDelegate=new Xs(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(e){return this.draggableTextDelegate.onDragStart(e)}canDrop(e){return this.draggableTextDelegate.canDrop(e)}doubleClickHandler(e){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}tripleClickHandler(e){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}_mouseDownHandler({e,alreadySelected:t}){this.canvas&&this.editable&&!ec(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),t&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||=t||this.isEditing))}mouseUpHandler({e,transform:t}){let n=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);let e=this.canvas._activeObject;if(e&&e!==this)return}!this.editable||this.group&&!this.group.interactive||t&&t.actionPerformed||ec(e)||n||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(e){let t=this.getSelectionStartFromPointer(e),n=this.selectionStart,r=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(n,r,t):(this.selectionStart=t,this.selectionEnd=t),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(e){let t=this.canvas.getScenePoint(e).transform(Nt(this.calcTransformMatrix())).add(new q(-this._getLeftOffset(),-this._getTopOffset())),n=0,r=0,i=0;for(let e=0;e<this._textLines.length&&n<=t.y;e++)n+=this.getHeightOfLine(e),i=e,e>0&&(r+=this._textLines[e-1].length+this.missingNewlineOffset(e-1));let a=Math.abs(this._getLineLeftOffset(i)),o=this._textLines[i].length,s=this.__charBounds[i];for(let e=0;e<o;e++){let n=a+s[e].kernedWidth;if(t.x<=n){Math.abs(t.x-n)<=Math.abs(t.x-a)&&r++;break}a=n,r++}return Math.min(this.flipX?o-r:r,this._text.length)}},nc=`moveCursorUp`,rc=`moveCursorDown`,ic=`moveCursorLeft`,ac=`moveCursorRight`,oc=`exitEditing`,sc=(e,t)=>{let n=t.getRetinaScaling();e.setTransform(n,0,0,n,0,0);let r=t.viewportTransform;e.transform(r[0],r[1],r[2],r[3],r[4],r[5])},cc={selectionStart:0,selectionEnd:0,selectionColor:`rgba(17,119,255,0.3)`,isEditing:!1,editable:!0,editingBorderColor:`rgba(102,153,255,0.25)`,cursorWidth:2,cursorColor:``,cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:oc,27:oc,33:nc,34:rc,35:ac,36:ic,37:ic,38:nc,39:ac,40:rc},keysMapRtl:{9:oc,27:oc,33:nc,34:rc,35:ic,36:ac,37:ac,38:nc,39:ic,40:rc},ctrlKeysMapDown:{65:`cmdAll`},ctrlKeysMapUp:{67:`copy`,88:`cut`},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1},lc=class e extends tc{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}get type(){let e=super.type;return e===`itext`?`i-text`:e}constructor(t,n){super(t,{...e.ownDefaults,...n}),this.initBehavior()}_set(e,t){return this.isEditing&&this._savedProps&&e in this._savedProps?(this._savedProps[e]=t,this):(e===`canvas`&&(this.canvas instanceof hs&&this.canvas.textEditingManager.remove(this),t instanceof hs&&t.textEditingManager.add(this)),super._set(e,t))}setSelectionStart(e){e=Math.max(e,0),this._updateAndFire(`selectionStart`,e)}setSelectionEnd(e){e=Math.min(e,this.text.length),this._updateAndFire(`selectionEnd`,e)}_updateAndFire(e,t){this[e]!==t&&(this._fireSelectionChanged(),this[e]=t),this._updateTextarea()}_fireSelectionChanged(){this.fire(`selection:changed`),this.canvas&&this.canvas.fire(`text:selection:changed`,{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(e=this.selectionStart||0,t=this.selectionEnd,n){return super.getSelectionStyles(e,t,n)}setSelectionStyles(e,t=this.selectionStart||0,n=this.selectionEnd){return super.setSelectionStyles(e,t,n)}get2DCursorLocation(e=this.selectionStart,t){return super.get2DCursorLocation(e,t)}render(e){super.render(e),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(e){let t=this.isEditing;this.isEditing=!1;let n=super.toCanvasElement(e);return this.isEditing=t,n}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;let e=this.clearContextTop(!0);if(!e)return;let t=this._getCursorBoundaries(),n=this.findAncestorsWithClipPath(),r=n.length>0,i,a=e;if(r){i=Dt(e.canvas),a=i.getContext(`2d`),sc(a,this.canvas);let t=this.calcTransformMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(a,t):this.renderCursor(a,t),r)for(let t of n){let n=t.clipPath,r=Dt(e.canvas),i=r.getContext(`2d`);if(sc(i,this.canvas),!n.absolutePositioned){let e=t.calcTransformMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}n.transform(i),n.drawObject(i,!0,{}),this.drawClipPathOnCache(a,n,r)}r&&(e.setTransform(1,0,0,1,0,0),e.drawImage(i,0,0)),this.canvas.contextTopDirty=!0,e.restore()}findAncestorsWithClipPath(){let e=[],t=this;for(;t;)t.clipPath&&e.push(t),t=t.parent;return e}_getCursorBoundaries(e=this.selectionStart,t){let n=this._getLeftOffset(),r=this._getTopOffset(),i=this._getCursorBoundariesOffsets(e,t);return{left:n,top:r,leftOffset:i.left,topOffset:i.top}}_getCursorBoundariesOffsets(e,t){return t?this.__getCursorBoundariesOffsets(e):this.cursorOffsetCache&&`top`in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(e)}__getCursorBoundariesOffsets(e){let t=0,n=0,{charIndex:r,lineIndex:i}=this.get2DCursorLocation(e),{textAlign:a,direction:o}=this;for(let e=0;e<i;e++)t+=this.getHeightOfLine(e);let s=this._getLineLeftOffset(i),c=this.__charBounds[i][r];c&&(n=c.left),this.charSpacing!==0&&r===this._textLines[i].length&&(n-=this._getWidthOfCharSpacing());let l=s+(n>0?n:0);return o===`rtl`&&(a===`right`||a===`justify`||a===`justify-right`?l*=-1:a===`left`||a===`justify-left`?l=s-(n>0?n:0):a!==`center`&&a!==`justify-center`||(l=s-(n>0?n:0))),{top:t,left:l}}renderCursorAt(e){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(e,!0),e)}renderCursor(e,t){this._renderCursor(e,t,this.selectionStart)}getCursorRenderingData(e=this.selectionStart,t=this._getCursorBoundaries(e)){let n=this.get2DCursorLocation(e),r=n.lineIndex,i=n.charIndex>0?n.charIndex-1:0,a=this.getValueOfPropertyAt(r,i,`fontSize`),o=this.getObjectScaling().x*this.canvas.getZoom(),s=this.cursorWidth/o,c=this.getValueOfPropertyAt(r,i,`deltaY`),l=t.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-a*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,i,`fill`),opacity:this._currentCursorOpacity,left:t.left+t.leftOffset-s/2,top:l+t.top+c,width:s,height:a}}_renderCursor(e,t,n){let{color:r,opacity:i,left:a,top:o,width:s,height:c}=this.getCursorRenderingData(n,t);e.fillStyle=r,e.globalAlpha=i,e.fillRect(a,o,s,c)}renderSelection(e,t){let n={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(e,n,t)}renderDragSourceEffect(){let e=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,e,this._getCursorBoundaries(e.selectionStart,!0))}renderDropTargetEffect(e){let t=this.getSelectionStartFromPointer(e);this.renderCursorAt(t)}_renderSelection(e,t,n){let{textAlign:r,direction:i}=this,a=t.selectionStart,o=t.selectionEnd,s=r.includes(Dr),c=this.get2DCursorLocation(a),l=this.get2DCursorLocation(o),u=c.lineIndex,d=l.lineIndex,f=c.charIndex<0?0:c.charIndex,p=l.charIndex<0?0:l.charIndex;for(let t=u;t<=d;t++){let a=this._getLineLeftOffset(t)||0,o=this.getHeightOfLine(t),c=0,l=0;if(t===u&&(c=this.__charBounds[u][f].left),t>=u&&t<d)l=s&&!this.isEndOfWrapping(t)?this.width:this.getLineWidth(t)||5;else if(t===d)if(p===0)l=this.__charBounds[d][p].left;else{let e=this._getWidthOfCharSpacing();l=this.__charBounds[d][p-1].left+this.__charBounds[d][p-1].width-e}let m=o;(this.lineHeight<1||t===d&&this.lineHeight>1)&&(o/=this.lineHeight);let h=n.left+a+c,g=o,_=0,v=l-c;this.inCompositionMode?(e.fillStyle=this.compositionColor||`black`,g=1,_=o):e.fillStyle=this.selectionColor,i===`rtl`&&(r===`right`||r===`justify`||r===`justify-right`?h=this.width-h-v:r===`left`||r===`justify-left`?h=n.left+a-l:r!==`center`&&r!==`justify-center`||(h=n.left+a-l)),e.fillRect(h,n.top+n.topOffset+_,v,g),n.topOffset+=m}}getCurrentCharFontSize(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,`fontSize`)}getCurrentCharColor(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,ot)}_getCurrentCharIndex(){let e=this.get2DCursorLocation(this.selectionStart,!0),t=e.charIndex>0?e.charIndex-1:0;return{l:e.lineIndex,c:t}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}};H(lc,`ownDefaults`,cc),H(lc,`type`,`IText`),K.setClass(lc),K.setClass(lc,`i-text`);var uc=class e extends lc{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(t,{...e.ownDefaults,...n})}static createControls(){return{controls:ma()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set(`width`,this.dynamicMinWidth),this.textAlign.includes(`justify`)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(e){let t=0,n=0,r=0,i={};for(let a=0;a<e.graphemeLines.length;a++)e.graphemeText[r]===`
|
|
28
|
+
`&&a>0?(n=0,r++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[r])&&a>0&&(n++,r++),i[a]={line:t,offset:n},r+=e.graphemeLines[a].length,n+=e.graphemeLines[a].length;return i}styleHas(e,t){if(this._styleMap&&!this.isWrapping){let e=this._styleMap[t];e&&(t=e.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t,n,r=0,i=!1,a=this._styleMap[e],o=this._styleMap[e+1];a&&(e=a.line,r=a.offset),o&&(t=o.line,i=t===e,n=o.offset);let s=e===void 0?this.styles:{line:this.styles[e]};for(let e in s)for(let t in s[e]){let a=parseInt(t,10);if(a>=r&&(!i||a<n))for(let n in s[e][t])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){let n=this._styleMap[e];if(!n)return{};e=n.line,t=n.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,n){let r=this._styleMap[e];super._setStyleDeclaration(r.line,r.offset+t,n)}_deleteStyleDeclaration(e,t){let n=this._styleMap[e];super._deleteStyleDeclaration(n.line,n.offset+t)}_getLineStyle(e){let t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){let t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;let n=this.getGraphemeDataForRender(e),r=[];for(let e=0;e<n.wordsData.length;e++)r.push(...this._wrapLine(e,t,n));return this.isWrapping=!1,r}getGraphemeDataForRender(e){let t=this.splitByGrapheme,n=t?``:` `,r=0;return{wordsData:e.map((e,i)=>{let a=0,o=t?this.graphemeSplit(e):this.wordSplit(e);return o.length===0?[{word:[],width:0}]:o.map(e=>{let o=t?[e]:this.graphemeSplit(e),s=this._measureWord(o,i,a);return r=Math.max(s,r),a+=o.length+n.length,{word:o,width:s}})}),largestWordWidth:r}}_measureWord(e,t,n=0){let r,i=0;for(let a=0,o=e.length;a<o;a++)i+=this._getGraphemeBox(e[a],t,a+n,r,!0).kernedWidth,r=e[a];return i}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,{largestWordWidth:n,wordsData:r},i=0){let a=this._getWidthOfCharSpacing(),o=this.splitByGrapheme,s=[],c=o?``:` `,l=0,u=[],d=0,f=0,p=!0;t-=i;let m=Math.max(t,n,this.dynamicMinWidth),h=r[e],g;for(g=0;g<h.length;g++){let{word:t,width:n}=h[g];d+=t.length,l+=f+n-a,l>m&&!p?(s.push(u),u=[],l=n,p=!0):l+=a,p||o||u.push(c),u=u.concat(t),f=o?0:this._measureWord([c],e,d),d++,p=!1}return g&&s.push(u),n+i>this.dynamicMinWidth&&(this.dynamicMinWidth=n-a+i),s}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?+!!this.isEndOfWrapping(e):1}_splitTextIntoLines(e){let t=super._splitTextIntoLines(e),n=this._wrapText(t.lines,this.width),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[e].join(``);return t.lines=r,t.graphemeLines=n,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let e=new Map;for(let t in this._styleMap){let n=parseInt(t,10);if(this._textLines[n]){let n=this._styleMap[t].line;e.set(`${n}`,!0)}}for(let t in this.styles)e.has(t)||delete this.styles[t]}toObject(e=[]){return super.toObject([`minWidth`,`splitByGrapheme`,...e])}};H(uc,`type`,`Textbox`),H(uc,`textLayoutProperties`,[...lc.textLayoutProperties,`width`]),H(uc,`ownDefaults`,{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),K.setClass(uc);var dc=class extends ro{shouldPerformLayout(e){return!!e.target.clipPath&&super.shouldPerformLayout(e)}shouldLayoutClipPath(){return!1}calcLayoutResult(e,t){let{target:n}=e,{clipPath:r,group:i}=n;if(!r||!this.shouldPerformLayout(e))return;let{width:a,height:o}=Cn(no(n,r)),s=new q(a,o);if(r.absolutePositioned)return{center:jn(r.getRelativeCenterPoint(),void 0,i?i.calcTransformMatrix():void 0),size:s};{let i=r.getRelativeCenterPoint().transform(n.calcOwnMatrix(),!0);if(this.shouldPerformLayout(e)){let{center:n=new q,correction:r=new q}=this.calcBoundingBox(t,e)||{};return{center:n.add(i),correction:r.subtract(i),size:s}}return{center:n.getRelativeCenterPoint().add(i),size:s}}}};H(dc,`type`,`clip-path`),K.setClass(dc);var fc=class extends ro{getInitialSize({target:e},{size:t}){return new q(e.width||t.x,e.height||t.y)}};H(fc,`type`,`fixed`),K.setClass(fc);var pc=class extends oo{subscribeTargets(e){let t=e.target;e.targets.reduce((e,t)=>(t.parent&&e.add(t.parent),e),new Set).forEach(e=>{e.layoutManager.subscribeTargets({target:e,targets:[t]})})}unsubscribeTargets(e){let t=e.target,n=t.getObjects();e.targets.reduce((e,t)=>(t.parent&&e.add(t.parent),e),new Set).forEach(e=>{!n.some(t=>t.parent===e)&&e.layoutManager.unsubscribeTargets({target:e,targets:[t]})})}},mc=class e extends co{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(n);let{left:r,top:i,layoutManager:a}=n;this.groupInit(t,{left:r,top:i,layoutManager:a??new pc})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(...e){this.multiSelectionStacking===`selection-order`?this.add(...e):e.forEach(e=>{let t=this._objects.findIndex(t=>t.isInFrontOf(e)),n=t===-1?this.size():t;this.insertAt(n,e)})}canEnterGroup(e){return this.getObjects().some(t=>t.isDescendantOf(e)||e.isDescendantOf(t))?(we(`error`,`ActiveSelection: circular object trees are not supported, this call has no effect`),!1):super.canEnterGroup(e)}enterGroup(e,t){e.parent&&e.parent===e.group?e.parent._exitGroup(e):e.group&&e.parent!==e.group&&e.group.remove(e),this._enterGroup(e,t)}exitGroup(e,t){this._exitGroup(e,t),e.parent&&e.parent._enterGroup(e,!0)}_onAfterObjectsChange(e,t){super._onAfterObjectsChange(e,t);let n=new Set;t.forEach(e=>{let{parent:t}=e;t&&n.add(t)}),e===`removed`?n.forEach(e=>{e._onAfterObjectsChange(to,t)}):n.forEach(e=>{e._set(`dirty`,!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(e,t,n){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;let r={hasControls:!1,...n,forActiveSelection:!0};for(let t=0;t<this._objects.length;t++)this._objects[t]._renderControls(e,r);super._renderControls(e,t),e.restore()}};H(mc,`type`,`ActiveSelection`),H(mc,`ownDefaults`,{multiSelectionStacking:`canvas-stacking`}),K.setClass(mc),K.setClass(mc,`activeSelection`);var hc=class{constructor(){H(this,`resources`,{})}applyFilters(e,t,n,r,i){let a=i.getContext(`2d`,{willReadFrequently:!0,desynchronized:!0});if(!a)return;a.drawImage(t,0,0,n,r);let o={sourceWidth:n,sourceHeight:r,imageData:a.getImageData(0,0,n,r),originalEl:t,originalImageData:a.getImageData(0,0,n,r),canvasEl:i,ctx:a,filterBackend:this};e.forEach(e=>{e.applyTo(o)});let{imageData:s}=o;return s.width===n&&s.height===r||(i.width=s.width,i.height=s.height),a.putImageData(s,0,0),o}},gc=class{constructor({tileSize:e=U.textureSize}={}){H(this,`aPosition`,new Float32Array([0,0,0,1,1,0,1,1])),H(this,`resources`,{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(e,t){this.dispose(),this.createWebGLCanvas(e,t)}createWebGLCanvas(e,t){let n=Dt({width:e,height:t}),r=n.getContext(`webgl`,{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=n,this.gl=r)}applyFilters(e,t,n,r,i,a){let o=this.gl,s=i.getContext(`2d`);if(!o||!s)return;let c;a&&(c=this.getCachedTexture(a,t));let l={originalWidth:t.width||t.naturalWidth||0,originalHeight:t.height||t.naturalHeight||0,sourceWidth:n,sourceHeight:r,destinationWidth:n,destinationHeight:r,context:o,sourceTexture:this.createTexture(o,n,r,c?void 0:t),targetTexture:this.createTexture(o,n,r),originalTexture:c||this.createTexture(o,n,r,c?void 0:t),passes:e.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:i},u=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,u),e.forEach(e=>{e&&e.applyTo(l)}),function(e){let t=e.targetCanvas,n=t.width,r=t.height,i=e.destinationWidth,a=e.destinationHeight;n===i&&r===a||(t.width=i,t.height=a)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(u),s.setTransform(1,0,0,1,0,0),l}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(e,t,n,r,i){let{NEAREST:a,TEXTURE_2D:o,RGBA:s,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:l,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:p}=e,m=e.createTexture();return e.bindTexture(o,m),e.texParameteri(o,u,i||a),e.texParameteri(o,d,i||a),e.texParameteri(o,f,l),e.texParameteri(o,p,l),r?e.texImage2D(o,0,s,s,c,r):e.texImage2D(o,0,s,t,n,0,s,c,null),m}getCachedTexture(e,t,n){let{textureCache:r}=this;if(r[e])return r[e];{let i=this.createTexture(this.gl,t.width,t.height,t,n);return i&&(r[e]=i),i}}evictCachesForKey(e){this.textureCache[e]&&(this.gl.deleteTexture(this.textureCache[e]),delete this.textureCache[e])}copyGLTo2D(e,t){let n=e.canvas,r=t.targetCanvas,i=r.getContext(`2d`);if(!i)return;i.translate(0,r.height),i.scale(1,-1);let a=n.height-r.height;i.drawImage(n,0,a,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(e,t){let n=t.targetCanvas.getContext(`2d`),r=t.destinationWidth,i=t.destinationHeight,a=r*i*4;if(!n)return;let o=new Uint8Array(this.imageBuffer,0,a),s=new Uint8ClampedArray(this.imageBuffer,0,a);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,o);let c=new ImageData(s,r,i);n.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;let e=this.gl,t={renderer:``,vendor:``};if(!e)return t;let n=e.getExtension(`WEBGL_debug_renderer_info`);if(n){let r=e.getParameter(n.UNMASKED_RENDERER_WEBGL),i=e.getParameter(n.UNMASKED_VENDOR_WEBGL);r&&(t.renderer=r.toLowerCase()),i&&(t.vendor=i.toLowerCase())}return this.gpuInfo=t,t}},_c;function vc(){let{WebGLProbe:e}=je();return e.queryWebGL(wt()),U.enableGLFiltering&&e.isSupported(U.textureSize)?new gc({tileSize:U.textureSize}):new hc}function yc(e=!0){return!_c&&e&&(_c=vc()),_c}var bc=[`cropX`,`cropY`],xc=class e extends _a{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(),H(this,`_lastScaleX`,1),H(this,`_lastScaleY`,1),H(this,`_filterScalingX`,1),H(this,`_filterScalingY`,1),this.filters=[],Object.assign(this,e.ownDefaults),this.setOptions(n),this.cacheKey=`texture${Ct()}`,this.setElement(typeof t==`string`?(this.canvas&&an(this.canvas.getElement())||Me()).getElementById(t):t,n)}getElement(){return this._element}setElement(e,t={}){this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=e,this._originalElement=e,this._setWidthHeight(t),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(e){let t=yc(!1);t instanceof gc&&t.evictCachesForKey(e)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,[`_originalElement`,`_element`,`_filteredEl`,`_cacheCanvas`].forEach(e=>{let t=this[e];t&&je().dispose(t),this[e]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){let e=this.getElement();return e?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}}_stroke(e){if(!this.stroke||this.strokeWidth===0)return;let t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,-n),e.lineTo(t,-n),e.lineTo(t,n),e.lineTo(-t,n),e.lineTo(-t,-n),e.closePath()}toObject(e=[]){let t=[];return this.filters.forEach(e=>{e&&t.push(e.toObject())}),{...super.toObject([...bc,...e]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:t,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){let e=[],t=this._element,n=-this.width/2,r=-this.height/2,i=[],a=[],o=``,s=``;if(!t)return[];if(this.hasCrop()){let e=Ct();i.push(`<clipPath id="imageCrop_`+e+`">
|
|
29
|
+
`,` <rect x="`+n+`" y="`+r+`" width="`+Z(this.width)+`" height="`+Z(this.height)+`" />
|
|
30
|
+
`,`</clipPath>
|
|
31
|
+
`),o=` clip-path="url(#imageCrop_`+e+`)" `}if(this.imageSmoothing||(s=` image-rendering="optimizeSpeed"`),e.push(` <image `,`COMMON_PARTS`,`xlink:href="${Z(this.getSrc(!0))}" x="${n-this.cropX}" y="${r-this.cropY}" width="${t.width||t.naturalWidth}" height="${t.height||t.naturalHeight}"${s}${o}></image>\n`),this.stroke||this.strokeDashArray){let e=this.fill;this.fill=null,a=[`\t<rect x="${n}" y="${r}" width="${Z(this.width)}" height="${Z(this.height)}" style="${this.getSvgStyles()}" />\n`],this.fill=e}return i=this.paintFirst===`fill`?i.concat(e,a):i.concat(a,e),i}getSrc(e){let t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute(`src`)||``:t.src:this.src||``}getSvgSrc(e){return this.getSrc(e)}setSrc(e,{crossOrigin:t,signal:n}={}){return qt(e,{crossOrigin:t,signal:n}).then(e=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(e)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){let e=this.resizeFilter,t=this.minimumScaleTrigger,n=this.getTotalObjectScaling(),r=n.x,i=n.y,a=this._filteredEl||this._originalElement;if(this.group&&this.set(`dirty`,!0),!e||r>t&&i>t)return this._element=a,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=i);let o=Dt(a),{width:s,height:c}=a;this._element=o,this._lastScaleX=e.scaleX=r,this._lastScaleY=e.scaleY=i,yc().applyFilters([e],a,s,c,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(e=this.filters||[]){if(e=e.filter(e=>e&&!e.isNeutralState()),this.set(`dirty`,!0),this.removeTexture(`${this.cacheKey}_filtered`),e.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);let t=this._originalElement,n=t.naturalWidth||t.width,r=t.naturalHeight||t.height;if(this._element===this._originalElement){let e=Dt({width:n,height:r});this._element=e,this._filteredEl=e}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext(`2d`).clearRect(0,0,n,r),this._lastScaleX=1,this._lastScaleY=1);yc().applyFilters(e,this._originalElement,n,r,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){let t=this._element;if(!t)return;let n=this._filterScalingX,r=this._filterScalingY,i=this.width,a=this.height,o=Math.max(this.cropX,0),s=Math.max(this.cropY,0),c=t.naturalWidth||t.width,l=t.naturalHeight||t.height,u=o*n,d=s*r,f=Math.min(i*n,c-u),p=Math.min(a*r,l-d),m=-i/2,h=-a/2,g=Math.min(i,c/n-o),_=Math.min(a,l/r-s);t&&e.drawImage(t,u,d,f,p,m,h,g,_)}_needsResize(){let e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight({width:e,height:t}={}){let n=this.getOriginalSize();this.width=e||n.width,this.height=t||n.height}parsePreserveAspectRatioAttribute(){let e=hr(this.preserveAspectRatio||``),t=this.width,n=this.height,r={width:t,height:n},i,a=this._element.width,o=this._element.height,s=1,c=1,l=0,u=0,d=0,f=0;return!e||e.alignX===`none`&&e.alignY===`none`?(s=t/a,c=n/o):(e.meetOrSlice===`meet`&&(s=c=uo(this._element,r),i=(t-a*s)/2,e.alignX===`Min`&&(l=-i),e.alignX===`Max`&&(l=i),i=(n-o*c)/2,e.alignY===`Min`&&(u=-i),e.alignY===`Max`&&(u=i)),e.meetOrSlice===`slice`&&(s=c=fo(this._element,r),i=a-t/s,e.alignX===`Mid`&&(d=i/2),e.alignX===`Max`&&(d=i),i=o-n/c,e.alignY===`Mid`&&(f=i/2),e.alignY===`Max`&&(f=i),a=t/s,o=n/c)),{width:a,height:o,scaleX:s,scaleY:c,offsetLeft:l,offsetTop:u,cropX:d,cropY:f}}static fromObject({filters:e,resizeFilter:t,src:n,crossOrigin:r,type:i,...a},o){return Promise.all([qt(n,{...o,crossOrigin:r}),e&&Jt(e,o),t?Jt([t],o):[],Yt(a,o)]).then(([e,t=[],[r],i={}])=>new this(e,{...a,src:n,filters:t,resizeFilter:r,...i}))}static fromURL(e,{crossOrigin:t=null,signal:n}={},r){return qt(e,{crossOrigin:t,signal:n}).then(e=>new this(e,r))}static async fromElement(e,t={},n){let r=Za(e,this.ATTRIBUTE_NAMES,n);return this.fromURL(r[`xlink:href`]||r.href,t,r).catch(e=>(we(`log`,`Unable to parse Image`,e),null))}};H(xc,`type`,`Image`),H(xc,`cacheProperties`,[...Br,...bc]),H(xc,`ownDefaults`,{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),H(xc,`ATTRIBUTE_NAMES`,[...Oa,`x`,`y`,`width`,`height`,`preserveAspectRatio`,`xlink:href`,`href`,`crossOrigin`,`image-rendering`]),K.setClass(xc),K.setSVGClass(xc),vr([`pattern`,`defs`,`symbol`,`metadata`,`clipPath`,`mask`,`desc`]);var Sc=e=>e.webgl!==void 0,Cc=`precision highp float`,wc=`\n ${Cc};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`,Tc=new RegExp(Cc,`g`),Q=class{get type(){return this.constructor.type}constructor({type:e,...t}={}){Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return wc}getVertexSource(){return`
|
|
32
|
+
attribute vec2 aPosition;
|
|
33
|
+
varying vec2 vTexCoord;
|
|
34
|
+
void main() {
|
|
35
|
+
vTexCoord = aPosition;
|
|
36
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
37
|
+
}`}createProgram(e,t=this.getFragmentSource(),n=this.getVertexSource()){let{WebGLProbe:{GLPrecision:r=`highp`}}=je();r!==`highp`&&(t=t.replace(Tc,Cc.replace(`highp`,r)));let i=e.createShader(e.VERTEX_SHADER),a=e.createShader(e.FRAGMENT_SHADER),o=e.createProgram();if(!i||!a||!o)throw new Te(`Vertex, fragment shader or program creation error`);if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new Te(`Vertex shader compile error for ${this.type}: ${e.getShaderInfoLog(i)}`);if(e.shaderSource(a,t),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS))throw new Te(`Fragment shader compile error for ${this.type}: ${e.getShaderInfoLog(a)}`);if(e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Te(`Shader link error for "${this.type}" ${e.getProgramInfoLog(o)}`);let s=this.getUniformLocations(e,o)||{};return s.uStepW=e.getUniformLocation(o,`uStepW`),s.uStepH=e.getUniformLocation(o,`uStepH`),{program:o,attributeLocations:this.getAttributeLocations(e,o),uniformLocations:s}}getAttributeLocations(e,t){return{aPosition:e.getAttribLocation(t,`aPosition`)}}getUniformLocations(e,t){let n=this.constructor.uniformLocations,r={};for(let i=0;i<n.length;i++)r[n[i]]=e.getUniformLocation(t,n[i]);return r}sendAttributeData(e,t,n){let r=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)}_setupFrameBuffer(e){let t=e.context;if(e.passes>1){let n=e.destinationWidth,r=e.destinationHeight;e.sourceWidth===n&&e.sourceHeight===r||(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,r)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)}else t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish()}_swapTextures(e){e.passes--,e.pass++;let t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t}isNeutralState(e){return!1}applyTo(e){Sc(e)?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){}getCacheKey(){return this.type}retrieveShader(e){let t=this.getCacheKey();return e.programCache[t]||(e.programCache[t]=this.createProgram(e.context)),e.programCache[t]}applyToWebGL(e){let t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)}unbindAdditionalTexture(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)}sendUniformData(e,t){}createHelpLayer(e){if(!e.helpLayer){let{sourceWidth:t,sourceHeight:n}=e;e.helpLayer=Dt({width:t,height:n})}}toObject(){let e=Object.keys(this.constructor.defaults||{});return{type:this.type,...e.reduce((e,t)=>(e[t]=this[t],e),{})}}toJSON(){return this.toObject()}static async fromObject({type:e,...t},n){return new this(t)}};H(Q,`type`,`BaseFilter`),H(Q,`uniformLocations`,[]);var Ec={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
38
|
+
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
39
|
+
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
40
|
+
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
41
|
+
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
|
42
|
+
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
|
43
|
+
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
|
44
|
+
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
|
45
|
+
`,overlay:`
|
|
46
|
+
if (uColor.r < 0.5) {
|
|
47
|
+
gl_FragColor.r *= 2.0 * uColor.r;
|
|
48
|
+
} else {
|
|
49
|
+
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
|
50
|
+
}
|
|
51
|
+
if (uColor.g < 0.5) {
|
|
52
|
+
gl_FragColor.g *= 2.0 * uColor.g;
|
|
53
|
+
} else {
|
|
54
|
+
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
|
55
|
+
}
|
|
56
|
+
if (uColor.b < 0.5) {
|
|
57
|
+
gl_FragColor.b *= 2.0 * uColor.b;
|
|
58
|
+
} else {
|
|
59
|
+
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
|
60
|
+
}
|
|
61
|
+
`,tint:`
|
|
62
|
+
gl_FragColor.rgb *= (1.0 - uColor.a);
|
|
63
|
+
gl_FragColor.rgb += uColor.rgb;
|
|
64
|
+
`},Dc=class extends Q{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n gl_FragColor = color;\n if (color.a > 0.0) {\n ${Ec[this.mode]}\n }\n }\n `}applyTo2d({imageData:{data:e}}){let t=new fr(this.color).getSource(),n=this.alpha,r=t[0]*n,i=t[1]*n,a=t[2]*n,o=1-n;for(let t=0;t<e.length;t+=4){let n=e[t],s=e[t+1],c=e[t+2],l,u,d;switch(this.mode){case`multiply`:l=n*r/255,u=s*i/255,d=c*a/255;break;case`screen`:l=255-(255-n)*(255-r)/255,u=255-(255-s)*(255-i)/255,d=255-(255-c)*(255-a)/255;break;case`add`:l=n+r,u=s+i,d=c+a;break;case`difference`:l=Math.abs(n-r),u=Math.abs(s-i),d=Math.abs(c-a);break;case`subtract`:l=n-r,u=s-i,d=c-a;break;case`darken`:l=Math.min(n,r),u=Math.min(s,i),d=Math.min(c,a);break;case`lighten`:l=Math.max(n,r),u=Math.max(s,i),d=Math.max(c,a);break;case`overlay`:l=r<128?2*n*r/255:255-2*(255-n)*(255-r)/255,u=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,d=a<128?2*c*a/255:255-2*(255-c)*(255-a)/255;break;case`exclusion`:l=r+n-2*r*n/255,u=i+s-2*i*s/255,d=a+c-2*a*c/255;break;case`tint`:l=r+n*o,u=i+s*o,d=a+c*o}e[t]=l,e[t+1]=u,e[t+2]=d}}sendUniformData(e,t){let n=new fr(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,e.uniform4fv(t.uColor,n)}};H(Dc,`defaults`,{color:`#F95C63`,mode:`multiply`,alpha:1}),H(Dc,`type`,`BlendColor`),H(Dc,`uniformLocations`,[`uColor`]),K.setClass(Dc);var Oc={multiply:`
|
|
65
|
+
precision highp float;
|
|
66
|
+
uniform sampler2D uTexture;
|
|
67
|
+
uniform sampler2D uImage;
|
|
68
|
+
uniform vec4 uColor;
|
|
69
|
+
varying vec2 vTexCoord;
|
|
70
|
+
varying vec2 vTexCoord2;
|
|
71
|
+
void main() {
|
|
72
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
73
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
74
|
+
color.rgba *= color2.rgba;
|
|
75
|
+
gl_FragColor = color;
|
|
76
|
+
}
|
|
77
|
+
`,mask:`
|
|
78
|
+
precision highp float;
|
|
79
|
+
uniform sampler2D uTexture;
|
|
80
|
+
uniform sampler2D uImage;
|
|
81
|
+
uniform vec4 uColor;
|
|
82
|
+
varying vec2 vTexCoord;
|
|
83
|
+
varying vec2 vTexCoord2;
|
|
84
|
+
void main() {
|
|
85
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
86
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
87
|
+
color.a = color2.a;
|
|
88
|
+
gl_FragColor = color;
|
|
89
|
+
}
|
|
90
|
+
`},kc=class extends Q{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return Oc[this.mode]}getVertexSource(){return`
|
|
91
|
+
attribute vec2 aPosition;
|
|
92
|
+
varying vec2 vTexCoord;
|
|
93
|
+
varying vec2 vTexCoord2;
|
|
94
|
+
uniform mat3 uTransformMatrix;
|
|
95
|
+
void main() {
|
|
96
|
+
vTexCoord = aPosition;
|
|
97
|
+
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
98
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
99
|
+
}
|
|
100
|
+
`}applyToWebGL(e){let t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),super.applyToWebGL(e),this.unbindAdditionalTexture(t,t.TEXTURE1)}createTexture(e,t){return e.getCachedTexture(t.cacheKey,t.getElement())}calculateMatrix(){let e=this.image,{width:t,height:n}=e.getElement();return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]}applyTo2d({imageData:{data:e,width:t,height:n},filterBackend:{resources:r}}){let i=this.image;r.blendImage||=wt();let a=r.blendImage,o=a.getContext(`2d`);a.width!==t||a.height!==n?(a.width=t,a.height=n):o.clearRect(0,0,t,n),o.setTransform(i.scaleX,0,0,i.scaleY,i.left,i.top),o.drawImage(i.getElement(),0,0,t,n);let s=o.getImageData(0,0,t,n).data;for(let t=0;t<e.length;t+=4){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=s[t],c=s[t+1],l=s[t+2],u=s[t+3];switch(this.mode){case`multiply`:e[t]=n*o/255,e[t+1]=r*c/255,e[t+2]=i*l/255,e[t+3]=a*u/255;break;case`mask`:e[t+3]=u}}}sendUniformData(e,t){let n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject({type:e,image:t,...n},r){return xc.fromObject(t,r).then(e=>new this({...n,image:e}))}};H(kc,`type`,`BlendImage`),H(kc,`defaults`,{mode:`multiply`,alpha:1}),H(kc,`uniformLocations`,[`uTransformMatrix`,`uImage`]),K.setClass(kc);var Ac=class extends Q{getFragmentSource(){return`
|
|
101
|
+
precision highp float;
|
|
102
|
+
uniform sampler2D uTexture;
|
|
103
|
+
uniform vec2 uDelta;
|
|
104
|
+
varying vec2 vTexCoord;
|
|
105
|
+
const float nSamples = 15.0;
|
|
106
|
+
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
|
107
|
+
float random(vec3 scale) {
|
|
108
|
+
/* use the fragment position for a different seed per-pixel */
|
|
109
|
+
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
|
110
|
+
}
|
|
111
|
+
void main() {
|
|
112
|
+
vec4 color = vec4(0.0);
|
|
113
|
+
float totalC = 0.0;
|
|
114
|
+
float totalA = 0.0;
|
|
115
|
+
float offset = random(v3offset);
|
|
116
|
+
for (float t = -nSamples; t <= nSamples; t++) {
|
|
117
|
+
float percent = (t + offset - 0.5) / nSamples;
|
|
118
|
+
vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
|
|
119
|
+
float weight = 1.0 - abs(percent);
|
|
120
|
+
float alpha = weight * sample.a;
|
|
121
|
+
color.rgb += sample.rgb * alpha;
|
|
122
|
+
color.a += alpha;
|
|
123
|
+
totalA += weight;
|
|
124
|
+
totalC += alpha;
|
|
125
|
+
}
|
|
126
|
+
gl_FragColor.rgb = color.rgb / totalC;
|
|
127
|
+
gl_FragColor.a = color.a / totalA;
|
|
128
|
+
}
|
|
129
|
+
`}applyTo(e){Sc(e)?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d({imageData:{data:e,width:t,height:n}}){this.aspectRatio=t/n,this.horizontal=!0;let r=this.getBlurValue()*t,i=new Uint8ClampedArray(e),a=4*t;for(let t=0;t<e.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t-t%a,d=u+a;for(let i=-14;i<15;i++){let a=i/15,f=4*Math.floor(r*a),p=1-Math.abs(a),m=t+f;m<u?m=u:m>d&&(m=d);let h=e[m+3]*p;n+=e[m]*h,o+=e[m+1]*h,s+=e[m+2]*h,c+=h,l+=p}i[t]=n/c,i[t+1]=o/c,i[t+2]=s/c,i[t+3]=c/l}this.horizontal=!1,r=this.getBlurValue()*n;for(let t=0;t<i.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t%a,d=i.length-a+u;for(let e=-14;e<15;e++){let f=e/15,p=Math.floor(r*f)*a,m=1-Math.abs(f),h=t+p;h<u?h=u:h>d&&(h=d);let g=i[h+3]*m;n+=i[h]*g,o+=i[h+1]*g,s+=i[h+2]*g,c+=g,l+=m}e[t]=n/c,e[t+1]=o/c,e[t+2]=s/c,e[t+3]=c/l}}sendUniformData(e,t){let n=this.chooseRightDelta();e.uniform2fv(t.uDelta,n)}isNeutralState(){return this.blur===0}getBlurValue(){let e=1,{horizontal:t,aspectRatio:n}=this;return t?n>1&&(e=1/n):n<1&&(e=n),e*this.blur*.12}chooseRightDelta(){let e=this.getBlurValue();return this.horizontal?[e,0]:[0,e]}};H(Ac,`type`,`Blur`),H(Ac,`defaults`,{blur:0}),H(Ac,`uniformLocations`,[`uDelta`]),K.setClass(Ac);var jc=class extends Q{getFragmentSource(){return`
|
|
130
|
+
precision highp float;
|
|
131
|
+
uniform sampler2D uTexture;
|
|
132
|
+
uniform float uBrightness;
|
|
133
|
+
varying vec2 vTexCoord;
|
|
134
|
+
void main() {
|
|
135
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
136
|
+
color.rgb += uBrightness;
|
|
137
|
+
gl_FragColor = color;
|
|
138
|
+
}
|
|
139
|
+
`}applyTo2d({imageData:{data:e}}){let t=Math.round(255*this.brightness);for(let n=0;n<e.length;n+=4)e[n]+=t,e[n+1]+=t,e[n+2]+=t}isNeutralState(){return this.brightness===0}sendUniformData(e,t){e.uniform1f(t.uBrightness,this.brightness)}};H(jc,`type`,`Brightness`),H(jc,`defaults`,{brightness:0}),H(jc,`uniformLocations`,[`uBrightness`]),K.setClass(jc);var Mc={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0},Nc=class extends Q{getFragmentSource(){return`
|
|
140
|
+
precision highp float;
|
|
141
|
+
uniform sampler2D uTexture;
|
|
142
|
+
varying vec2 vTexCoord;
|
|
143
|
+
uniform mat4 uColorMatrix;
|
|
144
|
+
uniform vec4 uConstants;
|
|
145
|
+
void main() {
|
|
146
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
147
|
+
color *= uColorMatrix;
|
|
148
|
+
color += uConstants;
|
|
149
|
+
gl_FragColor = color;
|
|
150
|
+
}`}applyTo2d(e){let t=e.imageData.data,n=this.matrix,r=this.colorsOnly;for(let e=0;e<t.length;e+=4){let i=t[e],a=t[e+1],o=t[e+2];if(t[e]=i*n[0]+a*n[1]+o*n[2]+255*n[4],t[e+1]=i*n[5]+a*n[6]+o*n[7]+255*n[9],t[e+2]=i*n[10]+a*n[11]+o*n[12]+255*n[14],!r){let r=t[e+3];t[e]+=r*n[3],t[e+1]+=r*n[8],t[e+2]+=r*n[13],t[e+3]=i*n[15]+a*n[16]+o*n[17]+r*n[18]+255*n[19]}}}sendUniformData(e,t){let n=this.matrix,r=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,r),e.uniform4fv(t.uConstants,i)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}};function Pc(e,t){var n;let r=(H(n=class extends Nc{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},`type`,e),H(n,`defaults`,{colorsOnly:!1,matrix:t}),n);return K.setClass(r,e),r}H(Nc,`type`,`ColorMatrix`),H(Nc,`defaults`,Mc),H(Nc,`uniformLocations`,[`uColorMatrix`,`uConstants`]),K.setClass(Nc);var Fc=Pc(`Brownie`,[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Ic=Pc(`Vintage`,[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Lc=Pc(`Kodachrome`,[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Rc=Pc(`Technicolor`,[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),zc=Pc(`Polaroid`,[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Bc=Pc(`Sepia`,[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Vc=Pc(`BlackWhite`,[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]),Hc=class extends Q{constructor(e={}){super(e),this.subFilters=e.subFilters||[]}applyTo(e){Sc(e)&&(e.passes+=this.subFilters.length-1),this.subFilters.forEach(t=>{t.applyTo(e)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(e=>e.toObject())}}isNeutralState(){return!this.subFilters.some(e=>!e.isNeutralState())}static fromObject(e,t){return Promise.all((e.subFilters||[]).map(e=>K.getClass(e.type).fromObject(e,t))).then(e=>new this({subFilters:e}))}};H(Hc,`type`,`Composed`),K.setClass(Hc);var Uc=class extends Q{getFragmentSource(){return`
|
|
151
|
+
precision highp float;
|
|
152
|
+
uniform sampler2D uTexture;
|
|
153
|
+
uniform float uContrast;
|
|
154
|
+
varying vec2 vTexCoord;
|
|
155
|
+
void main() {
|
|
156
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
157
|
+
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
|
158
|
+
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
|
159
|
+
gl_FragColor = color;
|
|
160
|
+
}`}isNeutralState(){return this.contrast===0}applyTo2d({imageData:{data:e}}){let t=Math.floor(255*this.contrast),n=259*(t+255)/(255*(259-t));for(let t=0;t<e.length;t+=4)e[t]=n*(e[t]-128)+128,e[t+1]=n*(e[t+1]-128)+128,e[t+2]=n*(e[t+2]-128)+128}sendUniformData(e,t){e.uniform1f(t.uContrast,this.contrast)}};H(Uc,`type`,`Contrast`),H(Uc,`defaults`,{contrast:0}),H(Uc,`uniformLocations`,[`uContrast`]),K.setClass(Uc);var Wc={Convolute_3_1:`
|
|
161
|
+
precision highp float;
|
|
162
|
+
uniform sampler2D uTexture;
|
|
163
|
+
uniform float uMatrix[9];
|
|
164
|
+
uniform float uStepW;
|
|
165
|
+
uniform float uStepH;
|
|
166
|
+
varying vec2 vTexCoord;
|
|
167
|
+
void main() {
|
|
168
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
169
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
170
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
171
|
+
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
|
172
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
gl_FragColor = color;
|
|
176
|
+
}
|
|
177
|
+
`,Convolute_3_0:`
|
|
178
|
+
precision highp float;
|
|
179
|
+
uniform sampler2D uTexture;
|
|
180
|
+
uniform float uMatrix[9];
|
|
181
|
+
uniform float uStepW;
|
|
182
|
+
uniform float uStepH;
|
|
183
|
+
varying vec2 vTexCoord;
|
|
184
|
+
void main() {
|
|
185
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
186
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
187
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
188
|
+
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
|
189
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
193
|
+
gl_FragColor = color;
|
|
194
|
+
gl_FragColor.a = alpha;
|
|
195
|
+
}
|
|
196
|
+
`,Convolute_5_1:`
|
|
197
|
+
precision highp float;
|
|
198
|
+
uniform sampler2D uTexture;
|
|
199
|
+
uniform float uMatrix[25];
|
|
200
|
+
uniform float uStepW;
|
|
201
|
+
uniform float uStepH;
|
|
202
|
+
varying vec2 vTexCoord;
|
|
203
|
+
void main() {
|
|
204
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
205
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
206
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
207
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
208
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
gl_FragColor = color;
|
|
212
|
+
}
|
|
213
|
+
`,Convolute_5_0:`
|
|
214
|
+
precision highp float;
|
|
215
|
+
uniform sampler2D uTexture;
|
|
216
|
+
uniform float uMatrix[25];
|
|
217
|
+
uniform float uStepW;
|
|
218
|
+
uniform float uStepH;
|
|
219
|
+
varying vec2 vTexCoord;
|
|
220
|
+
void main() {
|
|
221
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
222
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
223
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
224
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
225
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
229
|
+
gl_FragColor = color;
|
|
230
|
+
gl_FragColor.a = alpha;
|
|
231
|
+
}
|
|
232
|
+
`,Convolute_7_1:`
|
|
233
|
+
precision highp float;
|
|
234
|
+
uniform sampler2D uTexture;
|
|
235
|
+
uniform float uMatrix[49];
|
|
236
|
+
uniform float uStepW;
|
|
237
|
+
uniform float uStepH;
|
|
238
|
+
varying vec2 vTexCoord;
|
|
239
|
+
void main() {
|
|
240
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
241
|
+
for (float h = 0.0; h < 7.0; h+=1.0) {
|
|
242
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
243
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
244
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
gl_FragColor = color;
|
|
248
|
+
}
|
|
249
|
+
`,Convolute_7_0:`
|
|
250
|
+
precision highp float;
|
|
251
|
+
uniform sampler2D uTexture;
|
|
252
|
+
uniform float uMatrix[49];
|
|
253
|
+
uniform float uStepW;
|
|
254
|
+
uniform float uStepH;
|
|
255
|
+
varying vec2 vTexCoord;
|
|
256
|
+
void main() {
|
|
257
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
258
|
+
for (float h = 0.0; h < 7.0; h+=1.0) {
|
|
259
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
260
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
261
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
265
|
+
gl_FragColor = color;
|
|
266
|
+
gl_FragColor.a = alpha;
|
|
267
|
+
}
|
|
268
|
+
`,Convolute_9_1:`
|
|
269
|
+
precision highp float;
|
|
270
|
+
uniform sampler2D uTexture;
|
|
271
|
+
uniform float uMatrix[81];
|
|
272
|
+
uniform float uStepW;
|
|
273
|
+
uniform float uStepH;
|
|
274
|
+
varying vec2 vTexCoord;
|
|
275
|
+
void main() {
|
|
276
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
277
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
278
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
279
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
280
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
gl_FragColor = color;
|
|
284
|
+
}
|
|
285
|
+
`,Convolute_9_0:`
|
|
286
|
+
precision highp float;
|
|
287
|
+
uniform sampler2D uTexture;
|
|
288
|
+
uniform float uMatrix[81];
|
|
289
|
+
uniform float uStepW;
|
|
290
|
+
uniform float uStepH;
|
|
291
|
+
varying vec2 vTexCoord;
|
|
292
|
+
void main() {
|
|
293
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
294
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
295
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
296
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
297
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
301
|
+
gl_FragColor = color;
|
|
302
|
+
gl_FragColor.a = alpha;
|
|
303
|
+
}
|
|
304
|
+
`},Gc=class extends Q{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${+!!this.opaque}`}getFragmentSource(){return Wc[this.getCacheKey()]}applyTo2d(e){let t=e.imageData,n=t.data,r=this.matrix,i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=t.width,s=t.height,c=e.ctx.createImageData(o,s),l=c.data,u=+!!this.opaque,d,f,p,m,h,g,_,v,y,b,x,S,C;for(x=0;x<s;x++)for(b=0;b<o;b++){for(h=4*(x*o+b),d=0,f=0,p=0,m=0,C=0;C<i;C++)for(S=0;S<i;S++)_=x+C-a,g=b+S-a,_<0||_>=s||g<0||g>=o||(v=4*(_*o+g),y=r[C*i+S],d+=n[v]*y,f+=n[v+1]*y,p+=n[v+2]*y,u||(m+=n[v+3]*y));l[h]=d,l[h+1]=f,l[h+2]=p,l[h+3]=u?n[h+3]:m}e.imageData=c}sendUniformData(e,t){e.uniform1fv(t.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}};H(Gc,`type`,`Convolute`),H(Gc,`defaults`,{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),H(Gc,`uniformLocations`,[`uMatrix`,`uOpaque`,`uHalfSize`,`uSize`]),K.setClass(Gc);var Kc=`Gamma`,qc=class extends Q{getFragmentSource(){return`
|
|
305
|
+
precision highp float;
|
|
306
|
+
uniform sampler2D uTexture;
|
|
307
|
+
uniform vec3 uGamma;
|
|
308
|
+
varying vec2 vTexCoord;
|
|
309
|
+
void main() {
|
|
310
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
311
|
+
vec3 correction = (1.0 / uGamma);
|
|
312
|
+
color.r = pow(color.r, correction.r);
|
|
313
|
+
color.g = pow(color.g, correction.g);
|
|
314
|
+
color.b = pow(color.b, correction.b);
|
|
315
|
+
gl_FragColor = color;
|
|
316
|
+
gl_FragColor.rgb *= color.a;
|
|
317
|
+
}
|
|
318
|
+
`}constructor(e={}){super(e),this.gamma=e.gamma||this.constructor.defaults.gamma.concat()}applyTo2d({imageData:{data:e}}){let t=this.gamma,n=1/t[0],r=1/t[1],i=1/t[2];this.rgbValues||={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)};let a=this.rgbValues;for(let e=0;e<256;e++)a.r[e]=255*(e/255)**n,a.g[e]=255*(e/255)**r,a.b[e]=255*(e/255)**i;for(let t=0;t<e.length;t+=4)e[t]=a.r[e[t]],e[t+1]=a.g[e[t+1]],e[t+2]=a.b[e[t+2]]}sendUniformData(e,t){e.uniform3fv(t.uGamma,this.gamma)}isNeutralState(){let{gamma:e}=this;return e[0]===1&&e[1]===1&&e[2]===1}toObject(){return{type:Kc,gamma:this.gamma.concat()}}};H(qc,`type`,Kc),H(qc,`defaults`,{gamma:[1,1,1]}),H(qc,`uniformLocations`,[`uGamma`]),K.setClass(qc);var Jc={average:`
|
|
319
|
+
precision highp float;
|
|
320
|
+
uniform sampler2D uTexture;
|
|
321
|
+
varying vec2 vTexCoord;
|
|
322
|
+
void main() {
|
|
323
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
324
|
+
float average = (color.r + color.b + color.g) / 3.0;
|
|
325
|
+
gl_FragColor = vec4(average, average, average, color.a);
|
|
326
|
+
}
|
|
327
|
+
`,lightness:`
|
|
328
|
+
precision highp float;
|
|
329
|
+
uniform sampler2D uTexture;
|
|
330
|
+
uniform int uMode;
|
|
331
|
+
varying vec2 vTexCoord;
|
|
332
|
+
void main() {
|
|
333
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
334
|
+
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
|
335
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
336
|
+
}
|
|
337
|
+
`,luminosity:`
|
|
338
|
+
precision highp float;
|
|
339
|
+
uniform sampler2D uTexture;
|
|
340
|
+
uniform int uMode;
|
|
341
|
+
varying vec2 vTexCoord;
|
|
342
|
+
void main() {
|
|
343
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
344
|
+
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
345
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
346
|
+
}
|
|
347
|
+
`},Yc=class extends Q{applyTo2d({imageData:{data:e}}){for(let t,n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2];switch(this.mode){case`average`:t=(r+i+a)/3;break;case`lightness`:t=(Math.min(r,i,a)+Math.max(r,i,a))/2;break;case`luminosity`:t=.21*r+.72*i+.07*a}e[n+2]=e[n+1]=e[n]=t}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return Jc[this.mode]}sendUniformData(e,t){e.uniform1i(t.uMode,1)}isNeutralState(){return!1}};H(Yc,`type`,`Grayscale`),H(Yc,`defaults`,{mode:`average`}),H(Yc,`uniformLocations`,[`uMode`]),K.setClass(Yc);var Xc={...Mc,rotation:0},Zc=class extends Nc{calculateMatrix(){let e=this.rotation*Math.PI,t=mt(e),n=ht(e),r=1/3,i=Math.sqrt(r)*n,a=1-t;this.matrix=[t+a/3,r*a-i,r*a+i,0,0,r*a+i,t+r*a,r*a-i,0,0,r*a-i,r*a+i,t+r*a,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(e){this.calculateMatrix(),super.applyTo(e)}toObject(){return{type:this.type,rotation:this.rotation}}};H(Zc,`type`,`HueRotation`),H(Zc,`defaults`,Xc),K.setClass(Zc);var Qc=class extends Q{applyTo2d({imageData:{data:e}}){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2],this.alpha&&(e[t+3]=255-e[t+3])}getFragmentSource(){return`
|
|
348
|
+
precision highp float;
|
|
349
|
+
uniform sampler2D uTexture;
|
|
350
|
+
uniform int uInvert;
|
|
351
|
+
uniform int uAlpha;
|
|
352
|
+
varying vec2 vTexCoord;
|
|
353
|
+
void main() {
|
|
354
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
355
|
+
if (uInvert == 1) {
|
|
356
|
+
if (uAlpha == 1) {
|
|
357
|
+
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
|
|
358
|
+
} else {
|
|
359
|
+
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
gl_FragColor = color;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
`}isNeutralState(){return!this.invert}sendUniformData(e,t){e.uniform1i(t.uInvert,Number(this.invert)),e.uniform1i(t.uAlpha,Number(this.alpha))}};H(Qc,`type`,`Invert`),H(Qc,`defaults`,{alpha:!1,invert:!0}),H(Qc,`uniformLocations`,[`uInvert`,`uAlpha`]),K.setClass(Qc);var $c=class extends Q{getFragmentSource(){return`
|
|
366
|
+
precision highp float;
|
|
367
|
+
uniform sampler2D uTexture;
|
|
368
|
+
uniform float uStepH;
|
|
369
|
+
uniform float uNoise;
|
|
370
|
+
uniform float uSeed;
|
|
371
|
+
varying vec2 vTexCoord;
|
|
372
|
+
float rand(vec2 co, float seed, float vScale) {
|
|
373
|
+
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
|
374
|
+
}
|
|
375
|
+
void main() {
|
|
376
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
377
|
+
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
|
378
|
+
gl_FragColor = color;
|
|
379
|
+
}
|
|
380
|
+
`}applyTo2d({imageData:{data:e}}){let t=this.noise;for(let n=0;n<e.length;n+=4){let r=(.5-Math.random())*t;e[n]+=r,e[n+1]+=r,e[n+2]+=r}}sendUniformData(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())}isNeutralState(){return this.noise===0}};H($c,`type`,`Noise`),H($c,`defaults`,{noise:0}),H($c,`uniformLocations`,[`uNoise`,`uSeed`]),K.setClass($c);var el=class extends Q{applyTo2d({imageData:{data:e,width:t,height:n}}){for(let r=0;r<n;r+=this.blocksize)for(let i=0;i<t;i+=this.blocksize){let a=4*r*t+4*i,o=e[a],s=e[a+1],c=e[a+2],l=e[a+3];for(let a=r;a<Math.min(r+this.blocksize,n);a++)for(let n=i;n<Math.min(i+this.blocksize,t);n++){let r=4*a*t+4*n;e[r]=o,e[r+1]=s,e[r+2]=c,e[r+3]=l}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
|
381
|
+
precision highp float;
|
|
382
|
+
uniform sampler2D uTexture;
|
|
383
|
+
uniform float uBlocksize;
|
|
384
|
+
uniform float uStepW;
|
|
385
|
+
uniform float uStepH;
|
|
386
|
+
varying vec2 vTexCoord;
|
|
387
|
+
void main() {
|
|
388
|
+
float blockW = uBlocksize * uStepW;
|
|
389
|
+
float blockH = uBlocksize * uStepH;
|
|
390
|
+
int posX = int(vTexCoord.x / blockW);
|
|
391
|
+
int posY = int(vTexCoord.y / blockH);
|
|
392
|
+
float fposX = float(posX);
|
|
393
|
+
float fposY = float(posY);
|
|
394
|
+
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
|
395
|
+
vec4 color = texture2D(uTexture, squareCoords);
|
|
396
|
+
gl_FragColor = color;
|
|
397
|
+
}
|
|
398
|
+
`}sendUniformData(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}};H(el,`type`,`Pixelate`),H(el,`defaults`,{blocksize:4}),H(el,`uniformLocations`,[`uBlocksize`]),K.setClass(el);var tl=class extends Q{getFragmentSource(){return`
|
|
399
|
+
precision highp float;
|
|
400
|
+
uniform sampler2D uTexture;
|
|
401
|
+
uniform vec4 uLow;
|
|
402
|
+
uniform vec4 uHigh;
|
|
403
|
+
varying vec2 vTexCoord;
|
|
404
|
+
void main() {
|
|
405
|
+
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
406
|
+
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
|
407
|
+
gl_FragColor.a = 0.0;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
`}applyTo2d({imageData:{data:e}}){let t=255*this.distance,n=new fr(this.color).getSource(),r=[n[0]-t,n[1]-t,n[2]-t],i=[n[0]+t,n[1]+t,n[2]+t];for(let t=0;t<e.length;t+=4){let n=e[t],a=e[t+1],o=e[t+2];n>r[0]&&a>r[1]&&o>r[2]&&n<i[0]&&a<i[1]&&o<i[2]&&(e[t+3]=0)}}sendUniformData(e,t){let n=new fr(this.color).getSource(),r=this.distance,i=[0+n[0]/255-r,0+n[1]/255-r,0+n[2]/255-r,1],a=[n[0]/255+r,n[1]/255+r,n[2]/255+r,1];e.uniform4fv(t.uLow,i),e.uniform4fv(t.uHigh,a)}};H(tl,`type`,`RemoveColor`),H(tl,`defaults`,{color:`#FFFFFF`,distance:.02,useAlpha:!1}),H(tl,`uniformLocations`,[`uLow`,`uHigh`]),K.setClass(tl);var nl=class extends Q{sendUniformData(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)}getFilterWindow(){let e=this.tempScale;return Math.ceil(this.lanczosLobes/e)}getCacheKey(){let e=this.getFilterWindow();return`${this.type}_${e}`}getFragmentSource(){let e=this.getFilterWindow();return this.generateShader(e)}getTaps(){let e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),r=Array(n);for(let i=1;i<=n;i++)r[i-1]=e(i*t);return r}generateShader(e){let t=Array(e);for(let n=1;n<=e;n++)t[n-1]=`${n}.0 * uDelta`;return`\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${e}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${t.map((e,t)=>`\n color += texture2D(uTexture, vTexCoord + ${e}) * uTaps[${t}] + texture2D(uTexture, vTexCoord - ${e}) * uTaps[${t}];\n sum += 2.0 * uTaps[${t}];\n `).join(`
|
|
411
|
+
`)}\n gl_FragColor = color / sum;\n }\n `}applyToForWebgl(e){e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,super.applyTo(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,super.applyTo(e),e.sourceHeight=e.destinationHeight}applyTo(e){Sc(e)?this.applyToForWebgl(e):this.applyTo2d(e)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(e){return t=>{if(t>=e||t<=-e)return 0;if(t<1.1920929e-7&&t>-1.1920929e-7)return 1;let n=(t*=Math.PI)/e;return Math.sin(t)/t*Math.sin(n)/n}}applyTo2d(e){let t=e.imageData,n=this.scaleX,r=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/r;let i=t.width,a=t.height,o=Math.round(i*n),s=Math.round(a*r),c;c=this.resizeType===`sliceHack`?this.sliceByTwo(e,i,a,o,s):this.resizeType===`hermite`?this.hermiteFastResize(e,i,a,o,s):this.resizeType===`bilinear`?this.bilinearFiltering(e,i,a,o,s):this.resizeType===`lanczos`?this.lanczosResize(e,i,a,o,s):new ImageData(o,s),e.imageData=c}sliceByTwo(e,t,n,r,i){let a=e.imageData,o=.5,s=!1,c=!1,l=t*o,u=n*o,d=e.filterBackend.resources,f=0,p=0,m=t,h=0;d.sliceByTwo||=wt();let g=d.sliceByTwo;(g.width<1.5*t||g.height<n)&&(g.width=1.5*t,g.height=n);let _=g.getContext(`2d`);for(_.clearRect(0,0,1.5*t,n),_.putImageData(a,0,0),r=Math.floor(r),i=Math.floor(i);!s||!c;)t=l,n=u,r<Math.floor(l*o)?l=Math.floor(l*o):(l=r,s=!0),i<Math.floor(u*o)?u=Math.floor(u*o):(u=i,c=!0),_.drawImage(g,f,p,t,n,m,h,l,u),f=m,p=h,h+=u;return _.getImageData(f,p,r,i)}lanczosResize(e,t,n,r,i){let a=e.imageData.data,o=e.ctx.createImageData(r,i),s=o.data,c=this.lanczosCreate(this.lanczosLobes),l=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,f=2/this.rcpScaleY,p=Math.ceil(l*this.lanczosLobes/2),m=Math.ceil(u*this.lanczosLobes/2),h={},g={x:0,y:0},_={x:0,y:0};return function e(v){let y,b,x,S,C,w,T,E,D,O,k;for(g.x=(v+.5)*l,_.x=Math.floor(g.x),y=0;y<i;y++){for(g.y=(y+.5)*u,_.y=Math.floor(g.y),C=0,w=0,T=0,E=0,D=0,b=_.x-p;b<=_.x+p;b++)if(!(b<0||b>=t)){O=Math.floor(1e3*Math.abs(b-g.x)),h[O]||(h[O]={});for(let e=_.y-m;e<=_.y+m;e++)e<0||e>=n||(k=Math.floor(1e3*Math.abs(e-g.y)),h[O][k]||(h[O][k]=c(Math.sqrt((O*d)**2+(k*f)**2)/1e3)),x=h[O][k],x>0&&(S=4*(e*t+b),C+=x,w+=x*a[S],T+=x*a[S+1],E+=x*a[S+2],D+=x*a[S+3]))}S=4*(y*r+v),s[S]=w/C,s[S+1]=T/C,s[S+2]=E/C,s[S+3]=D/C}return++v<r?e(v):o}(0)}bilinearFiltering(e,t,n,r,i){let a,o,s,c,l,u,d,f,p,m,h,g,_,v=0,y=this.rcpScaleX,b=this.rcpScaleY,x=4*(t-1),S=e.imageData.data,C=e.ctx.createImageData(r,i),w=C.data;for(d=0;d<i;d++)for(f=0;f<r;f++)for(l=Math.floor(y*f),u=Math.floor(b*d),p=y*f-l,m=b*d-u,_=4*(u*t+l),h=0;h<4;h++)a=S[_+h],o=S[_+4+h],s=S[_+x+h],c=S[_+x+4+h],g=a*(1-p)*(1-m)+o*p*(1-m)+s*m*(1-p)+c*p*m,w[v++]=g;return C}hermiteFastResize(e,t,n,r,i){let a=this.rcpScaleX,o=this.rcpScaleY,s=Math.ceil(a/2),c=Math.ceil(o/2),l=e.imageData.data,u=e.ctx.createImageData(r,i),d=u.data;for(let e=0;e<i;e++)for(let n=0;n<r;n++){let i=4*(n+e*r),u,f=0,p=0,m=0,h=0,g=0,_=0,v=(e+.5)*o;for(let r=Math.floor(e*o);r<(e+1)*o;r++){let e=Math.abs(v-(r+.5))/c,i=(n+.5)*a,o=e*e;for(let e=Math.floor(n*a);e<(n+1)*a;e++){let n=Math.abs(i-(e+.5))/s,a=Math.sqrt(o+n*n);a>1&&a<-1||(u=2*a*a*a-3*a*a+1,u>0&&(n=4*(e+r*t),_+=u*l[n+3],p+=u,l[n+3]<255&&(u=u*l[n+3]/250),m+=u*l[n],h+=u*l[n+1],g+=u*l[n+2],f+=u))}}d[i]=m/f,d[i+1]=h/f,d[i+2]=g/f,d[i+3]=_/p}return u}};H(nl,`type`,`Resize`),H(nl,`defaults`,{resizeType:`hermite`,scaleX:1,scaleY:1,lanczosLobes:3}),H(nl,`uniformLocations`,[`uDelta`,`uTaps`]),K.setClass(nl);var rl=class extends Q{getFragmentSource(){return`
|
|
412
|
+
precision highp float;
|
|
413
|
+
uniform sampler2D uTexture;
|
|
414
|
+
uniform float uSaturation;
|
|
415
|
+
varying vec2 vTexCoord;
|
|
416
|
+
void main() {
|
|
417
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
418
|
+
float rgMax = max(color.r, color.g);
|
|
419
|
+
float rgbMax = max(rgMax, color.b);
|
|
420
|
+
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
|
421
|
+
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
|
422
|
+
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
|
423
|
+
gl_FragColor = color;
|
|
424
|
+
}
|
|
425
|
+
`}applyTo2d({imageData:{data:e}}){let t=-this.saturation;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a);e[n]+=o===r?0:(o-r)*t,e[n+1]+=o===i?0:(o-i)*t,e[n+2]+=o===a?0:(o-a)*t}}sendUniformData(e,t){e.uniform1f(t.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}};H(rl,`type`,`Saturation`),H(rl,`defaults`,{saturation:0}),H(rl,`uniformLocations`,[`uSaturation`]),K.setClass(rl);var il=class extends Q{getFragmentSource(){return`
|
|
426
|
+
precision highp float;
|
|
427
|
+
uniform sampler2D uTexture;
|
|
428
|
+
uniform float uVibrance;
|
|
429
|
+
varying vec2 vTexCoord;
|
|
430
|
+
void main() {
|
|
431
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
432
|
+
float max = max(color.r, max(color.g, color.b));
|
|
433
|
+
float avg = (color.r + color.g + color.b) / 3.0;
|
|
434
|
+
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
|
435
|
+
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
|
436
|
+
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
|
437
|
+
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
438
|
+
gl_FragColor = color;
|
|
439
|
+
}
|
|
440
|
+
`}applyTo2d({imageData:{data:e}}){let t=-this.vibrance;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a),s=(r+i+a)/3,c=2*Math.abs(o-s)/255*t;e[n]+=o===r?0:(o-r)*c,e[n+1]+=o===i?0:(o-i)*c,e[n+2]+=o===a?0:(o-a)*c}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};H(il,`type`,`Vibrance`),H(il,`defaults`,{vibrance:0}),H(il,`uniformLocations`,[`uVibrance`]),K.setClass(il),be({BaseFilter:()=>Q,BlackWhite:()=>Vc,BlendColor:()=>Dc,BlendImage:()=>kc,Blur:()=>Ac,Brightness:()=>jc,Brownie:()=>Fc,ColorMatrix:()=>Nc,Composed:()=>Hc,Contrast:()=>Uc,Convolute:()=>Gc,Gamma:()=>qc,Grayscale:()=>Yc,HueRotation:()=>Zc,Invert:()=>Qc,Kodachrome:()=>Lc,Noise:()=>$c,Pixelate:()=>el,Polaroid:()=>zc,RemoveColor:()=>tl,Resize:()=>nl,Saturation:()=>rl,Sepia:()=>Bc,Technicolor:()=>Rc,Vibrance:()=>il,Vintage:()=>Ic});function al(e){let t=e instanceof uc||e instanceof lc;return{id:e.customId??e.toString(),type:e.type??`object`,left:Math.round(e.left??0),top:Math.round(e.top??0),width:Math.round((e.width??0)*(e.scaleX??1)),height:Math.round((e.height??0)*(e.scaleY??1)),angle:Math.round(e.angle??0),opacity:e.opacity??1,fill:typeof e.fill==`string`?e.fill:null,stroke:typeof e.stroke==`string`?e.stroke:null,strokeWidth:e.strokeWidth??0,...t?{fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:e.textAlign}:{}}}function ol(e){return e.getObjects().filter(e=>e.customId!==`__artboard__`).map((e,t)=>({id:e.customId??`obj-${t}`,type:e.type??`object`,name:e.customName??ve(e.type??`object`,t),visible:e.visible!==!1,locked:!e.selectable}))}function sl(e){let t={left:e.left,top:e.top,selectable:e.selectable!==!1};switch(e.fill!==void 0&&(t.fill=e.fill),e.stroke!==void 0&&(t.stroke=e.stroke),e.strokeWidth!==void 0&&(t.strokeWidth=e.strokeWidth),e.opacity!==void 0&&(t.opacity=e.opacity),e.angle!==void 0&&(t.angle=e.angle),e.scaleX!==void 0&&(t.scaleX=e.scaleX),e.scaleY!==void 0&&(t.scaleY=e.scaleY),e.type){case`rect`:{let n={...t};return e.width!==void 0&&(n.width=e.width),e.height!==void 0&&(n.height=e.height),e.rx!==void 0&&(n.rx=e.rx),e.ry!==void 0&&(n.ry=e.ry),new $a(n)}case`ellipse`:return new Bs({...t,rx:e.rx??(e.width?e.width/2:50),ry:e.ry??(e.height?e.height/2:50)});case`textbox`:{let n={...t};return e.width!==void 0&&(n.width=e.width),e.fontSize!==void 0&&(n.fontSize=e.fontSize),e.fontFamily!==void 0&&(n.fontFamily=e.fontFamily),e.fontWeight!==void 0&&(n.fontWeight=e.fontWeight),e.textAlign!==void 0&&(n.textAlign=e.textAlign),new uc(e.text??``,n)}case`line`:return new Ls([e.left,e.top,e.left+(e.width??100),e.top+(e.height??0)],t);case`path`:return new $a({...t,width:e.width??50,height:e.height??50});default:return new $a({...t,width:e.width??50,height:e.height??50})}}var cl=0;function ll(e){let t=e;return t.customId||=`obj-${++cl}`,t.customId}function ul(e,t){switch(e){case`rect`:return new $a({left:t.x,top:t.y,width:0,height:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1});case`circle`:return new Bs({left:t.x,top:t.y,rx:0,ry:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1});case`line`:return new Ls([t.x,t.y,t.x,t.y],{stroke:`#000000`,strokeWidth:2});case`polygon`:return new $a({left:t.x,top:t.y,width:0,height:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1,rx:8,ry:8});default:return null}}function dl(e){let{activeTool:t,object:n,start:r,pointer:i}=e;return t===`line`&&n instanceof Ls?(n.set({x2:i.x,y2:i.y}),!0):t===`circle`&&n instanceof Bs?(n.set({rx:Math.abs(i.x-r.x)/2,ry:Math.abs(i.y-r.y)/2,left:Math.min(r.x,i.x),top:Math.min(r.y,i.y)}),!0):(n.set({left:Math.min(r.x,i.x),top:Math.min(r.y,i.y),width:Math.abs(i.x-r.x),height:Math.abs(i.y-r.y)}),!0)}function fl(e){return e===`draw`?{isDrawingMode:!0,selection:!0,defaultCursor:`default`,hoverCursor:`move`,pencilBrush:{color:`#000000`,width:3}}:e===`select`?{isDrawingMode:!1,selection:!0,defaultCursor:`default`,hoverCursor:`move`,pencilBrush:null}:{isDrawingMode:!1,selection:!1,defaultCursor:`crosshair`,hoverCursor:`crosshair`,pencilBrush:null}}var $=n(),pl=(0,V.forwardRef)(function({artboardWidth:e,artboardHeight:t,activeTool:n,onSelectionChange:r,onCanvasModified:i,onLayersChange:a,onZoomChange:o},s){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>{let e=l.current;e&&a(ol(e))},[a]),p=(0,V.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.getActiveObject();if(!t){r([],null);return}r([ll(t)],al(t))},[r]),m=(0,V.useCallback)(()=>{p(),i(),f()},[p,i,f]),h=(0,V.useCallback)(()=>{let n=l.current,r=u.current;if(!n||!r)return;let{width:i,height:a}=r.getBoundingClientRect(),{scale:s,offsetX:c,offsetY:d}=he(e,t,i,a);n.setDimensions({width:i,height:a});let f=n.viewportTransform;f[0]=s,f[3]=s,f[4]=c,f[5]=d,n.setViewportTransform(f),o(s),n.requestRenderAll()},[e,t,o]);return(0,V.useEffect)(()=>{let n=c.current;if(!n)return;let i=new hs(n,{backgroundColor:`transparent`,preserveObjectStacking:!0,selection:!0});l.current=i;let a=new $a({width:e,height:t,fill:`#ffffff`,selectable:!1,evented:!1,left:0,top:0,shadow:new Lr({color:`rgba(0,0,0,0.3)`,blur:20,offsetX:0,offsetY:4})});return a.customId=`__artboard__`,i.add(a),d.current=a,i.on(`selection:created`,p),i.on(`selection:updated`,p),i.on(`selection:cleared`,()=>r([],null)),i.on(`object:modified`,m),i.on(`object:added`,f),i.on(`object:removed`,f),requestAnimationFrame(()=>h()),()=>{i.dispose(),l.current=null,d.current=null}},[]),(0,V.useEffect)(()=>{let n=d.current;n&&(n.set({width:e,height:t}),h())},[e,t,h]),(0,V.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(()=>{requestAnimationFrame(()=>h())});return t.observe(e),()=>t.disconnect()},[h]),(0,V.useEffect)(()=>{let e=l.current;if(!e)return;let t=fl(n);e.isDrawingMode=t.isDrawingMode,e.selection=t.selection,e.defaultCursor=t.defaultCursor,e.hoverCursor=t.hoverCursor,t.pencilBrush&&(e.freeDrawingBrush=new Ns(e),e.freeDrawingBrush.color=t.pencilBrush.color,e.freeDrawingBrush.width=t.pencilBrush.width),e.requestRenderAll()},[n]),(0,V.useEffect)(()=>{let e=l.current;if(!e||n===`select`||n===`draw`||n===`image`)return;let t=!1,r=0,a=0,o=null,s=s=>{let c=s.scenePoint;if(t=!0,r=c.x,a=c.y,n===`text`){let n=new uc(`Type here`,{left:c.x,top:c.y,width:200,fontSize:24,fontFamily:`Inter, sans-serif`,fill:`#000000`});ll(n),e.add(n),e.setActiveObject(n),n.enterEditing(),i(),t=!1;return}o=ul(n,c),o&&(ll(o),e.add(o))},c=i=>{if(!t||!o)return;let s=i.scenePoint;dl({activeTool:n,object:o,start:{x:r,y:a},pointer:s}),e.requestRenderAll()},u=()=>{t&&(t=!1,o&&(e.setActiveObject(o),i()),o=null)};return e.on(`mouse:down`,s),e.on(`mouse:move`,c),e.on(`mouse:up`,u),()=>{e.off(`mouse:down`,s),e.off(`mouse:move`,c),e.off(`mouse:up`,u)}},[n,i]),(0,V.useImperativeHandle)(s,()=>({toJSON:()=>{let e=l.current;return e?JSON.stringify(e.toObject([`customId`,`customName`])):`{}`},loadJSON:async e=>{let t=l.current;t&&(await t.loadFromJSON(e),t.requestRenderAll(),f())},exportPNG:(n=1)=>{let r=l.current,i=d.current;return!r||!i?``:r.toDataURL({format:`png`,multiplier:n,left:i.left,top:i.top,width:e,height:t})},exportSVG:()=>{let e=l.current;return e?e.toSVG():``},getCanvas:()=>l.current,addObject:e=>{let t=l.current;t&&(ll(e),t.add(e),t.setActiveObject(e),i())},fitToView:h,applyGeneratedLayout:e=>{let t=l.current;if(!t)return;let n=t.getObjects();for(let e of n)e.customId!==`__artboard__`&&t.remove(e);for(let n of e){let e=sl(n),r=e;n.customId&&(r.customId=n.customId),n.customName&&(r.customName=n.customName),ll(e),t.add(e)}t.discardActiveObject(),t.requestRenderAll(),i(),f()}})),(0,$.jsx)(`div`,{ref:u,className:`relative flex-1 overflow-hidden bg-muted/35 dark:bg-background`,children:(0,$.jsx)(`canvas`,{ref:c})})}),ml=t(),hl=[{id:`rect`,icon:v,label:`Rectangle`},{id:`circle`,icon:P,label:`Circle`},{id:`line`,icon:w,label:`Line`},{id:`polygon`,icon:L,label:`Rounded Rectangle`}],gl=(0,V.memo)(function(e){let t=(0,ml.c)(17),{activeTool:n,onToolChange:r}=e,[a,o]=(0,V.useState)(!1),s=hl.some(e=>e.id===n),c;t[0]===n?c=t[1]:(c=hl.find(e=>e.id===n),t[0]=n,t[1]=c);let l=c?.icon??v,u=`inline-flex h-7 items-center gap-0.5 rounded-md px-1.5 text-muted-foreground hover:bg-accent hover:text-foreground ${s?`bg-accent text-foreground`:``}`,d;t[2]===l?d=t[3]:(d=(0,$.jsx)(l,{className:`size-3.5`}),t[2]=l,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(i,{className:`size-2.5`}),t[4]=f):f=t[4];let p;t[5]!==u||t[6]!==d?(p=(0,$.jsxs)(_,{className:u,"aria-label":`Shape tools`,children:[d,f]}),t[5]=u,t[6]=d,t[7]=p):p=t[7];let m;t[8]!==n||t[9]!==r?(m=hl.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{onClick:()=>{r(e.id),o(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-accent ${n===e.id?`bg-accent text-foreground`:`text-muted-foreground`}`,children:[(0,$.jsx)(t,{className:`size-3.5`}),e.label]},e.id)}),t[8]=n,t[9]=r,t[10]=m):m=t[10];let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(k,{side:`top`,className:`w-36 p-1`,children:m}),t[11]=m,t[12]=h);let g;return t[13]!==a||t[14]!==p||t[15]!==h?(g=(0,$.jsxs)(E,{open:a,onOpenChange:o,children:[p,h]}),t[13]=a,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}),_l=(0,V.memo)(function(e){let t=(0,ml.c)(77),{activeTool:n,onToolChange:r,canUndo:i,canRedo:l,onUndo:u,onRedo:d,zoomLevel:f,onZoomIn:p,onZoomOut:m,onFitToView:h,canvasRef:g,onCanvasModified:_}=e,v=(0,V.useRef)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{v.current?.click()},t[0]=y):y=t[0];let b=y,x;t[1]!==g||t[2]!==_?(x=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.addEventListener(`load`,async()=>{let e=n.result,t=await xc.fromURL(e);t.scaleToWidth(300),g.current?.addObject(t),_()}),n.readAsDataURL(t),e.target.value=``},t[1]=g,t[2]=_,t[3]=x):x=t[3];let S=x,C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C={id:`select`,icon:(0,$.jsx)(re,{className:`size-3.5`}),label:`Select (V)`},t[4]=C):C=t[4];let w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=[C,{id:`text`,icon:(0,$.jsx)(a,{className:`size-3.5`}),label:`Text (T)`}],t[5]=w):w=t[5];let T=w,E,D;t[6]!==n||t[7]!==r?(E=T.map(e=>(0,$.jsxs)(c,{children:[(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:n===e.id,onPressedChange:()=>r(e.id),"aria-label":e.label,size:`xs`,variant:`default`,children:e.icon})}),(0,$.jsx)(o,{side:`top`,children:e.label})]},e.id)),D=(0,$.jsx)(gl,{activeTool:n,onToolChange:r}),t[6]=n,t[7]=r,t[8]=E,t[9]=D):(E=t[8],D=t[9]);let O=n===`image`,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(R,{className:`size-3.5`}),t[10]=k):k=t[10];let A;t[11]===O?A=t[12]:(A=(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:O,onPressedChange:b,"aria-label":`Image`,size:`xs`,variant:`default`,children:k})}),t[11]=O,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(o,{side:`top`,children:`Upload Image`}),t[13]=M):M=t[13];let N;t[14]===A?N=t[15]:(N=(0,$.jsxs)(c,{children:[A,M]}),t[14]=A,t[15]=N);let P=n===`draw`,I;t[16]===r?I=t[17]:(I=()=>r(`draw`),t[16]=r,t[17]=I);let ee;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ie,{className:`size-3.5`}),t[18]=ee):ee=t[18];let L;t[19]!==P||t[20]!==I?(L=(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:P,onPressedChange:I,"aria-label":`Draw`,size:`xs`,variant:`default`,children:ee})}),t[19]=P,t[20]=I,t[21]=L):L=t[21];let z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(o,{side:`top`,children:`Freehand Draw (D)`}),t[22]=z):z=t[22];let B;t[23]===L?B=t[24]:(B=(0,$.jsxs)(c,{children:[L,z]}),t[23]=L,t[24]=B);let ne;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),t[25]=ne):ne=t[25];let oe=!i,se;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(j,{className:`size-3.5`}),t[26]=se):se=t[26];let ue;t[27]!==u||t[28]!==oe?(ue=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:u,disabled:oe,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent`,"aria-label":`Undo`,children:se})}),t[27]=u,t[28]=oe,t[29]=ue):ue=t[29];let de;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(o,{side:`top`,children:`Undo (Ctrl+Z)`}),t[30]=de):de=t[30];let fe;t[31]===ue?fe=t[32]:(fe=(0,$.jsxs)(c,{children:[ue,de]}),t[31]=ue,t[32]=fe);let pe=!l,me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(ae,{className:`size-3.5`}),t[33]=me):me=t[33];let he;t[34]!==d||t[35]!==pe?(he=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:d,disabled:pe,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent`,"aria-label":`Redo`,children:me})}),t[34]=d,t[35]=pe,t[36]=he):he=t[36];let ge;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(o,{side:`top`,children:`Redo (Ctrl+Shift+Z)`}),t[37]=ge):ge=t[37];let _e;t[38]===he?_e=t[39]:(_e=(0,$.jsxs)(c,{children:[he,ge]}),t[38]=he,t[39]=_e);let ve;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(`div`,{className:`flex-1`}),t[40]=ve):ve=t[40];let ye;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(le,{className:`size-3.5`}),t[41]=ye):ye=t[41];let be;t[42]===m?be=t[43]:(be=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:m,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Zoom out`,children:ye})}),t[42]=m,t[43]=be);let xe;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(o,{side:`top`,children:`Zoom Out`}),t[44]=xe):xe=t[44];let Se;t[45]===be?Se=t[46]:(Se=(0,$.jsxs)(c,{children:[be,xe]}),t[45]=be,t[46]=Se);let H;t[47]===f?H=t[48]:(H=Math.round(f*100),t[47]=f,t[48]=H);let Ce;t[49]===H?Ce=t[50]:(Ce=(0,$.jsxs)(`span`,{className:`min-w-[3rem] text-center text-xs tabular-nums text-muted-foreground`,children:[H,`%`]}),t[49]=H,t[50]=Ce);let U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ce,{className:`size-3.5`}),t[51]=U):U=t[51];let we;t[52]===p?we=t[53]:(we=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:p,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Zoom in`,children:U})}),t[52]=p,t[53]=we);let Te;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(o,{side:`top`,children:`Zoom In`}),t[54]=Te):Te=t[54];let Ee;t[55]===we?Ee=t[56]:(Ee=(0,$.jsxs)(c,{children:[we,Te]}),t[55]=we,t[56]=Ee);let De;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,$.jsx)(te,{className:`size-3.5`}),t[57]=De):De=t[57];let Oe;t[58]===h?Oe=t[59]:(Oe=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:h,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Fit to view`,children:De})}),t[58]=h,t[59]=Oe);let ke;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,$.jsx)(o,{side:`top`,children:`Fit to View`}),t[60]=ke):ke=t[60];let Ae;t[61]===Oe?Ae=t[62]:(Ae=(0,$.jsxs)(c,{children:[Oe,ke]}),t[61]=Oe,t[62]=Ae);let je;t[63]===S?je=t[64]:(je=(0,$.jsx)(`input`,{ref:v,type:`file`,accept:`image/*`,className:`hidden`,onChange:S}),t[63]=S,t[64]=je);let Me;return t[65]!==N||t[66]!==B||t[67]!==fe||t[68]!==_e||t[69]!==Se||t[70]!==Ce||t[71]!==Ee||t[72]!==Ae||t[73]!==je||t[74]!==E||t[75]!==D?(Me=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-t border-border bg-card px-2 py-1.5`,children:[E,D,N,B,ne,fe,_e,ve,Se,Ce,Ee,Ae,je]}),t[65]=N,t[66]=B,t[67]=fe,t[68]=_e,t[69]=Se,t[70]=Ce,t[71]=Ee,t[72]=Ae,t[73]=je,t[74]=E,t[75]=D,t[76]=Me):Me=t[76],Me});function vl(e){switch(e){case`textbox`:case`i-text`:return a;case`rect`:return v;case`circle`:case`ellipse`:return P;case`image`:return z;case`path`:return ie;default:return v}}var yl=(0,V.memo)(function(e){let t=(0,ml.c)(12),{layers:n,selectedObjectIds:r,onLayerSelect:i,onLayerVisibilityToggle:a}=e;if(n.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`No objects on canvas`}),t[0]=e):e=t[0],e}let o;if(t[1]!==n||t[2]!==i||t[3]!==a||t[4]!==r){let e;t[6]!==i||t[7]!==a||t[8]!==r?(e=e=>{let t=vl(e.type),n=r.includes(e.id);return(0,$.jsxs)(`div`,{onClick:()=>i(e.id),className:`flex cursor-pointer items-center gap-1.5 rounded px-1.5 py-1 text-[10px] ${n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:[(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),a(e.id)},className:`inline-flex size-4 items-center justify-center rounded hover:bg-accent`,children:e.visible?(0,$.jsx)(b,{className:`size-2.5`}):(0,$.jsx)(m,{className:`size-2.5 opacity-40`})}),(0,$.jsx)(t,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.id)},t[6]=i,t[7]=a,t[8]=r,t[9]=e):e=t[9],o=[...n].toReversed().map(e),t[1]=n,t[2]=i,t[3]=a,t[4]=r,t[5]=o}else o=t[5];let s;return t[10]===o?s=t[11]:(s=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:o}),t[10]=o,t[11]=s),s}),bl=(0,V.memo)(function(e){let t=(0,ml.c)(29),{open:n,properties:r,layers:i,onClose:a,onPropertyChange:o,onLayerSelect:s,onLayerVisibilityToggle:c,onMoveUp:l,onMoveDown:u,onBringToFront:d,onSendToBack:m}=e,h;t[0]===o?h=t[1]:(h=(e,t)=>{let n=Number.parseFloat(t);Number.isNaN(n)||o(e,n)},t[0]=o,t[1]=h);let _=h;if(!n)return null;let v=r?.type===`textbox`||r?.type===`i-text`,y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Properties`}),t[2]=y):y=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(C,{className:`size-3`}),t[3]=b):b=t[3];let x;t[4]===a?x=t[5]:(x=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[y,(0,$.jsx)(`button`,{onClick:a,className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground`,children:b})]}),t[4]=a,t[5]=x);let S;t[6]!==_||t[7]!==v||t[8]!==d||t[9]!==u||t[10]!==l||t[11]!==o||t[12]!==m||t[13]!==r?(S=r?(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transform`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(xl,{label:`X`,value:r.left,onChange:e=>_(`left`,e)}),(0,$.jsx)(xl,{label:`Y`,value:r.top,onChange:e=>_(`top`,e)}),(0,$.jsx)(xl,{label:`W`,value:r.width,onChange:e=>_(`scaleWidth`,e)}),(0,$.jsx)(xl,{label:`H`,value:r.height,onChange:e=>_(`scaleHeight`,e)}),(0,$.jsx)(xl,{label:`R`,value:r.angle,onChange:e=>_(`angle`,e)})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Appearance`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Sl,{label:`Fill`,value:r.fill??``,onChange:e=>o(`fill`,e)}),(0,$.jsx)(Sl,{label:`Stroke`,value:r.stroke??``,onChange:e=>o(`stroke`,e)}),(0,$.jsx)(xl,{label:`Stroke W`,value:r.strokeWidth,onChange:e=>_(`strokeWidth`,e)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Opacity`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.01,value:r.opacity,onChange:e=>o(`opacity`,Number.parseFloat(e.target.value)),className:`h-1 flex-1 appearance-none rounded-full bg-border accent-primary`}),(0,$.jsxs)(`span`,{className:`w-8 text-right text-[10px] tabular-nums text-muted-foreground`,children:[Math.round(r.opacity*100),`%`]})]})]})]}),v&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Text`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Font`}),(0,$.jsx)(`input`,{type:`text`,value:r.fontFamily??`Inter`,onChange:e=>o(`fontFamily`,e.target.value),className:`h-6 flex-1 rounded border border-border bg-background px-1.5 text-[10px] text-foreground`})]}),(0,$.jsx)(xl,{label:`Size`,value:r.fontSize??16,onChange:e=>_(`fontSize`,e)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Align`}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:[`left`,`center`,`right`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(`textAlign`,e),className:`rounded px-1.5 py-0.5 text-[10px] ${r.textAlign===e?`bg-primary text-primary-foreground`:`bg-background text-muted-foreground hover:text-foreground`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Order`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Cl,{icon:(0,$.jsx)(g,{className:`size-3`}),label:`Bring to front`,onClick:d}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(p,{className:`size-3`}),label:`Move up`,onClick:l}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(f,{className:`size-3`}),label:`Move down`,onClick:u}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(N,{className:`size-3`}),label:`Send to back`,onClick:m})]})]})]}):null,t[6]=_,t[7]=v,t[8]=d,t[9]=u,t[10]=l,t[11]=o,t[12]=m,t[13]=r,t[14]=S):S=t[14];let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Layers`}),t[15]=w):w=t[15];let T;t[16]===r?T=t[17]:(T=r?[r.id]:[],t[16]=r,t[17]=T);let E;t[18]!==i||t[19]!==s||t[20]!==c||t[21]!==T?(E=(0,$.jsxs)(`div`,{className:`border-t border-border p-3`,children:[w,(0,$.jsx)(yl,{layers:i,selectedObjectIds:T,onLayerSelect:s,onLayerVisibilityToggle:c})]}),t[18]=i,t[19]=s,t[20]=c,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==S||t[24]!==E?(D=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[S,E]}),t[23]=S,t[24]=E,t[25]=D):D=t[25];let O;return t[26]!==x||t[27]!==D?(O=(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 z-10 flex h-full w-56 flex-col border-l border-border bg-card`,children:[x,D]}),t[26]=x,t[27]=D,t[28]=O):O=t[28],O});function xl(e){let t=(0,ml.c)(12),{label:n,value:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`label`,{className:`w-5 text-[10px] text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=Math.round(r),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=e=>i(e.target.value),t[4]=i,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,$.jsx)(`input`,{type:`number`,value:o,onChange:s,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px] tabular-nums text-foreground`}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function Sl(e){let t=(0,ml.c)(15),{label:n,value:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o=r||`#000000`,s;t[2]===i?s=t[3]:(s=e=>i(e.target.value),t[2]=i,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsx)(`input`,{type:`color`,value:o,onChange:s,className:`size-5 cursor-pointer rounded border border-border`}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l=r||`none`,u;t[7]===l?u=t[8]:(u=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:l}),t[7]=l,t[8]=u);let d;t[9]!==c||t[10]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,u]}),t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,d]}),t[12]=a,t[13]=d,t[14]=f):f=t[14],f}function Cl(e){let t=(0,ml.c)(4),{icon:n,label:r,onClick:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=(0,$.jsx)(`button`,{onClick:i,className:`inline-flex size-7 items-center justify-center rounded border border-border bg-background text-muted-foreground hover:text-foreground`,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var wl=(0,V.memo)(function(e){let t=(0,ml.c)(67),{artboardPresetId:n,artboardWidth:r,artboardHeight:a,onSelectPreset:o,onCustomSize:s}=e,[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(String(r)),[f,p]=(0,V.useState)(String(a)),m;t[0]===n?m=t[1]:(m=n?de.get(n):null,t[0]=n,t[1]=m);let h=m,g=h?h.label:`${r} x ${a}`,v,y,b,x,S,C,w,T,D,O,A;if(t[2]!==a||t[3]!==r||t[4]!==f||t[5]!==u||t[6]!==g||t[7]!==s||t[8]!==c){let e=fe(),n;t[20]!==f||t[21]!==u||t[22]!==s?(n=()=>{let e=Number.parseInt(u,10),t=Number.parseInt(f,10);e>0&&t>0&&(s(e,t),l(!1))},t[20]=f,t[21]=u,t[22]=s,t[23]=n):n=t[23],b=n,y=E,D=c,O=l;let o;t[24]===g?o=t[25]:(o=(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:g}),t[24]=g,t[25]=o);let d;t[26]!==a||t[27]!==r?(d=(0,$.jsxs)(`span`,{className:`tabular-nums opacity-60`,children:[r,`x`,a]}),t[26]=a,t[27]=r,t[28]=d):d=t[28];let p;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(i,{className:`size-3`}),t[29]=p):p=t[29],t[30]!==o||t[31]!==d?(A=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[o,d,p]}),t[30]=o,t[31]=d,t[32]=A):A=t[32],v=k,C=`bottom`,w=`start`,T=`w-64 p-0`,S=`max-h-72 overflow-y-auto p-1`,x=[...e.entries()],t[2]=a,t[3]=r,t[4]=f,t[5]=u,t[6]=g,t[7]=s,t[8]=c,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=D,t[18]=O,t[19]=A}else v=t[9],y=t[10],b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],D=t[17],O=t[18],A=t[19];let j;t[33]!==n||t[34]!==o||t[35]!==x?(j=x.map(e=>{let[t,r]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:t}),r.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{o(e),l(!1)},className:`flex w-full items-center justify-between rounded-md px-2 py-1.5 text-xs hover:bg-accent ${n===e.id?`bg-accent text-foreground`:`text-muted-foreground`}`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsxs)(`span`,{className:`tabular-nums opacity-60`,children:[e.width,`x`,e.height]})]},e.id))]},t)}),t[33]=n,t[34]=o,t[35]=x,t[36]=j):j=t[36];let M;t[37]!==j||t[38]!==S?(M=(0,$.jsx)(`div`,{className:S,children:j}),t[37]=j,t[38]=S,t[39]=M):M=t[39];let N;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Custom Size`}),t[40]=N):N=t[40];let P;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>d(e.target.value),t[41]=P):P=t[41];let F;t[42]===u?F=t[43]:(F=(0,$.jsx)(`input`,{type:`number`,value:u,onChange:P,placeholder:`Width`,className:`h-6 w-20 rounded border border-border bg-background px-1.5 text-[10px] tabular-nums`}),t[42]=u,t[43]=F);let I;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`x`}),t[44]=I):I=t[44];let ee;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>p(e.target.value),t[45]=ee):ee=t[45];let L;t[46]===f?L=t[47]:(L=(0,$.jsx)(`input`,{type:`number`,value:f,onChange:ee,placeholder:`Height`,className:`h-6 w-20 rounded border border-border bg-background px-1.5 text-[10px] tabular-nums`}),t[46]=f,t[47]=L);let R;t[48]===b?R=t[49]:(R=(0,$.jsx)(`button`,{onClick:b,className:`h-6 rounded bg-primary px-2 text-[10px] font-medium text-primary-foreground hover:bg-primary/90`,children:`Apply`}),t[48]=b,t[49]=R);let z;t[50]!==F||t[51]!==L||t[52]!==R?(z=(0,$.jsxs)(`div`,{className:`border-t border-border p-2`,children:[N,(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[F,I,L,R]})]}),t[50]=F,t[51]=L,t[52]=R,t[53]=z):z=t[53];let B;t[54]!==v||t[55]!==M||t[56]!==z||t[57]!==C||t[58]!==w||t[59]!==T?(B=(0,$.jsxs)(v,{side:C,align:w,className:T,children:[M,z]}),t[54]=v,t[55]=M,t[56]=z,t[57]=C,t[58]=w,t[59]=T,t[60]=B):B=t[60];let te;return t[61]!==y||t[62]!==B||t[63]!==D||t[64]!==O||t[65]!==A?(te=(0,$.jsxs)(y,{open:D,onOpenChange:O,children:[A,B]}),t[61]=y,t[62]=B,t[63]=D,t[64]=O,t[65]=A,t[66]=te):te=t[66],te}),Tl=(0,V.memo)(function({canvasRef:e,artboardWidth:t,artboardHeight:n,savedDesigns:r,onSaveDesign:i,onLoadDesign:a,onDeleteDesign:o}){let[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),f=t=>{let n=e.current?.exportPNG(t);n&&pe(n,`design-${Date.now()}.png`),c(!1)},p=()=>{let t=e.current?.exportSVG();t&&me(new Blob([t],{type:`image/svg+xml`}),`design-${Date.now()}.svg`),c(!1)},m=async()=>{let r=e.current?.exportPNG(2);if(!r)return;let{jsPDF:i}=await d(async()=>{let{jsPDF:e}=await import(`./jspdf.es.min-_OjqfV_L.js`);return{jsPDF:e}},__vite__mapDeps([0,1,2,3])),a=new i({orientation:t>n?`landscape`:`portrait`,unit:`px`,format:[t,n]});a.addImage(r,`PNG`,0,0,t,n),a.save(`design-${Date.now()}.pdf`),c(!1)},h=()=>{let t=e.current?.toJSON();t&&(i(`design-${Date.now()}`,`Design ${new Date().toLocaleString()}`,t),c(!1))},g=e=>{a(e),c(!1),u(!1)},v=Object.entries(r).toSorted(([,e],[,t])=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());return(0,$.jsxs)(E,{open:s,onOpenChange:e=>{c(e),e||u(!1)},children:[(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md bg-success px-2.5 py-1 text-xs font-medium text-white hover:bg-success`,children:[(0,$.jsx)(M,{className:`size-3`}),`Export`]}),(0,$.jsx)(k,{side:`bottom`,align:`end`,className:`w-52 p-1`,children:l?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`button`,{onClick:()=>u(!1),className:`mb-1 w-full rounded px-2 py-1 text-left text-[10px] text-muted-foreground hover:bg-accent`,children:`← Back`}),v.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded px-1 py-0.5 hover:bg-accent`,children:[(0,$.jsx)(`button`,{onClick:()=>g(t.json),className:`flex-1 truncate px-1 py-1 text-left text-xs text-foreground`,children:t.name}),(0,$.jsx)(`button`,{onClick:()=>o(e),className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(oe,{className:`size-3`})})]},e))]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(El,{label:`Export`,children:[(0,$.jsx)(Dl,{icon:(0,$.jsx)(z,{className:`size-3.5`}),label:`PNG (1x)`,onClick:()=>f(1)}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(z,{className:`size-3.5`}),label:`PNG (2x)`,onClick:()=>f(2)}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(I,{className:`size-3.5`}),label:`SVG`,onClick:p}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(x,{className:`size-3.5`}),label:`PDF`,onClick:()=>void m()})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,$.jsxs)(El,{label:`Design`,children:[(0,$.jsx)(Dl,{icon:(0,$.jsx)(y,{className:`size-3.5`}),label:`Save Design`,onClick:h}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(ee,{className:`size-3.5`}),label:`Load Design (${v.length})`,onClick:()=>u(!0),disabled:v.length===0})]})]})})]})});function El(e){let t=(0,ml.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,$.jsxs)(`div`,{children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Dl(e){let t=(0,ml.c)(5),{icon:n,label:r,onClick:i,disabled:a}=e,o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=(0,$.jsxs)(`button`,{onClick:i,disabled:a,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,children:[n,r]}),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}var Ol=(0,V.memo)(function(e){let t=(0,ml.c)(26),{canvasRef:n,artboardWidth:r,artboardHeight:i,brandKit:a,onCanvasModified:o}=e,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),d;t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n||t[4]!==o||t[5]!==l?(d=()=>{let e=l.trim();if(!e)return;let t=S(e,r,i,a);n.current?.applyGeneratedLayout(t.objects),o(),u(``),c(!1)},t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=l,t[6]=d):d=t[6];let f=d,p;t[7]===f?p=t[8]:(p=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f())},t[7]=f,t[8]=p);let m=p,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/20`,children:[(0,$.jsx)(se,{className:`size-3`}),`Quick Create`]}),t[9]=h):h=t[9];let g,v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-foreground`,children:`Generate Design`}),v=(0,$.jsx)(`p`,{className:`mb-3 text-[10px] text-muted-foreground`,children:`Describe what you want and we'll generate a canvas layout for you.`}),t[10]=g,t[11]=v):(g=t[10],v=t[11]);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>u(e.target.value),t[12]=y):y=t[12];let b;t[13]!==m||t[14]!==l?(b=(0,$.jsx)(`textarea`,{value:l,onChange:y,onKeyDown:m,placeholder:`e.g. Bold sale announcement for Instagram...`,rows:3,className:`mb-2 w-full resize-none rounded-md border border-border bg-background px-2.5 py-2 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0}),t[13]=m,t[14]=l,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`Press Enter to generate`}),t[16]=x):x=t[16];let C=!l.trim(),w;t[17]!==f||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[x,(0,$.jsx)(`button`,{onClick:f,disabled:C,className:`rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:`Generate`})]}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]!==w||t[21]!==b?(T=(0,$.jsxs)(k,{side:`bottom`,align:`start`,className:`w-80 p-3`,children:[g,v,b,w]}),t[20]=w,t[21]=b,t[22]=T):T=t[22];let D;return t[23]!==s||t[24]!==T?(D=(0,$.jsxs)(E,{open:s,onOpenChange:c,children:[h,T]}),t[23]=s,t[24]=T,t[25]=D):D=t[25],D}),kl={social:`Social Media`,business:`Business`,marketing:`Marketing`,presentation:`Presentations`},Al=(0,V.memo)(function(e){let t=(0,ml.c)(50),{canvasRef:n,brandKit:r,onCanvasModified:i,onSelectPreset:a}=e,[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u,d,f,p,m,g,v,y,b,x,C;if(t[0]!==c||t[1]!==r||t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o){let e=h(),w=[...e.keys()],D=c?e.get(c)??[]:T,O;t[17]!==r||t[18]!==n||t[19]!==i||t[20]!==a?(O=e=>{let t=de.get(e.presetId);t&&a(t);let o=t?.width??1080,c=t?.height??1080,l=S(e.previewPrompt,o,c,r);requestAnimationFrame(()=>{n.current?.applyGeneratedLayout(l.objects),i()}),s(!1)},t[17]=r,t[18]=n,t[19]=i,t[20]=a,t[21]=O):O=t[21];let A=O;d=E,b=o,x=s,t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,$.jsx)(B,{className:`size-3`}),`Templates`]}),t[22]=C):C=t[22],u=k,m=`bottom`,g=`start`,v=`w-80 p-0`;let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>l(null),t[23]=j):j=t[23];let M=`rounded-md px-2 py-1 text-[10px] font-medium ${c===null?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground`}`,N;t[24]===M?N=t[25]:(N=(0,$.jsx)(`button`,{onClick:j,className:M,children:`All`}),t[24]=M,t[25]=N);let P;t[26]!==c||t[27]!==w?(P=w.map(e=>(0,$.jsx)(`button`,{onClick:()=>l(e),className:`rounded-md px-2 py-1 text-[10px] font-medium ${c===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground`}`,children:kl[e]??e},e)),t[26]=c,t[27]=w,t[28]=P):P=t[28],t[29]!==N||t[30]!==P?(y=(0,$.jsxs)(`div`,{className:`flex gap-1 border-b border-border px-2 py-1.5`,children:[N,P]}),t[29]=N,t[30]=P,t[31]=y):y=t[31],f=`grid max-h-64 grid-cols-2 gap-1.5 overflow-y-auto p-2`;let F;t[32]===A?F=t[33]:(F=e=>{let t=de.get(e.presetId);return(0,$.jsxs)(`button`,{onClick:()=>A(e),className:`group flex flex-col rounded-lg border border-border p-2 text-left hover:border-primary/50 hover:bg-accent/50`,children:[(0,$.jsx)(`div`,{className:`mb-1.5 h-12 w-full rounded-md`,style:{background:e.style===`bold`?`linear-gradient(135deg, #1f2937, #374151)`:e.style===`gradient`?`linear-gradient(135deg, #4f46e5, #818cf8)`:e.style===`centered`?`linear-gradient(135deg, #fef3c7, #fde68a)`:e.style===`split`?`linear-gradient(90deg, #0ea5e9 45%, #f8fafc 45%)`:`#f8fafc`}}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-foreground group-hover:text-primary`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:t?.label??e.presetId})]},e.id)},t[32]=A,t[33]=F),p=D.map(F),t[0]=c,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=g,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=C}else u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],g=t[11],v=t[12],y=t[13],b=t[14],x=t[15],C=t[16];let w;t[34]!==f||t[35]!==p?(w=(0,$.jsx)(`div`,{className:f,children:p}),t[34]=f,t[35]=p,t[36]=w):w=t[36];let D;t[37]!==u||t[38]!==w||t[39]!==m||t[40]!==g||t[41]!==v||t[42]!==y?(D=(0,$.jsxs)(u,{side:m,align:g,className:v,children:[y,w]}),t[37]=u,t[38]=w,t[39]=m,t[40]=g,t[41]=v,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==d||t[45]!==D||t[46]!==b||t[47]!==x||t[48]!==C?(O=(0,$.jsxs)(d,{open:b,onOpenChange:x,children:[C,D]}),t[44]=d,t[45]=D,t[46]=b,t[47]=x,t[48]=C,t[49]=O):O=t[49],O});function jl(e){let t=(0,ml.c)(13),{label:n,value:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i(e.target.value),t[0]=i,t[1]=a);let o;t[2]!==a||t[3]!==r?(o=(0,$.jsx)(`input`,{type:`color`,value:r,onChange:a,className:`size-5 cursor-pointer rounded border border-border`}),t[2]=a,t[3]=r,t[4]=o):o=t[4];let s;t[5]===n?s=t[6]:(s=(0,$.jsx)(`span`,{className:`flex-1 text-[10px] text-muted-foreground`,children:n}),t[5]=n,t[6]=s);let c;t[7]===r?c=t[8]:(c=(0,$.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground/60`,children:r}),t[7]=r,t[8]=c);let l;return t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[o,s,c]}),t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}var Ml=[`Inter, sans-serif`,`Georgia, serif`,`Menlo, monospace`,`system-ui, sans-serif`,`Helvetica, Arial, sans-serif`,`Times New Roman, serif`],Nl=(0,V.memo)(function(e){let t=(0,ml.c)(70),{brandKit:n,onUpdate:r,onReset:i}=e,[a,o]=(0,V.useState)(!1),s;t[0]===r?s=t[1]:(s=(e,t)=>{r({[e]:t})},t[0]=r,t[1]=s);let c=s,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,$.jsx)(D,{className:`size-3`}),`Brand`]}),t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Brand Kit`}),t[3]=u):u=t[3];let d;t[4]===i?d=t[5]:(d=(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[u,(0,$.jsx)(`button`,{onClick:i,className:`text-[10px] text-muted-foreground hover:text-foreground`,children:`Reset`})]}),t[4]=i,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Colors`}),t[6]=f):f=t[6];let p;t[7]===c?p=t[8]:(p=e=>c(`primaryColor`,e),t[7]=c,t[8]=p);let m;t[9]!==n.primaryColor||t[10]!==p?(m=(0,$.jsx)(jl,{label:`Primary`,value:n.primaryColor,onChange:p}),t[9]=n.primaryColor,t[10]=p,t[11]=m):m=t[11];let h;t[12]===c?h=t[13]:(h=e=>c(`secondaryColor`,e),t[12]=c,t[13]=h);let g;t[14]!==n.secondaryColor||t[15]!==h?(g=(0,$.jsx)(jl,{label:`Secondary`,value:n.secondaryColor,onChange:h}),t[14]=n.secondaryColor,t[15]=h,t[16]=g):g=t[16];let v;t[17]===c?v=t[18]:(v=e=>c(`accentColor`,e),t[17]=c,t[18]=v);let y;t[19]!==n.accentColor||t[20]!==v?(y=(0,$.jsx)(jl,{label:`Accent`,value:n.accentColor,onChange:v}),t[19]=n.accentColor,t[20]=v,t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=e=>c(`backgroundColor`,e),t[22]=c,t[23]=b);let x;t[24]!==n.backgroundColor||t[25]!==b?(x=(0,$.jsx)(jl,{label:`Background`,value:n.backgroundColor,onChange:b}),t[24]=n.backgroundColor,t[25]=b,t[26]=x):x=t[26];let S;t[27]===c?S=t[28]:(S=e=>c(`textColor`,e),t[27]=c,t[28]=S);let C;t[29]!==n.textColor||t[30]!==S?(C=(0,$.jsx)(jl,{label:`Text`,value:n.textColor,onChange:S}),t[29]=n.textColor,t[30]=S,t[31]=C):C=t[31];let w;t[32]!==y||t[33]!==x||t[34]!==C||t[35]!==m||t[36]!==g?(w=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f,m,g,y,x,C]}),t[32]=y,t[33]=x,t[34]=C,t[35]=m,t[36]=g,t[37]=w):w=t[37];let T;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Fonts`}),t[38]=T):T=t[38];let O;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`span`,{className:`mb-1 block text-[10px] text-muted-foreground`,children:`Body Font`}),t[39]=O):O=t[39];let A=n.fontFamily,j;t[40]===r?j=t[41]:(j=e=>r({fontFamily:e.target.value}),t[40]=r,t[41]=j);let M;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(M=Ml.map(Pl),t[42]=M):M=t[42];let N;t[43]!==n.fontFamily||t[44]!==j?(N=(0,$.jsxs)(`label`,{className:`block`,children:[O,(0,$.jsx)(`select`,{value:A,onChange:j,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px]`,children:M})]}),t[43]=n.fontFamily,t[44]=j,t[45]=N):N=t[45];let P;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`span`,{className:`mb-1 block text-[10px] text-muted-foreground`,children:`Heading Font`}),t[46]=P):P=t[46];let F=n.headingFontFamily,I;t[47]===r?I=t[48]:(I=e=>r({headingFontFamily:e.target.value}),t[47]=r,t[48]=I);let ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ee=Ml.map(Fl),t[49]=ee):ee=t[49];let L;t[50]!==n.headingFontFamily||t[51]!==I?(L=(0,$.jsxs)(`label`,{className:`block`,children:[P,(0,$.jsx)(`select`,{value:F,onChange:I,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px]`,children:ee})]}),t[50]=n.headingFontFamily,t[51]=I,t[52]=L):L=t[52];let R;t[53]!==N||t[54]!==L?(R=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[T,N,L]}),t[53]=N,t[54]=L,t[55]=R):R=t[55];let z;t[56]!==n.accentColor||t[57]!==n.backgroundColor||t[58]!==n.primaryColor||t[59]!==n.secondaryColor||t[60]!==n.textColor?(z=(0,$.jsx)(`div`,{className:`mt-3 flex gap-1 rounded-md border border-border p-1.5`,children:[n.primaryColor,n.secondaryColor,n.accentColor,n.backgroundColor,n.textColor].map(Il)}),t[56]=n.accentColor,t[57]=n.backgroundColor,t[58]=n.primaryColor,t[59]=n.secondaryColor,t[60]=n.textColor,t[61]=z):z=t[61];let B;t[62]!==w||t[63]!==R||t[64]!==z||t[65]!==d?(B=(0,$.jsxs)(k,{side:`bottom`,align:`end`,className:`w-64 p-3`,children:[d,w,R,z]}),t[62]=w,t[63]=R,t[64]=z,t[65]=d,t[66]=B):B=t[66];let te;return t[67]!==a||t[68]!==B?(te=(0,$.jsxs)(E,{open:a,onOpenChange:o,children:[l,B]}),t[67]=a,t[68]=B,t[69]=te):te=t[69],te});function Pl(e){return(0,$.jsx)(`option`,{value:e,children:e.split(`,`)[0]},e)}function Fl(e){return(0,$.jsx)(`option`,{value:e,children:e.split(`,`)[0]},e)}function Il(e){return(0,$.jsx)(`div`,{className:`h-4 flex-1 rounded-sm`,style:{backgroundColor:e}},e)}var Ll=(0,V.memo)(function({onClose:e}){let t=(0,V.useRef)(null),n=(0,V.useRef)(new u(()=>{let e=t.current?.toJSON();e&&A.getState().pushHistorySnapshot(e)},{wait:500}));(0,V.useEffect)(()=>{let e=n.current;return()=>{e.cancel()}},[]);let{activeTool:r,artboardPresetId:i,artboardWidth:a,artboardHeight:o,selectedObjectProperties:s,propertiesPanelOpen:c,historyIndex:l,historyStack:d,layers:f,zoomLevel:p,savedDesigns:m,brandKit:h,setActiveTool:g,setArtboard:_,setSelectedObjects:v,clearSelection:y,setPropertiesPanelOpen:b,setLayers:x,setZoomLevel:w,undo:T,redo:E,resetHistory:D,saveDesign:k,deleteDesign:j,updateBrandKit:M,setBrandKit:N}=A();(0,V.useEffect)(()=>{let e=setTimeout(()=>{let e=t.current?.toJSON();e&&A.getState().pushHistorySnapshot(e)},100);return()=>clearTimeout(e)},[]),(0,V.useEffect)(()=>{let e=A.subscribe((e,n)=>{if(e.pendingGeneratePrompt&&e.pendingGeneratePrompt!==n.pendingGeneratePrompt){let e=A.getState().consumePendingGenerate();if(e&&t.current){let n=S(e,a,o,h);t.current.applyGeneratedLayout(n.objects)}}}),n=A.getState().consumePendingGenerate();return n&&t.current&&requestAnimationFrame(()=>{let e=S(n,a,o,h);t.current?.applyGeneratedLayout(e.objects)}),e},[a,o,h]);let P=(0,V.useCallback)(()=>{n.current.maybeExecute()},[]),F=(0,V.useCallback)(e=>{g(e)},[g]),I=(0,V.useCallback)(e=>{_(e.id,e.width,e.height),D()},[_,D]),ee=(0,V.useCallback)((e,t)=>{_(null,e,t),D()},[_,D]),L=(0,V.useCallback)(()=>{let e=T();e&&t.current?.loadJSON(e)},[T]),R=(0,V.useCallback)(()=>{let e=E();e&&t.current?.loadJSON(e)},[E]),z=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=ge(p),r=e.viewportTransform;r[0]=n,r[3]=n,e.setViewportTransform(r),w(n),e.requestRenderAll()},[p,w]),B=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=_e(p),r=e.viewportTransform;r[0]=n,r[3]=n,e.setViewportTransform(r),w(n),e.requestRenderAll()},[p,w]),te=(0,V.useCallback)(()=>{t.current?.fitToView()},[]),re=(0,V.useCallback)((e,n)=>{let r=t.current?.getCanvas();if(!r)return;let i=r.getActiveObject();if(!i)return;if(e===`scaleWidth`){let e=i.width??1;i.set(`scaleX`,n/e)}else if(e===`scaleHeight`){let e=i.height??1;i.set(`scaleY`,n/e)}else i.set(e,n);i.setCoords(),r.requestRenderAll(),P();let a=A.getState().selectedObjectProperties;if(a){let t={...a,[e===`scaleWidth`?`width`:e===`scaleHeight`?`height`:e]:n};v([a.id],t)}},[P,v]),ie=(0,V.useCallback)(e=>{let n=t.current?.getCanvas();if(!n)return;let r=n.getObjects().find(t=>t.customId===e);r&&(n.setActiveObject(r),n.requestRenderAll())},[]),ae=(0,V.useCallback)(e=>{let n=t.current?.getCanvas();if(!n)return;let r=n.getObjects().find(t=>t.customId===e);if(r){r.visible=!r.visible,n.requestRenderAll();let t=f.map(t=>t.id===e?{...t,visible:!t.visible}:t);x(t)}},[f,x]),oe=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.bringObjectForward(n),e.requestRenderAll(),P())},[P]),se=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.sendObjectBackwards(n),e.requestRenderAll(),P())},[P]),ce=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.bringObjectToFront(n),e.requestRenderAll(),P())},[P]),le=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();if(n){let t=e.getObjects().findIndex(e=>e.customId===`__artboard__`);e.moveObjectTo(n,t+1),e.requestRenderAll(),P()}},[P]),ue=(0,V.useCallback)(async e=>{await t.current?.loadJSON(e),D();let n=t.current?.toJSON();n&&A.getState().pushHistorySnapshot(n)},[D]),de=(0,V.useCallback)((e,t,n)=>{k(e,t,n)},[k]);(0,V.useEffect)(()=>{let e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)){if(!e.metaKey&&!e.ctrlKey)switch(e.key.toLowerCase()){case`v`:g(`select`);return;case`t`:g(`text`);return;case`r`:g(`rect`);return;case`d`:g(`draw`);return}if((e.metaKey||e.ctrlKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?R():L()),e.key===`Delete`||e.key===`Backspace`){let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&n.customId!==`__artboard__`&&(e.remove(n),y(),P())}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,L,R,y,P]);let fe=l>0,pe=l<d.length-1;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Canvas`}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsx)(Ol,{canvasRef:t,artboardWidth:a,artboardHeight:o,brandKit:h,onCanvasModified:P}),(0,$.jsx)(Al,{canvasRef:t,brandKit:h,onCanvasModified:P,onSelectPreset:I}),(0,$.jsx)(Nl,{brandKit:h,onUpdate:M,onReset:()=>N(O)}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(wl,{artboardPresetId:i,artboardWidth:a,artboardHeight:o,onSelectPreset:I,onCustomSize:ee}),(0,$.jsx)(Tl,{canvasRef:t,artboardWidth:a,artboardHeight:o,savedDesigns:m,onSaveDesign:de,onLoadDesign:e=>void ue(e),onDeleteDesign:j}),e?(0,$.jsx)(`button`,{onClick:e,className:`inline-flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(C,{className:`size-3.5`})}):null]}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[f.length===0&&(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(ne,{className:`size-7 text-muted-foreground/20`}),(0,$.jsx)(`p`,{className:`text-[12px] text-muted-foreground/35`,children:`Use Quick Create or Templates to start designing.`})]}),(0,$.jsx)(pl,{ref:t,artboardWidth:a,artboardHeight:o,activeTool:r,onSelectionChange:v,onCanvasModified:P,onLayersChange:x,onZoomChange:w}),(0,$.jsx)(bl,{open:c,properties:s,layers:f,onClose:()=>b(!1),onPropertyChange:re,onLayerSelect:ie,onLayerVisibilityToggle:ae,onMoveUp:oe,onMoveDown:se,onBringToFront:ce,onSendToBack:le})]}),(0,$.jsx)(_l,{activeTool:r,onToolChange:F,canUndo:fe,canRedo:pe,onUndo:L,onRedo:R,zoomLevel:p,onZoomIn:z,onZoomOut:B,onFitToView:te,canvasRef:t,onCanvasModified:P})]})});export{Ll as CanvasPanel,Ll as default};
|
|
441
|
+
//# sourceMappingURL=CanvasPanel-BIN3OTEQ.js.map
|